assert(d != NULL);
- ir_variable *const var = d->var->as_variable();
+ ir_variable *const var = d->variable_referenced();
assert(var != NULL);
ir_rvalue *array_index)
: ir_dereference(ir_reference_array)
{
- this->selector.array_index = array_index;
+ this->array_index = array_index;
this->set_array(value);
}
ir_rvalue *array_index)
: ir_dereference(ir_reference_array)
{
- this->selector.array_index = array_index;
+ this->array_index = array_index;
this->set_array(new ir_dereference_variable(var));
}
void
ir_dereference_array::set_array(ir_rvalue *value)
{
- this->var = value;
+ this->array = value;
this->type = glsl_type::error_type;
- if (this->var != NULL) {
- const glsl_type *const vt = this->var->type;
+ if (this->array != NULL) {
+ const glsl_type *const vt = this->array->type;
if (vt->is_array()) {
type = vt->element_type();
const char *field)
: ir_dereference(ir_reference_record)
{
- this->var = value;
- this->selector.field = field;
- this->type = (this->var != NULL)
- ? this->var->type->field_type(field) : glsl_type::error_type;
+ this->record = value;
+ this->field = field;
+ this->type = (this->record != NULL)
+ ? this->record->type->field_type(field) : glsl_type::error_type;
}
const char *field)
: ir_dereference(ir_reference_record)
{
- this->var = new ir_dereference_variable(var);
- this->selector.field = field;
- this->type = (this->var != NULL)
- ? this->var->type->field_type(field) : glsl_type::error_type;
+ this->record = new ir_dereference_variable(var);
+ this->field = field;
+ this->type = (this->record != NULL)
+ ? this->record->type->field_type(field) : glsl_type::error_type;
}
ir_reference_record
} mode;
- /**
- * Object being dereferenced.
- *
- * Must be either an \c ir_variable or an \c ir_rvalue.
- */
- ir_instruction *var;
-
- union {
- ir_rvalue *array_index;
- const char *field;
- } selector;
-
protected:
ir_dereference(ir_deref_mode mode)
: mode(mode)
*/
virtual ir_variable *variable_referenced()
{
- return (ir_variable *) this->var;
+ return this->var;
}
virtual void accept(ir_visitor *v)
}
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
+
+ /**
+ * Object being dereferenced.
+ */
+ ir_variable *var;
};
*/
virtual ir_variable *variable_referenced()
{
- return ((ir_rvalue *) this->var)->variable_referenced();
+ return this->array->variable_referenced();
}
virtual void accept(ir_visitor *v)
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
+ ir_rvalue *array;
+ ir_rvalue *array_index;
+
private:
void set_array(ir_rvalue *value);
};
*/
virtual ir_variable *variable_referenced()
{
- return ((ir_rvalue *) this->var)->variable_referenced();
+ return this->record->variable_referenced();
}
virtual void accept(ir_visitor *v)
}
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
+
+ ir_rvalue *record;
+ const char *field;
};
void
ir_constant_visitor::visit(ir_dereference_array *ir)
{
+ (void) ir;
value = NULL;
/* FINISHME: Other dereference modes. */
}
void
ir_constant_visitor::visit(ir_dereference_record *ir)
{
+ (void) ir;
value = NULL;
/* FINISHME: Other dereference modes. */
}
ir_constant_folding_visitor::visit(ir_dereference_array *ir)
{
ir_constant *const_val =
- ir->selector.array_index->constant_expression_value();
+ ir->array_index->constant_expression_value();
if (const_val)
- ir->selector.array_index = const_val;
+ ir->array_index = const_val;
else
- ir->selector.array_index->accept(this);
+ ir->array_index->accept(this);
- ir->var->accept(this);
+ ir->array->accept(this);
}
void
ir_constant_folding_visitor::visit(ir_dereference_record *ir)
{
- ir->var->accept(this);
+ ir->record->accept(this);
}
void
ir_copy_propagation_visitor::visit(ir_dereference_array *ir)
{
- ir->var->accept(this);
- ir->selector.array_index->accept(this);
+ ir->array->accept(this);
+ ir->array_index->accept(this);
}
void
ir_copy_propagation_visitor::visit(ir_dereference_record *ir)
{
- ir->var->accept(this);
+ ir->record->accept(this);
}
void
ir_dereference *lhs_deref = ir->lhs->as_dereference();
if (!lhs_deref || lhs_deref->mode != ir_dereference::ir_reference_variable)
return;
- ir_variable *lhs_var = lhs_deref->var->as_variable();
+ ir_variable *lhs_var = lhs_deref->variable_referenced();
ir_dereference *rhs_deref = ir->rhs->as_dereference();
if (!rhs_deref || rhs_deref->mode != ir_dereference::ir_reference_variable)
return;
- ir_variable *rhs_var = rhs_deref->var->as_variable();
+ ir_variable *rhs_var = rhs_deref->variable_referenced();
entry = new acp_entry(lhs_var, rhs_var);
acp->push_tail(entry);
virtual ir_visitor_status visit_enter(class ir_dereference_array *ir)
{
- ir->selector.array_index->accept(visitor);
+ ir->array_index->accept(visitor);
return visit_continue;
}
void
ir_expression_flattening_visitor::visit(ir_dereference_array *ir)
{
- ir->selector.array_index->accept(this);
- ir->var->accept(this);
+ ir->array_index->accept(this);
+ ir->array->accept(this);
}
void
ir_expression_flattening_visitor::visit(ir_dereference_record *ir)
{
- ir->var->accept(this);
+ ir->record->accept(this);
}
void
void
ir_function_cloning_visitor::visit(ir_dereference_array *ir)
{
- ir->var->accept(this);
+ ir->array->accept(this);
ir_rvalue *var = this->result->as_rvalue();
- ir->selector.array_index->accept(this);
+ ir->array_index->accept(this);
ir_rvalue *index = this->result->as_rvalue();
void
ir_function_cloning_visitor::visit(ir_dereference_record *ir)
{
- ir->var->accept(this);
+ ir->record->accept(this);
ir_rvalue *var = this->result->as_rvalue();
- this->result = new ir_dereference_record(var, strdup(ir->selector.field));
+ this->result = new ir_dereference_record(var, strdup(ir->field));
}
void
void
ir_function_inlining_visitor::visit(ir_dereference_array *ir)
{
- ir->selector.array_index->accept(this);
- ir->var->accept(this);
+ ir->array_index->accept(this);
+ ir->array->accept(this);
}
void
ir_function_inlining_visitor::visit(ir_dereference_record *ir)
{
- ir->var->accept(this);
+ ir->record->accept(this);
}
void
if (s != visit_continue)
return (s == visit_continue_with_parent) ? visit_continue : s;
- s = this->selector.array_index->accept(v);
+ s = this->array_index->accept(v);
if (s != visit_continue)
return (s == visit_continue_with_parent) ? visit_continue : s;
- s = this->var->accept(v);
+ s = this->array->accept(v);
return (s == visit_stop) ? s : v->visit_leave(this);
}
if (s != visit_continue)
return (s == visit_continue_with_parent) ? visit_continue : s;
- s = this->var->accept(v);
+ s = this->record->accept(v);
return (s == visit_stop) ? s : v->visit_leave(this);
}
void ir_print_visitor::visit(ir_dereference_array *ir)
{
printf("(array_ref ");
- ir->var->accept(this);
- ir->selector.array_index->accept(this);
+ ir->array->accept(this);
+ ir->array_index->accept(this);
printf(") ");
}
void ir_print_visitor::visit(ir_dereference_record *ir)
{
printf("(record_ref ");
- ir->var->accept(this);
- printf("(%s)) ", ir->selector.field);
+ ir->record->accept(this);
+ printf("(%s)) ", ir->field);
}