This is the modeling appropriate for other languages.
Mode_i says that all integers shall be implemented as a
32 bit integer value. */
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
printf("\nCreating an IR graph: ARRAY-HEAP_EXAMPLE...\n");
# define U_BOUND 9
array_type = new_type_array(id_from_str("a", 1), N_DIMS, prim_t_int);
set_array_bounds(array_type, 1,
- new_Const(mode_I, tarval_from_long (mode_I, L_BOUND)),
- new_Const(mode_I, tarval_from_long (mode_I, U_BOUND)));
+ new_Const(mode_Iu, tarval_from_long (mode_Iu, L_BOUND)),
+ new_Const(mode_Iu, tarval_from_long (mode_Iu, U_BOUND)));
/* As the array is accessed by Sel nodes, we need information about
the entity the node selects. Entities of an array are it's elements
which are, in this case, integers. */
/* better: read bounds out of array type information */
size = (U_BOUND - L_BOUND + 1) * get_mode_size(elt_type_mode);
/* make constant representing the size */
- arr_size = new_Const(mode_I, tarval_from_long (mode_I, size));
+ arr_size = new_Const(mode_Iu, tarval_from_long (mode_Iu, size));
/* allocate and generate the Proj nodes. */
array = new_Alloc(get_store(), arr_size, (type*)array_type, stack_alloc);
set_store(new_Proj(array, mode_M, 0)); /* make the changed memory visible */
- array_ptr = new_Proj(array, mode_p, 2); /* remember the pointer to the array */
+ array_ptr = new_Proj(array, mode_P, 2); /* remember the pointer to the array */
/* Now the "real" program: */
/* Load element 3 of the array. For this first generate the pointer to this
by (three * elt_size), but this complicates some optimizations. The
type information accessible via the entity allows to generate the
pointer increment later. */
- c3 = new_Const (mode_I, tarval_from_long (mode_I, 3));
+ c3 = new_Const (mode_Iu, tarval_from_long (mode_Iu, 3));
{
ir_node *in[1];
in[0] = c3;
}
val = new_Load(get_store(), elt);
set_store(new_Proj(val, mode_M, 0));
- val = new_Proj(val, mode_i, 2);
+ val = new_Proj(val, mode_Is, 2);
/* return the result of procedure main */
{
printf("use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
- return (1);
+ return (0);
}
This is the modeling appropriate for other languages.
Mode_i says that all language-integers shall be implemented
as a 32 bit processor-integer value. */
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
/* build typeinformation of procedure main */
owner = new_type_class (id_from_str ("ARRAY-STACK_EXAMPLE", 19));
# define U_BOUND 9
array_type = new_type_array(id_from_str("a_tp", 4), N_DIMS, prim_t_int);
set_array_bounds(array_type, 1,
- new_Const(mode_I, tarval_from_long (mode_I, L_BOUND)),
- new_Const(mode_I, tarval_from_long (mode_I, U_BOUND)));
+ new_Const(mode_Iu, tarval_from_long (mode_Iu, L_BOUND)),
+ new_Const(mode_Iu, tarval_from_long (mode_Iu, U_BOUND)));
/* The array is an entity of the method, placed on the mehtod's own memory,
the stack frame. */
array_ent = new_entity(get_cur_frame_type(), id_from_str("a", 1), array_type);
array pointer by (three * elt_size), but this complicates some
optimizations.) The type information accessible via the entity
allows to generate the pointer increment later. */
- c3 = new_Const (mode_I, tarval_from_long (mode_I, 3));
+ c3 = new_Const (mode_Iu, tarval_from_long (mode_Iu, 3));
{
ir_node *in[1];
in[0] = c3;
}
val = new_Load(get_store(), elt);
set_store(new_Proj(val, mode_M, 0));
- val = new_Proj(val, mode_i, 2);
+ val = new_Proj(val, mode_Is, 2);
/* return the result of procedure main */
{
printf("Use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
- return (1);
+ return (0);
}
string_ptr = new_type_pointer (
id_from_str ("ptr_to_string", 13),
new_type_array (id_from_str ("char_arr", 8), 1,
- new_type_primitive (id_from_str("char", 4), mode_c)));
+ new_type_primitive (id_from_str("char", 4), mode_Bu)));
/* FIRM was designed for oo languages where all methods belong to a class.
* For imperative languages like C we view a program as a large class containing
* all functions of the program as methods in this class. This class is
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* the string is entered in the constant table. const_str is a pointer to the string */
- const_str = new_Const (mode_p, tarval_p_from_str ("Hello world!"));
+ const_str = new_Const (mode_P, tarval_P_from_str ("Hello world!"));
/* get the pointer to the procedure from the class type */
/* this is how a pointer to be fixed by the linker is represented after
init_firm ();
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
/* FIRM was designed for oo languages where all methods belong to a class.
* For imperative languages like C we view a file as a large class containing
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* get the first argument a of method main - see irgraph.h */
- arg1 = new_Proj(get_irg_args(irg), mode_i, 0);
+ arg1 = new_Proj(get_irg_args(irg), mode_Is, 0);
/* arg1 as first first local variable - makes things simple */
set_value(0, arg1);
/* the expression that evaluates the condition */
/* cmpGt = a > 2 */
- c2 = new_Const (mode_i, tarval_from_long (mode_i, 2));
- cmpGt = new_Proj(new_Cmp(get_value(0, mode_i), c2), mode_b, Gt);
- cmpGt = new_Conv(cmpGt, mode_i);
+ c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
+ cmpGt = new_Proj(new_Cmp(get_value(0, mode_Is), c2), mode_b, Gt);
+ cmpGt = new_Conv(cmpGt, mode_Is);
/* cmpLt = a < 10 */
- c10 = new_Const (mode_i, tarval_from_long (mode_i, 10));
- cmpLt = new_Proj(new_Cmp(get_value(0, mode_i), c10), mode_b, Lt);
- cmpLt = new_Conv(cmpLt, mode_i);
+ c10 = new_Const (mode_Is, tarval_from_long (mode_Is, 10));
+ cmpLt = new_Proj(new_Cmp(get_value(0, mode_Is), c10), mode_b, Lt);
+ cmpLt = new_Conv(cmpLt, mode_Is);
/* cmpGt && cmpLt */
- and = new_And(cmpGt, cmpLt, mode_i);
+ and = new_And(cmpGt, cmpLt, mode_Is);
/* compare result and 0 because we have no cast from integer to bool */
- and = new_Cmp(and, new_Const (mode_i, tarval_from_long (mode_i, 0)));
+ and = new_Cmp(and, new_Const (mode_Is, tarval_from_long (mode_Is, 0)));
and = new_Proj(and, mode_b, Ne);
/* the conditional branch */
/* generate and fill the then block */
b = new_immBlock ();
add_in_edge (b, t);
- set_value (0, new_Const (mode_i, tarval_from_long (mode_i, 1)));
+ set_value (0, new_Const (mode_Is, tarval_from_long (mode_Is, 1)));
mature_block (b);
x_then = new_Jmp ();
/* Generate the return node into current region. */
{
ir_node *in[1]; /* this is the array containing the return parameters */
- in[0] = get_value(0, mode_i);
+ in[0] = get_value(0, mode_Is);
x = new_Return (get_store(), 1, in);
}
/* Now generate all instructions for this block and all its predecessor blocks
/** make the type information needed */
/* Language defined types */
- intt = new_type_primitive(inti, mode_i);
+ intt = new_type_primitive(inti, mode_Is);
/* Program defined types */
Ct = new_type_class(Ci);
ft = new_type_method(fti, 0, 0); /* 0 parameters, 0 results */
current_ir_graph = get_const_code_irg();
/* The pointer to the dispatch table is constant. */
/* The constant is the address of the given entity */
- n = new_Const(mode_p, tarval_p_from_entity(dipte));
+ n = new_Const(mode_P, tarval_p_from_entity(dipte));
set_entity_variability(diptpe, constant);
set_atomic_ent_value(diptpe, n);
/** The array type **/
/* Don't reuse int type so that graph layout is better readable */
- intt = new_type_primitive(inti, mode_i);
+ intt = new_type_primitive(inti, mode_Is);
arrt = new_type_array(arrti, 1, intt);
set_array_bounds_int(arrt, 0, 0, 4);
arrelte = get_array_element_entity(arrt);
arre = new_entity(get_glob_type(), arrei, arrt);
set_entity_variability(arre, constant);
current_ir_graph = get_const_code_irg();
- n = new_Const(mode_i, tarval_from_long (mode_i, 7));
+ n = new_Const(mode_Is, tarval_from_long (mode_Is, 7));
add_compound_ent_value(arre, n, arrelte);
- n = new_Const(mode_i, tarval_from_long (mode_i, 2));
+ n = new_Const(mode_Is, tarval_from_long (mode_Is, 2));
add_compound_ent_value(arre, n, arrelte);
- n = new_Const(mode_i, tarval_from_long (mode_i, 13));
+ n = new_Const(mode_Is, tarval_from_long (mode_Is, 13));
add_compound_ent_value(arre, n, arrelte);
- n = new_Const(mode_i, tarval_from_long (mode_i, 92));
+ n = new_Const(mode_Is, tarval_from_long (mode_Is, 92));
add_compound_ent_value(arre, n, arrelte);
}
printf("Done building the graph. Dumping it.\n");
init_firm ();
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
/* Try both optimizations: */
set_opt_constant_folding(1);
irg = new_ir_graph (ent, 4);
- a = new_Const (mode_i, tarval_from_long (mode_i, 7));
- b = new_Const (mode_i, tarval_from_long (mode_i, 5));
+ a = new_Const (mode_Is, tarval_from_long (mode_Is, 7));
+ b = new_Const (mode_Is, tarval_from_long (mode_Is, 5));
x = new_Jmp ();
mature_block (get_irg_current_block(irg));
/* To test const eval on DivMod
c = new_DivMod(get_store(), a, b);
set_store(new_Proj(c, mode_M, 0));
- d = new_Proj(c, mode_i, 3);
- c = new_Proj(c, mode_i, 2);
+ d = new_Proj(c, mode_Is, 3);
+ c = new_Proj(c, mode_Is, 2);
*/
- c = new_Add (new_Const (mode_i, tarval_from_long (mode_i, 5)),
- new_Const (mode_i, tarval_from_long (mode_i, 7)),
- mode_i);
- d = new_Add (new_Const (mode_i, tarval_from_long (mode_i, 7)),
- new_Const (mode_i, tarval_from_long (mode_i, 5)),
- mode_i);
+ c = new_Add (new_Const (mode_Is, tarval_from_long (mode_Is, 5)),
+ new_Const (mode_Is, tarval_from_long (mode_Is, 7)),
+ mode_Is);
+ d = new_Add (new_Const (mode_Is, tarval_from_long (mode_Is, 7)),
+ new_Const (mode_Is, tarval_from_long (mode_Is, 5)),
+ mode_Is);
{
ir_node *in[2];
init_firm ();
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
/* FIRM was designed for oo languages where all methods belong to a class.
* For imperative languages like C we view a file as a large class containing
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* to make a condition */
- c1 = new_Const (mode_i, tarval_from_long (mode_i, 1));
- c2 = new_Const (mode_i, tarval_from_long (mode_i, 2));
+ c1 = new_Const (mode_Is, tarval_from_long (mode_Is, 1));
+ c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
set_value(0, c2);
cond = new_Cond(new_Proj(new_Cmp(c1, c2), mode_b, Eq));
switch_block(endBlock);
{
ir_node *in[1];
- in[0] = get_value(0, mode_i);
+ in[0] = get_value(0, mode_Is);
get_store();
x = new_Return (get_store(), 1, in);
}
set_opt_global_cse(0);
set_opt_dead_node_elimination (1);
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
#define METHODNAME "main_tp"
#define NRARGS 1
irg = new_ir_graph (ent, 4);
/* Generate two values */
- set_value (0, new_Proj(get_irg_args(irg), mode_i, 0));
- set_value (1, new_Const (mode_i, tarval_from_long (mode_i, 1)));
+ set_value (0, new_Proj(get_irg_args(irg), mode_Is, 0));
+ set_value (1, new_Const (mode_Is, tarval_from_long (mode_Is, 1)));
x = new_Jmp();
mature_block (get_irg_current_block(irg));
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
add_in_edge (r, x);
- x = new_Cond (new_Proj(new_Cmp(new_Const (mode_i, tarval_from_long (mode_i, 0)),
- new_Const (mode_i, tarval_from_long (mode_i, 0))),
+ x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Is, tarval_from_long (mode_Is, 0)),
+ new_Const (mode_Is, tarval_from_long (mode_Is, 0))),
mode_b, Eq));
f = new_Proj (x, mode_X, 0);
t = new_Proj (x, mode_X, 1);
/* The code in the loop body,
as we are dealing with local variables only the dataflow edges
are manipulated. */
- set_value (2, get_value (0, mode_i));
- set_value (0, get_value (1, mode_i));
- set_value (1, get_value (2, mode_i));
+ set_value (2, get_value (0, mode_Is));
+ set_value (0, get_value (1, mode_Is));
+ set_value (1, get_value (2, mode_Is));
/* set VAR_A to constant value */
set_store (new_Proj (new_Store (get_store (),
- new_Const (mode_p, tarval_p_from_str ("VAR_A")),
- get_value(1, mode_i)),
+ new_Const (mode_P, tarval_P_from_str ("VAR_A")),
+ get_value(1, mode_Is)),
mode_M, 0));
mature_block (b);
{
ir_node *in[1];
- in[0] = new_Sub (get_value (0, mode_i), get_value (1, mode_i), mode_i);
+ in[0] = new_Sub (get_value (0, mode_Is), get_value (1, mode_Is), mode_Is);
x = new_Return (get_store (), 1, in);
}
#define NRARGS 0
#define NRES 1
/* The type of the method */
- prim_t_dbl = new_type_primitive(id_from_str ("dbl", 3), mode_d);
+ prim_t_dbl = new_type_primitive(id_from_str ("dbl", 3), mode_D);
proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
set_method_res_type(proc_main, 0, prim_t_dbl);
{
ir_node *in[1]; /* this is the array containing the return parameters */
- in[0] = new_Const(mode_d, tv);
+ in[0] = new_Const(mode_D, tv);
x = new_Return (get_store(), 1, in);
}
/* Now we generated all instructions for this block and all its predecessor
/* The type int. This type is necessary to model the result and parameters
the procedure. */
#define PRIM_NAME "int"
- typ = new_type_primitive(id_from_str(PRIM_NAME, strlen(PRIM_NAME)), mode_i);
+ typ = new_type_primitive(id_from_str(PRIM_NAME, strlen(PRIM_NAME)), mode_Is);
/* The parameter and result types of the procedure. */
set_method_param_type(proc_main, 0, typ);
set_method_res_type(proc_main, 0, typ);
/* Get the procedure parameter and assign it to the parameter variable
a. */
- set_value (a_pos, new_Proj (get_irg_args(irg), mode_i, 0));
+ set_value (a_pos, new_Proj (get_irg_args(irg), mode_Is, 0));
/* Generate the constant and assign it to b. The assignment is resovled to a
dataflow edge. */
- set_value (b_pos, new_Const (mode_i, tarval_from_long (mode_i, 2)));
+ set_value (b_pos, new_Const (mode_Is, tarval_from_long (mode_Is, 2)));
/* We know all predecessors of the block and all set_values and set_stores are
preformed. We can mature the block. */
mature_block (get_irg_current_block(irg));
/* Generate a conditional branch */
- cmp = new_Cmp(get_value(a_pos, mode_i), get_value(b_pos, mode_i)); /*
- cmp = new_Cmp(new_Const (mode_i, tarval_from_long (mode_i, 2)),
- new_Const (mode_i, tarval_from_long (mode_i, 2)));*/
+ cmp = new_Cmp(get_value(a_pos, mode_Is), get_value(b_pos, mode_Is)); /*
+ cmp = new_Cmp(new_Const (mode_Is, tarval_from_long (mode_Is, 2)),
+ new_Const (mode_Is, tarval_from_long (mode_Is, 2)));*/
x = new_Cond (new_Proj(cmp, mode_b, Eq));
f = new_Proj (x, mode_X, 0);
t = new_Proj (x, mode_X, 1);
/* generate and fill the then block */
r = new_immBlock ();
add_in_edge (r, t);
- a = new_Sub(get_value(a_pos, mode_i),
- new_Const (mode_i, tarval_from_long (mode_i, 3)),
- mode_i);
+ a = new_Sub(get_value(a_pos, mode_Is),
+ new_Const (mode_Is, tarval_from_long (mode_Is, 3)),
+ mode_Is);
set_value (a_pos, a);
mature_block (r);
/* generate the else block */
r = new_immBlock ();
add_in_edge (r, f);
- a = new_Sub(get_value(a_pos, mode_i),
- new_Const (mode_i, tarval_from_long (mode_i, 3)),
- mode_i);
- a = new_Add(a, new_Const (mode_i, tarval_from_long (mode_i, 5)), mode_i);
+ a = new_Sub(get_value(a_pos, mode_Is),
+ new_Const (mode_Is, tarval_from_long (mode_Is, 3)),
+ mode_Is);
+ a = new_Add(a, new_Const (mode_Is, tarval_from_long (mode_Is, 5)), mode_Is);
set_value (a_pos, a);
mature_block (r);
/* The Return statement */
{
ir_node *in[1], *store ;
- in[0] = get_value (a_pos, mode_i);
+ in[0] = get_value (a_pos, mode_Is);
store = get_store();
x = new_Return (store, 1, in);
This is the modeling appropriate for other languages.
Mode_i says that all integers shall be implemented as a
32 bit integer value. */
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
/* FIRM was designed for oo languages where all methods belong to a class.
* For imperative languages like C we view a file or compilation unit as
i_ptr = new_simpleSel(get_store(), get_irg_globals(irg), i_ent);
store = new_Store (get_store(), i_ptr,
- new_Const(mode_i, tarval_from_long (mode_i, 2)));
+ new_Const(mode_Is, tarval_from_long (mode_Is, 2)));
set_store(new_Proj(store, mode_M, 0));
{
init_firm ();
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
/* FIRM was designed for oo languages where all methods belong to a class.
* For imperative languages like C we view a file as a large class containing
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* Generate two constants */
- c0 = new_Const (mode_i, tarval_from_long (mode_i, 0));
- c1 = new_Const (mode_i, tarval_from_long (mode_i, 1));
+ c0 = new_Const (mode_Is, tarval_from_long (mode_Is, 0));
+ c1 = new_Const (mode_Is, tarval_from_long (mode_Is, 1));
/* set a and b to constants */
set_value (0, c0); /* this (0) is variable a */
set_value (1, c1); /* this (1) is variable b */
/* the expression that evaluates the condition */
- c2 = new_Const (mode_i, tarval_from_long (mode_i, 2));
- cmpGt = new_Proj(new_Cmp(get_value(0, mode_i), c2), mode_b, Gt);
+ c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
+ cmpGt = new_Proj(new_Cmp(get_value(0, mode_Is), c2), mode_b, Gt);
/* the conditional branch */
x = new_Cond (cmpGt);
/* generate and fill the then block */
b = new_immBlock ();
add_in_edge (b, t);
- set_value (0, get_value(1, mode_i));
+ set_value (0, get_value(1, mode_Is));
mature_block (b);
x_then = new_Jmp ();
/* generate and fill the else block */
b = new_immBlock ();
add_in_edge (b, f);
- set_value (1, new_Const (mode_i, tarval_from_long (mode_i, 2)));
+ set_value (1, new_Const (mode_Is, tarval_from_long (mode_Is, 2)));
mature_block (b);
x_else = new_Jmp ();
/* Generate the return node into current region. */
{
ir_node *in[2]; /* this is the array containing the return parameters */
- in[0] = get_value(0, mode_i);
- in[1] = get_value(1, mode_i);
+ in[0] = get_value(0, mode_Is);
+ in[1] = get_value(1, mode_Is);
x = new_Return (get_store(), 2, in);
}
/* Now generate all instructions for this block and all its predecessor
/* The type int. This type is necessary to model the result and parameters
the procedure. */
#define PRIM_NAME "int"
- typ = new_type_primitive(id_from_str(PRIM_NAME, strlen(PRIM_NAME)), mode_i);
+ typ = new_type_primitive(id_from_str(PRIM_NAME, strlen(PRIM_NAME)), mode_Is);
/* The parameter and result types of the procedure. */
set_method_param_type(proc_main, 0, typ);
set_method_res_type(proc_main, 0, typ);
/* Get the procedure parameter and assign it to the parameter variable
a. */
- set_value (a_pos, new_Proj (get_irg_args(irg), mode_i, 0));
+ set_value (a_pos, new_Proj (get_irg_args(irg), mode_Is, 0));
/* Generate the constant and assign it to b. The assignment is resovled to a
dataflow edge. */
- set_value (b_pos, new_Const (mode_i, tarval_from_long (mode_i, 2)));
+ set_value (b_pos, new_Const (mode_Is, tarval_from_long (mode_Is, 2)));
/* We know all predecessors of the block and all set_values and set_stores are
preformed. We can mature the block. */
mature_block (get_irg_current_block(irg));
/* Generate a conditional branch */
- cmp = new_Cmp(get_value(a_pos, mode_i), get_value(b_pos, mode_i));
+ cmp = new_Cmp(get_value(a_pos, mode_Is), get_value(b_pos, mode_Is));
x = new_Cond (new_Proj(cmp, mode_b, Eq));
f = new_Proj (x, mode_X, 0);
t = new_Proj (x, mode_X, 1);
/* generate and fill the then block */
r = new_immBlock ();
add_in_edge (r, t);
- a = new_Sub(get_value(a_pos, mode_i),
- new_Const (mode_i, tarval_from_long (mode_i, 3)),
- mode_i);
+ a = new_Sub(get_value(a_pos, mode_Is),
+ new_Const (mode_Is, tarval_from_long (mode_Is, 3)),
+ mode_Is);
set_value (a_pos, a);
mature_block (r);
/* The Return statement */
{
ir_node *in[1], *store ;
- in[0] = get_value (a_pos, mode_i);
+ in[0] = get_value (a_pos, mode_Is);
store = get_store();
x = new_Return (store, 1, in);
set_opt_dead_node_elimination (1);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_I);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Iu);
#define METHODNAME "main"
#define NRARGS 0
irg = new_ir_graph (ent, 4);
/* Generate two constants */
- set_value (0, new_Const (mode_I, tarval_from_long (mode_I, 0)));
- set_value (1, new_Const (mode_I, tarval_from_long (mode_I, 1)));
+ set_value (0, new_Const (mode_Iu, tarval_from_long (mode_Iu, 0)));
+ set_value (1, new_Const (mode_Iu, tarval_from_long (mode_Iu, 1)));
mature_block (get_irg_current_block(irg));
/* Generate a conditional branch */
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
add_in_edge (r, x);
- x = new_Cond (new_Proj(new_Cmp(new_Const (mode_I, tarval_from_long (mode_i, 0)),
- new_Const (mode_I, tarval_from_long (mode_i, 0))),
+ x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Iu, tarval_from_long (mode_Is, 0)),
+ new_Const (mode_Iu, tarval_from_long (mode_Is, 0))),
mode_b, Eq));
f = new_Proj (x, mode_X, 0);
t = new_Proj (x, mode_X, 1);
/* the code in the loop body,
as we are dealing with local variables only the dataflow edges
are manipulated */
- set_value (2, get_value (0, mode_I));
- set_value (0, get_value (1, mode_I));
- set_value (1, get_value (2, mode_I));
+ set_value (2, get_value (0, mode_Iu));
+ set_value (0, get_value (1, mode_Iu));
+ set_value (1, get_value (2, mode_Iu));
mature_block (b);
/* generate the return block */
{
ir_node *in[1];
- in[0] = new_Sub (get_value (0, mode_I), get_value (1, mode_I), mode_I);
+ in[0] = new_Sub (get_value (0, mode_Iu), get_value (1, mode_Iu), mode_Iu);
x = new_Return (get_store (), 1, in);
}
/** make the type information needed */
/* Language defined types */
- intt = new_type_primitive(inti, mode_I);
+ intt = new_type_primitive(inti, mode_Iu);
/* Program defined types */
it = new_type_class(ii); /* The fact that this is an interface is
of no interest. It's just a class without
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* two make two conditionals that represent a switch */
- expr = new_Const (mode_i, tarval_from_long (mode_i, 0));
- c1 = new_Const (mode_i, tarval_from_long (mode_i, 1));
- c2 = new_Const (mode_i, tarval_from_long (mode_i, 2));
+ expr = new_Const (mode_Is, tarval_from_long (mode_Is, 0));
+ c1 = new_Const (mode_Is, tarval_from_long (mode_Is, 1));
+ c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
cond = new_Cond(new_Proj(new_Cmp(expr, c1), mode_b, Eq));
f = new_Proj(cond, mode_X, 0);
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* to make three conditionals */
- expr = new_Const (mode_i, tarval_from_long (mode_i, 0));
- c1 = new_Const (mode_i, tarval_from_long (mode_i, 1));
- c2 = new_Const (mode_i, tarval_from_long (mode_i, 2));
- c3 = new_Const (mode_i, tarval_from_long (mode_i, 2));
+ expr = new_Const (mode_Is, tarval_from_long (mode_Is, 0));
+ c1 = new_Const (mode_Is, tarval_from_long (mode_Is, 1));
+ c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
+ c3 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
cond = new_Cond(new_Proj(new_Cmp(expr, c1), mode_b, Eq));
f = new_Proj(cond, mode_X, 0);
set_opt_dead_node_elimination (1);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_I);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Iu);
/* a class to get started with, containing the main procedure */
owner = new_type_class (id_from_str ("MEMORY_EXAMPLE", 14));
/* generate two constant pointers to string constants */
/* this simulates two global variables, a and b point to these variables */
- a = new_Const (mode_p, tarval_p_from_str ("VAR_A"));
- b = new_Const (mode_p, tarval_p_from_str ("VAR_B"));
+ a = new_Const (mode_P, tarval_P_from_str ("VAR_A"));
+ b = new_Const (mode_P, tarval_P_from_str ("VAR_B"));
/* set VAR_A and VAR_B to constant values */
set_store (new_Proj (new_Store (get_store (), a,
- new_Const (mode_I, tarval_from_long (mode_i, 0))),
+ new_Const (mode_Iu, tarval_from_long (mode_Is, 0))),
mode_M, 0));
set_store (new_Proj (new_Store (get_store (), b,
- new_Const (mode_I, tarval_from_long (mode_i, 1))),
+ new_Const (mode_Iu, tarval_from_long (mode_Is, 1))),
mode_M, 0));
/* finish this first block */
/* load the value and make it's effects visible. */
x = new_Load (get_store (), a);
set_store (new_Proj (x, mode_M, 0));
- x = new_Proj(x, mode_I, 2);
+ x = new_Proj(x, mode_Iu, 2);
/* the same again: load the value and make it's effects visible. */
y = new_Load (get_store (), b);
set_store (new_Proj (y, mode_M, 0));
- y = new_Proj(y, mode_I, 2);
+ y = new_Proj(y, mode_Iu, 2);
/* store the exchanged values. */
set_store (new_Proj (new_Store (get_store (), a, y), mode_M, 0));
set_store (new_Proj (new_Store (get_store (), b, x), mode_M, 0));
x = new_Cond (
new_Proj (
new_Cmp (
- new_Const (mode_I, tarval_from_long (mode_i, 0)),
+ new_Const (mode_Iu, tarval_from_long (mode_Is, 0)),
x),
mode_b, Gt));
{
ir_node *in[1];
x = new_Load (get_store (), a);
- in[0] = new_Proj (x, mode_I, 2);
+ in[0] = new_Proj (x, mode_Iu, 2);
x = new_Return (new_Proj(x, mode_M, 0), 1, in);
}
set_opt_dead_node_elimination(1);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
/*** Make type information for the class (PRIMA). ***/
/* The type of the class */
set_irp_main_irg(main_irg);
/* Make the constants. They are independent of a block. */
- c2 = new_Const (mode_i, tarval_from_long (mode_i, 2));
- c5 = new_Const (mode_i, tarval_from_long (mode_i, 5));
+ c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
+ c5 = new_Const (mode_Is, tarval_from_long (mode_Is, 5));
/* There is only one block in main, it contains the allocation and the calls. */
/* Allocate the defined object and generate the type information. */
obj_size = new_SymConst((type_or_id_p)class_prima, size);
obj_o = new_Alloc(get_store(), obj_size, class_prima, heap_alloc);
set_store(new_Proj(obj_o, mode_M, 0)); /* make the changed memory visible */
- obj_o = new_Proj(obj_o, mode_p, 2); /* remember the pointer to the object */
+ obj_o = new_Proj(obj_o, mode_P, 2); /* remember the pointer to the object */
set_value(o_pos, obj_o);
/* Get the pointer to the procedure from the object. */
proc_ptr = new_simpleSel(get_store(), /* The memory containing the object. */
- get_value(o_pos, mode_p),/* The pointer to the object. */
+ get_value(o_pos, mode_P),/* The pointer to the object. */
proc_set_a_e ); /* The feature to select. */
/* Call procedure set_a, first built array with parameters. */
{
ir_node *in[2];
- in[0] = get_value(o_pos, mode_p);
+ in[0] = get_value(o_pos, mode_P);
in[1] = c2;
set_a_call = new_Call(get_store(), proc_ptr, 2, in, proc_set_a);
set_store(new_Proj(set_a_call, mode_M, 0));
/* Get the pointer to the nest procedure from the object. */
- proc_ptr = new_simpleSel(get_store(), get_value(o_pos, mode_p), proc_c_e);
+ proc_ptr = new_simpleSel(get_store(), get_value(o_pos, mode_P), proc_c_e);
/* call procedure c, first built array with parameters */
{
ir_node *in[2];
- in[0] = get_value(o_pos, mode_p);
+ in[0] = get_value(o_pos, mode_P);
in[1] = c5;
c_call = new_Call(get_store(), proc_ptr, 2, in, proc_c);
}
set_store(new_Proj(c_call, mode_M, 0));
/* Get the result of the procedure: select the result tuple from the call,
then the proper result from the tuple. */
- res = new_Proj(new_Proj(c_call, mode_T, 2), mode_i, 0);
+ res = new_Proj(new_Proj(c_call, mode_T, 2), mode_Is, 0);
/* return the results of procedure main */
{
self_pos = 0; e_pos = 1;
/* get the procedure parameter */
- self = new_Proj(get_irg_args(set_a_irg), mode_p, 0);
+ self = new_Proj(get_irg_args(set_a_irg), mode_P, 0);
set_value(self_pos, self);
- par1 = new_Proj(get_irg_args(set_a_irg), mode_i, 1);
+ par1 = new_Proj(get_irg_args(set_a_irg), mode_Is, 1);
set_value(e_pos, par1);
/* Create and select the entity to set */
a_ptr = new_simpleSel(get_store(), self, a_e);
c_irg = new_ir_graph (proc_c_e, 5);
/* get the procedure parameter */
- self = new_Proj(get_irg_args(c_irg), mode_p, 0);
+ self = new_Proj(get_irg_args(c_irg), mode_P, 0);
set_value(0, self);
- par1 = new_Proj(get_irg_args(c_irg), mode_i, 1);
+ par1 = new_Proj(get_irg_args(c_irg), mode_Is, 1);
set_value(1, par1);
- set_value(2, new_Const (mode_i, tarval_from_long (mode_i, 0)));
+ set_value(2, new_Const (mode_Is, tarval_from_long (mode_Is, 0)));
x = new_Jmp();
mature_block (get_irg_current_block(c_irg));
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
add_in_edge (r, x);
- x = new_Cond (new_Proj(new_Cmp(new_Const (mode_i, tarval_from_long (mode_i, 0)),
- new_Const (mode_i, tarval_from_long (mode_i, 0))),
+ x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Is, tarval_from_long (mode_Is, 0)),
+ new_Const (mode_Is, tarval_from_long (mode_Is, 0))),
mode_b, Eq));
- /* x = new_Cond (new_Proj(new_Cmp(new_Const (mode_i, tarval_from_long (mode_i, 0)),
- get_value(1, mode_i)),
+ /* x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Is, tarval_from_long (mode_Is, 0)),
+ get_value(1, mode_Is)),
mode_b, Eq));*/
f = new_Proj (x, mode_X, 0);
t = new_Proj (x, mode_X, 1);
/* The code in the loop body,
as we are dealing with local variables only the dataflow edges
are manipulated. */
- set_value (3, get_value (1, mode_i));
- set_value (1, get_value (2, mode_i));
- set_value (2, get_value (3, mode_i));
+ set_value (3, get_value (1, mode_Is));
+ set_value (1, get_value (2, mode_Is));
+ set_value (2, get_value (3, mode_Is));
a_ptr = new_simpleSel(get_store(), self, a_e);
- set_store(new_Store(get_store(), a_ptr, get_value(2, mode_i)));
+ set_store(new_Store(get_store(), a_ptr, get_value(2, mode_Is)));
x = new_Jmp ();
add_in_edge(r, x);
mature_block (b);
a_ptr = new_simpleSel(get_store(), self, a_e);
a_val = new_Load(get_store(), a_ptr);
set_store(new_Proj(a_val, mode_M, 0));
- a_val = new_Proj(a_val, mode_i, 2);
+ a_val = new_Proj(a_val, mode_Is, 2);
/* return the result */
{
ir_node *in[1];
- in[0] = new_Add(par1, a_val, mode_i);
+ in[0] = new_Add(par1, a_val, mode_Is);
x = new_Return (get_store (), 1, in);
}
printf("Use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
- return (1);
+ return (0);
}
set_opt_dead_node_elimination(1);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
/*** Make type information for the class (PRIMA). ***/
/* The type of the class */
set_irp_main_irg(main_irg);
/* Make the constants. They are independent of a block. */
- c2 = new_Const (mode_i, tarval_from_long (mode_i, 2));
- c5 = new_Const (mode_i, tarval_from_long (mode_i, 5));
+ c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
+ c5 = new_Const (mode_Is, tarval_from_long (mode_Is, 5));
/* There is only one block in main, it contains the allocation and the calls. */
/* Allocate the defined object and generate the type information. */
obj_size = new_SymConst((type_or_id_p)class_prima, size);
obj_o = new_Alloc(get_store(), obj_size, class_prima, heap_alloc);
set_store(new_Proj(obj_o, mode_M, 0)); /* make the changed memory visible */
- obj_o = new_Proj(obj_o, mode_p, 2); /* remember the pointer to the object */
+ obj_o = new_Proj(obj_o, mode_P, 2); /* remember the pointer to the object */
set_value(o_pos, obj_o);
/* Get the pointer to the procedure from the object. */
proc_ptr = new_simpleSel(get_store(), /* The memory containing the object. */
- get_value(o_pos, mode_p),/* The pointer to the object. */
+ get_value(o_pos, mode_P),/* The pointer to the object. */
proc_set_a_e ); /* The feature to select. */
/* Call procedure set_a, first built array with parameters. */
{
ir_node *in[2];
- in[0] = get_value(o_pos, mode_p);
+ in[0] = get_value(o_pos, mode_P);
in[1] = c2;
call = new_Call(get_store(), proc_ptr, 2, in, proc_set_a);
}
set_store(new_Proj(call, mode_M, 0));
/* Get the pointer to the nest procedure from the object. */
- proc_ptr = new_simpleSel(get_store(), get_value(o_pos, mode_p), proc_c_e);
+ proc_ptr = new_simpleSel(get_store(), get_value(o_pos, mode_P), proc_c_e);
/* call procedure c, first built array with parameters */
{
ir_node *in[2];
- in[0] = get_value(o_pos, mode_p);
+ in[0] = get_value(o_pos, mode_P);
in[1] = c5;
call = new_Call(get_store(), proc_ptr, 2, in, proc_c);
}
set_store(new_Proj(call, mode_M, 0));
/* Get the result of the procedure: select the result tuple from the call,
then the proper result from the tuple. */
- res = new_Proj(new_Proj(call, mode_T, 2), mode_i, 0);
+ res = new_Proj(new_Proj(call, mode_T, 2), mode_Is, 0);
/* return the results of procedure main */
{
self_pos = 0; e_pos = 1;
/* get the procedure parameter */
- self = new_Proj(get_irg_args(set_a_irg), mode_p, 0);
+ self = new_Proj(get_irg_args(set_a_irg), mode_P, 0);
set_value(self_pos, self);
- par1 = new_Proj(get_irg_args(set_a_irg), mode_i, 1);
+ par1 = new_Proj(get_irg_args(set_a_irg), mode_Is, 1);
set_value(e_pos, par1);
/* Create and select the entity to set */
a_ptr = new_simpleSel(get_store(), self, a_e);
c_irg = new_ir_graph (proc_c_e, 2);
/* get the procedure parameter */
- self = new_Proj(get_irg_args(c_irg), mode_p, 0);
- par1 = new_Proj(get_irg_args(c_irg), mode_i, 1);
+ self = new_Proj(get_irg_args(c_irg), mode_P, 0);
+ par1 = new_Proj(get_irg_args(c_irg), mode_Is, 1);
/* Select the entity and load the value */
a_ptr = new_simpleSel(get_store(), self, a_e);
a_val = new_Load(get_store(), a_ptr);
set_store(new_Proj(a_val, mode_M, 0));
- a_val = new_Proj(a_val, mode_i, 2);
+ a_val = new_Proj(a_val, mode_Is, 2);
/* return the result */
{
ir_node *in[1];
- in[0] = new_Add(par1, a_val, mode_i);
+ in[0] = new_Add(par1, a_val, mode_Is);
x = new_Return (get_store (), 1, in);
}
printf("Use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
- return (1);
+ return (0);
}
set_optimize(1);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
/* FIRM was designed for oo languages where all methods belong to a class.
* For imperative languages like C we view a file as a large class containing
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* to make a condition */
- c1 = new_Const (mode_i, tarval_from_long (mode_i, 1));
- c2 = new_Proj (get_irg_args(irg), mode_i, 0);
+ c1 = new_Const (mode_Is, tarval_from_long (mode_Is, 1));
+ c2 = new_Proj (get_irg_args(irg), mode_Is, 0);
set_value(1, c2);
cond = new_Cond(new_Proj(new_Cmp(c1, c2), mode_b, Eq));
- set_value(0, new_Const (mode_i, tarval_from_long (mode_i, 6)));
+ set_value(0, new_Const (mode_Is, tarval_from_long (mode_Is, 6)));
f = new_Proj(cond, mode_X, 0);
t = new_Proj(cond, mode_X, 1);
mature_block(get_irg_current_block(irg));
Block1 = new_immBlock();
add_in_edge(Block1, t);
mature_block(Block1);
- set_value(0, new_Const (mode_i, tarval_from_long (mode_i, 5)));
+ set_value(0, new_Const (mode_Is, tarval_from_long (mode_Is, 5)));
jmp = new_Jmp();
add_in_edge(endBlock, jmp);
scndCondBlock = new_immBlock();
add_in_edge(scndCondBlock, f);
mature_block(scndCondBlock);
- c1 = new_Const (mode_i, tarval_from_long (mode_i, 3));
- cond = new_Cond(new_Proj(new_Cmp(c1, get_value(1, mode_i)), mode_b, Eq));
+ c1 = new_Const (mode_Is, tarval_from_long (mode_Is, 3));
+ cond = new_Cond(new_Proj(new_Cmp(c1, get_value(1, mode_Is)), mode_b, Eq));
f = new_Proj(cond, mode_X, 0);
t = new_Proj(cond, mode_X, 1);
mature_block(get_irg_current_block(irg));
switch_block(endBlock);
{
ir_node *in[1];
- in[0] = get_value(0, mode_i);
+ in[0] = get_value(0, mode_Is);
x = new_Return (get_store(), 1, in);
}
mature_block (get_irg_current_block(irg));
set_opt_cse(1);
set_opt_dead_node_elimination (1);
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i);
+ prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
#define METHODNAME "main_tp"
#define NRARGS 1
irg = new_ir_graph (ent, 4);
/* Generate two values */
- set_value (0, new_Proj(get_irg_args(irg), mode_i, 0));
- set_value (1, new_Const (mode_i, tarval_from_long (mode_i, 1)));
+ set_value (0, new_Proj(get_irg_args(irg), mode_Is, 0));
+ set_value (1, new_Const (mode_Is, tarval_from_long (mode_Is, 1)));
x = new_Jmp();
mature_block (get_irg_current_block(irg));
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
add_in_edge (r, x);
- x = new_Cond (new_Proj(new_Cmp(new_Const (mode_i, tarval_from_long (mode_i, 0)),
- get_value(1, mode_i)),
+ x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Is, tarval_from_long (mode_Is, 0)),
+ get_value(1, mode_Is)),
mode_b, Eq));
f = new_Proj (x, mode_X, 0);
t = new_Proj (x, mode_X, 1);
/* The code in the loop body,
as we are dealing with local variables only the dataflow edges
are manipulated. */
- set_value (2, get_value (0, mode_i));
- set_value (0, get_value (1, mode_i));
- set_value (1, get_value (2, mode_i));
+ set_value (2, get_value (0, mode_Is));
+ set_value (0, get_value (1, mode_Is));
+ set_value (1, get_value (2, mode_Is));
mature_block (b);
mature_block (r);
{
ir_node *in[1];
- in[0] = new_Sub (get_value (0, mode_i), get_value (1, mode_i), mode_i);
+ in[0] = new_Sub (get_value (0, mode_Is), get_value (1, mode_Is), mode_Is);
x = new_Return (get_store (), 1, in);
}