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.
This commit is contained in:
Ian Romanick
2010-03-31 16:37:10 -07:00
parent 4ef183e51d
commit 6a15d5b514
4 changed files with 18 additions and 6 deletions

View File

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

View File

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

View File

@@ -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],

12
ir.h
View File

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