diff options
Diffstat (limited to 'mesalib/src/glsl/ir_hierarchical_visitor.cpp')
-rw-r--r-- | mesalib/src/glsl/ir_hierarchical_visitor.cpp | 158 |
1 files changed, 97 insertions, 61 deletions
diff --git a/mesalib/src/glsl/ir_hierarchical_visitor.cpp b/mesalib/src/glsl/ir_hierarchical_visitor.cpp index d3c00ecdb..adb629414 100644 --- a/mesalib/src/glsl/ir_hierarchical_visitor.cpp +++ b/mesalib/src/glsl/ir_hierarchical_visitor.cpp @@ -27,16 +27,18 @@ ir_hierarchical_visitor::ir_hierarchical_visitor() { this->base_ir = NULL; - this->callback = NULL; - this->data = NULL; + this->callback_enter = NULL; + this->callback_leave = NULL; + this->data_enter = NULL; + this->data_leave = NULL; this->in_assignee = false; } ir_visitor_status ir_hierarchical_visitor::visit(ir_rvalue *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -44,8 +46,8 @@ ir_hierarchical_visitor::visit(ir_rvalue *ir) ir_visitor_status ir_hierarchical_visitor::visit(ir_variable *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -53,8 +55,8 @@ ir_hierarchical_visitor::visit(ir_variable *ir) ir_visitor_status ir_hierarchical_visitor::visit(ir_constant *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -62,8 +64,8 @@ ir_hierarchical_visitor::visit(ir_constant *ir) ir_visitor_status ir_hierarchical_visitor::visit(ir_loop_jump *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -71,8 +73,8 @@ ir_hierarchical_visitor::visit(ir_loop_jump *ir) ir_visitor_status ir_hierarchical_visitor::visit(ir_dereference_variable *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -80,8 +82,8 @@ ir_hierarchical_visitor::visit(ir_dereference_variable *ir) ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_loop *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -89,15 +91,17 @@ ir_hierarchical_visitor::visit_enter(ir_loop *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_loop *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_function_signature *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -105,15 +109,17 @@ ir_hierarchical_visitor::visit_enter(ir_function_signature *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_function_signature *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_function *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -121,15 +127,17 @@ ir_hierarchical_visitor::visit_enter(ir_function *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_function *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_expression *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -137,15 +145,17 @@ ir_hierarchical_visitor::visit_enter(ir_expression *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_expression *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_texture *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -153,15 +163,17 @@ ir_hierarchical_visitor::visit_enter(ir_texture *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_texture *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_swizzle *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -169,15 +181,17 @@ ir_hierarchical_visitor::visit_enter(ir_swizzle *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_swizzle *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_dereference_array *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -185,15 +199,17 @@ ir_hierarchical_visitor::visit_enter(ir_dereference_array *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_dereference_array *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_dereference_record *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -201,15 +217,17 @@ ir_hierarchical_visitor::visit_enter(ir_dereference_record *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_dereference_record *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_assignment *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -217,15 +235,17 @@ ir_hierarchical_visitor::visit_enter(ir_assignment *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_assignment *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_call *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -233,15 +253,17 @@ ir_hierarchical_visitor::visit_enter(ir_call *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_call *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_return *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -249,15 +271,17 @@ ir_hierarchical_visitor::visit_enter(ir_return *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_return *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_discard *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -265,15 +289,17 @@ ir_hierarchical_visitor::visit_enter(ir_discard *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_discard *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_if *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -281,15 +307,17 @@ ir_hierarchical_visitor::visit_enter(ir_if *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_if *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_emit_vertex *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -297,15 +325,17 @@ ir_hierarchical_visitor::visit_enter(ir_emit_vertex *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_emit_vertex *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } ir_visitor_status ir_hierarchical_visitor::visit_enter(ir_end_primitive *ir) { - if (this->callback != NULL) - this->callback(ir, this->data); + if (this->callback_enter != NULL) + this->callback_enter(ir, this->data_enter); return visit_continue; } @@ -313,7 +343,9 @@ ir_hierarchical_visitor::visit_enter(ir_end_primitive *ir) ir_visitor_status ir_hierarchical_visitor::visit_leave(ir_end_primitive *ir) { - (void) ir; + if (this->callback_leave != NULL) + this->callback_leave(ir, this->data_leave); + return visit_continue; } @@ -326,13 +358,17 @@ ir_hierarchical_visitor::run(exec_list *instructions) void visit_tree(ir_instruction *ir, - void (*callback)(class ir_instruction *ir, void *data), - void *data) + void (*callback_enter)(class ir_instruction *ir, void *data), + void *data_enter, + void (*callback_leave)(class ir_instruction *ir, void *data), + void *data_leave) { ir_hierarchical_visitor v; - v.callback = callback; - v.data = data; + v.callback_enter = callback_enter; + v.callback_leave = callback_leave; + v.data_enter = data_enter; + v.data_leave = data_leave; ir->accept(&v); } |