glsl2: When dumping IR for debug, indent nested blocks.
No more trying to match parens in my head when looking at the body of a short function containing an if statement.
This commit is contained in:
@@ -65,6 +65,13 @@ _mesa_print_ir(exec_list *instructions,
|
|||||||
printf("\n)");
|
printf("\n)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ir_print_visitor::indent(void)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < indentation; i++)
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_type(const glsl_type *t)
|
print_type(const glsl_type *t)
|
||||||
{
|
{
|
||||||
@@ -102,23 +109,43 @@ void ir_print_visitor::visit(ir_variable *ir)
|
|||||||
void ir_print_visitor::visit(ir_function_signature *ir)
|
void ir_print_visitor::visit(ir_function_signature *ir)
|
||||||
{
|
{
|
||||||
printf("(signature ");
|
printf("(signature ");
|
||||||
|
indentation++;
|
||||||
|
|
||||||
print_type(ir->return_type);
|
print_type(ir->return_type);
|
||||||
printf("\n (parameters\n");
|
printf("\n");
|
||||||
|
indent();
|
||||||
|
|
||||||
|
printf("(parameters\n");
|
||||||
|
indentation++;
|
||||||
|
|
||||||
foreach_iter(exec_list_iterator, iter, ir->parameters) {
|
foreach_iter(exec_list_iterator, iter, ir->parameters) {
|
||||||
ir_variable *const inst = (ir_variable *) iter.get();
|
ir_variable *const inst = (ir_variable *) iter.get();
|
||||||
|
|
||||||
|
indent();
|
||||||
inst->accept(this);
|
inst->accept(this);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
printf(" )\n(");
|
indentation--;
|
||||||
|
|
||||||
|
indent();
|
||||||
|
printf(")\n");
|
||||||
|
|
||||||
|
indent();
|
||||||
|
|
||||||
|
printf("(\n");
|
||||||
|
indentation++;
|
||||||
|
|
||||||
foreach_iter(exec_list_iterator, iter, ir->body) {
|
foreach_iter(exec_list_iterator, iter, ir->body) {
|
||||||
ir_instruction *const inst = (ir_instruction *) iter.get();
|
ir_instruction *const inst = (ir_instruction *) iter.get();
|
||||||
|
|
||||||
|
indent();
|
||||||
inst->accept(this);
|
inst->accept(this);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
indentation--;
|
||||||
|
indent();
|
||||||
printf("))\n");
|
printf("))\n");
|
||||||
|
indentation--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -135,13 +162,16 @@ void ir_print_visitor::visit(ir_function *ir)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
printf("(function %s\n", ir->name);
|
printf("(function %s\n", ir->name);
|
||||||
|
indentation++;
|
||||||
foreach_iter(exec_list_iterator, iter, *ir) {
|
foreach_iter(exec_list_iterator, iter, *ir) {
|
||||||
ir_function_signature *const sig = (ir_function_signature *) iter.get();
|
ir_function_signature *const sig = (ir_function_signature *) iter.get();
|
||||||
|
|
||||||
|
indent();
|
||||||
sig->accept(this);
|
sig->accept(this);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
indentation--;
|
||||||
|
indent();
|
||||||
printf(")\n\n");
|
printf(")\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,21 +382,33 @@ ir_print_visitor::visit(ir_if *ir)
|
|||||||
ir->condition->accept(this);
|
ir->condition->accept(this);
|
||||||
|
|
||||||
printf("(\n");
|
printf("(\n");
|
||||||
|
indentation++;
|
||||||
|
|
||||||
foreach_iter(exec_list_iterator, iter, ir->then_instructions) {
|
foreach_iter(exec_list_iterator, iter, ir->then_instructions) {
|
||||||
ir_instruction *const inst = (ir_instruction *) iter.get();
|
ir_instruction *const inst = (ir_instruction *) iter.get();
|
||||||
|
|
||||||
|
indent();
|
||||||
inst->accept(this);
|
inst->accept(this);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
indentation--;
|
||||||
|
indent();
|
||||||
printf(")\n");
|
printf(")\n");
|
||||||
|
|
||||||
|
indent();
|
||||||
printf("(\n");
|
printf("(\n");
|
||||||
|
indentation++;
|
||||||
|
|
||||||
foreach_iter(exec_list_iterator, iter, ir->else_instructions) {
|
foreach_iter(exec_list_iterator, iter, ir->else_instructions) {
|
||||||
ir_instruction *const inst = (ir_instruction *) iter.get();
|
ir_instruction *const inst = (ir_instruction *) iter.get();
|
||||||
|
|
||||||
|
indent();
|
||||||
inst->accept(this);
|
inst->accept(this);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
indentation--;
|
||||||
|
indent();
|
||||||
printf("))\n");
|
printf("))\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,12 +429,17 @@ ir_print_visitor::visit(ir_loop *ir)
|
|||||||
if (ir->increment != NULL)
|
if (ir->increment != NULL)
|
||||||
ir->increment->accept(this);
|
ir->increment->accept(this);
|
||||||
printf(") (\n");
|
printf(") (\n");
|
||||||
|
indentation++;
|
||||||
|
|
||||||
foreach_iter(exec_list_iterator, iter, ir->body_instructions) {
|
foreach_iter(exec_list_iterator, iter, ir->body_instructions) {
|
||||||
ir_instruction *const inst = (ir_instruction *) iter.get();
|
ir_instruction *const inst = (ir_instruction *) iter.get();
|
||||||
|
|
||||||
|
indent();
|
||||||
inst->accept(this);
|
inst->accept(this);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
indentation--;
|
||||||
|
indent();
|
||||||
printf("))\n");
|
printf("))\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,9 +38,8 @@ extern void _mesa_print_ir(exec_list *instructions,
|
|||||||
class ir_print_visitor : public ir_visitor {
|
class ir_print_visitor : public ir_visitor {
|
||||||
public:
|
public:
|
||||||
ir_print_visitor()
|
ir_print_visitor()
|
||||||
: deref_depth(0)
|
|
||||||
{
|
{
|
||||||
/* empty */
|
indentation = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~ir_print_visitor()
|
virtual ~ir_print_visitor()
|
||||||
@@ -48,6 +47,8 @@ public:
|
|||||||
/* empty */
|
/* empty */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void indent(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \name Visit methods
|
* \name Visit methods
|
||||||
*
|
*
|
||||||
@@ -76,7 +77,7 @@ public:
|
|||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int deref_depth;
|
int indentation;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* IR_PRINT_VISITOR_H */
|
#endif /* IR_PRINT_VISITOR_H */
|
||||||
|
Reference in New Issue
Block a user