* FINISHME: required or not.
*/
- if (var->type->array_size() <= earlier->max_array_access) {
+ if (var->type->array_size() <= (int)earlier->max_array_access) {
YYLTYPE loc = this->get_location();
_mesa_glsl_error(& loc, state, "array size must be > %u due to "
assert(state->current_function == NULL);
state->current_function = signature;
- ir_label *label = new ir_label(signature->function_name());
+ ir_label *label = new ir_label(signature->function_name(), signature);
if (signature->definition == NULL) {
signature->definition = label;
}
ir_variable *const var = proto->clone();
- instructions->push_tail(var);
+ signature->body.push_tail(var);
/* The only way a parameter would "exist" is if two parameters have
* the same name.
* instructions to the list that currently consists of the function label
* and the function parameters.
*/
- this->body->hir(instructions, state);
+ this->body->hir(&signature->body, state);
state->symbols->pop_scope();
ir_function_signature *const sig = new ir_function_signature(type);
f->add_signature(sig);
- ir_label *const label = new ir_label(name);
+ ir_label *const label = new ir_label(name, sig);
instructions->push_tail(label);
sig->definition = label;
static const char *arg_names[] = {
var = new ir_variable(type, arg_names[i]);
var->mode = ir_var_in;
- instructions->push_tail(var);
+ sig->body.push_tail(var);
declarations[i] = var;
}
ir_variable *retval = new ir_variable(ret_type, "__retval");
- instructions->push_tail(retval);
+ sig->body.push_tail(retval);
declarations[16] = retval;
- generate(instructions, declarations, type);
+ generate(&sig->body, declarations, type);
}
void
*/
static ir_label *
generate_constructor_intro(const glsl_type *type, unsigned parameter_count,
- exec_list *parameters, exec_list *instructions,
+ ir_function_signature *const signature,
+ exec_list *instructions,
ir_variable **declarations)
{
/* Names of parameters used in vector and matrix constructors
const glsl_type *const parameter_type = type->get_base_type();
- ir_label *const label = new ir_label(type->name);
+ ir_label *const label = new ir_label(type->name, signature);
instructions->push_tail(label);
for (unsigned i = 0; i < parameter_count; i++) {
ir_variable *var = new ir_variable(parameter_type, names[i]);
var->mode = ir_var_in;
- parameters->push_tail(var);
+ signature->parameters.push_tail(var);
var = new ir_variable(parameter_type, names[i]);
var->mode = ir_var_in;
- instructions->push_tail(var);
+ signature->body.push_tail(var);
declarations[i] = var;
}
ir_variable *retval = new ir_variable(type, "__retval");
- instructions->push_tail(retval);
+ signature->body.push_tail(retval);
declarations[16] = retval;
return label;
f->add_signature(sig);
sig->definition =
- generate_constructor_intro(& types[i], 1, & sig->parameters,
+ generate_constructor_intro(& types[i], 1, sig,
instructions, declarations);
if (types[i].is_vector()) {
- generate_vec_body_from_scalar(instructions, declarations);
+ generate_vec_body_from_scalar(&sig->body, declarations);
ir_function_signature *const vec_sig =
new ir_function_signature(& types[i]);
vec_sig->definition =
generate_constructor_intro(& types[i], types[i].vector_elements,
- & vec_sig->parameters, instructions,
+ vec_sig, instructions,
declarations);
- generate_vec_body_from_N_scalars(instructions, declarations);
+ generate_vec_body_from_N_scalars(&sig->body, declarations);
} else {
assert(types[i].is_matrix());
- generate_mat_body_from_scalar(instructions, declarations);
+ generate_mat_body_from_scalar(&sig->body, declarations);
ir_function_signature *const mat_sig =
new ir_function_signature(& types[i]);
generate_constructor_intro(& types[i],
(types[i].vector_elements
* types[i].matrix_columns),
- & mat_sig->parameters, instructions,
+ mat_sig, instructions,
declarations);
generate_mat_body_from_N_scalars(instructions, declarations);
}
return num_operands[this->operation];
}
-ir_label::ir_label(const char *label)
- : ir_instruction(), label(label)
+ir_label::ir_label(const char *label, ir_function_signature *signature)
+ : ir_instruction(), label(label), signature(signature)
{
/* empty */
}
class ir_label : public ir_instruction {
public:
- ir_label(const char *label);
+ ir_label(const char *label, ir_function_signature *signature);
virtual void accept(ir_visitor *v)
{
}
const char *label;
+
+ ir_function_signature *signature;
};
/*@{*/
class ir_function_signature : public ir_instruction {
+ /* An ir_function_signature will be part of the list of signatures in
+ * an ir_function.
+ */
public:
ir_function_signature(const glsl_type *return_type);
*/
ir_label *definition;
+ /** Body of instructions in the function. */
+ struct exec_list body;
+
private:
/** Function of which this signature is one overload. */
class ir_function *function;
void
ir_constant_folding_visitor::visit(ir_label *ir)
{
- (void) ir;
+ ir->signature->accept(this);
}
void
ir_constant_folding_visitor::visit(ir_function_signature *ir)
{
- (void) ir;
+ visit_exec_list(&ir->body, this);
}
void ir_print_visitor::visit(ir_label *ir)
{
- printf("\n(label %s)", ir->label);
+ printf("\n(label %s\n", ir->label);
+ ir->signature->accept(this);
+ printf(")");
}
void ir_print_visitor::visit(ir_function_signature *ir)
{
- printf("%s:%d:\n", __func__, __LINE__);
- (void) ir;
+ foreach_iter(exec_list_iterator, iter, ir->body) {
+ ir_instruction *const inst = (ir_instruction *) iter.get();
+
+ inst->accept(this);
+ printf("\n");
+ }
}