Browse Source

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.
tags/mesa-7.9-rc1
Eric Anholt 15 years ago
parent
commit
fbc7c0b8f2
4 changed files with 12 additions and 15 deletions
  1. 2
    6
      ast_to_hir.cpp
  2. 0
    4
      builtin_function.cpp
  3. 0
    5
      glsl_types.cpp
  4. 10
    0
      ir_print_visitor.cpp

+ 2
- 6
ast_to_hir.cpp View File

@@ -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.

+ 0
- 4
builtin_function.cpp View File

@@ -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;
}


+ 0
- 5
glsl_types.cpp View File

@@ -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;
}


+ 10
- 0
ir_print_visitor.cpp View File

@@ -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…
Cancel
Save