From fbc7c0b8f2e161bce1c048c63d2d5cfcdeb096f1 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 7 Apr 2010 14:32:53 -0700 Subject: [PATCH] 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. --- ast_to_hir.cpp | 8 ++------ builtin_function.cpp | 4 ---- glsl_types.cpp | 5 ----- ir_print_visitor.cpp | 10 ++++++++++ 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index d74e54c602e..aa9a3a1a04d 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -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. diff --git a/builtin_function.cpp b/builtin_function.cpp index 9cefbd4ae5f..e537141e3f0 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -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; } diff --git a/glsl_types.cpp b/glsl_types.cpp index b7abdaef2ce..c8d18b9ee7a 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -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; } diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp index 8396973f6c5..908f1c3ad8d 100644 --- a/ir_print_visitor.cpp +++ b/ir_print_visitor.cpp @@ -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(); -- 2.30.2