2 * Copyright © 2010 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 #include "ir_print_visitor.h"
25 #include "glsl_types.h"
28 print_type(const glsl_type
*t
)
30 if (t
->base_type
== GLSL_TYPE_ARRAY
) {
33 print_type(t
->fields
.array
);
36 printf(" (%u)\n", t
->length
);
38 } else if (t
->base_type
== GLSL_TYPE_STRUCT
) {
39 printf("struct (%s %u\n", t
->name
? t
->name
: "@", t
->length
);
40 printf(" (FINISHME: structure fields go here)\n");
43 printf("%s", t
->name
);
48 void ir_print_visitor::visit(ir_variable
*ir
)
50 printf("(declare \n");
52 const char *const cent
= (ir
->centroid
) ? "centroid " : "";
53 const char *const inv
= (ir
->invariant
) ? "invariant " : "";
54 const char *const mode
[] = { "", "uniform ", "in ", "out ", "inout " };
55 const char *const interp
[] = { "", "flat", "noperspective" };
57 printf(" (%s%s%s%s)\n",
58 cent
, inv
, mode
[ir
->mode
], interp
[ir
->interpolation
]);
64 printf(" (%s)\n", ir
->name
);
69 void ir_print_visitor::visit(ir_label
*ir
)
71 printf("(label %s)\n", ir
->label
);
75 void ir_print_visitor::visit(ir_function_signature
*ir
)
77 printf("%s:%d:\n", __func__
, __LINE__
);
82 void ir_print_visitor::visit(ir_function
*ir
)
84 printf("(function %s\n", ir
->name
);
89 void ir_print_visitor::visit(ir_expression
*ir
)
91 printf("%s:%d:\n", __func__
, __LINE__
);
96 void ir_print_visitor::visit(ir_dereference
*ir
)
98 printf("%s:%d:\n", __func__
, __LINE__
);
103 void ir_print_visitor::visit(ir_assignment
*ir
)
109 ir
->condition
->accept(this);
115 ir
->lhs
->accept(this);
119 ir
->rhs
->accept(this);
124 void ir_print_visitor::visit(ir_constant
*ir
)
128 printf("(constant\n");
130 print_type(ir
->type
);
132 printf(" (FINISHME: value goes here)\n");
138 ir_print_visitor::visit(ir_call
*ir
)
142 printf("(call FINISHME: function name here\n");
143 printf(" (FINISHME: function paramaters here))\n");
148 ir_print_visitor::visit(ir_return
*ir
)
152 ir_expression
*const value
= ir
->get_value();