return this;
}
- virtual void accept(ir_visitor *v)
- {
- v->visit(this);
- }
-
bool is_lvalue();
/**
return (ir_variable *) this->var;
}
+ virtual void accept(ir_visitor *v)
+ {
+ v->visit(this);
+ }
+
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
};
return ((ir_rvalue *) this->var)->variable_referenced();
}
+ virtual void accept(ir_visitor *v)
+ {
+ v->visit(this);
+ }
+
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
private:
return ((ir_rvalue *) this->var)->variable_referenced();
}
+ virtual void accept(ir_visitor *v)
+ {
+ v->visit(this);
+ }
+
virtual ir_visitor_status accept(ir_hierarchical_visitor *);
};
virtual void visit(ir_function *);
virtual void visit(ir_expression *);
virtual void visit(ir_swizzle *);
- virtual void visit(ir_dereference *);
+ virtual void visit(ir_dereference_variable *);
+ virtual void visit(ir_dereference_array *);
+ virtual void visit(ir_dereference_record *);
virtual void visit(ir_assignment *);
virtual void visit(ir_constant *);
virtual void visit(ir_call *);
void
-ir_constant_visitor::visit(ir_dereference *ir)
+ir_constant_visitor::visit(ir_dereference_variable *ir)
{
value = NULL;
- if (ir->mode == ir_dereference::ir_reference_variable) {
- ir_variable *var = ir->var->as_variable();
- if (var && var->constant_value) {
- value = new ir_constant(ir->type, &var->constant_value->value);
- }
- }
+ ir_variable *var = ir->variable_referenced();
+ if (var && var->constant_value)
+ value = new ir_constant(ir->type, &var->constant_value->value);
+}
+
+
+void
+ir_constant_visitor::visit(ir_dereference_array *ir)
+{
+ value = NULL;
+ /* FINISHME: Other dereference modes. */
+}
+
+
+void
+ir_constant_visitor::visit(ir_dereference_record *ir)
+{
+ value = NULL;
/* FINISHME: Other dereference modes. */
}
virtual void visit(ir_function *);
virtual void visit(ir_expression *);
virtual void visit(ir_swizzle *);
- virtual void visit(ir_dereference *);
+ virtual void visit(ir_dereference_variable *);
+ virtual void visit(ir_dereference_array *);
+ virtual void visit(ir_dereference_record *);
virtual void visit(ir_assignment *);
virtual void visit(ir_constant *);
virtual void visit(ir_call *);
void
-ir_constant_folding_visitor::visit(ir_dereference *ir)
-{
- if (ir->mode == ir_dereference::ir_reference_array) {
- ir_constant *const_val = ir->selector.array_index->constant_expression_value();
- if (const_val)
- ir->selector.array_index = const_val;
- else
- ir->selector.array_index->accept(this);
- }
+ir_constant_folding_visitor::visit(ir_dereference_variable *ir)
+{
+ (void) ir;
+}
+
+
+void
+ir_constant_folding_visitor::visit(ir_dereference_array *ir)
+{
+ ir_constant *const_val =
+ ir->selector.array_index->constant_expression_value();
+
+ if (const_val)
+ ir->selector.array_index = const_val;
+ else
+ ir->selector.array_index->accept(this);
+
+ ir->var->accept(this);
+}
+
+
+void
+ir_constant_folding_visitor::visit(ir_dereference_record *ir)
+{
ir->var->accept(this);
}
virtual void visit(ir_function *);
virtual void visit(ir_expression *);
virtual void visit(ir_swizzle *);
- virtual void visit(ir_dereference *);
+ virtual void visit(ir_dereference_variable *);
+ virtual void visit(ir_dereference_array *);
+ virtual void visit(ir_dereference_record *);
virtual void visit(ir_assignment *);
virtual void visit(ir_constant *);
virtual void visit(ir_call *);
* must not be shared by multiple IR operations!
*/
void
-ir_copy_propagation_visitor::visit(ir_dereference *ir)
+ir_copy_propagation_visitor::visit(ir_dereference_variable *ir)
{
- ir_variable *var;
+ ir_variable *var = ir->variable_referenced();
- if (ir->mode == ir_dereference::ir_reference_array) {
- ir->selector.array_index->accept(this);
- }
-
- var = ir->var->as_variable();
- if (var) {
- foreach_iter(exec_list_iterator, iter, *this->acp) {
- acp_entry *entry = (acp_entry *)iter.get();
+ foreach_iter(exec_list_iterator, iter, *this->acp) {
+ acp_entry *entry = (acp_entry *)iter.get();
- if (var == entry->lhs) {
- ir->var = entry->rhs;
- this->progress = true;
- break;
- }
+ if (var == entry->lhs) {
+ ir->var = entry->rhs;
+ this->progress = true;
+ break;
}
- } else {
- ir->var->accept(this);
}
}
+void
+ir_copy_propagation_visitor::visit(ir_dereference_array *ir)
+{
+ ir->var->accept(this);
+ ir->selector.array_index->accept(this);
+}
+
+void
+ir_copy_propagation_visitor::visit(ir_dereference_record *ir)
+{
+ ir->var->accept(this);
+}
+
void
ir_copy_propagation_visitor::visit(ir_assignment *ir)
{
virtual void visit(ir_function *);
virtual void visit(ir_expression *);
virtual void visit(ir_swizzle *);
- virtual void visit(ir_dereference *);
+ virtual void visit(ir_dereference_variable *);
+ virtual void visit(ir_dereference_array *);
+ virtual void visit(ir_dereference_record *);
virtual void visit(ir_assignment *);
virtual void visit(ir_constant *);
virtual void visit(ir_call *);
void
-ir_expression_flattening_visitor::visit(ir_dereference *ir)
+ir_expression_flattening_visitor::visit(ir_dereference_variable *ir)
+{
+ ir->var->accept(this);
+}
+
+void
+ir_expression_flattening_visitor::visit(ir_dereference_array *ir)
+{
+ ir->selector.array_index->accept(this);
+ ir->var->accept(this);
+}
+
+void
+ir_expression_flattening_visitor::visit(ir_dereference_record *ir)
{
- if (ir->mode == ir_dereference::ir_reference_array) {
- ir->selector.array_index->accept(this);
- }
ir->var->accept(this);
}
virtual void visit(ir_function *);
virtual void visit(ir_expression *);
virtual void visit(ir_swizzle *);
- virtual void visit(ir_dereference *);
+ virtual void visit(ir_dereference_variable *);
+ virtual void visit(ir_dereference_array *);
+ virtual void visit(ir_dereference_record *);
virtual void visit(ir_assignment *);
virtual void visit(ir_constant *);
virtual void visit(ir_call *);
virtual void visit(ir_function *);
virtual void visit(ir_expression *);
virtual void visit(ir_swizzle *);
- virtual void visit(ir_dereference *);
+ virtual void visit(ir_dereference_variable *);
+ virtual void visit(ir_dereference_array *);
+ virtual void visit(ir_dereference_record *);
virtual void visit(ir_assignment *);
virtual void visit(ir_constant *);
virtual void visit(ir_call *);
}
void
-ir_function_cloning_visitor::visit(ir_dereference *ir)
+ir_function_cloning_visitor::visit(ir_dereference_variable *ir)
{
- if (ir->mode == ir_dereference::ir_reference_variable) {
- ir_variable *var = this->get_remapped_variable(ir->variable_referenced());
- this->result = new ir_dereference_variable(var);
- } else if (ir->mode == ir_dereference::ir_reference_array) {
- ir->var->accept(this);
+ ir_variable *var = this->get_remapped_variable(ir->variable_referenced());
+ this->result = new ir_dereference_variable(var);
+}
- ir_rvalue *var = this->result->as_rvalue();
+void
+ir_function_cloning_visitor::visit(ir_dereference_array *ir)
+{
+ ir->var->accept(this);
- ir->selector.array_index->accept(this);
+ ir_rvalue *var = this->result->as_rvalue();
- ir_rvalue *index = this->result->as_rvalue();
+ ir->selector.array_index->accept(this);
- this->result = new ir_dereference_array(var, index);
- } else {
- assert(ir->mode == ir_dereference::ir_reference_record);
+ ir_rvalue *index = this->result->as_rvalue();
- ir->var->accept(this);
+ this->result = new ir_dereference_array(var, index);
+}
- ir_rvalue *var = this->result->as_rvalue();
+void
+ir_function_cloning_visitor::visit(ir_dereference_record *ir)
+{
+ ir->var->accept(this);
- this->result = new ir_dereference_record(var, strdup(ir->selector.field));
- }
+ ir_rvalue *var = this->result->as_rvalue();
+
+ this->result = new ir_dereference_record(var, strdup(ir->selector.field));
}
void
void
-ir_function_inlining_visitor::visit(ir_dereference *ir)
+ir_function_inlining_visitor::visit(ir_dereference_variable *ir)
+{
+ ir->var->accept(this);
+}
+
+void
+ir_function_inlining_visitor::visit(ir_dereference_array *ir)
+{
+ ir->selector.array_index->accept(this);
+ ir->var->accept(this);
+}
+
+void
+ir_function_inlining_visitor::visit(ir_dereference_record *ir)
{
- if (ir->mode == ir_dereference::ir_reference_array) {
- ir->selector.array_index->accept(this);
- }
ir->var->accept(this);
}
void ir_print_visitor::visit(ir_variable *ir)
{
- if (deref_depth) {
- printf("%s", ir->name);
- } else {
- printf("(declare ");
+ printf("(declare ");
- const char *const cent = (ir->centroid) ? "centroid " : "";
- const char *const inv = (ir->invariant) ? "invariant " : "";
- const char *const mode[] = { "", "uniform ", "in ", "out ", "inout " };
- const char *const interp[] = { "", "flat", "noperspective" };
+ const char *const cent = (ir->centroid) ? "centroid " : "";
+ const char *const inv = (ir->invariant) ? "invariant " : "";
+ const char *const mode[] = { "", "uniform ", "in ", "out ", "inout " };
+ const char *const interp[] = { "", "flat", "noperspective" };
- printf("(%s%s%s%s) ",
- cent, inv, mode[ir->mode], interp[ir->interpolation]);
+ printf("(%s%s%s%s) ",
+ cent, inv, mode[ir->mode], interp[ir->interpolation]);
- print_type(ir->type);
- printf(" %s)", ir->name);
- }
+ print_type(ir->type);
+ printf(" %s)", ir->name);
}
}
-void ir_print_visitor::visit(ir_dereference *ir)
+void ir_print_visitor::visit(ir_dereference_variable *ir)
{
- deref_depth++;
-
- switch (ir->mode) {
- case ir_dereference::ir_reference_variable: {
- printf("(var_ref ");
- ir->var->accept(this);
- printf(") ");
- break;
- }
- case ir_dereference::ir_reference_array:
- printf("(array_ref ");
- ir->var->accept(this);
- ir->selector.array_index->accept(this);
- printf(") ");
- break;
- case ir_dereference::ir_reference_record:
- printf("(record_ref ");
- ir->var->accept(this);
- printf("(%s)) ", ir->selector.field);
- break;
- }
+ printf("(var_ref %s) ", ir->variable_referenced()->name);
+}
+
- deref_depth--;
+void ir_print_visitor::visit(ir_dereference_array *ir)
+{
+ printf("(array_ref ");
+ ir->var->accept(this);
+ ir->selector.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);
}
virtual void visit(ir_function *);
virtual void visit(ir_expression *);
virtual void visit(ir_swizzle *);
- virtual void visit(ir_dereference *);
+ virtual void visit(ir_dereference_variable *);
+ virtual void visit(ir_dereference_array *);
+ virtual void visit(ir_dereference_record *);
virtual void visit(ir_assignment *);
virtual void visit(ir_constant *);
virtual void visit(ir_call *);
virtual void visit(class ir_function *) = 0;
virtual void visit(class ir_expression *) = 0;
virtual void visit(class ir_swizzle *) = 0;
- virtual void visit(class ir_dereference *) = 0;
+ virtual void visit(class ir_dereference_variable *) = 0;
+ virtual void visit(class ir_dereference_array *) = 0;
+ virtual void visit(class ir_dereference_record *) = 0;
virtual void visit(class ir_assignment *) = 0;
virtual void visit(class ir_constant *) = 0;
virtual void visit(class ir_call *) = 0;