summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-08-13 20:50:10 -0700
committerEric Anholt <[email protected]>2010-08-13 17:54:47 -0700
commit42cab131dac469475c67ab38a2c29f2f66e6ff49 (patch)
tree5746746b89dc7fe9a91bacebc0aac6cdfd2485c8 /src
parentb3b0cf6a4c6b23e0ebe7e5f5ab1b7cacf27268b1 (diff)
glsl2: Convert ir_constant_propagation to ir_rvalue_visitor.
This one is a little tricky because of the LHS handling.
Diffstat (limited to 'src')
-rw-r--r--src/glsl/ir_constant_propagation.cpp64
1 files changed, 9 insertions, 55 deletions
diff --git a/src/glsl/ir_constant_propagation.cpp b/src/glsl/ir_constant_propagation.cpp
index adae0aa1171..76c1ce7013f 100644
--- a/src/glsl/ir_constant_propagation.cpp
+++ b/src/glsl/ir_constant_propagation.cpp
@@ -36,6 +36,7 @@
#include "ir.h"
#include "ir_visitor.h"
+#include "ir_rvalue_visitor.h"
#include "ir_basic_block.h"
#include "ir_optimization.h"
#include "glsl_types.h"
@@ -72,7 +73,7 @@ public:
unsigned write_mask;
};
-class ir_constant_propagation_visitor : public ir_hierarchical_visitor {
+class ir_constant_propagation_visitor : public ir_rvalue_visitor {
public:
ir_constant_propagation_visitor()
{
@@ -90,12 +91,8 @@ public:
virtual ir_visitor_status visit_enter(class ir_function_signature *);
virtual ir_visitor_status visit_enter(class ir_function *);
virtual ir_visitor_status visit_enter(class ir_assignment *);
- virtual ir_visitor_status visit_leave(class ir_assignment *);
- virtual ir_visitor_status visit_enter(class ir_expression *);
virtual ir_visitor_status visit_enter(class ir_call *);
virtual ir_visitor_status visit_enter(class ir_if *);
- virtual ir_visitor_status visit_enter(class ir_dereference_array *);
- virtual ir_visitor_status visit_enter(class ir_texture *);
void add_constant(ir_assignment *ir);
void kill(ir_variable *ir, unsigned write_mask);
@@ -221,30 +218,20 @@ ir_constant_propagation_visitor::visit_enter(ir_function_signature *ir)
ir_visitor_status
ir_constant_propagation_visitor::visit_enter(ir_assignment *ir)
{
- handle_rvalue(&ir->condition);
+ /* Inline accepting children, skipping the LHS. */
+ ir->rhs->accept(this);
handle_rvalue(&ir->rhs);
- return visit_continue;
-}
+ if (ir->condition) {
+ ir->condition->accept(this);
+ handle_rvalue(&ir->condition);
+ }
-ir_visitor_status
-ir_constant_propagation_visitor::visit_leave(ir_assignment *ir)
-{
kill(ir->lhs->variable_referenced(), ir->write_mask);
add_constant(ir);
- return visit_continue;
-}
-
-ir_visitor_status
-ir_constant_propagation_visitor::visit_enter(ir_expression *ir)
-{
- for (unsigned int i = 0; i < ir->get_num_operands(); i++) {
- handle_rvalue(&ir->operands[i]);
- }
-
- return visit_continue;
+ return visit_continue_with_parent;
}
ir_visitor_status
@@ -331,39 +318,6 @@ ir_constant_propagation_visitor::visit_enter(ir_if *ir)
}
ir_visitor_status
-ir_constant_propagation_visitor::visit_enter(ir_dereference_array *ir)
-{
- handle_rvalue(&ir->array_index);
- return visit_continue;
-}
-
-ir_visitor_status
-ir_constant_propagation_visitor::visit_enter(ir_texture *ir)
-{
- handle_rvalue(&ir->coordinate);
- handle_rvalue(&ir->projector);
- handle_rvalue(&ir->shadow_comparitor);
-
- switch (ir->op) {
- case ir_tex:
- break;
- case ir_txb:
- handle_rvalue(&ir->lod_info.bias);
- break;
- case ir_txf:
- case ir_txl:
- handle_rvalue(&ir->lod_info.lod);
- break;
- case ir_txd:
- handle_rvalue(&ir->lod_info.grad.dPdx);
- handle_rvalue(&ir->lod_info.grad.dPdy);
- break;
- }
-
- return visit_continue;
-}
-
-ir_visitor_status
ir_constant_propagation_visitor::visit_enter(ir_loop *ir)
{
exec_list *orig_acp = this->acp;