void ir_print_visitor::visit(ir_expression *ir)
{
+ static const char *const operators[] = {
+ "~",
+ "!",
+ "-",
+ "abs",
+ "rcp",
+ "rsq",
+ "sqrt",
+ "exp",
+ "log",
+ "exp2",
+ "log2",
+ "f2i",
+ "i2f",
+ "u2f",
+ "trunc",
+ "ceil",
+ "floor",
+ "+",
+ "-",
+ "*",
+ "/",
+ "%",
+ "<",
+ ">",
+ "<=",
+ ">=",
+ "==",
+ "!=",
+ "<<",
+ ">>",
+ "&",
+ "^",
+ "|",
+ "&&",
+ "^^",
+ "||",
+ "!",
+ "dot",
+ "min",
+ "max",
+ "pow",
+ };
+
printf("(expression ");
- printf("(FINISHME: operator) ");
+ assert((unsigned int)ir->operation <
+ sizeof(operators) / sizeof(operators[0]));
+ printf("%s", operators[ir->operation]);
printf("(");
if (ir->operands[0])
ir->operands[0]->accept(this);
}
+void ir_print_visitor::visit(ir_swizzle *ir)
+{
+ const unsigned swiz[4] = {
+ ir->mask.x,
+ ir->mask.y,
+ ir->mask.z,
+ ir->mask.w,
+ };
+
+ printf("(swiz ");
+ for (unsigned i = 0; i < ir->mask.num_components; i++) {
+ printf("%c", "xyzw"[swiz[i]]);
+ }
+ printf(" ");
+ ir->val->accept(this);
+ printf(")");
+}
+
+
void ir_print_visitor::visit(ir_dereference *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(")) ");
+ printf(") ");
break;
}
case ir_dereference::ir_reference_array:
print_type(base_type);
printf(") ");
- const unsigned num_values = 1
- * ((ir->type->vector_elements > 0) ? ir->type->vector_elements : 1)
- * ((ir->type->matrix_columns > 0) ? ir->type->matrix_columns : 1);
-
- printf("(%d) (", num_values);
- for (unsigned i = 0; i < num_values; i++) {
+ printf("(%d) (", ir->type->components());
+ for (unsigned i = 0; i < ir->type->components(); i++) {
if (i != 0)
printf(", ");
void
ir_print_visitor::visit(ir_call *ir)
{
- (void) ir;
+ printf("(call (%s) ", ir->callee_name());
+ foreach_iter(exec_list_iterator, iter, *ir) {
+ ir_instruction *const inst = (ir_instruction *) iter.get();
- printf("(call FINISHME: function name here\n");
- printf(" (FINISHME: function paramaters here))\n");
+ inst->accept(this);
+ }
}
printf(")");
}
+
+
+void
+ir_print_visitor::visit(ir_if *ir)
+{
+ printf("(if ");
+ ir->condition->accept(this);
+
+ printf("(\n");
+ foreach_iter(exec_list_iterator, iter, ir->then_instructions) {
+ ir_instruction *const inst = (ir_instruction *) iter.get();
+
+ inst->accept(this);
+ }
+ printf(")\n");
+
+ printf("(\n");
+ foreach_iter(exec_list_iterator, iter, ir->else_instructions) {
+ ir_instruction *const inst = (ir_instruction *) iter.get();
+
+ inst->accept(this);
+ }
+ printf("))\n");
+}