summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-05-05 11:45:30 -0700
committerEric Anholt <eric@anholt.net>2010-05-05 11:47:33 -0700
commitbdd9b1f3ffa2a195d983816adfeca20480256119 (patch)
tree09cfda2b66313b75f58c37d4d45c5f4404c14421
parent6255a1f4c6425aa311c90e9dc7fca41c34e8dc2b (diff)
Move optimization pass prototypes to a single header.
-rw-r--r--glsl_parser_extras.cpp10
-rw-r--r--ir_constant_folding.cpp49
-rw-r--r--ir_constant_folding.h63
-rw-r--r--ir_copy_propagation.cpp2
-rw-r--r--ir_copy_propagation.h24
-rw-r--r--ir_dead_code.h32
-rw-r--r--ir_function_inlining.cpp36
-rw-r--r--ir_function_inlining.h37
-rw-r--r--ir_if_simplification.h31
-rw-r--r--ir_optimization.h6
10 files changed, 92 insertions, 198 deletions
diff --git a/glsl_parser_extras.cpp b/glsl_parser_extras.cpp
index 58656c70ae..18280e0301 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 1b53440669..913d42f0d9 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 44bdbd0175..0000000000
--- 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 018a30d77c..6c34652112 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 cfb0f63250..0000000000
--- 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 25bf6f6256..0000000000
--- 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 0d072c1b76..09604c04df 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 b68a55a1a9..6db011bbca 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 84b09ef0fd..0000000000
--- 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 22ce75e10f..d9e30ce08c 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);