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
*/ | */ | ||||
state->symbols->push_scope(); | state->symbols->push_scope(); | ||||
foreach_iter(exec_list_iterator, iter, signature->parameters) { | 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 only way a parameter would "exist" is if two parameters have | ||||
* the same name. | * the same name. |
for (i = 0; i < n_args; i++) { | for (i = 0; i < n_args; i++) { | ||||
ir_variable *var = new ir_variable(type, arg_names[i]); | ir_variable *var = new ir_variable(type, arg_names[i]); | ||||
var = new ir_variable(type, arg_names[i]); | |||||
var->mode = ir_var_in; | var->mode = ir_var_in; | ||||
sig->parameters.push_tail(var); | 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; | declarations[i] = var; | ||||
} | } | ||||
var->mode = ir_var_in; | var->mode = ir_var_in; | ||||
signature->parameters.push_tail(var); | 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; | declarations[i] = var; | ||||
} | } | ||||
void ir_print_visitor::visit(ir_label *ir) | void ir_print_visitor::visit(ir_label *ir) | ||||
{ | { | ||||
printf("\n(label %s\n", ir->label); | printf("\n(label %s\n", ir->label); | ||||
ir->signature->accept(this); | ir->signature->accept(this); | ||||
printf(")"); | printf(")"); | ||||
} | } | ||||
void ir_print_visitor::visit(ir_function_signature *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) { | foreach_iter(exec_list_iterator, iter, ir->body) { | ||||
ir_instruction *const inst = (ir_instruction *) iter.get(); | ir_instruction *const inst = (ir_instruction *) iter.get(); | ||||