From: Eric Anholt Date: Wed, 5 May 2010 18:45:30 +0000 (-0700) Subject: Move optimization pass prototypes to a single header. X-Git-Tag: 062012170305~10660^2~625^2~277 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bdd9b1f3ffa2a195d983816adfeca20480256119;p=profile%2Fivi%2Fmesa.git Move optimization pass prototypes to a single header. --- diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp index 58656c7..18280e0 100644 --- a/glsl_parser_extras.cpp +++ b/glsl_parser_extras.cpp @@ -34,11 +34,6 @@ #include "ast.h" #include "glsl_parser_extras.h" #include "glsl_parser.h" -#include "ir_constant_folding.h" -#include "ir_copy_propagation.h" -#include "ir_dead_code.h" -#include "ir_function_inlining.h" -#include "ir_if_simplification.h" #include "ir_optimization.h" #include "ir_print_visitor.h" #include "ir_reader.h" @@ -791,10 +786,7 @@ main(int argc, char **argv) progress = do_copy_propagation(&instructions) || progress; progress = do_dead_code_local(&instructions) || progress; progress = do_dead_code_unlinked(&instructions) || progress; - - /* Constant folding */ - ir_constant_folding_visitor constant_folding; - visit_exec_list(&instructions, &constant_folding); + progress = do_constant_folding(&instructions) || progress; } while (progress); } diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index 1b53440..913d42f 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -29,13 +29,49 @@ #define NULL 0 #include "ir.h" #include "ir_visitor.h" -#include "ir_constant_folding.h" +#include "ir_optimization.h" #include "glsl_types.h" /** * Visitor class for replacing expressions with ir_constant values. */ +class ir_constant_folding_visitor : public ir_visitor { +public: + ir_constant_folding_visitor() + { + /* empty */ + } + + virtual ~ir_constant_folding_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + /*@}*/ +}; + void ir_constant_folding_visitor::visit(ir_variable *ir) { @@ -152,3 +188,14 @@ ir_constant_folding_visitor::visit(ir_loop_jump *ir) { (void) ir; } + +bool +do_constant_folding(exec_list *instructions) +{ + ir_constant_folding_visitor constant_folding; + + visit_exec_list(instructions, &constant_folding); + + /* FINISHME: Return real progress. */ + return false; +} diff --git a/ir_constant_folding.h b/ir_constant_folding.h deleted file mode 100644 index 44bdbd0..0000000 --- a/ir_constant_folding.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_constant_folding.h - * Replace constant-valued expressions with references to constant values. - */ - -class ir_constant_folding_visitor : public ir_visitor { -public: - ir_constant_folding_visitor() - { - /* empty */ - } - - virtual ~ir_constant_folding_visitor() - { - /* empty */ - } - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - /*@}*/ -}; diff --git a/ir_copy_propagation.cpp b/ir_copy_propagation.cpp index 018a30d..6c34652 100644 --- a/ir_copy_propagation.cpp +++ b/ir_copy_propagation.cpp @@ -37,7 +37,7 @@ #include "ir_visitor.h" #include "ir_print_visitor.h" #include "ir_basic_block.h" -#include "ir_copy_propagation.h" +#include "ir_optimization.h" #include "glsl_types.h" class acp_entry : public exec_node diff --git a/ir_copy_propagation.h b/ir_copy_propagation.h deleted file mode 100644 index cfb0f63..0000000 --- a/ir_copy_propagation.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -bool do_copy_propagation(exec_list *instructions); diff --git a/ir_dead_code.h b/ir_dead_code.h deleted file mode 100644 index 25bf6f6..0000000 --- a/ir_dead_code.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - -/** - * \file ir_dead_code.h - * - * Eliminates dead assignments and variable declarations from the code. - */ - -bool do_dead_code(exec_list *instructions); -bool do_dead_code_unlinked(exec_list *instructions); diff --git a/ir_function_inlining.cpp b/ir_function_inlining.cpp index 0d072c1..09604c0 100644 --- a/ir_function_inlining.cpp +++ b/ir_function_inlining.cpp @@ -34,6 +34,42 @@ #include "ir_expression_flattening.h" #include "glsl_types.h" +class ir_function_inlining_visitor : public ir_visitor { +public: + ir_function_inlining_visitor() + { + /* empty */ + } + + virtual ~ir_function_inlining_visitor() + { + /* empty */ + } + + /** + * \name Visit methods + * + * As typical for the visitor pattern, there must be one \c visit method for + * each concrete subclass of \c ir_instruction. Virtual base classes within + * the hierarchy should not have \c visit methods. + */ + /*@{*/ + virtual void visit(ir_variable *); + virtual void visit(ir_loop *); + virtual void visit(ir_loop_jump *); + virtual void visit(ir_function_signature *); + virtual void visit(ir_function *); + virtual void visit(ir_expression *); + virtual void visit(ir_swizzle *); + virtual void visit(ir_dereference *); + virtual void visit(ir_assignment *); + virtual void visit(ir_constant *); + virtual void visit(ir_call *); + virtual void visit(ir_return *); + virtual void visit(ir_if *); + /*@}*/ +}; + class variable_remap : public exec_node { public: variable_remap(const ir_variable *old_var, ir_variable *new_var) diff --git a/ir_function_inlining.h b/ir_function_inlining.h index b68a55a..6db011b 100644 --- a/ir_function_inlining.h +++ b/ir_function_inlining.h @@ -27,41 +27,4 @@ * Replaces calls to functions with the body of the function. */ -class ir_function_inlining_visitor : public ir_visitor { -public: - ir_function_inlining_visitor() - { - /* empty */ - } - - virtual ~ir_function_inlining_visitor() - { - /* empty */ - } - - /** - * \name Visit methods - * - * As typical for the visitor pattern, there must be one \c visit method for - * each concrete subclass of \c ir_instruction. Virtual base classes within - * the hierarchy should not have \c visit methods. - */ - /*@{*/ - virtual void visit(ir_variable *); - virtual void visit(ir_loop *); - virtual void visit(ir_loop_jump *); - virtual void visit(ir_function_signature *); - virtual void visit(ir_function *); - virtual void visit(ir_expression *); - virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); - virtual void visit(ir_assignment *); - virtual void visit(ir_constant *); - virtual void visit(ir_call *); - virtual void visit(ir_return *); - virtual void visit(ir_if *); - /*@}*/ -}; - -bool do_function_inlining(exec_list *instructions); bool can_inline(ir_call *call); diff --git a/ir_if_simplification.h b/ir_if_simplification.h deleted file mode 100644 index 84b09ef..0000000 --- a/ir_if_simplification.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/** - * \file ir_if_simplification.h - * - * Moves constant branches of if statements out to the surrounding - * instruction stream. - */ - -bool do_if_simplification(exec_list *instructions); diff --git a/ir_optimization.h b/ir_optimization.h index 22ce75e..d9e30ce 100644 --- a/ir_optimization.h +++ b/ir_optimization.h @@ -28,4 +28,10 @@ * Prototypes for optimization passes to be called by the compiler and drivers. */ +bool do_constant_folding(exec_list *instructions); +bool do_copy_propagation(exec_list *instructions); +bool do_dead_code(exec_list *instructions); bool do_dead_code_local(exec_list *instructions); +bool do_dead_code_unlinked(exec_list *instructions); +bool do_function_inlining(exec_list *instructions); +bool do_if_simplification(exec_list *instructions);