X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglsl%2Foptimize.h;h=e21dd98fd0fcbe63e578e3012cd072d108c5437d;hb=cc5483cc709fdf7b6966a3e69dabfcafebaaffa0;hp=249a859a03763c6e198b9c0f04020dc0589ea360;hpb=3415ed0f925d781df9d8243e0f4c454516b1c450;p=libs%2Fgl.git diff --git a/source/glsl/optimize.h b/source/glsl/optimize.h index 249a859a..e21dd98f 100644 --- a/source/glsl/optimize.h +++ b/source/glsl/optimize.h @@ -27,7 +27,7 @@ private: /** Finds functions which are candidates for inlining. Currently this means functions which have no flow control statements, no more than one return -statement, and are only called once. */ +statement, and are either builtins or only called once. */ class InlineableFunctionLocator: private TraversingVisitor { private: @@ -227,6 +227,26 @@ private: virtual void visit(Iteration &); }; +class UnreachableCodeRemover: private TraversingVisitor +{ +private: + bool reachable; + std::set unreachable_nodes; + +public: + UnreachableCodeRemover(); + + virtual bool apply(Stage &); + +private: + virtual void visit(Block &); + virtual void visit(FunctionDeclaration &); + virtual void visit(Conditional &); + virtual void visit(Iteration &); + virtual void visit(Return &) { reachable = false; } + virtual void visit(Jump &) { reachable = false; } +}; + /** Removes types which are not used anywhere. */ class UnusedTypeRemover: private TraversingVisitor {