summaryrefslogtreecommitdiffstats
path: root/ir_print_visitor.cpp
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2010-03-26 11:00:07 -0700
committerIan Romanick <[email protected]>2010-03-26 17:51:40 -0700
commite65e12fdbc2f51ecc3ca9265993c0c7a03e05a84 (patch)
tree996a88e2b024cc986c4c0ecdc0a80cd11e194dd4 /ir_print_visitor.cpp
parentd1dfe8b994218e4b593b71fc756055a48d469527 (diff)
IR print visitor: Print out something for the operator.
Diffstat (limited to 'ir_print_visitor.cpp')
-rw-r--r--ir_print_visitor.cpp57
1 files changed, 44 insertions, 13 deletions
diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp
index 6d0f797807c..f055e8f1d8f 100644
--- a/ir_print_visitor.cpp
+++ b/ir_print_visitor.cpp
@@ -86,22 +86,53 @@ void ir_print_visitor::visit(ir_function *ir)
void ir_print_visitor::visit(ir_expression *ir)
{
- printf("(expression ");
+ static const char *const operators[] = {
+ "~",
+ "!",
+ "-",
+ "abs",
+ "rcp",
+ "rsq",
+ "exp",
+ "log",
+ "f2i",
+ "i2f",
+ "u2f",
+ "trunc",
+ "ceil",
+ "floor",
+ "+",
+ "-",
+ "*",
+ "/",
+ "%",
+ "<",
+ ">",
+ "<=",
+ ">=",
+ "==",
+ "!=",
+ "<<",
+ ">>",
+ "&",
+ "^",
+ "|",
+ "&&",
+ "^^",
+ "||",
+ "!",
+ "dot",
+ "min",
+ "max",
+ };
- const char *str;
- char buf[256];
+ printf("(expression ");
- switch (ir->operation) {
- case ir_unop_f2i: str = "f2i"; break;
- case ir_unop_i2f: str = "i2f"; break;
- case ir_unop_u2f: str = "u2f"; break;
- default:
- snprintf(buf, sizeof(buf), "operator %u", ir->operation);
- str = buf;
- break;
- }
+ assert((unsigned int)ir->operation <
+ sizeof(operators) / sizeof(operators[0]));
- printf("(%s) (", str);
+ printf("%s", operators[ir->operation]);
+ printf("(");
if (ir->operands[0])
ir->operands[0]->accept(this);
printf(") ");