mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 11:38:05 +02:00
IR print visitor: print ir_dereference instructions
Also make a slight change to ir_variable. The ir_dereference tracks the number of nested dereferences. If an ir_variable is visited and the count is non-zero, just print the name of the variable.
This commit is contained in:
parent
6e7c278e24
commit
8c70a62193
2 changed files with 53 additions and 14 deletions
|
|
@ -47,21 +47,24 @@ print_type(const glsl_type *t)
|
|||
|
||||
void ir_print_visitor::visit(ir_variable *ir)
|
||||
{
|
||||
printf("(declare ");
|
||||
if (deref_depth) {
|
||||
printf("(%s)", ir->name);
|
||||
} else {
|
||||
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]);
|
||||
|
||||
printf("(");
|
||||
print_type(ir->type);
|
||||
printf(") ");
|
||||
|
||||
printf("(%s))\n", ir->name);
|
||||
printf("(");
|
||||
print_type(ir->type);
|
||||
printf(") ");
|
||||
printf("(%s))\n", ir->name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -94,8 +97,40 @@ void ir_print_visitor::visit(ir_expression *ir)
|
|||
|
||||
void ir_print_visitor::visit(ir_dereference *ir)
|
||||
{
|
||||
printf("%s:%d:\n", __func__, __LINE__);
|
||||
(void) ir;
|
||||
deref_depth++;
|
||||
|
||||
switch (ir->mode) {
|
||||
case ir_dereference::ir_reference_variable: {
|
||||
const unsigned swiz[4] = {
|
||||
ir->selector.swizzle.x,
|
||||
ir->selector.swizzle.y,
|
||||
ir->selector.swizzle.z,
|
||||
ir->selector.swizzle.w,
|
||||
};
|
||||
|
||||
printf("(var_ref ");
|
||||
ir->var->accept(this);
|
||||
printf("(");
|
||||
for (unsigned i = 0; i < ir->selector.swizzle.num_components; i++) {
|
||||
printf("%c", "xyzw"[swiz[i]]);
|
||||
}
|
||||
printf("))\n");
|
||||
break;
|
||||
}
|
||||
case ir_dereference::ir_reference_array:
|
||||
printf("(array_ref ");
|
||||
ir->var->accept(this);
|
||||
ir->selector.array_index->accept(this);
|
||||
printf(")\n");
|
||||
break;
|
||||
case ir_dereference::ir_reference_record:
|
||||
printf("(record_ref ");
|
||||
ir->var->accept(this);
|
||||
printf("(%s))\n", ir->selector.field);
|
||||
break;
|
||||
}
|
||||
|
||||
deref_depth--;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
class ir_print_visitor : public ir_visitor {
|
||||
public:
|
||||
ir_print_visitor()
|
||||
: deref_depth(0)
|
||||
{
|
||||
/* empty */
|
||||
}
|
||||
|
|
@ -63,6 +64,9 @@ public:
|
|||
virtual void visit(ir_call *);
|
||||
virtual void visit(ir_return *);
|
||||
/*@}*/
|
||||
|
||||
private:
|
||||
int deref_depth;
|
||||
};
|
||||
|
||||
#endif /* IR_PRINT_VISITOR_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue