From 3e5692defee7bec4dcd584b83d1c79baaf6a63c7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=B6tz=20Lindenmaier?= Date: Fri, 21 Dec 2001 12:30:26 +0000 Subject: [PATCH] Asserts in irvrfy that verify the mode of Proj nodes. For Start, Call, Return they check the corresponding function type! Corrected bugs in testprograms. [r292] --- Changes | 5 ++ ir/ir/irvrfy.c | 139 ++++++++++++++++++++++++++++- ir/ir/irvrfy.h | 3 +- ir/tr/entity.c | 1 - ir/tr/type.c | 26 +++++- testprograms/array-heap_example.c | 4 +- testprograms/array-stack_example.c | 2 +- testprograms/call_str_example.c | 6 ++ testprograms/cond_example.c | 8 +- testprograms/const_eval_example.c | 6 ++ testprograms/dead_block_example.c | 7 +- testprograms/if_while_example.c | 7 +- testprograms/memory_example.c | 7 +- testprograms/oo_program_example.c | 10 +-- testprograms/while_example.c | 17 ++-- 15 files changed, 224 insertions(+), 24 deletions(-) diff --git a/Changes b/Changes index f91f9e24a..aea33da8c 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,8 @@ + 21.12.2001 Goetz + Asserts in irvrfy that verify the mode of Proj nodes. For Start, + Call, Return they check the corresponding function type! Corrected + bugs in testprograms. + 20.12.2001 Goetz Some access routines for visited flags in entity.h, irnode.h, bug in oo_program_example. diff --git a/ir/ir/irvrfy.c b/ir/ir/irvrfy.c index 9a3cebdc2..73f4a7307 100644 --- a/ir/ir/irvrfy.c +++ b/ir/ir/irvrfy.c @@ -16,6 +16,8 @@ # include "irvrfy.h" # include "irgwalk.h" +void vrfy_Proj_proj(ir_node *p); + void irn_vrfy (ir_node *n) { @@ -25,6 +27,7 @@ irn_vrfy (ir_node *n) int op_is_symmetric = 1; /* 0: asymmetric 1: operands have identical modes 2: modes of operands == mode of this node */ + type *mt; /* A method type */ ir_node **in; @@ -71,6 +74,15 @@ irn_vrfy (ir_node *n) assert ( mode_is_data(get_irn_mode(in[i])) ); /* operand datai */ }; assert ( mymode == mode_X ); /* result X */ + /* Compare returned results with result types of method type */ + mt = get_entity_type(get_irg_ent(current_ir_graph)); + assert(get_Return_n_res(n) == get_method_n_res(mt) && + "Number of results for Return doesn't match number of results in type."); + for (i = 0; i < get_Return_n_res(n); i++) + assert((get_irn_mode(get_Return_res(n, i)) + == get_type_mode(get_method_res_type(mt, i))) && + "Mode of result for Return doesn't match mode of result type."); + break; case iro_Raise: op1mode = get_irn_mode(in[1]); @@ -117,6 +129,14 @@ irn_vrfy (ir_node *n) assert ( mode_is_data(get_irn_mode(in[i])) ); /* operand datai */ }; assert ( mymode == mode_T ); /* result T */ + /* Compare arguments of node with those of type */ + mt = get_Call_type(n); + assert(get_Call_n_params(n) == get_method_n_params(mt) && + "Number of args for Call doesn't match number of args in type."); + for (i = 0; i < get_Call_n_params(n); i++) + assert((get_irn_mode(get_Call_param(n, i)) + == get_type_mode(get_method_param_type(mt, i))) && + "Mode of arg for Call doesn't match mode of arg type."); break; case iro_Add: op1mode = get_irn_mode(in[1]); @@ -326,11 +346,128 @@ irn_vrfy (ir_node *n) }; assert ( mymode == mode_M ); break; - + case iro_Proj: + vrfy_Proj_proj(n); + break; default: ; } } + +void +vrfy_Proj_proj(ir_node *p) { + ir_node *pred; + ir_mode *mode; + int proj; + + pred = skip_nop(get_Proj_pred(p)); + assert(get_irn_mode(pred) == mode_T); + mode = get_irn_mode(p); + proj = get_Proj_proj(p); + + switch (get_irn_opcode(pred)) { + case iro_Start: + assert ((proj == 0 && mode == mode_X) || + (proj == 1 && mode == mode_M) || + (proj == 2 && mode == mode_p) || + (proj == 3 && mode == mode_p) || + (proj == 4 && mode == mode_T) && + "wrong Proj from Start" ); + break; + case iro_Cond: + assert ((proj >= 0 && mode == mode_X) && + "wrong Proj from Cond"); + break; + case iro_Raise: + assert ((proj == 0 && mode == mode_X) || + (proj == 1 && mode == mode_M) && + "wrong Proj from Raise" ); + break; + case iro_Call: + assert ((proj == 0 && mode == mode_M) || + (proj == 1 && mode == mode_X) || + (proj == 2 && mode == mode_T) || + (proj == 3 && mode == mode_M) && + "wrong Proj from Call" ); + break; + case iro_Quot: + assert ((proj == 0 && mode == mode_M) || + (proj == 1 && mode == mode_X) || + (proj == 2 && mode_is_float(mode)) && + "wrong Proj from Quot"); + break; + case iro_DivMod: + assert ((proj == 0 && mode == mode_M) || + (proj == 1 && mode == mode_X) || + (proj == 2 && mode == mode_i) || + (proj == 3 && mode == mode_i) && + "wrong Proj from DivMod" ); + break; + case iro_Div: + case iro_Mod: + assert ((proj == 0 && mode == mode_M) || + (proj == 1 && mode == mode_X) || + (proj == 2 && mode == mode_i) && + "wrong Proj from Div or Mod" ); + break; + case iro_Cmp: + assert ((proj >= 0 && proj <= 15 && mode == mode_b) && + "wrong Proj from Cmp"); + break; + case iro_Load: + assert ((proj == 0 && mode == mode_M) || + (proj == 1 && mode == mode_X) || + (proj == 2 && mode_is_data(mode)) && + "wrong Proj from Load"); + break; + case iro_Store: + assert ((proj == 0 && mode == mode_M) || + (proj == 1 && mode == mode_X) && + "wrong Proj from Store"); + break; + case iro_Alloc: + assert ((proj == 0 && mode == mode_M) || + (proj == 1 /* && mode == mode_X*/) || + (proj == 2 && mode == mode_p) && + "wrong Proj from Alloc"); + break; + case iro_Proj: { + type *mt; /* A method type */ + pred = skip_nop(get_Proj_pred(pred)); + assert(get_irn_mode(pred) == mode_T); + switch (get_irn_opcode(pred)) { + case iro_Start: { + assert (proj >= 0 && mode_is_data(mode) && + "wrong Proj from Proj from Start"); + mt = get_entity_type(get_irg_ent(current_ir_graph)); + assert(proj < get_method_n_params(mt) && + "More Projs for args than args in type"); + assert(mode == get_type_mode(get_method_param_type(mt, proj)) && + "Mode of Proj from Start doesn't match mode of param type."); + } break; + case iro_Call: { + assert (proj >= 0 && mode_is_data(mode) && + "wrong Proj from Proj from Call"); + mt = get_Call_type(pred); + assert(proj < get_method_n_res(mt) && + "More Projs for results than results in type."); + assert(mode == get_type_mode(get_method_res_type(mt, proj)) && + "Mode of Proj from Call doesn't match mode of result type."); + } break; + case iro_Tuple: ; + /* We don't test */ + break; + default: assert(0); + } break; + } + case iro_Tuple: + /* We don't test */ + break; + default: assert(0); + } +} + + /*******************************************************************/ /* Verify the whole graph. */ /*******************************************************************/ diff --git a/ir/ir/irvrfy.h b/ir/ir/irvrfy.h index f2a281b56..77ddc2af6 100644 --- a/ir/ir/irvrfy.h +++ b/ir/ir/irvrfy.h @@ -14,7 +14,8 @@ # include "irnode.h" # include "irgraph.h" -/* Tests the types of predecessors of checknode. */ +/* Tests the modes of chechnode and its predecessors. + Checknode must be in current_ir_graph. */ void irn_vrfy (struct ir_node *checknode); /* Calls irn_vrfy for each node in irg. */ diff --git a/ir/tr/entity.c b/ir/tr/entity.c index 9340397f1..609bb00b8 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -283,7 +283,6 @@ set_compound_ent_value(entity *ent, ir_node *val, entity *member, int pos) { ent->val_ents[pos+1] = member; } - inline int get_entity_offset (entity *ent) { return ent->offset; diff --git a/ir/tr/type.c b/ir/tr/type.c index ada05cd90..4e9241c11 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -232,10 +232,12 @@ int get_class_n_member (type *clss) { } entity *get_class_member (type *clss, int pos) { assert(clss && (clss->type_op == type_class)); + assert(pos >= 0 && pos < get_class_n_member(clss)); return clss->attr.ca.members[pos+1]; } void set_class_member (type *clss, entity *member, int pos) { assert(clss && (clss->type_op == type_class)); + assert(pos >= 0 && pos < get_class_n_member(clss)); clss->attr.ca.members[pos+1] = member; } void remove_class_member(type *clss, entity *member) { @@ -266,10 +268,12 @@ int get_class_n_subtype (type *clss) { } type *get_class_subtype (type *clss, int pos) { assert(clss && (clss->type_op == type_class)); + assert(pos >= 0 && pos < get_class_n_subtype(clss)); return clss->attr.ca.subtypes[pos+1] = skip_tid(clss->attr.ca.subtypes[pos+1]); } void set_class_subtype (type *clss, type *subtype, int pos) { assert(clss && (clss->type_op == type_class)); + assert(pos >= 0 && pos < get_class_n_subtype(clss)); clss->attr.ca.subtypes[pos+1] = subtype; } void remove_class_subtype(type *clss, type *subtype) { @@ -301,10 +305,12 @@ int get_class_n_supertype (type *clss) { } type *get_class_supertype (type *clss, int pos) { assert(clss && (clss->type_op == type_class)); + assert(pos >= 0 && pos < get_class_n_supertype(clss)); return clss->attr.ca.supertypes[pos+1] = skip_tid(clss->attr.ca.supertypes[pos+1]); } void set_class_supertype (type *clss, type *supertype, int pos) { assert(clss && (clss->type_op == type_class)); + assert(pos >= 0 && pos < get_class_n_supertype(clss)); clss->attr.ca.supertypes[pos+1] = supertype; } void remove_class_supertype(type *clss, type *supertype) { @@ -350,10 +356,12 @@ int get_struct_n_member (type *strct) { } entity *get_struct_member (type *strct, int pos) { assert(strct && (strct->type_op == type_struct)); + assert(pos >= 0 && pos < get_struct_n_member(strct)); return strct->attr.sa.members[pos+1]; } void set_struct_member (type *strct, int pos, entity *member) { assert(strct && (strct->type_op == type_struct)); + assert(pos >= 0 && pos < get_struct_n_member(strct)); strct->attr.sa.members[pos+1] = member; } void remove_struct_member(type *strct, entity *member) { @@ -400,10 +408,12 @@ int get_method_n_params (type *method) { } type *get_method_param_type(type *method, int pos) { assert(method && (method->type_op == type_method)); + assert(pos >= 0 && pos < get_method_n_params(method)); return method->attr.ma.param_type[pos] = skip_tid(method->attr.ma.param_type[pos]); } void set_method_param_type(type *method, int pos, type* type) { assert(method && (method->type_op == type_method)); + assert(pos >= 0 && pos < get_method_n_params(method)); method->attr.ma.param_type[pos] = type; } @@ -413,10 +423,12 @@ int get_method_n_res (type *method) { } type *get_method_res_type(type *method, int pos) { assert(method && (method->type_op == type_method)); + assert(pos >= 0 && pos < get_method_n_res(method)); return method->attr.ma.res_type[pos] = skip_tid(method->attr.ma.res_type[pos]); } void set_method_res_type(type *method, int pos, type* type) { assert(method && (method->type_op == type_method)); + assert(pos >= 0 && pos < get_method_n_res(method)); method->attr.ma.res_type[pos] = type; } @@ -444,7 +456,7 @@ inline void free_union_attrs (type *uni) { assert(uni && (uni->type_op == type_union)); DEL_ARR_F(uni->attr.ua.members); } -/* manipulate private fields of struct */ +/* manipulate private fields of union */ #if 0 int get_union_n_types (type *uni) { assert(uni && (uni->type_op == type_union)); @@ -452,22 +464,27 @@ int get_union_n_types (type *uni) { } type *get_union_unioned_type (type *uni, int pos) { assert(uni && (uni->type_op == type_union)); + assert(pos >= 0 && pos < get_union_n_types(uni)); return uni->attr.ua.unioned_type[pos] = skip_tid(uni->attr.ua.unioned_type[pos]); } void set_union_unioned_type (type *uni, int pos, type *type) { assert(uni && (uni->type_op == type_union)); + assert(pos >= 0 && pos < get_union_n_types(uni)); uni->attr.ua.unioned_type[pos] = type; } ident *get_union_delim_nameid (type *uni, int pos) { assert(uni && (uni->type_op == type_union)); + assert(pos >= 0 && pos < get_union_n_types(uni)); return uni->attr.ua.delim_names[pos]; } const char *get_union_delim_name (type *uni, int pos) { assert(uni && (uni->type_op == type_union)); + assert(pos >= 0 && pos < get_union_n_types(uni)); return id_to_str(uni->attr.ua.delim_names[pos]); } void set_union_delim_nameid (type *uni, int pos, ident *id) { assert(uni && (uni->type_op == type_union)); + assert(pos >= 0 && pos < get_union_n_types(uni)); uni->attr.ua.delim_names[pos] = id; } #endif @@ -481,10 +498,12 @@ void add_union_member (type *uni, entity *member) { } entity *get_union_member (type *uni, int pos) { assert(uni && (uni->type_op == type_union)); + assert(pos >= 0 && pos < get_union_n_members(uni)); return uni->attr.ua.members[pos+1]; } void set_union_member (type *uni, int pos, entity *member) { assert(uni && (uni->type_op == type_union)); + assert(pos >= 0 && pos < get_union_n_members(uni)); uni->attr.ua.members[pos+1] = member; } void remove_union_member(type *uni, entity *member) { @@ -617,22 +636,27 @@ int get_enumeration_n_enums (type *enumeration) { } void set_enumeration_enum (type *enumeration, int pos, tarval *con) { assert(enumeration && (enumeration->type_op == type_enumeration)); + assert(pos >= 0 && pos < get_enumeration_n_enums(enumeration)); enumeration->attr.ea.enumer[pos] = con; } tarval *get_enumeration_enum (type *enumeration, int pos) { assert(enumeration && (enumeration->type_op == type_enumeration)); + assert(pos >= 0 && pos < get_enumeration_n_enums(enumeration)); return enumeration->attr.ea.enumer[pos]; } void set_enumeration_nameid (type *enumeration, int pos, ident *id) { assert(enumeration && (enumeration->type_op == type_enumeration)); + assert(pos >= 0 && pos < get_enumeration_n_enums(enumeration)); enumeration->attr.ea.enum_nameid[pos] = id; } ident *get_enumeration_nameid (type *enumeration, int pos) { assert(enumeration && (enumeration->type_op == type_enumeration)); + assert(pos >= 0 && pos < get_enumeration_n_enums(enumeration)); return enumeration->attr.ea.enum_nameid[pos]; } const char *get_enumeration_name(type *enumeration, int pos) { assert(enumeration && (enumeration->type_op == type_enumeration)); + assert(pos >= 0 && pos < get_enumeration_n_enums(enumeration)); return id_to_str(enumeration->attr.ea.enum_nameid[pos]); } diff --git a/testprograms/array-heap_example.c b/testprograms/array-heap_example.c index f8389dc24..c09bcdc61 100644 --- a/testprograms/array-heap_example.c +++ b/testprograms/array-heap_example.c @@ -109,7 +109,7 @@ main(void) /* 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, 1); /* 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 @@ -125,7 +125,7 @@ main(void) } val = new_Load(get_store(), elt); set_store(new_Proj(val, mode_M, 0)); - val = new_Proj(val, mode_i, 1); + val = new_Proj(val, mode_i, 2); /* return the result of procedure main */ { diff --git a/testprograms/array-stack_example.c b/testprograms/array-stack_example.c index 722124b86..38287fd48 100644 --- a/testprograms/array-stack_example.c +++ b/testprograms/array-stack_example.c @@ -115,7 +115,7 @@ main(void) } val = new_Load(get_store(), elt); set_store(new_Proj(val, mode_M, 0)); - val = new_Proj(val, mode_i, 1); + val = new_Proj(val, mode_i, 2); /* return the result of procedure main */ { diff --git a/testprograms/call_str_example.c b/testprograms/call_str_example.c index 7c8f5e2d4..3fa59baa5 100644 --- a/testprograms/call_str_example.c +++ b/testprograms/call_str_example.c @@ -27,6 +27,7 @@ int main(int argc, char **argv) type *owner; /* the class in which this method is defined */ type *proc_main; /* type information for the method main */ type *proc_called; /* type information for called method f */ + type *string_ptr; /* type for pointers to strings. */ entity *ent; /* represents this method as entity of owner */ ir_node *x, *const_str, *proc_ptr, *call; @@ -35,6 +36,10 @@ int main(int argc, char **argv) /* init library */ init_firm (); + 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))); /* 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 @@ -56,6 +61,7 @@ int main(int argc, char **argv) owner = get_glob_type(); proc_called = new_type_method(id_from_str(F_METHODNAME, strlen(F_METHODNAME)), F_NRARGS, F_NRES); + set_method_param_type(proc_called, 0, string_ptr); /* Make the entity for main needed for a correct ir_graph. */ #define ENTITYNAME "main" diff --git a/testprograms/cond_example.c b/testprograms/cond_example.c index 5f4694cee..e10205fb3 100644 --- a/testprograms/cond_example.c +++ b/testprograms/cond_example.c @@ -23,6 +23,7 @@ int main(int argc, char **argv) { + type *prim_t_int; ir_graph *irg; /* this variable contains the irgraph */ type *owner; /* the class in which this method is defined */ type *method; /* the type of this method */ @@ -34,6 +35,9 @@ int main(int argc, char **argv) /* init library */ init_firm (); + /*** Make basic type information for primitive type int. ***/ + prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i); + /* 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 * all functions as methods in this file. @@ -44,7 +48,9 @@ int main(int argc, char **argv) #define ENTITYNAME "main" owner = new_type_class (id_from_str (CLASSNAME, strlen(CLASSNAME))); - method = new_type_method (id_from_str("main", 4), 0, 2); + method = new_type_method (id_from_str("main", 4), 1, 1); + set_method_param_type(method, 0, prim_t_int); + set_method_res_type(method, 0, prim_t_int); ent = new_entity (owner, id_from_str (ENTITYNAME, strlen(ENTITYNAME)), method); diff --git a/testprograms/const_eval_example.c b/testprograms/const_eval_example.c index 3e7b6e9a3..59384ef68 100644 --- a/testprograms/const_eval_example.c +++ b/testprograms/const_eval_example.c @@ -25,6 +25,7 @@ int main(void) { + type *prim_t_int; ir_graph *irg; type *owner; type *method; /* the type of this method */ @@ -35,6 +36,9 @@ main(void) init_firm (); + /*** Make basic type information for primitive type int. ***/ + prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i); + /* Try both optimizations: */ set_opt_constant_folding(1); set_opt_cse(1); @@ -42,6 +46,8 @@ main(void) owner = new_type_class (id_from_str ("CONST_EVAL_EXAMPLE", 18)); method = new_type_method (id_from_str("main", 4), 0, 2); + set_method_res_type(method, 0, prim_t_int); + set_method_res_type(method, 1, prim_t_int); ent = new_entity (owner, id_from_str ("main", 4), method); irg = new_ir_graph (ent, 4); diff --git a/testprograms/dead_block_example.c b/testprograms/dead_block_example.c index cc3522b2f..113c21c5d 100644 --- a/testprograms/dead_block_example.c +++ b/testprograms/dead_block_example.c @@ -47,6 +47,7 @@ int main(int argc, char **argv) ir_graph *irg; /* this variable contains the irgraph */ type *owner; /* the class in which this method is defined */ type *proc_main; /* type information for the method main */ + type *prim_t_int; entity *ent; /* represents this method as entity of owner */ ir_node *c1, *c2, *cond, *f, *t, *endBlock, *Block1, *jmp, *Block2, *deadBlock, *x; @@ -56,6 +57,9 @@ int main(int argc, char **argv) set_opt_cse(0); /* there is a bug: first and start block are cse!! @@@ */ + /*** Make basic type information for primitive type int. ***/ + prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_i); + /* 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 * all functions as methods in this file. @@ -65,12 +69,13 @@ int main(int argc, char **argv) #define CLASSNAME "DEAD_BLOCK" #define METHODNAME "main" #define NRARGS 0 -#define NRES 0 +#define NRES 1 printf("\nCreating an IR graph: %s...\n", CLASSNAME); owner = new_type_class (id_from_str (CLASSNAME, strlen(CLASSNAME))); proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)), NRARGS, NRES); + set_method_res_type(proc_main, 0, prim_t_int); ent = new_entity (owner, id_from_str (METHODNAME, strlen(METHODNAME)), proc_main); diff --git a/testprograms/if_while_example.c b/testprograms/if_while_example.c index f97582092..0b572b801 100644 --- a/testprograms/if_while_example.c +++ b/testprograms/if_while_example.c @@ -36,6 +36,7 @@ main(void) ir_graph *irg; type *owner; type *proc_main; + type *prim_t_int; entity *ent; ir_node *b, *x, *r, *t, *f; @@ -50,12 +51,16 @@ main(void) set_opt_cse(1); 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); + #define METHODNAME "main" #define NRARGS 0 -#define NRES 0 +#define NRES 1 proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)), NRARGS, NRES); + set_method_res_type(proc_main, 0, prim_t_int); owner = new_type_class (id_from_str ("IF_WHILE_EXAMPLE", 16)); ent = new_entity (owner, id_from_str ("main", 4), proc_main); diff --git a/testprograms/memory_example.c b/testprograms/memory_example.c index 5366b4ac8..64dd4ff5b 100644 --- a/testprograms/memory_example.c +++ b/testprograms/memory_example.c @@ -55,6 +55,7 @@ main(void) ir_graph *irg; type *owner; type *method; /* the type of this method */ + type *prim_t_int; entity *ent; ir_node *a, *b, *x, *y, *r; @@ -64,9 +65,13 @@ main(void) 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); + /* a class to get started with, containing the main procedure */ owner = new_type_class (id_from_str ("MEMORY_EXAMPLE", 14)); - method = new_type_method (id_from_str("main", 4), 0, 2); + method = new_type_method (id_from_str("main", 4), 0, 1); + set_method_res_type(method, 0, prim_t_int); ent = new_entity (owner, id_from_str ("main", 4), method); /* Generates start and end blocks and nodes and a first, initial block */ diff --git a/testprograms/oo_program_example.c b/testprograms/oo_program_example.c index b54cdf814..dae7ddb32 100644 --- a/testprograms/oo_program_example.c +++ b/testprograms/oo_program_example.c @@ -147,7 +147,7 @@ main(void) 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_i, 0); /* return the results of procedure main */ { @@ -174,7 +174,7 @@ main(void) /* get the procedure parameter */ 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_i, 1); set_value(e_pos, par1); /* Create and select the entity to set */ a_ptr = new_simpleSel(get_store(), self, a_e); @@ -201,18 +201,18 @@ main(void) /* 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); + par1 = new_Proj(get_irg_args(c_irg), mode_i, 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, 1); + a_val = new_Proj(a_val, mode_i, 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_i); x = new_Return (get_store (), 1, in); } diff --git a/testprograms/while_example.c b/testprograms/while_example.c index d7173f62f..a4d4e2654 100644 --- a/testprograms/while_example.c +++ b/testprograms/while_example.c @@ -8,6 +8,7 @@ # include "irdump.h" # include "firm.h" +# include "irnode.h" /** *** This file constructs the ir for the following pseudo-program: @@ -62,16 +63,16 @@ main(void) irg = new_ir_graph (ent, 4); /* Generate two constants */ - 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_i, 0)); + set_value (1, new_Const (mode_i, tarval_from_long (mode_i, 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_i, tarval_from_long (mode_i, 0)), + new_Const (mode_i, tarval_from_long (mode_i, 0))), mode_b, Eq)); f = new_Proj (x, mode_X, 0); t = new_Proj (x, mode_X, 1); @@ -85,9 +86,9 @@ main(void) /* 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_i)); + set_value (0, get_value (1, mode_i)); + set_value (1, get_value (2, mode_i)); mature_block (b); mature_block (r); @@ -98,7 +99,7 @@ main(void) { 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_i), get_value (1, mode_i), mode_i); x = new_Return (get_store (), 1, in); } -- 2.20.1