1 /* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
2 ** All rights reserved.
4 ** Authors: Christian Schaefer, Goetz Lindenmaier
13 *** This file constructs the ir for the following pseudo-program:
32 ir_node *a, *b, *c, *d, *x;
34 printf("creating an IR graph: CONST_EVAL_EXAMPLE...\n");
38 /* Try both optimizations: */
39 set_opt_constant_folding(1);
41 set_opt_dead_node_elimination (0);
43 owner = new_type_class (id_from_str ("CONST_EVAL_EXAMPLE", 18));
44 method = new_type_method (id_from_str("main", 4), 0, 2);
45 ent = new_entity ((type *)owner, id_from_str ("main", 4), (type *)method);
47 irg = new_ir_graph (ent, 4);
49 a = new_Const (mode_i, tarval_from_long (mode_i, 7));
50 b = new_Const (mode_i, tarval_from_long (mode_i, 5));
53 mature_block (irg->current_block);
55 /* To test const eval on DivMod
56 c = new_DivMod(get_store(), a, b);
57 set_store(new_Proj(c, mode_M, 0));
58 d = new_Proj(c, mode_i, 3);
59 c = new_Proj(c, mode_i, 2);
62 c = new_Add (new_Const (mode_i, tarval_from_long (mode_i, 5)),
63 new_Const (mode_i, tarval_from_long (mode_i, 7)),
65 d = new_Add (new_Const (mode_i, tarval_from_long (mode_i, 7)),
66 new_Const (mode_i, tarval_from_long (mode_i, 5)),
74 x = new_Return (get_store (), 2, in);
77 add_in_edge (irg->end_block, x);
78 mature_block (irg->end_block);
80 /* verify the graph */
83 dead_node_elimination(irg);
87 printf("\nDone building the graph. Dumping it.\n");
88 dump_ir_block_graph (irg);
90 printf("use xvcg to view this graph:\n");
91 printf("/ben/goetz/bin/xvcg GRAPHNAME\n");