2010-03-09 16:23:37 -08:00
|
|
|
/*
|
|
|
|
* Copyright © 2010 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
2010-06-22 10:38:52 -07:00
|
|
|
|
2010-03-09 16:23:37 -08:00
|
|
|
#include "ir_print_visitor.h"
|
2010-03-09 21:44:34 -08:00
|
|
|
#include "glsl_types.h"
|
2010-04-28 13:14:53 -07:00
|
|
|
#include "glsl_parser_extras.h"
|
|
|
|
|
|
|
|
static void print_type(const glsl_type *t);
|
2010-03-09 21:44:34 -08:00
|
|
|
|
2010-06-22 12:09:21 -07:00
|
|
|
void
|
2010-06-23 11:37:12 -07:00
|
|
|
ir_instruction::print(void) const
|
2010-06-22 12:09:21 -07:00
|
|
|
{
|
2010-06-23 11:37:12 -07:00
|
|
|
ir_instruction *deconsted = const_cast<ir_instruction *>(this);
|
|
|
|
|
2010-06-22 12:09:21 -07:00
|
|
|
ir_print_visitor v;
|
2010-06-23 11:37:12 -07:00
|
|
|
deconsted->accept(&v);
|
2010-06-22 12:09:21 -07:00
|
|
|
}
|
|
|
|
|
2010-04-28 13:04:15 -07:00
|
|
|
void
|
|
|
|
_mesa_print_ir(exec_list *instructions,
|
|
|
|
struct _mesa_glsl_parse_state *state)
|
|
|
|
{
|
2010-07-29 15:04:45 -07:00
|
|
|
if (state) {
|
|
|
|
for (unsigned i = 0; i < state->num_user_structures; i++) {
|
|
|
|
const glsl_type *const s = state->user_structures[i];
|
2010-04-28 13:14:53 -07:00
|
|
|
|
2010-07-29 15:04:45 -07:00
|
|
|
printf("(structure (%s) (%s@%p) (%u) (\n",
|
2010-08-11 14:00:36 -06:00
|
|
|
s->name, s->name, (void *) s, s->length);
|
2010-04-28 13:14:53 -07:00
|
|
|
|
2010-07-29 15:04:45 -07:00
|
|
|
for (unsigned j = 0; j < s->length; j++) {
|
|
|
|
printf("\t((");
|
|
|
|
print_type(s->fields.structure[j].type);
|
|
|
|
printf(")(%s))\n", s->fields.structure[j].name);
|
|
|
|
}
|
2010-04-28 13:14:53 -07:00
|
|
|
|
2010-07-29 15:04:45 -07:00
|
|
|
printf(")\n");
|
|
|
|
}
|
2010-04-28 13:14:53 -07:00
|
|
|
}
|
2010-04-28 13:04:15 -07:00
|
|
|
|
|
|
|
printf("(\n");
|
|
|
|
foreach_iter(exec_list_iterator, iter, *instructions) {
|
2010-07-29 14:20:39 -07:00
|
|
|
ir_instruction *ir = (ir_instruction *)iter.get();
|
|
|
|
ir->print();
|
|
|
|
if (ir->ir_type != ir_type_function)
|
|
|
|
printf("\n");
|
2010-04-28 13:04:15 -07:00
|
|
|
}
|
|
|
|
printf("\n)");
|
|
|
|
}
|
|
|
|
|
2010-07-29 14:36:59 -07:00
|
|
|
|
|
|
|
void ir_print_visitor::indent(void)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < indentation; i++)
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
|
2010-03-09 21:44:34 -08:00
|
|
|
static void
|
|
|
|
print_type(const glsl_type *t)
|
|
|
|
{
|
|
|
|
if (t->base_type == GLSL_TYPE_ARRAY) {
|
2010-04-07 14:41:13 -07:00
|
|
|
printf("(array ");
|
2010-03-09 21:44:34 -08:00
|
|
|
print_type(t->fields.array);
|
2010-04-09 17:59:51 -07:00
|
|
|
printf(" %u)", t->length);
|
2010-04-28 13:14:53 -07:00
|
|
|
} else if ((t->base_type == GLSL_TYPE_STRUCT)
|
|
|
|
&& (strncmp("gl_", t->name, 3) != 0)) {
|
2010-08-11 14:00:36 -06:00
|
|
|
printf("%s@%p", t->name, (void *) t);
|
2010-03-09 21:44:34 -08:00
|
|
|
} else {
|
|
|
|
printf("%s", t->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-09 16:23:37 -08:00
|
|
|
|
|
|
|
void ir_print_visitor::visit(ir_variable *ir)
|
|
|
|
{
|
2010-05-19 13:20:12 +02:00
|
|
|
printf("(declare ");
|
2010-03-09 16:23:37 -08:00
|
|
|
|
2010-05-19 13:20:12 +02:00
|
|
|
const char *const cent = (ir->centroid) ? "centroid " : "";
|
|
|
|
const char *const inv = (ir->invariant) ? "invariant " : "";
|
2010-07-22 16:18:57 -07:00
|
|
|
const char *const mode[] = { "", "uniform ", "in ", "out ", "inout ",
|
2011-01-12 15:37:37 -08:00
|
|
|
"const_in ", "sys ", "temporary " };
|
2010-05-19 13:20:12 +02:00
|
|
|
const char *const interp[] = { "", "flat", "noperspective" };
|
2010-03-09 16:23:37 -08:00
|
|
|
|
2010-05-19 13:20:12 +02:00
|
|
|
printf("(%s%s%s%s) ",
|
|
|
|
cent, inv, mode[ir->mode], interp[ir->interpolation]);
|
2010-03-09 21:44:34 -08:00
|
|
|
|
2010-05-19 13:20:12 +02:00
|
|
|
print_type(ir->type);
|
2010-08-11 14:00:36 -06:00
|
|
|
printf(" %s@%p)", ir->name, (void *) ir);
|
2010-03-09 16:23:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ir_print_visitor::visit(ir_function_signature *ir)
|
|
|
|
{
|
2010-04-21 17:28:46 -07:00
|
|
|
printf("(signature ");
|
2010-07-29 14:36:59 -07:00
|
|
|
indentation++;
|
|
|
|
|
2010-04-21 17:28:46 -07:00
|
|
|
print_type(ir->return_type);
|
2010-07-29 14:36:59 -07:00
|
|
|
printf("\n");
|
|
|
|
indent();
|
|
|
|
|
|
|
|
printf("(parameters\n");
|
|
|
|
indentation++;
|
|
|
|
|
2010-04-07 14:32:53 -07:00
|
|
|
foreach_iter(exec_list_iterator, iter, ir->parameters) {
|
|
|
|
ir_variable *const inst = (ir_variable *) iter.get();
|
|
|
|
|
2010-07-29 14:36:59 -07:00
|
|
|
indent();
|
2010-04-07 14:32:53 -07:00
|
|
|
inst->accept(this);
|
|
|
|
printf("\n");
|
|
|
|
}
|
2010-07-29 14:36:59 -07:00
|
|
|
indentation--;
|
|
|
|
|
|
|
|
indent();
|
|
|
|
printf(")\n");
|
|
|
|
|
|
|
|
indent();
|
|
|
|
|
|
|
|
printf("(\n");
|
|
|
|
indentation++;
|
2010-04-07 14:32:53 -07:00
|
|
|
|
2010-04-07 13:19:11 -07:00
|
|
|
foreach_iter(exec_list_iterator, iter, ir->body) {
|
|
|
|
ir_instruction *const inst = (ir_instruction *) iter.get();
|
|
|
|
|
2010-07-29 14:36:59 -07:00
|
|
|
indent();
|
2010-04-07 13:19:11 -07:00
|
|
|
inst->accept(this);
|
|
|
|
printf("\n");
|
|
|
|
}
|
2010-07-29 14:36:59 -07:00
|
|
|
indentation--;
|
|
|
|
indent();
|
2010-04-21 12:30:22 -07:00
|
|
|
printf("))\n");
|
2010-07-29 14:36:59 -07:00
|
|
|
indentation--;
|
2010-03-09 16:23:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ir_print_visitor::visit(ir_function *ir)
|
|
|
|
{
|
|
|
|
printf("(function %s\n", ir->name);
|
2010-07-29 14:36:59 -07:00
|
|
|
indentation++;
|
2010-04-21 12:30:22 -07:00
|
|
|
foreach_iter(exec_list_iterator, iter, *ir) {
|
|
|
|
ir_function_signature *const sig = (ir_function_signature *) iter.get();
|
2010-07-29 14:36:59 -07:00
|
|
|
indent();
|
2010-04-21 12:30:22 -07:00
|
|
|
sig->accept(this);
|
|
|
|
printf("\n");
|
|
|
|
}
|
2010-07-29 14:36:59 -07:00
|
|
|
indentation--;
|
|
|
|
indent();
|
2010-07-29 14:20:39 -07:00
|
|
|
printf(")\n\n");
|
2010-03-09 16:23:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ir_print_visitor::visit(ir_expression *ir)
|
|
|
|
{
|
2010-03-25 18:25:37 -07:00
|
|
|
printf("(expression ");
|
|
|
|
|
2010-04-07 16:36:32 -07:00
|
|
|
print_type(ir->type);
|
|
|
|
|
2010-04-07 17:18:29 -07:00
|
|
|
printf(" %s ", ir->operator_string());
|
2010-04-07 16:36:32 -07:00
|
|
|
|
2010-11-10 16:33:10 -08:00
|
|
|
for (unsigned i = 0; i < ir->get_num_operands(); i++) {
|
|
|
|
ir->operands[i]->accept(this);
|
|
|
|
}
|
2010-03-25 18:25:37 -07:00
|
|
|
|
2010-04-12 14:52:37 -07:00
|
|
|
printf(") ");
|
2010-03-09 16:23:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-26 15:15:31 -07:00
|
|
|
void ir_print_visitor::visit(ir_texture *ir)
|
|
|
|
{
|
|
|
|
printf("(%s ", ir->opcode_string());
|
|
|
|
|
2011-02-25 14:29:36 -08:00
|
|
|
print_type(ir->type);
|
|
|
|
printf(" ");
|
|
|
|
|
2010-05-26 15:15:31 -07:00
|
|
|
ir->sampler->accept(this);
|
|
|
|
printf(" ");
|
|
|
|
|
|
|
|
ir->coordinate->accept(this);
|
|
|
|
|
2011-01-08 23:49:23 -08:00
|
|
|
printf(" ");
|
|
|
|
|
|
|
|
if (ir->offset != NULL) {
|
|
|
|
ir->offset->accept(this);
|
|
|
|
} else {
|
|
|
|
printf("0");
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(" ");
|
2010-05-26 15:15:31 -07:00
|
|
|
|
|
|
|
if (ir->op != ir_txf) {
|
|
|
|
if (ir->projector)
|
|
|
|
ir->projector->accept(this);
|
|
|
|
else
|
|
|
|
printf("1");
|
|
|
|
|
|
|
|
if (ir->shadow_comparitor) {
|
|
|
|
printf(" ");
|
|
|
|
ir->shadow_comparitor->accept(this);
|
|
|
|
} else {
|
|
|
|
printf(" ()");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(" ");
|
|
|
|
switch (ir->op)
|
|
|
|
{
|
|
|
|
case ir_tex:
|
|
|
|
break;
|
|
|
|
case ir_txb:
|
|
|
|
ir->lod_info.bias->accept(this);
|
|
|
|
break;
|
|
|
|
case ir_txl:
|
|
|
|
case ir_txf:
|
|
|
|
ir->lod_info.lod->accept(this);
|
|
|
|
break;
|
|
|
|
case ir_txd:
|
|
|
|
printf("(");
|
|
|
|
ir->lod_info.grad.dPdx->accept(this);
|
|
|
|
printf(" ");
|
|
|
|
ir->lod_info.grad.dPdy->accept(this);
|
|
|
|
printf(")");
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
printf(")");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-26 01:20:08 -07:00
|
|
|
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(")");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-19 13:20:12 +02:00
|
|
|
void ir_print_visitor::visit(ir_dereference_variable *ir)
|
2010-03-09 16:23:37 -08:00
|
|
|
{
|
2010-06-24 09:07:38 -07:00
|
|
|
ir_variable *var = ir->variable_referenced();
|
2010-08-11 14:00:36 -06:00
|
|
|
printf("(var_ref %s@%p) ", var->name, (void *) var);
|
2010-05-19 13:20:12 +02:00
|
|
|
}
|
|
|
|
|
2010-03-25 17:38:13 -07:00
|
|
|
|
2010-05-19 13:20:12 +02:00
|
|
|
void ir_print_visitor::visit(ir_dereference_array *ir)
|
|
|
|
{
|
|
|
|
printf("(array_ref ");
|
2010-05-19 13:52:29 +02:00
|
|
|
ir->array->accept(this);
|
|
|
|
ir->array_index->accept(this);
|
2010-05-19 13:20:12 +02:00
|
|
|
printf(") ");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ir_print_visitor::visit(ir_dereference_record *ir)
|
|
|
|
{
|
|
|
|
printf("(record_ref ");
|
2010-05-19 13:52:29 +02:00
|
|
|
ir->record->accept(this);
|
2010-05-26 15:20:59 -07:00
|
|
|
printf(" %s) ", ir->field);
|
2010-03-09 16:23:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ir_print_visitor::visit(ir_assignment *ir)
|
|
|
|
{
|
2010-04-09 17:29:47 -07:00
|
|
|
printf("(assign ");
|
2010-03-09 16:40:45 -08:00
|
|
|
|
|
|
|
if (ir->condition)
|
|
|
|
ir->condition->accept(this);
|
2010-08-02 18:48:25 -07:00
|
|
|
|
|
|
|
char mask[5];
|
|
|
|
unsigned j = 0;
|
|
|
|
|
|
|
|
for (unsigned i = 0; i < 4; i++) {
|
|
|
|
if ((ir->write_mask & (1 << i)) != 0) {
|
|
|
|
mask[j] = "xyzw"[i];
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mask[j] = '\0';
|
|
|
|
|
|
|
|
printf(" (%s) ", mask);
|
2010-03-25 18:29:25 -07:00
|
|
|
|
2010-03-09 16:40:45 -08:00
|
|
|
ir->lhs->accept(this);
|
|
|
|
|
2010-04-09 17:29:47 -07:00
|
|
|
printf(" ");
|
2010-03-25 18:29:25 -07:00
|
|
|
|
2010-03-09 16:40:45 -08:00
|
|
|
ir->rhs->accept(this);
|
2010-03-25 18:29:25 -07:00
|
|
|
printf(") ");
|
2010-03-09 16:23:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ir_print_visitor::visit(ir_constant *ir)
|
|
|
|
{
|
2010-03-25 18:38:28 -07:00
|
|
|
const glsl_type *const base_type = ir->type->get_base_type();
|
2010-03-09 21:44:34 -08:00
|
|
|
|
2010-04-07 14:41:13 -07:00
|
|
|
printf("(constant ");
|
2010-04-07 14:40:44 -07:00
|
|
|
print_type(ir->type);
|
2010-04-07 14:41:13 -07:00
|
|
|
printf(" (");
|
2010-03-25 18:38:28 -07:00
|
|
|
|
2010-07-20 01:28:09 -07:00
|
|
|
if (ir->type->is_array()) {
|
|
|
|
for (unsigned i = 0; i < ir->type->length; i++)
|
|
|
|
ir->get_array_element(i)->accept(this);
|
2010-12-02 10:11:49 -08:00
|
|
|
} else if (ir->type->is_record()) {
|
|
|
|
ir_constant *value = (ir_constant *) ir->components.get_head();
|
|
|
|
for (unsigned i = 0; i < ir->type->length; i++) {
|
|
|
|
printf("(%s ", ir->type->fields.structure->name);
|
|
|
|
value->accept(this);
|
|
|
|
printf(")");
|
|
|
|
|
|
|
|
value = (ir_constant *) value->next;
|
|
|
|
}
|
2010-07-20 01:28:09 -07:00
|
|
|
} else {
|
|
|
|
for (unsigned i = 0; i < ir->type->components(); i++) {
|
|
|
|
if (i != 0)
|
|
|
|
printf(" ");
|
|
|
|
switch (base_type->base_type) {
|
|
|
|
case GLSL_TYPE_UINT: printf("%u", ir->value.u[i]); break;
|
|
|
|
case GLSL_TYPE_INT: printf("%d", ir->value.i[i]); break;
|
|
|
|
case GLSL_TYPE_FLOAT: printf("%f", ir->value.f[i]); break;
|
|
|
|
case GLSL_TYPE_BOOL: printf("%d", ir->value.b[i]); break;
|
|
|
|
default: assert(0);
|
|
|
|
}
|
2010-03-25 18:38:28 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
printf(")) ");
|
2010-03-09 16:23:37 -08:00
|
|
|
}
|
2010-03-11 14:34:27 -08:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ir_print_visitor::visit(ir_call *ir)
|
|
|
|
{
|
2010-04-22 00:44:12 -07:00
|
|
|
printf("(call %s (", ir->callee_name());
|
2010-03-26 17:30:30 -07:00
|
|
|
foreach_iter(exec_list_iterator, iter, *ir) {
|
|
|
|
ir_instruction *const inst = (ir_instruction *) iter.get();
|
2010-03-11 14:34:27 -08:00
|
|
|
|
2010-03-26 17:30:30 -07:00
|
|
|
inst->accept(this);
|
|
|
|
}
|
2010-04-22 00:44:12 -07:00
|
|
|
printf("))\n");
|
2010-03-11 14:34:27 -08:00
|
|
|
}
|
2010-03-19 16:44:52 -07:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ir_print_visitor::visit(ir_return *ir)
|
|
|
|
{
|
|
|
|
printf("(return");
|
|
|
|
|
2010-03-26 00:25:36 -07:00
|
|
|
ir_rvalue *const value = ir->get_value();
|
2010-03-19 16:44:52 -07:00
|
|
|
if (value) {
|
|
|
|
printf(" ");
|
|
|
|
value->accept(this);
|
|
|
|
}
|
|
|
|
|
2010-03-25 18:29:25 -07:00
|
|
|
printf(")");
|
2010-03-19 16:44:52 -07:00
|
|
|
}
|
2010-03-29 14:11:25 -07:00
|
|
|
|
|
|
|
|
2010-06-30 10:47:34 -07:00
|
|
|
void
|
|
|
|
ir_print_visitor::visit(ir_discard *ir)
|
|
|
|
{
|
|
|
|
printf("(discard ");
|
|
|
|
|
|
|
|
if (ir->condition != NULL) {
|
|
|
|
printf(" ");
|
|
|
|
ir->condition->accept(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(")");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-29 14:11:25 -07:00
|
|
|
void
|
|
|
|
ir_print_visitor::visit(ir_if *ir)
|
|
|
|
{
|
|
|
|
printf("(if ");
|
|
|
|
ir->condition->accept(this);
|
|
|
|
|
|
|
|
printf("(\n");
|
2010-07-29 14:36:59 -07:00
|
|
|
indentation++;
|
|
|
|
|
2010-03-29 14:11:25 -07:00
|
|
|
foreach_iter(exec_list_iterator, iter, ir->then_instructions) {
|
|
|
|
ir_instruction *const inst = (ir_instruction *) iter.get();
|
|
|
|
|
2010-07-29 14:36:59 -07:00
|
|
|
indent();
|
2010-03-29 14:11:25 -07:00
|
|
|
inst->accept(this);
|
2010-04-06 12:13:02 -07:00
|
|
|
printf("\n");
|
2010-03-29 14:11:25 -07:00
|
|
|
}
|
2010-07-29 14:36:59 -07:00
|
|
|
|
|
|
|
indentation--;
|
|
|
|
indent();
|
2010-03-29 14:11:25 -07:00
|
|
|
printf(")\n");
|
|
|
|
|
2010-07-29 14:36:59 -07:00
|
|
|
indent();
|
2010-08-12 14:55:48 -07:00
|
|
|
if (!ir->else_instructions.is_empty()) {
|
|
|
|
printf("(\n");
|
|
|
|
indentation++;
|
2010-07-29 14:36:59 -07:00
|
|
|
|
2010-08-12 14:55:48 -07:00
|
|
|
foreach_iter(exec_list_iterator, iter, ir->else_instructions) {
|
|
|
|
ir_instruction *const inst = (ir_instruction *) iter.get();
|
2010-03-29 14:11:25 -07:00
|
|
|
|
2010-08-12 14:55:48 -07:00
|
|
|
indent();
|
|
|
|
inst->accept(this);
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
indentation--;
|
2010-07-29 14:36:59 -07:00
|
|
|
indent();
|
2010-08-12 14:55:48 -07:00
|
|
|
printf("))\n");
|
|
|
|
} else {
|
|
|
|
printf("())\n");
|
2010-03-29 14:11:25 -07:00
|
|
|
}
|
|
|
|
}
|
2010-04-05 16:16:07 -07:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ir_print_visitor::visit(ir_loop *ir)
|
|
|
|
{
|
|
|
|
printf("(loop (");
|
|
|
|
if (ir->counter != NULL)
|
|
|
|
ir->counter->accept(this);
|
|
|
|
printf(") (");
|
|
|
|
if (ir->from != NULL)
|
|
|
|
ir->from->accept(this);
|
|
|
|
printf(") (");
|
|
|
|
if (ir->to != NULL)
|
|
|
|
ir->to->accept(this);
|
|
|
|
printf(") (");
|
|
|
|
if (ir->increment != NULL)
|
|
|
|
ir->increment->accept(this);
|
2010-04-05 16:38:20 -07:00
|
|
|
printf(") (\n");
|
2010-07-29 14:36:59 -07:00
|
|
|
indentation++;
|
|
|
|
|
2010-04-05 16:16:07 -07:00
|
|
|
foreach_iter(exec_list_iterator, iter, ir->body_instructions) {
|
|
|
|
ir_instruction *const inst = (ir_instruction *) iter.get();
|
|
|
|
|
2010-07-29 14:36:59 -07:00
|
|
|
indent();
|
2010-04-05 16:16:07 -07:00
|
|
|
inst->accept(this);
|
2010-04-05 16:38:20 -07:00
|
|
|
printf("\n");
|
2010-04-05 16:16:07 -07:00
|
|
|
}
|
2010-07-29 14:36:59 -07:00
|
|
|
indentation--;
|
|
|
|
indent();
|
2010-04-05 16:16:07 -07:00
|
|
|
printf("))\n");
|
|
|
|
}
|
2010-04-05 16:28:15 -07:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ir_print_visitor::visit(ir_loop_jump *ir)
|
|
|
|
{
|
|
|
|
printf("%s", ir->is_break() ? "break" : "continue");
|
|
|
|
}
|