Move optimization pass prototypes to a single header.
authorEric Anholt <eric@anholt.net>
Wed, 5 May 2010 18:45:30 +0000 (11:45 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 5 May 2010 18:47:33 +0000 (11:47 -0700)
glsl_parser_extras.cpp
ir_constant_folding.cpp
ir_constant_folding.h [deleted file]
ir_copy_propagation.cpp
ir_copy_propagation.h [deleted file]
ir_dead_code.h [deleted file]
ir_function_inlining.cpp
ir_function_inlining.h
ir_if_simplification.h [deleted file]
ir_optimization.h

index 58656c7..18280e0 100644 (file)
 #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);
    }
 
index 1b53440..913d42f 100644 (file)
 #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 (file)
index 44bdbd0..0000000
+++ /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 *);
-   /*@}*/
-};
index 018a30d..6c34652 100644 (file)
@@ -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 (file)
index cfb0f63..0000000
+++ /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 (file)
index 25bf6f6..0000000
+++ /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);
index 0d072c1..09604c0 100644 (file)
 #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)
index b68a55a..6db011b 100644 (file)
  * 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 (file)
index 84b09ef..0000000
+++ /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);
index 22ce75e..d9e30ce 100644 (file)
  * 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);