X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Fircons.c;h=7966d17a8d56d35230cbe14f8a7695d70a0a0806;hb=8399216d8aebc713bbda04b6e3e250a1d52b20bf;hp=531baa01f5772b7bfb2cd569a1defac8d095c8d1;hpb=3fea1f421457fe16f48f9487ceaefbfcecb32f2b;p=libfirm diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index 531baa01f..7966d17a8 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -12,7 +12,17 @@ */ #ifdef HAVE_CONFIG_H -# include +# include "config.h" +#endif + +#ifdef HAVE_ALLOCA_H +#include +#endif +#ifdef HAVE_MALLOC_H +#include +#endif +#ifdef HAVE_STRING_H +#include #endif # include "irgraph_t.h" @@ -25,8 +35,6 @@ # include "iropt_t.h" # include "irgmod.h" # include "array.h" -/* memset belongs to string.h */ -# include "string.h" # include "irbackedge_t.h" # include "irflag_t.h" @@ -52,8 +60,9 @@ typedef struct Phi_in_stack Phi_in_stack; */ static default_initialize_local_variable_func_t *default_initialize_local_variable = NULL; -/*** ******************************************** */ -/** privat interfaces, for professional use only */ +/* -------------------------------------------- */ +/* privat interfaces, for professional use only */ +/* -------------------------------------------- */ /* Constructs a Block with a fixed number of predecessors. Does not set current_block. Can not be used with automatic @@ -69,9 +78,10 @@ new_rd_Block (dbg_info* db, ir_graph *irg, int arity, ir_node **in) /* res->attr.block.exc = exc_normal; */ /* res->attr.block.handler_entry = 0; */ - res->attr.block.irg = irg; - res->attr.block.backedge = new_backedge_arr(irg->obst, arity); - res->attr.block.in_cg = NULL; + res->attr.block.dead = 0; + res->attr.block.irg = irg; + res->attr.block.backedge = new_backedge_arr(irg->obst, arity); + res->attr.block.in_cg = NULL; res->attr.block.cg_backedge = NULL; IRN_VRFY_IRG(res, irg); @@ -153,7 +163,7 @@ new_rd_Const_type (dbg_info* db, ir_graph *irg, ir_node *block, ir_mode *mode, t INLINE ir_node * new_rd_Const (dbg_info* db, ir_graph *irg, ir_node *block, ir_mode *mode, tarval *con) { - type *tp = unknown_type; + type *tp = firm_unknown_type; /* removing this somehow causes errors in jack. */ return new_rd_Const_type (db, irg, block, mode, con, tp); } @@ -217,6 +227,8 @@ new_rd_Cast (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *op, type *to_ { ir_node *res; + assert(is_atomic_type(to_tp)); + res = new_ir_node(db, irg, block, op_Cast, get_irn_mode(op), 1, &op); res->attr.cast.totype = to_tp; res = optimize_node(res); @@ -697,8 +709,7 @@ new_rd_InstOf (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store, INLINE ir_node * new_rd_SymConst_type (dbg_info* db, ir_graph *irg, ir_node *block, symconst_symbol value, - symconst_kind symkind, type *tp) -{ + symconst_kind symkind, type *tp) { ir_node *res; ir_mode *mode; @@ -706,6 +717,7 @@ new_rd_SymConst_type (dbg_info* db, ir_graph *irg, ir_node *block, symconst_symb mode = mode_P_mach; else mode = mode_Iu; + res = new_ir_node(db, irg, block, op_SymConst, mode, 0, NULL); res->attr.i.num = symkind; @@ -721,7 +733,7 @@ INLINE ir_node * new_rd_SymConst (dbg_info* db, ir_graph *irg, ir_node *block, symconst_symbol value, symconst_kind symkind) { - ir_node *res = new_rd_SymConst_type(db, irg, block, value, symkind, unknown_type); + ir_node *res = new_rd_SymConst_type(db, irg, block, value, symkind, firm_unknown_type); return res; } @@ -848,27 +860,27 @@ new_rd_Filter (dbg_info *db, ir_graph *irg, ir_node *block, ir_node *arg, ir_mod res = optimize_node(res); IRN_VRFY_IRG(res, irg); return res; +} +INLINE ir_node * +new_rd_NoMem (ir_graph *irg) { + return irg->no_mem; } -ir_node * -new_rd_FuncCall (dbg_info* db, ir_graph *irg, ir_node *block, - ir_node *callee, int arity, ir_node **in, type *tp) +INLINE ir_node * +new_rd_Mux (dbg_info *db, ir_graph *irg, ir_node *block, + ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode) { - ir_node **r_in; + ir_node *in[3]; ir_node *res; - int r_arity; - r_arity = arity+1; - NEW_ARR_A(ir_node *, r_in, r_arity); - r_in[0] = callee; - memcpy(&r_in[1], in, sizeof (ir_node *) * arity); + in[0] = sel; + in[1] = ir_false; + in[2] = ir_true; - res = new_ir_node(db, irg, block, op_FuncCall, mode_T, r_arity, r_in); + res = new_ir_node(db, irg, block, op_Mux, mode, 3, in); + assert(res); - assert(is_method_type(tp)); - set_FuncCall_type(res, tp); - res->attr.call.callee_arr = NULL; res = optimize_node(res); IRN_VRFY_IRG(res, irg); return res; @@ -1063,10 +1075,12 @@ INLINE ir_node *new_r_Filter (ir_graph *irg, ir_node *block, ir_node *arg, ir_mode *mode, long proj) { return new_rd_Filter(NULL, irg, block, arg, mode, proj); } -INLINE ir_node *new_r_FuncCall (ir_graph *irg, ir_node *block, - ir_node *callee, int arity, ir_node **in, - type *tp) { - return new_rd_FuncCall(NULL, irg, block, callee, arity, in, tp); +INLINE ir_node *new_r_NoMem (ir_graph *irg) { + return new_rd_NoMem(irg); +} +INLINE ir_node *new_r_Mux (ir_graph *irg, ir_node *block, + ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode) { + return new_rd_Mux(NULL, irg, block, sel, ir_false, ir_true, mode); } @@ -2371,14 +2385,16 @@ new_d_Filter (dbg_info *db, ir_node *arg, ir_mode *mode, long proj) } ir_node * -new_d_FuncCall (dbg_info* db, ir_node *callee, int arity, ir_node **in, - type *tp) +(new_d_NoMem)(void) { - ir_node *res; - res = new_rd_FuncCall (db, current_ir_graph, current_ir_graph->current_block, - callee, arity, in, tp); + return __new_d_NoMem(); +} - return res; +ir_node * +new_d_Mux (dbg_info *db, ir_node *sel, ir_node *ir_false, + ir_node *ir_true, ir_mode *mode) { + return new_rd_Mux (db, current_ir_graph, current_ir_graph->current_block, + sel, ir_false, ir_true, mode); } /* ********************************************************************* */ @@ -2395,12 +2411,13 @@ ir_node *new_d_immBlock (dbg_info* db) { /* creates a new dynamic in-array as length of in is -1 */ res = new_ir_node (db, current_ir_graph, NULL, op_Block, mode_BB, -1, NULL); current_ir_graph->current_block = res; - res->attr.block.matured = 0; + res->attr.block.matured = 0; + res->attr.block.dead = 0; /* res->attr.block.exc = exc_normal; */ /* res->attr.block.handler_entry = 0; */ - res->attr.block.irg = current_ir_graph; - res->attr.block.backedge = NULL; - res->attr.block.in_cg = NULL; + res->attr.block.irg = current_ir_graph; + res->attr.block.backedge = NULL; + res->attr.block.in_cg = NULL; res->attr.block.cg_backedge = NULL; set_Block_block_visited(res, 0); @@ -2547,6 +2564,11 @@ ir_node *new_Raise (ir_node *store, ir_node *obj) { ir_node *new_Const (ir_mode *mode, tarval *con) { return new_d_Const(NULL, mode, con); } + +ir_node *new_Const_type(tarval *con, type *tp) { + return new_d_Const_type(NULL, get_type_mode(tp), con, tp); +} + ir_node *new_SymConst (symconst_symbol value, symconst_kind kind) { return new_d_SymConst(NULL, value, kind); } @@ -2681,6 +2703,9 @@ ir_node *new_Break (void) { ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj) { return new_d_Filter(NULL, arg, mode, proj); } -ir_node *new_FuncCall (ir_node *callee, int arity, ir_node **in, type *tp) { - return new_d_FuncCall(NULL, callee, arity, in, tp); +ir_node *new_NoMem (void) { + return new_d_NoMem(); +} +ir_node *new_Mux (ir_node *sel, ir_node *ir_false, ir_node *ir_true, ir_mode *mode) { + return new_d_Mux(NULL, sel, ir_false, ir_true, mode); }