mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-07 00:00:12 +01:00
ir_expression_flattening: Fix breakage from hierarchichal visitor.
Similar to other situations where the visitor pattern doesn't fit, in this case we need the pointer to the base instruction in the instruction stream for where to insert any new instructions we generate (not the instruction in the tree we're looking at). By removing the code for setting the base_ir, flattened expressions would end up, for example, before the function definition where they had appeared.
This commit is contained in:
parent
e668c2a9ee
commit
459e4a286c
1 changed files with 30 additions and 0 deletions
|
|
@ -55,6 +55,9 @@ public:
|
|||
|
||||
virtual ir_visitor_status visit_enter(ir_call *);
|
||||
virtual ir_visitor_status visit_enter(ir_return *);
|
||||
virtual ir_visitor_status visit_enter(ir_function_signature *);
|
||||
virtual ir_visitor_status visit_enter(ir_if *);
|
||||
virtual ir_visitor_status visit_enter(ir_loop *);
|
||||
virtual ir_visitor_status visit_leave(ir_expression *);
|
||||
|
||||
bool (*predicate)(ir_instruction *ir);
|
||||
|
|
@ -73,6 +76,33 @@ do_expression_flattening(exec_list *instructions,
|
|||
}
|
||||
}
|
||||
|
||||
ir_visitor_status
|
||||
ir_expression_flattening_visitor::visit_enter(ir_function_signature *ir)
|
||||
{
|
||||
do_expression_flattening(&ir->body, this->predicate);
|
||||
|
||||
return visit_continue_with_parent;
|
||||
}
|
||||
|
||||
ir_visitor_status
|
||||
ir_expression_flattening_visitor::visit_enter(ir_loop *ir)
|
||||
{
|
||||
do_expression_flattening(&ir->body_instructions, this->predicate);
|
||||
|
||||
return visit_continue_with_parent;
|
||||
}
|
||||
|
||||
ir_visitor_status
|
||||
ir_expression_flattening_visitor::visit_enter(ir_if *ir)
|
||||
{
|
||||
ir->condition->accept(this);
|
||||
|
||||
do_expression_flattening(&ir->then_instructions, this->predicate);
|
||||
do_expression_flattening(&ir->else_instructions, this->predicate);
|
||||
|
||||
return visit_continue_with_parent;
|
||||
}
|
||||
|
||||
ir_visitor_status
|
||||
ir_expression_flattening_visitor::visit_leave(ir_expression *ir)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue