mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 08:30:10 +01:00
Make function bodies rely on the parameter variable declarations.
Previously, generating inlined function bodies was going to be difficult, as there was no mapping between the body's declaration of variables where parameter values were supposed to live and the parameter variables that a caller would use in paramater setup. Presumably this also have been a problem for actual codegen.
This commit is contained in:
parent
6173312d84
commit
fbc7c0b8f2
4 changed files with 12 additions and 15 deletions
|
|
@ -1925,13 +1925,9 @@ ast_function_definition::hir(exec_list *instructions,
|
|||
*/
|
||||
state->symbols->push_scope();
|
||||
foreach_iter(exec_list_iterator, iter, signature->parameters) {
|
||||
ir_variable *const proto = ((ir_instruction *) iter.get())->as_variable();
|
||||
ir_variable *const var = ((ir_instruction *) iter.get())->as_variable();
|
||||
|
||||
assert(proto != NULL);
|
||||
|
||||
ir_variable *const var = proto->clone();
|
||||
|
||||
signature->body.push_tail(var);
|
||||
assert(var != NULL);
|
||||
|
||||
/* The only way a parameter would "exist" is if two parameters have
|
||||
* the same name.
|
||||
|
|
|
|||
|
|
@ -224,13 +224,9 @@ generate_function_instance(ir_function *f,
|
|||
for (i = 0; i < n_args; i++) {
|
||||
ir_variable *var = new ir_variable(type, arg_names[i]);
|
||||
|
||||
var = new ir_variable(type, arg_names[i]);
|
||||
var->mode = ir_var_in;
|
||||
sig->parameters.push_tail(var);
|
||||
|
||||
var = new ir_variable(type, arg_names[i]);
|
||||
var->mode = ir_var_in;
|
||||
sig->body.push_tail(var);
|
||||
declarations[i] = var;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -204,11 +204,6 @@ generate_constructor_intro(const glsl_type *type, unsigned parameter_count,
|
|||
var->mode = ir_var_in;
|
||||
signature->parameters.push_tail(var);
|
||||
|
||||
var = new ir_variable(parameter_type, names[i]);
|
||||
|
||||
var->mode = ir_var_in;
|
||||
signature->body.push_tail(var);
|
||||
|
||||
declarations[i] = var;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ void ir_print_visitor::visit(ir_variable *ir)
|
|||
void ir_print_visitor::visit(ir_label *ir)
|
||||
{
|
||||
printf("\n(label %s\n", ir->label);
|
||||
|
||||
ir->signature->accept(this);
|
||||
printf(")");
|
||||
}
|
||||
|
|
@ -74,6 +75,15 @@ void ir_print_visitor::visit(ir_label *ir)
|
|||
|
||||
void ir_print_visitor::visit(ir_function_signature *ir)
|
||||
{
|
||||
printf("(paramaters\n");
|
||||
foreach_iter(exec_list_iterator, iter, ir->parameters) {
|
||||
ir_variable *const inst = (ir_variable *) iter.get();
|
||||
|
||||
inst->accept(this);
|
||||
printf("\n");
|
||||
}
|
||||
printf(")\n");
|
||||
|
||||
foreach_iter(exec_list_iterator, iter, ir->body) {
|
||||
ir_instruction *const inst = (ir_instruction *) iter.get();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue