blob: 1f74cbb39dcea1906604e5b2251317bd101c15df [file] [log] [blame]
Ian Romanicka87ac252010-02-22 13:19:34 -08001/*
2 * Copyright © 2008, 2009 Intel Corporation
3 *
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:
10 *
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
13 * Software.
14 *
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.
22 */
23#include <stdio.h>
24#include <stdarg.h>
25#include <stdlib.h>
26#include <string.h>
27#include <assert.h>
28
29#include <sys/types.h>
30#include <sys/stat.h>
31#include <fcntl.h>
32#include <unistd.h>
33
34#include "ast.h"
35#include "glsl_parser_extras.h"
Ian Romanickd59673c2010-02-25 17:17:23 -080036#include "glsl_parser.h"
Eric Anholt62735692010-04-05 15:24:28 -070037#include "ir_constant_folding.h"
Eric Anholt7d211042010-04-16 16:43:47 -070038#include "ir_dead_code.h"
Eric Anholtcad97662010-04-07 11:46:26 -070039#include "ir_function_inlining.h"
Eric Anholt5ba94202010-04-14 17:03:03 -070040#include "ir_if_simplification.h"
Ian Romanick1c4156f2010-03-10 09:27:03 -080041#include "ir_print_visitor.h"
Ian Romanicka87ac252010-02-22 13:19:34 -080042
Ian Romanick5bfe30a2010-04-07 16:44:30 -070043const char *
44_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target)
45{
46 switch (target) {
47 case vertex_shader: return "vertex";
48 case fragment_shader: return "fragment";
49 case geometry_shader: return "geometry";
50 }
51
52 assert(!"Should not get here.");
53}
54
55
Ian Romanicka87ac252010-02-22 13:19:34 -080056void
Ian Romanick1f585182010-03-11 14:08:33 -080057_mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
58 const char *fmt, ...)
Ian Romanicka87ac252010-02-22 13:19:34 -080059{
60 char buf[1024];
61 int len;
62 va_list ap;
63
Ian Romanick71d0bbf2010-03-23 13:21:19 -070064 state->error = true;
Ian Romanick1f585182010-03-11 14:08:33 -080065
Ian Romanicka87ac252010-02-22 13:19:34 -080066 len = snprintf(buf, sizeof(buf), "%u:%u(%u): error: ",
67 locp->source, locp->first_line, locp->first_column);
68
69 va_start(ap, fmt);
70 vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
71 va_end(ap);
72
73 printf("%s\n", buf);
74}
75
76
Ian Romanick56b8b212010-04-07 14:47:46 -070077void
78_mesa_glsl_warning(const YYLTYPE *locp, const _mesa_glsl_parse_state *state,
79 const char *fmt, ...)
80{
81 char buf[1024];
82 int len;
83 va_list ap;
84
85 len = snprintf(buf, sizeof(buf), "%u:%u(%u): warning: ",
86 locp->source, locp->first_line, locp->first_column);
87
88 va_start(ap, fmt);
89 vsnprintf(buf + len, sizeof(buf) - len, fmt, ap);
90 va_end(ap);
91
92 printf("%s\n", buf);
93}
94
95
Ian Romanicke7017612010-04-07 16:46:25 -070096bool
97_mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
98 const char *behavior, YYLTYPE *behavior_locp,
99 _mesa_glsl_parse_state *state)
100{
101 enum {
102 extension_disable,
103 extension_enable,
104 extension_require,
105 extension_warn
106 } ext_mode;
Ian Romanicke7017612010-04-07 16:46:25 -0700107
108 if (strcmp(behavior, "warn") == 0) {
109 ext_mode = extension_warn;
110 } else if (strcmp(behavior, "require") == 0) {
111 ext_mode = extension_require;
112 } else if (strcmp(behavior, "enable") == 0) {
113 ext_mode = extension_enable;
114 } else if (strcmp(behavior, "disable") == 0) {
115 ext_mode = extension_disable;
116 } else {
117 _mesa_glsl_error(behavior_locp, state,
118 "Unknown extension behavior `%s'",
119 behavior);
120 return false;
121 }
122
Ian Romanick887a8b02010-04-07 16:57:56 -0700123 bool unsupported = false;
124
Ian Romanicke7017612010-04-07 16:46:25 -0700125 if (strcmp(name, "all") == 0) {
126 if ((ext_mode == extension_enable) || (ext_mode == extension_require)) {
127 _mesa_glsl_error(name_locp, state, "Cannot %s all extensions",
128 (ext_mode == extension_enable)
129 ? "enable" : "require");
130 return false;
131 }
Ian Romanickeb56cea2010-04-23 13:32:23 -0700132 } else if (strcmp(name, "GL_ARB_draw_buffers") == 0) {
Ian Romanickc77b2572010-04-07 16:59:46 -0700133 /* This extension is only supported in fragment shaders.
134 */
135 if (state->target != fragment_shader) {
136 unsupported = true;
137 } else {
138 state->ARB_draw_buffers_enable = (ext_mode != extension_disable);
139 state->ARB_draw_buffers_warn = (ext_mode == extension_warn);
140 }
Ian Romanickeb56cea2010-04-23 13:32:23 -0700141 } else if (strcmp(name, "GL_ARB_texture_rectangle") == 0) {
Ian Romanick0c824652010-04-07 17:13:44 -0700142 state->ARB_texture_rectangle_enable = (ext_mode != extension_disable);
143 state->ARB_texture_rectangle_warn = (ext_mode == extension_warn);
Ian Romanicke7017612010-04-07 16:46:25 -0700144 } else {
Ian Romanick887a8b02010-04-07 16:57:56 -0700145 unsupported = true;
146 }
147
148 if (unsupported) {
149 static const char *const fmt = "extension `%s' unsupported in %s shader";
150
Ian Romanicke7017612010-04-07 16:46:25 -0700151 if (ext_mode == extension_require) {
Ian Romanick887a8b02010-04-07 16:57:56 -0700152 _mesa_glsl_error(name_locp, state, fmt,
153 name, _mesa_glsl_shader_target_name(state->target));
Ian Romanicke7017612010-04-07 16:46:25 -0700154 return false;
Ian Romanick1799a0c2010-04-07 14:50:36 -0700155 } else {
Ian Romanick887a8b02010-04-07 16:57:56 -0700156 _mesa_glsl_warning(name_locp, state, fmt,
157 name, _mesa_glsl_shader_target_name(state->target));
Ian Romanicke7017612010-04-07 16:46:25 -0700158 }
159 }
160
161 return true;
162}
163
164
Ian Romanicka87ac252010-02-22 13:19:34 -0800165ast_node::~ast_node()
166{
167 /* empty */
168}
169
170
171void
172_mesa_ast_type_qualifier_print(const struct ast_type_qualifier *q)
173{
174 if (q->constant)
175 printf("const ");
176
177 if (q->invariant)
178 printf("invariant ");
179
180 if (q->attribute)
181 printf("attribute ");
182
183 if (q->varying)
184 printf("varying ");
185
186 if (q->in && q->out)
187 printf("inout ");
188 else {
189 if (q->in)
190 printf("in ");
191
192 if (q->out)
193 printf("out ");
194 }
195
196 if (q->centroid)
197 printf("centroid ");
198 if (q->uniform)
199 printf("uniform ");
200 if (q->smooth)
201 printf("smooth ");
202 if (q->flat)
203 printf("flat ");
204 if (q->noperspective)
205 printf("noperspective ");
206}
207
208
209void
210ast_node::print(void) const
211{
Ian Romanick03d3f3a2010-04-02 11:03:47 -0700212 printf("unhandled node ");
Ian Romanicka87ac252010-02-22 13:19:34 -0800213}
214
215
216ast_node::ast_node(void)
217{
Ian Romanick53d27742010-02-22 13:22:10 -0800218 make_empty_list(this);
Ian Romanicka87ac252010-02-22 13:19:34 -0800219}
220
Ian Romanicka87ac252010-02-22 13:19:34 -0800221
222static void
223ast_opt_array_size_print(bool is_array, const ast_expression *array_size)
224{
225 if (is_array) {
226 printf("[ ");
227
228 if (array_size)
229 array_size->print();
230
231 printf("] ");
232 }
233}
234
235
Ian Romanicka87ac252010-02-22 13:19:34 -0800236void
237ast_compound_statement::print(void) const
238{
239 const struct simple_node *ptr;
240
241 printf("{\n");
242
243 foreach(ptr, & statements) {
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800244 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800245 }
246
247 printf("}\n");
248}
249
250
251ast_compound_statement::ast_compound_statement(int new_scope,
252 ast_node *statements)
253{
254 this->new_scope = new_scope;
255 make_empty_list(& this->statements);
256
257 if (statements != NULL) {
258 /* This seems odd, but it works. The simple_list is,
259 * basically, a circular list. insert_at_tail adds
260 * the specified node to the list before the current
261 * head.
262 */
263 insert_at_tail((struct simple_node *) statements,
264 & this->statements);
265 }
266}
267
268
269void
270ast_expression::print(void) const
271{
Ian Romanicka87ac252010-02-22 13:19:34 -0800272 switch (oper) {
273 case ast_assign:
Ian Romanicka87ac252010-02-22 13:19:34 -0800274 case ast_mul_assign:
275 case ast_div_assign:
276 case ast_mod_assign:
277 case ast_add_assign:
278 case ast_sub_assign:
279 case ast_ls_assign:
280 case ast_rs_assign:
281 case ast_and_assign:
282 case ast_xor_assign:
283 case ast_or_assign:
284 subexpressions[0]->print();
Ian Romanick88349b22010-02-22 19:10:25 -0800285 printf("%s ", operator_string(oper));
Ian Romanicka87ac252010-02-22 13:19:34 -0800286 subexpressions[1]->print();
287 break;
288
289 case ast_field_selection:
290 subexpressions[0]->print();
291 printf(". %s ", primary_expression.identifier);
292 break;
293
294 case ast_plus:
295 case ast_neg:
296 case ast_bit_not:
297 case ast_logic_not:
298 case ast_pre_inc:
299 case ast_pre_dec:
Ian Romanick88349b22010-02-22 19:10:25 -0800300 printf("%s ", operator_string(oper));
Ian Romanicka87ac252010-02-22 13:19:34 -0800301 subexpressions[0]->print();
302 break;
303
304 case ast_post_inc:
305 case ast_post_dec:
306 subexpressions[0]->print();
Ian Romanick88349b22010-02-22 19:10:25 -0800307 printf("%s ", operator_string(oper));
Ian Romanicka87ac252010-02-22 13:19:34 -0800308 break;
309
310 case ast_conditional:
311 subexpressions[0]->print();
312 printf("? ");
313 subexpressions[1]->print();
314 printf(": ");
315 subexpressions[1]->print();
316 break;
317
318 case ast_array_index:
319 subexpressions[0]->print();
320 printf("[ ");
321 subexpressions[1]->print();
322 printf("] ");
323 break;
324
325 case ast_function_call: {
326 ast_expression *parameters = subexpressions[1];
327
328 subexpressions[0]->print();
329 printf("( ");
330
331 if (parameters != NULL) {
332 struct simple_node *ptr;
333
334 parameters->print();
335 foreach (ptr, (struct simple_node *) parameters) {
336 printf(", ");
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800337 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800338 }
339 }
340
341 printf(") ");
342 break;
343 }
344
345 case ast_identifier:
346 printf("%s ", primary_expression.identifier);
347 break;
348
349 case ast_int_constant:
350 printf("%d ", primary_expression.int_constant);
351 break;
352
353 case ast_uint_constant:
354 printf("%u ", primary_expression.uint_constant);
355 break;
356
357 case ast_float_constant:
358 printf("%f ", primary_expression.float_constant);
359 break;
360
361 case ast_bool_constant:
362 printf("%s ",
363 primary_expression.bool_constant
364 ? "true" : "false");
365 break;
366
367 case ast_sequence: {
368 struct simple_node *ptr;
369 struct simple_node *const head = first_elem(& expressions);
370
371 printf("( ");
372 foreach (ptr, & expressions) {
373 if (ptr != head)
374 printf(", ");
375
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800376 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800377 }
378 printf(") ");
379 break;
380 }
Ian Romanick88349b22010-02-22 19:10:25 -0800381
382 default:
383 assert(0);
384 break;
Ian Romanicka87ac252010-02-22 13:19:34 -0800385 }
386}
387
388ast_expression::ast_expression(int oper,
389 ast_expression *ex0,
390 ast_expression *ex1,
391 ast_expression *ex2)
392{
393 this->oper = ast_operators(oper);
394 this->subexpressions[0] = ex0;
395 this->subexpressions[1] = ex1;
396 this->subexpressions[2] = ex2;
397 make_empty_list(& expressions);
398}
399
400
401void
402ast_expression_statement::print(void) const
403{
404 if (expression)
405 expression->print();
406
407 printf("; ");
408}
409
410
411ast_expression_statement::ast_expression_statement(ast_expression *ex) :
412 expression(ex)
413{
414 /* empty */
415}
416
417
418void
419ast_function::print(void) const
420{
421 struct simple_node *ptr;
422
423 return_type->print();
424 printf(" %s (", identifier);
425
426 foreach(ptr, & parameters) {
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800427 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800428 }
429
430 printf(")");
431}
432
433
434ast_function::ast_function(void)
Ian Romanick92318a92010-03-31 18:23:21 -0700435 : is_definition(false), signature(NULL)
Ian Romanicka87ac252010-02-22 13:19:34 -0800436{
437 make_empty_list(& parameters);
438}
439
440
441void
442ast_fully_specified_type::print(void) const
443{
444 _mesa_ast_type_qualifier_print(& qualifier);
445 specifier->print();
446}
447
448
449void
450ast_parameter_declarator::print(void) const
451{
452 type->print();
453 if (identifier)
454 printf("%s ", identifier);
455 ast_opt_array_size_print(is_array, array_size);
456}
457
458
459void
460ast_function_definition::print(void) const
461{
462 prototype->print();
463 body->print();
464}
465
466
467void
468ast_declaration::print(void) const
469{
470 printf("%s ", identifier);
471 ast_opt_array_size_print(is_array, array_size);
472
473 if (initializer) {
474 printf("= ");
475 initializer->print();
476 }
477}
478
479
480ast_declaration::ast_declaration(char *identifier, int is_array,
481 ast_expression *array_size,
482 ast_expression *initializer)
483{
484 this->identifier = identifier;
485 this->is_array = is_array;
486 this->array_size = array_size;
487 this->initializer = initializer;
488}
489
490
491void
492ast_declarator_list::print(void) const
493{
494 struct simple_node *head;
495 struct simple_node *ptr;
496
497 assert(type || invariant);
498
499 if (type)
500 type->print();
501 else
502 printf("invariant ");
503
504 head = first_elem(& declarations);
505 foreach (ptr, & declarations) {
506 if (ptr != head)
507 printf(", ");
508
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800509 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800510 }
511
512 printf("; ");
513}
514
515
516ast_declarator_list::ast_declarator_list(ast_fully_specified_type *type)
517{
518 this->type = type;
519 make_empty_list(& this->declarations);
520}
521
522void
523ast_jump_statement::print(void) const
524{
525 switch (mode) {
526 case ast_continue:
527 printf("continue; ");
528 break;
529 case ast_break:
530 printf("break; ");
531 break;
532 case ast_return:
533 printf("return ");
534 if (opt_return_value)
535 opt_return_value->print();
536
537 printf("; ");
538 break;
539 case ast_discard:
540 printf("discard; ");
541 break;
542 }
543}
544
545
546ast_jump_statement::ast_jump_statement(int mode, ast_expression *return_value)
547{
548 this->mode = ast_jump_modes(mode);
549
550 if (mode == ast_return)
551 opt_return_value = return_value;
552}
553
554
555void
556ast_selection_statement::print(void) const
557{
558 printf("if ( ");
559 condition->print();
560 printf(") ");
561
562 then_statement->print();
563
564 if (else_statement) {
565 printf("else ");
566 else_statement->print();
567 }
568
569}
570
571
572ast_selection_statement::ast_selection_statement(ast_expression *condition,
573 ast_node *then_statement,
574 ast_node *else_statement)
575{
576 this->condition = condition;
577 this->then_statement = then_statement;
578 this->else_statement = else_statement;
579}
580
581
582void
583ast_iteration_statement::print(void) const
584{
585 switch (mode) {
586 case ast_for:
587 printf("for( ");
588 if (init_statement)
589 init_statement->print();
590 printf("; ");
591
592 if (condition)
593 condition->print();
594 printf("; ");
595
596 if (rest_expression)
597 rest_expression->print();
598 printf(") ");
599
600 body->print();
601 break;
602
603 case ast_while:
604 printf("while ( ");
605 if (condition)
606 condition->print();
607 printf(") ");
608 body->print();
609 break;
610
611 case ast_do_while:
612 printf("do ");
613 body->print();
614 printf("while ( ");
615 if (condition)
616 condition->print();
617 printf("); ");
618 break;
619 }
620}
621
622
623ast_iteration_statement::ast_iteration_statement(int mode,
624 ast_node *init,
625 ast_node *condition,
626 ast_expression *rest_expression,
627 ast_node *body)
628{
629 this->mode = ast_iteration_modes(mode);
630 this->init_statement = init;
631 this->condition = condition;
632 this->rest_expression = rest_expression;
633 this->body = body;
634}
635
636
637void
638ast_struct_specifier::print(void) const
639{
640 struct simple_node *ptr;
641
642 printf("struct %s { ", name);
643 foreach (ptr, & declarations) {
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800644 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800645 }
646 printf("} ");
647}
648
649
650ast_struct_specifier::ast_struct_specifier(char *identifier,
651 ast_node *declarator_list)
652{
653 name = identifier;
654
655 /* This seems odd, but it works. The simple_list is,
656 * basically, a circular list. insert_at_tail adds
657 * the specified node to the list before the current
658 * head.
659 */
660 insert_at_tail((struct simple_node *) declarator_list,
661 & declarations);
662}
663
664
665static char *
666load_text_file(const char *file_name, size_t *size)
667{
668 char *text = NULL;
669 struct stat st;
670 ssize_t total_read = 0;
671 int fd = open(file_name, O_RDONLY);
672
673 *size = 0;
674 if (fd < 0) {
675 return NULL;
676 }
677
678 if (fstat(fd, & st) == 0) {
679 text = (char *) malloc(st.st_size + 1);
680 if (text != NULL) {
681 do {
682 ssize_t bytes = read(fd, text + total_read,
683 st.st_size - total_read);
684 if (bytes < 0) {
685 free(text);
686 text = NULL;
687 break;
688 }
689
690 if (bytes == 0) {
691 break;
692 }
693
694 total_read += bytes;
695 } while (total_read < st.st_size);
696
697 text[total_read] = '\0';
698 *size = total_read;
699 }
700 }
701
702 close(fd);
703
704 return text;
705}
706
707
708int
709main(int argc, char **argv)
710{
711 struct _mesa_glsl_parse_state state;
712 char *shader;
713 size_t shader_len;
714 struct simple_node *ptr;
Ian Romanick0044e7e2010-03-08 23:44:00 -0800715 exec_list instructions;
Ian Romanicka87ac252010-02-22 13:19:34 -0800716
Ian Romanick8e6cd3b2010-03-10 09:31:30 -0800717 if (argc < 3) {
718 printf("Usage: %s [v|g|f] <shader_file>\n", argv[0]);
719 return EXIT_FAILURE;
720 }
721
722 switch (argv[1][0]) {
723 case 'v':
724 state.target = vertex_shader;
725 break;
726 case 'g':
727 state.target = geometry_shader;
728 break;
729 case 'f':
730 state.target = fragment_shader;
731 break;
732 default:
733 printf("Usage: %s [v|g|f] <shader_file>\n", argv[0]);
734 return EXIT_FAILURE;
735 }
736
737 shader = load_text_file(argv[2], & shader_len);
Ian Romanicka87ac252010-02-22 13:19:34 -0800738
739 state.scanner = NULL;
740 make_empty_list(& state.translation_unit);
Ian Romanick8bde4ce2010-03-19 11:57:24 -0700741 state.symbols = new glsl_symbol_table;
Ian Romanick1f585182010-03-11 14:08:33 -0800742 state.error = false;
Ian Romanick5185a5f2010-03-29 15:20:42 -0700743 state.temp_index = 0;
Ian Romanicke9d0f262010-04-05 17:01:53 -0700744 state.loop_or_switch_nesting = NULL;
Ian Romanick0c824652010-04-07 17:13:44 -0700745 state.ARB_texture_rectangle_enable = true;
Ian Romanicka87ac252010-02-22 13:19:34 -0800746
747 _mesa_glsl_lexer_ctor(& state, shader, shader_len);
748 _mesa_glsl_parse(& state);
749 _mesa_glsl_lexer_dtor(& state);
750
751 foreach (ptr, & state.translation_unit) {
Ian Romanicke41a1cd2010-02-25 12:49:55 -0800752 ((ast_node *)ptr)->print();
Ian Romanicka87ac252010-02-22 13:19:34 -0800753 }
754
Ian Romanickd949a9a2010-03-10 09:55:22 -0800755 _mesa_ast_to_hir(&instructions, &state);
Ian Romanicka87ac252010-02-22 13:19:34 -0800756
Eric Anholt62735692010-04-05 15:24:28 -0700757 /* Optimization passes */
758 if (!state.error) {
Eric Anholt2a7b2b22010-04-08 13:42:48 -0700759 bool progress;
760 do {
761 progress = false;
Eric Anholtcad97662010-04-07 11:46:26 -0700762
Eric Anholt2a7b2b22010-04-08 13:42:48 -0700763 progress = do_function_inlining(&instructions) || progress;
Eric Anholt5ba94202010-04-14 17:03:03 -0700764 progress = do_if_simplification(&instructions) || progress;
Eric Anholt7d211042010-04-16 16:43:47 -0700765 progress = do_dead_code_unlinked(&instructions) || progress;
Eric Anholt2a7b2b22010-04-08 13:42:48 -0700766
767 /* Constant folding */
768 ir_constant_folding_visitor constant_folding;
769 visit_exec_list(&instructions, &constant_folding);
770 } while (progress);
Eric Anholt62735692010-04-05 15:24:28 -0700771 }
772
773 /* Print out the resulting IR */
Ian Romanick1c4156f2010-03-10 09:27:03 -0800774 printf("\n\n");
Ian Romanick1c4156f2010-03-10 09:27:03 -0800775
Ian Romanick1f585182010-03-11 14:08:33 -0800776 if (!state.error) {
777 foreach_iter(exec_list_iterator, iter, instructions) {
778 ir_print_visitor v;
779
780 ((ir_instruction *)iter.get())->accept(& v);
Ian Romanickd1464272010-03-25 18:29:25 -0700781 printf("\n");
Ian Romanick1f585182010-03-11 14:08:33 -0800782 }
Ian Romanick1c4156f2010-03-10 09:27:03 -0800783 }
784
Ian Romanick8bde4ce2010-03-19 11:57:24 -0700785 delete state.symbols;
Ian Romanicka87ac252010-02-22 13:19:34 -0800786
Eric Anholt7c15bb22010-03-25 14:37:25 -0700787 return state.error != 0;
Ian Romanicka87ac252010-02-22 13:19:34 -0800788}