IR print visitor: Print out something for the operator.

This commit is contained in:
Eric Anholt
2010-03-26 11:00:07 -07:00
committed by Ian Romanick
parent d1dfe8b994
commit e65e12fdbc
2 changed files with 45 additions and 14 deletions
+1 -1
View File
@@ -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,
+44 -13
View File
@@ -86,22 +86,53 @@ void ir_print_visitor::visit(ir_function *ir)
void ir_print_visitor::visit(ir_expression *ir)
{
static const char *const operators[] = {
"~",
"!",
"-",
"abs",
"rcp",
"rsq",
"exp",
"log",
"f2i",
"i2f",
"u2f",
"trunc",
"ceil",
"floor",
"+",
"-",
"*",
"/",
"%",
"<",
">",
"<=",
">=",
"==",
"!=",
"<<",
">>",
"&",
"^",
"|",
"&&",
"^^",
"||",
"!",
"dot",
"min",
"max",
};
printf("(expression ");
const char *str;
char buf[256];
assert((unsigned int)ir->operation <
sizeof(operators) / sizeof(operators[0]));
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;
}
printf("(%s) (", str);
printf("%s", operators[ir->operation]);
printf("(");
if (ir->operands[0])
ir->operands[0]->accept(this);
printf(") ");