glsl/hierarchical_visitor: Call leave_callback on leaf nodes
Previously for leaf ir_instructions only the enter callback was called. This makes it a bit difficult to make a pass that wants to visit every instruction using a stack. Making it call the leave callback as well makes it behave less surprisingly. Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3885>
This commit is contained in:
@@ -37,8 +37,7 @@ ir_hierarchical_visitor::ir_hierarchical_visitor()
|
||||
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;
|
||||
}
|
||||
@@ -46,8 +45,7 @@ ir_hierarchical_visitor::visit(ir_rvalue *ir)
|
||||
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;
|
||||
}
|
||||
@@ -55,8 +53,7 @@ ir_hierarchical_visitor::visit(ir_variable *ir)
|
||||
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;
|
||||
}
|
||||
@@ -64,8 +61,7 @@ ir_hierarchical_visitor::visit(ir_constant *ir)
|
||||
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;
|
||||
}
|
||||
@@ -73,8 +69,7 @@ ir_hierarchical_visitor::visit(ir_loop_jump *ir)
|
||||
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;
|
||||
}
|
||||
@@ -82,8 +77,7 @@ ir_hierarchical_visitor::visit(ir_dereference_variable *ir)
|
||||
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;
|
||||
}
|
||||
@@ -382,6 +376,14 @@ ir_hierarchical_visitor::run(exec_list *instructions)
|
||||
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,
|
||||
|
||||
@@ -149,6 +149,12 @@ public:
|
||||
*/
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user