From c80fbec6466095a8df01d483fd22f1b578f4043b Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Fri, 11 Jul 2003 15:55:23 +0000 Subject: [PATCH] fixed: - mode_is_reference() instead of mode_P - use mode_P_mach in constructions instead of mode_P [r1467] --- ir/ana/cgana.c | 10 ++--- ir/ir/ircons.c | 4 +- ir/ir/ircons.h | 4 +- ir/ir/irgraph.c | 4 +- ir/ir/irmode.c | 16 +++++++- ir/ir/irmode.h | 38 ++++++++++------- ir/ir/iropt.c | 18 ++++---- ir/ir/irvrfy.c | 97 +++++++++++++++++++++++--------------------- ir/ir/old_fctnames.h | 2 +- ir/tr/entity.c | 2 +- ir/tr/type.c | 11 +++-- ir/tv/tv.c | 29 +++++++++---- ir/tv/tv.h | 13 +++++- 13 files changed, 151 insertions(+), 97 deletions(-) diff --git a/ir/ana/cgana.c b/ir/ana/cgana.c index 239e8313b..9b6663922 100644 --- a/ir/ana/cgana.c +++ b/ir/ana/cgana.c @@ -184,7 +184,7 @@ static void sel_methods_walker(ir_node * node, pmap * ldname_map) { assert(get_entity_irg(ent)); set_irg_current_block(current_ir_graph, get_nodes_Block(node)); new_node = new_d_Const(get_irn_dbg_info(node), - mode_P, new_tarval_from_entity(ent, mode_P)); DBG_OPT_NORMALIZE; + mode_P_mach, new_tarval_from_entity(ent, mode_P_mach)); DBG_OPT_NORMALIZE; exchange(node, new_node); } } @@ -382,7 +382,7 @@ static void callee_ana_proj(ir_node * node, long n, eset * methods) { static void callee_ana_node(ir_node * node, eset * methods) { int i; - assert((get_irn_mode(node) == mode_P) || is_Bad(node)); + assert(mode_is_reference(get_irn_mode(node)) || is_Bad(node)); /* rekursion verhindern */ if (get_irn_link(node) == MARK) { /* already visited */ @@ -550,7 +550,7 @@ static void free_mark_proj(ir_node * node, long n, eset * set) { static void free_mark(ir_node * node, eset * set) { int i; - assert(get_irn_mode(node) == mode_P); + assert(mode_is_reference(get_irn_mode(node))); if (get_irn_link(node) == MARK) { return; /* already visited */ } @@ -620,7 +620,7 @@ static void free_ana_walker(ir_node * node, eset * set) { set_irn_link(node, MARK); for (i = get_Call_arity(node) - 1; i >= 0; --i) { ir_node * pred = get_Call_param(node, i); - if (get_irn_mode(pred) == mode_P) { + if (mode_is_reference(get_irn_mode(pred))) { free_mark(pred, set); } } @@ -631,7 +631,7 @@ static void free_ana_walker(ir_node * node, eset * set) { set_irn_link(node, MARK); for (i = get_irn_arity(node) - 1; i >= 0; --i) { ir_node * pred = get_irn_n(node, i); - if (get_irn_mode(pred) == mode_P) { + if (mode_is_reference(get_irn_mode(pred))) { free_mark(pred, set); } } diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index af309d28f..d3c586276 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -616,7 +616,7 @@ new_rd_Sel (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, ir_node r_in[0] = store; r_in[1] = objptr; memcpy (&r_in[2], in, sizeof (ir_node *) * arity); - res = new_ir_node (db, irg, block, op_Sel, mode_P, r_arity, r_in); + res = new_ir_node (db, irg, block, op_Sel, mode_P_mach, r_arity, r_in); res->attr.s.ent = ent; @@ -654,7 +654,7 @@ new_rd_SymConst (dbg_info* db, ir_graph *irg, ir_node *block, type_or_id_p value ir_node *res; ir_mode *mode; if (symkind == linkage_ptr_info) - mode = mode_P; + mode = mode_P_mach; else mode = mode_Iu; res = new_ir_node (db, irg, block, op_SymConst, mode, 0, NULL); diff --git a/ir/ir/ircons.h b/ir/ir/ircons.h index a5d0f1a2d..d2840691e 100644 --- a/ir/ir/ircons.h +++ b/ir/ir/ircons.h @@ -592,7 +592,7 @@ * datastructure don't use * new_SymConst((type_or_id*)get_entity_ld_ident(ent), linkage_ptr_info);. * Use a real const instead: - * new_Const(mode_P, tarval_p_from_entity(ent)); + * new_Const(mode_P_mach, tarval_p_from_entity(ent)); * This makes the Constant independent of name changes of the entity due to * mangling. * @@ -616,7 +616,7 @@ * attr.i.*type, a pointer to a type_class. The mode of the node is mode_Is. * if it is linkage_ptr_info it contains * attr.i.*ptrinfo, an ident holding information for the linker. The mode - * of the node is mode_P. + * of the node is mode_P_mach. * * --------------- * diff --git a/ir/ir/irgraph.c b/ir/ir/irgraph.c index 4c60503d6..1c8a7410a 100644 --- a/ir/ir/irgraph.c +++ b/ir/ir/irgraph.c @@ -129,8 +129,8 @@ new_ir_graph (entity *ent, int n_loc) /* Proj results of start node */ projX = new_Proj (res->start, mode_X, pns_initial_exec); set_store (new_Proj (res->start, mode_M, pns_global_store)); - res->frame = new_Proj (res->start, mode_P, pns_frame_base); - res->globals = new_Proj (res->start, mode_P, pns_globals); + res->frame = new_Proj (res->start, mode_P_mach, pns_frame_base); + res->globals = new_Proj (res->start, mode_P_mach, pns_globals); res->args = new_Proj (res->start, mode_T, pns_args); #ifdef DEBUG_libfirm res->graph_nr = get_irp_new_node_nr(); diff --git a/ir/ir/irmode.c b/ir/ir/irmode.c index c5542dc50..0eb0662a1 100644 --- a/ir/ir/irmode.c +++ b/ir/ir/irmode.c @@ -156,7 +156,9 @@ ir_mode *mode_C; ir_mode *mode_U; ir_mode *mode_b; ir_mode *mode_P; -ir_mode *mode_P_mach; + +/* machine specific modes */ +ir_mode *mode_P_mach; /* machine specific pointer mode */ /* * * * functions defined in irmode.h @@ -457,6 +459,7 @@ is_mode (void *thing) { # undef mode_is_float # undef mode_is_int # undef mode_is_num +# undef mode_is_numP # undef mode_is_data # undef mode_is_datab # undef mode_is_dataM @@ -507,6 +510,14 @@ mode_is_num (const ir_mode *mode) return (mode_is_int(mode) || mode_is_float(mode)); } +int +mode_is_numP (const ir_mode *mode) +{ + ANNOUNCE(); + assert(mode); + return (mode_is_int(mode) || mode_is_float(mode) || mode_is_reference(mode)); +} + int mode_is_data (const ir_mode *mode) { @@ -823,4 +834,7 @@ init_mode (void) newmode.size = 32; mode_P = register_mode(&newmode); + + /* set the machine specific modes to the predifined ones */ + mode_P_mach = mode_P; } diff --git a/ir/ir/irmode.h b/ir/ir/irmode.h index f4b4073c8..cef56c7af 100644 --- a/ir/ir/irmode.h +++ b/ir/ir/irmode.h @@ -304,12 +304,18 @@ ir_mode *get_modeT(void); ir_mode *get_modeANY(void); ir_mode *get_modeBAD(void); +/** Returns the machine specific pointer mode. */ ir_mode *get_modeP_mach(void); -void set_modeP_mach(ir_mode *p); /** - Functions to check, whether a modecode is signed, float, int, num, data, - datab or dataM. + * Sets the machine specific pointer mode. + * If not set, the predefined mode mode_P will be used. + */ +void set_modeP_mach(ir_mode *p); + +/** + Functions to check, whether a modecode is signed, float, int, character, + reference, num, numP, data, datab or dataM. For more exact definitions read the corresponding pages in the firm documentation or the following enumeration @@ -320,25 +326,26 @@ void set_modeP_mach(ir_mode *p); The set of "int" is defined as: int = {irm_Bs, irm_Bu, irm_Hs, irm_Hu, irm_Is, irm_Iu, irm_Ls, irm_Lu} + The set of "character" is defined as: + character = {irm_C, irm_U} + + The set of "reference" is defined as: + reference = {irm_P} + The set of "num" is defined as: - num = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu, - irm_Is, irm_Iu, irm_Ls, irm_Lu} - = {float || int} + num = {float || int} + + The set of "numP" is defined as: + numP = {float || int || reference} The set of "data" is defined as: - data = {irm_F, irm_D, irm_E irm_Bs, irm_Bu, irm_Hs, irm_Hu, - irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P} - = {num || irm_C || irm_P} + data = {num || character || reference} The set of "datab" is defined as: - datab = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu, - irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_b} - = {data || irm_b } + datab = {data || irm_b } The set of "dataM" is defined as: - dataM = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu, - irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_U, irm_P, irm_M} - = {data || irm_M} + dataM = {data || irm_M} */ /*@}*/ /* Test for a certain class of modes. */ @@ -348,6 +355,7 @@ int mode_is_int (const ir_mode *mode); int mode_is_character (const ir_mode *mode); int mode_is_reference (const ir_mode *mode); int mode_is_num (const ir_mode *mode); +int mode_is_numP (const ir_mode *mode); int mode_is_data (const ir_mode *mode); int mode_is_datab (const ir_mode *mode); int mode_is_dataM (const ir_mode *mode); diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index 7da9a0b5c..ec80fb420 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -240,23 +240,23 @@ computed_value (ir_node *n) ir_node *aba = skip_nop(skip_Proj(ab)); if ( ( (/* aa is ProjP and aaa is Alloc */ (get_irn_op(aa) == op_Proj) - && (get_irn_mode(aa) == mode_P) + && (mode_is_reference(get_irn_mode(aa))) && (get_irn_op(aaa) == op_Alloc)) && ( (/* ab is constant void */ (get_irn_op(ab) == op_Const) - && (get_irn_mode(ab) == mode_P) - && (get_Const_tarval(ab) == get_mode_null(mode_P))) + && (mode_is_reference(get_irn_mode(ab))) + && (get_Const_tarval(ab) == get_mode_null(get_irn_mode(ab)))) || (/* ab is other Alloc */ (get_irn_op(ab) == op_Proj) - && (get_irn_mode(ab) == mode_P) + && (mode_is_reference(get_irn_mode(ab))) && (get_irn_op(aba) == op_Alloc) && (aaa != aba)))) || (/* aa is void and aba is Alloc */ (get_irn_op(aa) == op_Const) - && (get_irn_mode(aa) == mode_P) - && (get_Const_tarval(aa) == get_mode_null(mode_P)) + && (mode_is_reference(get_irn_mode(aa))) + && (get_Const_tarval(aa) == get_mode_null(get_irn_mode(aa))) && (get_irn_op(ab) == op_Proj) - && (get_irn_mode(ab) == mode_P) + && (mode_is_reference(get_irn_mode(ab))) && (get_irn_op(aba) == op_Alloc))) /* 3.: */ res = new_tarval_from_long (get_Proj_proj(n) & Ne, mode_b); @@ -287,8 +287,8 @@ computed_value (ir_node *n) static bool different_identity (ir_node *a, ir_node *b) { - assert (get_irn_mode (a) == mode_P - && get_irn_mode (b) == mode_P); + assert (mode_is_reference(get_irn_mode (a)) + && mode_is_reference(get_irn_mode (b))); if (get_irn_op (a) == op_Proj && get_irn_op(b) == op_Proj) { ir_node *a1 = get_Proj_pred (a); diff --git a/ir/ir/irvrfy.c b/ir/ir/irvrfy.c index c85c78e63..ff8447d75 100644 --- a/ir/ir/irvrfy.c +++ b/ir/ir/irvrfy.c @@ -39,11 +39,14 @@ vrfy_Proj_proj(ir_node *p, ir_graph *irg) { switch (get_irn_opcode(pred)) { case iro_Start: ASSERT_AND_RET( - ((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)), + ( + (proj == pns_initial_exec && mode == mode_X) || + (proj == pns_global_store && mode == mode_M) || + (proj == pns_frame_base && mode_is_reference(mode)) || + (proj == pns_globals && mode_is_reference(mode)) || + (proj == pns_args && mode == mode_T) || + (proj == pns_value_arg_base && mode_is_reference(mode)) + ), "wrong Proj from Start", 0); break; @@ -120,9 +123,11 @@ vrfy_Proj_proj(ir_node *p, ir_graph *irg) { case iro_Alloc: ASSERT_AND_RET( - ((proj == 0 && mode == mode_M) || + ( + (proj == 0 && mode == mode_M) || (proj == 1 /* && mode == mode_X*/) || - (proj == 2 && mode == mode_P)), + (proj == 2 && mode_is_reference(mode)) + ), "wrong Proj from Alloc", 0); break; @@ -142,7 +147,7 @@ vrfy_Proj_proj(ir_node *p, ir_graph *irg) { ASSERT_AND_RET( (proj < get_method_n_params(mt)), "More Projs for args than args in type", 0); - if ((mode == mode_P) && is_compound_type(get_method_param_type(mt, proj))) + if ((mode_is_reference(mode)) && is_compound_type(get_method_param_type(mt, proj))) /* value argument */ break; ASSERT_AND_RET( @@ -160,7 +165,7 @@ vrfy_Proj_proj(ir_node *p, ir_graph *irg) { ASSERT_AND_RET( (proj < get_method_n_ress(mt)), "More Projs for results than results in type.", 0); - if ((mode == mode_P) && is_compound_type(get_method_res_type(mt, proj))) + if ((mode_is_reference(mode)) && is_compound_type(get_method_res_type(mt, proj))) /* value result */ break; ASSERT_AND_RET( @@ -238,7 +243,7 @@ int irn_vrfy_irg(ir_node *n, ir_graph *irg) { case iro_Start: ASSERT_AND_RET( - /* Start: BB --> X x M x P x data1 x ... x datan */ + /* Start: BB --> X x M x ref x data1 x ... x datan x ref */ mymode == mode_T, "Start node", 0 ); break; @@ -291,8 +296,8 @@ int irn_vrfy_irg(ir_node *n, ir_graph *irg) op1mode = get_irn_mode(in[1]); op2mode = get_irn_mode(in[2]); ASSERT_AND_RET( - /* Sel: BB x M x P --> X x M */ - op1mode == mode_M && op2mode == mode_P && + /* Sel: BB x M x ref --> X x M */ + op1mode == mode_M && mode_is_reference(op2mode) && mymode == mode_T, "Raise node", 0 ); break; @@ -310,8 +315,8 @@ int irn_vrfy_irg(ir_node *n, ir_graph *irg) ASSERT_AND_RET( /* SymConst: BB --> int*/ (mode_is_int(mymode) || - /* SymConst: BB --> P*/ - mymode == mode_P) + /* SymConst: BB --> ref */ + mode_is_reference(mymode)) ,"SymConst node", 0); break; @@ -319,9 +324,9 @@ int irn_vrfy_irg(ir_node *n, ir_graph *irg) op1mode = get_irn_mode(in[1]); op2mode = get_irn_mode(in[2]); ASSERT_AND_RET( - /* Sel: BB x M x P x int^n --> P */ - op1mode == mode_M && op2mode == mode_P && - mymode == mode_P, "Sel node", 0 + /* Sel: BB x M x ref x int^n --> ref */ + (op1mode == mode_M && op2mode == mymode && mode_is_reference(mymode)), + "Sel node", 0 ); for (i=3; i < get_irn_arity(n); i++) { @@ -337,9 +342,9 @@ int irn_vrfy_irg(ir_node *n, ir_graph *irg) case iro_Call: op1mode = get_irn_mode(in[1]); op2mode = get_irn_mode(in[2]); - /* Call: BB x M x P x data1 x ... x datan + /* Call: BB x M x ref x data1 x ... x datan --> M x datan+1 x ... x data n+m */ - ASSERT_AND_RET( op1mode == mode_M && op2mode == mode_P, "Call node", 0 ); /* operand M x P */ + ASSERT_AND_RET( op1mode == mode_M && mode_is_reference(op2mode), "Call node", 0 ); /* operand M x ref */ for (i=3; i < get_irn_arity(n); i++) { ASSERT_AND_RET( mode_is_data(get_irn_mode(in[i])), "Call node", 0 ); /* operand datai */ }; @@ -371,19 +376,21 @@ int irn_vrfy_irg(ir_node *n, ir_graph *irg) op1mode = get_irn_mode(in[1]); op2mode = get_irn_mode(in[2]); ASSERT_AND_RET( - /* common Add: BB x num x num --> num */ - (( op1mode == mymode && op2mode == op1mode && mode_is_num(mymode)) || - /* Pointer Add: BB x P x int --> P */ - (op1mode == mode_P && mode_is_int(op2mode) && mymode == mode_P) || - /* Pointer Add: BB x int x P --> P */ - (mode_is_int(op1mode) && op2mode == mode_P && mymode == mode_P)), + ( + /* common Add: BB x numP x numP --> numP */ + (op1mode == mymode && op2mode == op1mode && mode_is_numP(mymode)) || + /* Pointer Add: BB x ref x int --> ref */ + (mode_is_reference(op1mode) && mode_is_int(op2mode) && op1mode == mymode) || + /* Pointer Add: BB x int x ref --> ref */ + (mode_is_int(op1mode) && op2mode == mymode && mode_is_reference(mymode)) + ), "Add node", 0 ); - if (op1mode == mode_P || op2mode == mode_P) { - /* BB x P x int --> P or BB x int x P --> P */ + if (mode_is_reference(op1mode) != mode_is_reference(op2mode)) { + /* BB x ref x int --> ref or BB x int x ref --> ref */ op_is_symmetric = 0; /* ArmRoq */ } else { - /* BB x num x num --> num */ + /* BB x num x num --> num or BB x ref x ref */ op_is_symmetric = 2; } break; @@ -392,19 +399,17 @@ int irn_vrfy_irg(ir_node *n, ir_graph *irg) op1mode = get_irn_mode(in[1]); op2mode = get_irn_mode(in[2]); ASSERT_AND_RET( - /* common Sub: BB x num x num --> num */ - ((mymode ==op1mode && mymode == op2mode && mode_is_num(op1mode)) || - /* Pointer Sub: BB x P x int --> P */ - (op1mode == mode_P && mode_is_int(op2mode) && mymode == mode_P) || - /* Pointer Sub: BB x int x P --> P */ - (mode_is_int(op1mode) && op2mode == mode_P && mymode == mode_P) || - /* Pointer Sub: BB x P x P --> int */ - (op1mode == mode_P && op2mode == mode_P && mode_is_int(mymode))), + /* common Sub: BB x numP x numP --> numP */ + ((mymode ==op1mode && mymode == op2mode && mode_is_numP(op1mode)) || + /* Pointer Sub: BB x ref x int --> ref */ + (op1mode == mymode && mode_is_int(op2mode) && mode_is_reference(mymode)) || + /* Pointer Sub: BB x int x ref --> ref */ + (mode_is_int(op1mode) && op2mode == mymode && mode_is_reference(mymode)) || + /* Pointer Sub: BB x ref x ref --> int */ + (op1mode == op2mode && mode_is_reference(op2mode) && mode_is_int(mymode))), "Sub node", 0 ); - if (op1mode == mode_P && op2mode == mode_P) { - op_is_symmetric = 1; /* ArmRoq */ - } else if (op1mode == mode_P || op2mode == mode_P) { + if (mode_is_reference(op1mode) != mode_is_reference(op2mode)) { op_is_symmetric = 0; /* ArmRoq */ } else { op_is_symmetric = 2; @@ -577,8 +582,8 @@ int irn_vrfy_irg(ir_node *n, ir_graph *irg) op1mode = get_irn_mode(in[1]); op2mode = get_irn_mode(in[2]); ASSERT_AND_RET( - /* Load: BB x M x P --> M x X x data */ - op1mode == mode_M && op2mode == mode_P, + /* Load: BB x M x ref --> M x X x data */ + op1mode == mode_M && mode_is_reference(op2mode), "Load node", 0 ); ASSERT_AND_RET( mymode == mode_T, "Load node", 0 ); @@ -589,8 +594,8 @@ int irn_vrfy_irg(ir_node *n, ir_graph *irg) op2mode = get_irn_mode(in[2]); op3mode = get_irn_mode(in[3]); ASSERT_AND_RET( - /* Load: BB x M x P x data --> M x X */ - op1mode == mode_M && op2mode == mode_P && mode_is_data(op3mode), + /* Load: BB x M x ref data --> M x X */ + op1mode == mode_M && mode_is_reference(op2mode) && mode_is_data(op3mode), "Store node", 0 ); ASSERT_AND_RET(mymode == mode_T, "Store node", 0); @@ -600,7 +605,7 @@ int irn_vrfy_irg(ir_node *n, ir_graph *irg) op1mode = get_irn_mode(in[1]); op2mode = get_irn_mode(in[2]); ASSERT_AND_RET( - /* Alloc: BB x M x int_u --> M x X x P */ + /* Alloc: BB x M x int_u --> M x X x ref */ op1mode == mode_M && mode_is_int(op2mode) && !mode_is_signed(op2mode) && @@ -613,8 +618,8 @@ int irn_vrfy_irg(ir_node *n, ir_graph *irg) op1mode = get_irn_mode(in[1]); op2mode = get_irn_mode(in[2]); ASSERT_AND_RET( - /* Free: BB x M x P --> M */ - op1mode == mode_M && op2mode == mode_P && + /* Free: BB x M x ref --> M */ + op1mode == mode_M && mode_is_reference(op2mode) && mymode == mode_M, "Free node",0 ); diff --git a/ir/ir/old_fctnames.h b/ir/ir/old_fctnames.h index 4160e7fe7..88048c7df 100644 --- a/ir/ir/old_fctnames.h +++ b/ir/ir/old_fctnames.h @@ -44,7 +44,7 @@ /* tarval.h */ #define tarval_from_long(X, Y) new_tarval_from_long(Y, X) -#define tarval_P_from_entity(X) new_tarval_from_entity(X, mode_P) +#define tarval_P_from_entity(X) new_tarval_from_entity(X, mode_P_mach) #define get_tarval_entity(X) tarval_to_entity(X) #endif diff --git a/ir/tr/entity.c b/ir/tr/entity.c index 8d52c28c5..1dd8826f1 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -85,7 +85,7 @@ new_entity (type *owner, ident *name, type *type) res->variability = constant; rem = current_ir_graph; current_ir_graph = get_const_code_irg(); - res->value = new_Const(mode_P, new_tarval_from_entity(res, mode_P)); + res->value = new_Const(mode_P_mach, new_tarval_from_entity(res, mode_P_mach)); current_ir_graph = rem; } else { res->variability = uninitialized; diff --git a/ir/tr/type.c b/ir/tr/type.c index b295cffd4..5ca5d7173 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -835,10 +835,10 @@ build_value_type(ident *name, int len, type **tps) { N_param is the number of parameters, n_res the number of results. */ INLINE type *new_type_method (ident *name, int n_param, int n_res) { type *res; - res = new_type(type_method, mode_P, name); + res = new_type(type_method, mode_P_mach, name); res->state = layout_fixed; - assert((get_mode_size_bytes(mode_P) != -1) && "unorthodox modes not implemented"); - res->size = get_mode_size_bytes(mode_P); + assert((get_mode_size_bytes(mode_P_mach) != -1) && "unorthodox modes not implemented"); + res->size = get_mode_size_bytes(mode_P_mach); res->attr.ma.n_params = n_param; res->attr.ma.param_type = (type **) xmalloc (sizeof (type *) * n_param); res->attr.ma.value_params = NULL; @@ -849,16 +849,19 @@ INLINE type *new_type_method (ident *name, int n_param, int n_res) { return res; } + type *new_d_type_method (ident *name, int n_param, int n_res, dbg_info* db) { type *res = new_type_method (name, n_param, n_res); set_type_dbg_info(res, db); return res; } + INLINE void free_method_attrs(type *method) { assert(method && (method->type_op == type_method)); free(method->attr.ma.param_type); free(method->attr.ma.res_type); } + /* manipulate private fields of method. */ int get_method_n_params (type *method) { assert(method && (method->type_op == type_method)); @@ -1281,7 +1284,7 @@ bool is_pointer_type (type *pointer) { /* create a new type primitive */ INLINE type *new_type_primitive (ident *name, ir_mode *mode) { type *res; - /* @@@ assert( mode_is_data(mode) && (!mode == mode_P)); */ + /* @@@ assert( mode_is_data(mode) && (!mode_is_reference(mode))); */ res = new_type(type_primitive, mode, name); assert((get_mode_size_bytes(mode) != -1) && "unorthodox modes not implemented"); res->size = get_mode_size_bytes(mode); diff --git a/ir/tv/tv.c b/ir/tv/tv.c index ec539c0ae..ebf92ba3c 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -1176,6 +1176,19 @@ int tarval_set_mode_output_option(ir_mode *mode, const tarval_mode_info *modeinf return 0; } +/* + * Returns the output options of one mode. + * + * This functions returns the modinfo of a given mode. + */ +const tarval_mode_info *tarval_get_mode_output_option(ir_mode *mode) +{ + assert(mode); + + return mode->tv_priv; +} + + /* Identifying some tarvals ??? */ /* Implemented in old tv.c as such: * return 0 for additive neutral, @@ -1210,11 +1223,11 @@ void init_tarval_1(void) /* init with default precision */ init_strcalc(0); /* init_fltcalc(0); not yet*/ - tarval_bad = (tarval*)malloc(sizeof(tarval)); + tarval_bad = (tarval*)malloc(sizeof(tarval)); tarval_undefined = (tarval*)malloc(sizeof(tarval)); - tarval_b_true = (tarval*)malloc(sizeof(tarval)); - tarval_b_false = (tarval*)malloc(sizeof(tarval)); - tarval_P_void = (tarval*)malloc(sizeof(tarval)); + tarval_b_true = (tarval*)malloc(sizeof(tarval)); + tarval_b_false = (tarval*)malloc(sizeof(tarval)); + tarval_P_void = (tarval*)malloc(sizeof(tarval)); } /** @@ -1243,11 +1256,11 @@ void init_tarval_2(void) { ANNOUNCE(); - tarval_bad->mode = mode_BAD; + tarval_bad->mode = mode_BAD; tarval_undefined->mode = mode_ANY; - tarval_b_true->mode = mode_b; - tarval_b_false->mode = mode_b; - tarval_P_void->mode = mode_P; + tarval_b_true->mode = mode_b; + tarval_b_false->mode = mode_b; + tarval_P_void->mode = mode_P; /* * assign output modes that are compatible with the diff --git a/ir/tv/tv.h b/ir/tv/tv.h index a1404673e..7fc684c41 100644 --- a/ir/tv/tv.h +++ b/ir/tv/tv.h @@ -503,10 +503,21 @@ typedef struct tarval_mode_info { * @param mode a ir_mode that should be associated * @param modeinfo the output format info * - * Returns zero on success. + * @return zero on success. */ int tarval_set_mode_output_option(ir_mode *mode, const tarval_mode_info *modeinfo); +/** + * Returns the output options of one mode. + * + * This functions returns the modinfo of a given mode. + * + * @param mode a ir_mode that should be associated + * + * @return the output option + */ +const tarval_mode_info *tarval_get_mode_output_option(ir_mode *mode); + /** * Returns Bit representation of a tarval value, as string of '0' and '1' * -- 2.20.1