summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ir.h2
-rw-r--r--ir_print_visitor.cpp57
2 files changed, 45 insertions, 14 deletions
diff --git a/ir.h b/ir.h
index e6cdf29ebd..c52efe6178 100644
--- a/ir.h
+++ b/ir.h
@@ -217,7 +217,7 @@ public:
ir_rvalue *condition;
};
-
+/* Update ir_print_visitor.cpp when updating this list. */
enum ir_expression_operation {
ir_unop_bit_not,
ir_unop_logic_not,
diff --git a/ir_print_visitor.cpp b/ir_print_visitor.cpp
index 6d0f797807..f055e8f1d8 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(") ");