From: Ian Romanick Date: Wed, 31 Mar 2010 23:37:10 +0000 (-0700) Subject: Use ir_function::add_signature to create link between function and signature X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6a15d5b514b703ff8dd024f96ffbcb68484a954e;p=mesa.git Use ir_function::add_signature to create link between function and signature ir_function_signature now has a pointer back to the ir_function that owns it. --- diff --git a/ast_to_hir.cpp b/ast_to_hir.cpp index 5341dd59ce2..78c92822e30 100644 --- a/ast_to_hir.cpp +++ b/ast_to_hir.cpp @@ -1530,7 +1530,7 @@ ast_function_definition::hir(exec_list *instructions, */ if (signature == NULL) { signature = new ir_function_signature(return_type); - f->signatures.push_tail(signature); + f->add_signature(signature); } else { /* Destroy all of the previous parameter information. The previous * parameter information comes from the function prototype, and it can diff --git a/builtin_function.cpp b/builtin_function.cpp index 8e7e1164b8c..684a10c8893 100644 --- a/builtin_function.cpp +++ b/builtin_function.cpp @@ -214,7 +214,7 @@ generate_function_instance(ir_function *f, ir_variable *declarations[17]; ir_function_signature *const sig = new ir_function_signature(type); - f->signatures.push_tail(sig); + f->add_signature(sig); ir_label *const label = new ir_label(name); instructions->push_tail(label); diff --git a/glsl_types.cpp b/glsl_types.cpp index a38750e9bb1..ba4f0297d81 100644 --- a/glsl_types.cpp +++ b/glsl_types.cpp @@ -129,7 +129,7 @@ glsl_type::generate_constructor_prototype(glsl_symbol_table *symtab) const assert(added); ir_function_signature *const sig = new ir_function_signature(this); - f->signatures.push_tail(sig); + f->add_signature(sig); for (unsigned i = 0; i < length; i++) { char *const param_name = (char *) malloc(10); @@ -433,7 +433,7 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, * appropriate from-scalars constructor. */ ir_function_signature *const sig = new ir_function_signature(& types[i]); - f->signatures.push_tail(sig); + f->add_signature(sig); sig->definition = generate_constructor_intro(& types[i], 1, & sig->parameters, @@ -444,7 +444,7 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, ir_function_signature *const vec_sig = new ir_function_signature(& types[i]); - f->signatures.push_tail(vec_sig); + f->add_signature(vec_sig); vec_sig->definition = generate_constructor_intro(& types[i], types[i].vector_elements, @@ -458,7 +458,7 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types, ir_function_signature *const mat_sig = new ir_function_signature(& types[i]); - f->signatures.push_tail(mat_sig); + f->add_signature(mat_sig); mat_sig->definition = generate_constructor_intro(& types[i], diff --git a/ir.h b/ir.h index aa3e03a2111..2d2da1df763 100644 --- a/ir.h +++ b/ir.h @@ -160,6 +160,12 @@ public: * Pointer to the label that begins the function definition. */ ir_label *definition; + +private: + /** Function of which this signature is one overload. */ + class ir_function *function; + + friend class ir_function; }; @@ -175,6 +181,12 @@ public: v->visit(this); } + void add_signature(ir_function_signature *sig) + { + sig->function = this; + signatures.push_tail(sig); + } + /** * Find a signature that matches a set of actual parameters. */