ir_visitor_status
ir_hierarchical_visitor::visit(ir_rvalue *ir)
{
- if (this->callback_enter != NULL)
- this->callback_enter(ir, this->data_enter);
+ call_enter_leave_callbacks(ir);
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit(ir_variable *ir)
{
- if (this->callback_enter != NULL)
- this->callback_enter(ir, this->data_enter);
+ call_enter_leave_callbacks(ir);
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit(ir_constant *ir)
{
- if (this->callback_enter != NULL)
- this->callback_enter(ir, this->data_enter);
+ call_enter_leave_callbacks(ir);
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit(ir_loop_jump *ir)
{
- if (this->callback_enter != NULL)
- this->callback_enter(ir, this->data_enter);
+ call_enter_leave_callbacks(ir);
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit(ir_dereference_variable *ir)
{
- if (this->callback_enter != NULL)
- this->callback_enter(ir, this->data_enter);
+ call_enter_leave_callbacks(ir);
return visit_continue;
}
ir_visitor_status
ir_hierarchical_visitor::visit(ir_barrier *ir)
{
- if (this->callback_enter != NULL)
- this->callback_enter(ir, this->data_enter);
+ call_enter_leave_callbacks(ir);
return visit_continue;
}
visit_list_elements(this, instructions);
}
+void
+ir_hierarchical_visitor::call_enter_leave_callbacks(class ir_instruction *ir)
+{
+ if (this->callback_enter != NULL)
+ this->callback_enter(ir, this->data_enter);
+ if (this->callback_leave != NULL)
+ this->callback_leave(ir, this->data_leave);
+}
void
visit_tree(ir_instruction *ir,
*/
void run(struct exec_list *instructions);
+ /**
+ * Utility function to call both the leave and enter callback functions.
+ * This is used for leaf nodes.
+ */
+ void call_enter_leave_callbacks(class ir_instruction *ir);
+
/* Some visitors may need to insert new variable declarations and
* assignments for portions of a subtree, which means they need a
* pointer to the current instruction in the stream, not just their