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:
31 ir_node *a, *b, *c, *d, *x;
33 printf("creating an IR graph: CONST_EVAL_EXAMPLE...\n");
37 /* Try both optimizations: */
38 set_opt_constant_folding(1);
41 owner = new_type_class (id_from_str ("CONST_EVAL_EXAMPLE", 18));
42 ent = new_entity ((type *)owner, id_from_str ("main", 4), NULL);
44 irg = new_ir_graph (ent, 4);
46 a = new_Const (mode_i, tarval_from_long (mode_i, 7));
47 b = new_Const (mode_i, tarval_from_long (mode_i, 5));
50 mature_block (irg->current_block);
52 /* To test const eval on DivMod
53 c = new_DivMod(get_store(), a, b);
54 set_store(new_Proj(c, mode_M, 0));
55 d = new_Proj(c, mode_i, 3);
56 c = new_Proj(c, mode_i, 2);
61 c = new_Add (new_Const (mode_i, tarval_from_long (mode_i, 5)),
62 new_Const (mode_i, tarval_from_long (mode_i, 7)),
64 d = new_Add (new_Const (mode_i, tarval_from_long (mode_i, 7)),
65 new_Const (mode_i, tarval_from_long (mode_i, 5)),
73 x = new_Return (get_store (), 2, in);
76 add_in_edge (irg->end_block, x);
77 mature_block (irg->end_block);
79 /* verify the graph */
82 printf("\nDone building the graph. Dumping it.\n");
83 dump_ir_block_graph (irg);
85 printf("use xvcg to view this graph:\n");
86 printf("/ben/goetz/bin/xvcg GRAPHNAME\n");