diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2010-05-19 13:20:12 +0200 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-05-26 15:23:25 -0700 |
commit | c7b1046a9fa6da916f11fb9e43d61fd772470183 (patch) | |
tree | ccc8b84f24edbfa38b5eb2fe3c8610274a48b52c /ir_constant_folding.cpp | |
parent | f3a002b503542fe2544025c6a42d552fdc4907c2 (diff) |
Refactor ir_dereference support for ir_visitor
Move the accept method for visitors from ir_dereference to the derived
classes.
Diffstat (limited to 'ir_constant_folding.cpp')
-rw-r--r-- | ir_constant_folding.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/ir_constant_folding.cpp b/ir_constant_folding.cpp index 913d42f0d9..9a2a7f3f2e 100644 --- a/ir_constant_folding.cpp +++ b/ir_constant_folding.cpp @@ -61,7 +61,9 @@ public: virtual void visit(ir_function *); virtual void visit(ir_expression *); virtual void visit(ir_swizzle *); - virtual void visit(ir_dereference *); + virtual void visit(ir_dereference_variable *); + virtual void visit(ir_dereference_array *); + virtual void visit(ir_dereference_record *); virtual void visit(ir_assignment *); virtual void visit(ir_constant *); virtual void visit(ir_call *); @@ -117,15 +119,30 @@ ir_constant_folding_visitor::visit(ir_swizzle *ir) void -ir_constant_folding_visitor::visit(ir_dereference *ir) -{ - if (ir->mode == ir_dereference::ir_reference_array) { - ir_constant *const_val = ir->selector.array_index->constant_expression_value(); - if (const_val) - ir->selector.array_index = const_val; - else - ir->selector.array_index->accept(this); - } +ir_constant_folding_visitor::visit(ir_dereference_variable *ir) +{ + (void) ir; +} + + +void +ir_constant_folding_visitor::visit(ir_dereference_array *ir) +{ + ir_constant *const_val = + ir->selector.array_index->constant_expression_value(); + + if (const_val) + ir->selector.array_index = const_val; + else + ir->selector.array_index->accept(this); + + ir->var->accept(this); +} + + +void +ir_constant_folding_visitor::visit(ir_dereference_record *ir) +{ ir->var->accept(this); } |