X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Flower%2Flower_hl.c;h=1ea642c31bc05119217e9229625bd169c8e8e32f;hb=288b414e4d82e0aa0d4b4348d8c387db02142cdb;hp=dcbf9e8c7044165a50243c735a00d4282ebec7a4;hpb=36332e717eebd9b98603a99ea24e390a1d2aa3be;p=libfirm diff --git a/ir/lower/lower_hl.c b/ir/lower/lower_hl.c index dcbf9e8c7..1ea642c31 100644 --- a/ir/lower/lower_hl.c +++ b/ir/lower/lower_hl.c @@ -23,9 +23,7 @@ * @author Boris Boesler, Goetz Lindenmaier, Michael Beck * @version $Id$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "config.h" #include "lowering.h" #include "irmode_t.h" @@ -54,17 +52,17 @@ static void lower_sel(ir_node *sel) { /* Do not lower frame type/global offset table access: must be lowered by the backend. */ ptr = get_Sel_ptr(sel); - if (ptr == get_irg_frame(current_ir_graph) || ptr == get_irg_globals(current_ir_graph)) + if (ptr == get_irg_frame(current_ir_graph)) return; ent = get_Sel_entity(sel); owner = get_entity_owner(ent); /* - * Cannot handle value param entities here. + * Cannot handle value param entities or frame type entities here. * Must be lowered by the backend. */ - if (is_value_param_type(owner)) + if (is_value_param_type(owner) || is_frame_type(owner)) return; dbg = get_irn_dbg_info(sel); @@ -101,11 +99,11 @@ static void lower_sel(ir_node *sel) { index = get_Sel_index(sel, 0); if (is_Array_type(owner)) { - ir_node *last_size; ir_type *arr_ty = owner; - int dims = get_array_n_dimensions(arr_ty); - int *map = alloca(sizeof(int) * dims); - int i; + int dims = get_array_n_dimensions(arr_ty); + int *map = ALLOCAN(int, dims); + ir_node *last_size; + int i; assert(dims == get_Sel_n_indexs(sel) && "array dimension must match number of indices of Sel node"); @@ -121,7 +119,7 @@ static void lower_sel(ir_node *sel) { /* Size of the array element */ tv = new_tarval_from_long(get_type_size_bytes(basetyp), mode_Int); - last_size = new_rd_Const(dbg, irg, get_irg_start_block(irg), mode_Int, tv); + last_size = new_rd_Const(dbg, irg, tv); /* * We compute the offset part of dimension d_i recursively @@ -190,7 +188,7 @@ static void lower_sel(ir_node *sel) { newn = new_rd_Add(dbg, irg, bl, get_Sel_ptr(sel), new_rd_Mul(dbg, irg, bl, index, - new_r_Const(irg, get_irg_start_block(irg), idx_mode, tv), + new_r_Const(irg, tv), idx_mode), mode); } @@ -203,14 +201,14 @@ static void lower_sel(ir_node *sel) { /* We need an additional load when accessing methods from a dispatch table. */ tv = new_tarval_from_long(get_entity_offset(ent), mode_Int); - cnst = new_rd_Const(dbg, irg, get_irg_start_block(irg), mode_Int, tv); + cnst = new_rd_Const(dbg, irg, tv); add = new_rd_Add(dbg, irg, bl, get_Sel_ptr(sel), cnst, mode); #ifdef DO_CACHEOPT /* cacheopt version */ - newn = new_rd_Load(dbg, irg, bl, get_Sel_mem(sel), sel, ent_mode); + newn = new_rd_Load(dbg, irg, bl, get_Sel_mem(sel), sel, ent_mode, 0); cacheopt_map_addrs_register_node(newn); set_Load_ptr(newn, add); #else /* normal code */ - newn = new_rd_Load(dbg, irg, bl, get_Sel_mem(sel), add, ent_mode); + newn = new_rd_Load(dbg, irg, bl, get_Sel_mem(sel), add, ent_mode, 0); #endif newn = new_r_Proj(irg, bl, newn, ent_mode, pn_Load_res); @@ -226,7 +224,7 @@ static void lower_sel(ir_node *sel) { ir_mode *mode_UInt = get_reference_mode_unsigned_eq(mode); tv = new_tarval_from_long(offset, mode_UInt); - cnst = new_r_Const(irg, get_irg_start_block(irg), mode_UInt, tv); + cnst = new_r_Const(irg, tv); newn = new_rd_Add(dbg, irg, bl, newn, cnst, mode); } } else { @@ -260,10 +258,7 @@ static void lower_symconst(ir_node *symc) { tp = get_SymConst_type(symc); assert(get_type_state(tp) == layout_fixed); mode = get_irn_mode(symc); - tv = new_tarval_from_long(get_type_size_bytes(tp), mode); - newn = new_r_Const(current_ir_graph, - get_irg_start_block(current_ir_graph), - get_irn_mode(symc), tv); + newn = new_Const_long(mode, get_type_size_bytes(tp)); assert(newn); /* run the hooks */ hook_lower(symc); @@ -274,10 +269,7 @@ static void lower_symconst(ir_node *symc) { tp = get_SymConst_type(symc); assert(get_type_state(tp) == layout_fixed); mode = get_irn_mode(symc); - tv = new_tarval_from_long(get_type_alignment_bytes(tp), mode); - newn = new_r_Const(current_ir_graph, - get_irg_start_block(current_ir_graph), - mode, tv); + newn = new_Const_long(mode, get_type_alignment_bytes(tp)); assert(newn); /* run the hooks */ hook_lower(symc); @@ -294,10 +286,7 @@ static void lower_symconst(ir_node *symc) { ent = get_SymConst_entity(symc); assert(get_type_state(get_entity_type(ent)) == layout_fixed); mode = get_irn_mode(symc); - tv = new_tarval_from_long(get_entity_offset(ent), mode); - newn = new_r_Const(current_ir_graph, - get_irg_start_block(current_ir_graph), - mode, tv); + newn = new_Const_long(mode, get_entity_offset(ent)); assert(newn); /* run the hooks */ hook_lower(symc); @@ -308,17 +297,12 @@ static void lower_symconst(ir_node *symc) { ec = get_SymConst_enum(symc); assert(get_type_state(get_enumeration_owner(ec)) == layout_fixed); tv = get_enumeration_value(ec); - newn = new_r_Const(current_ir_graph, - get_irg_start_block(current_ir_graph), - get_irn_mode(symc), tv); + newn = new_Const(tv); assert(newn); /* run the hooks */ hook_lower(symc); exchange(symc, newn); break; - case symconst_label: - /* leave */ - break; default: assert(!"unknown SymConst kind"); @@ -354,7 +338,7 @@ static void lower_bitfields_loads(ir_node *proj, ir_node *load) { int offset, bit_offset, bits, bf_bits, old_cse; dbg_info *db; - if (get_irn_op(sel) != op_Sel) + if (!is_Sel(sel)) return; ent = get_Sel_entity(sel); @@ -407,11 +391,11 @@ static void lower_bitfields_loads(ir_node *proj, ir_node *load) { if (shift_count_up) { res = new_r_Shl(current_ir_graph, block, res, - new_r_Const(current_ir_graph, block, mode_Iu, new_tarval_from_long(shift_count_up, mode_Iu)), mode); + new_Const_long(mode_Iu, shift_count_up), mode); } if (shift_count_down) { res = new_r_Shrs(current_ir_graph, block, res, - new_r_Const(current_ir_graph, block, mode_Iu, new_tarval_from_long(shift_count_down, mode_Iu)), mode); + new_Const_long(mode_Iu, shift_count_down), mode); } } else { /* unsigned */ int shift_count_down = bit_offset; @@ -419,11 +403,11 @@ static void lower_bitfields_loads(ir_node *proj, ir_node *load) { if (shift_count_down) { res = new_r_Shr(current_ir_graph, block, res, - new_r_Const(current_ir_graph, block, mode_Iu, new_tarval_from_long(shift_count_down, mode_Iu)), mode); + new_Const_long(mode_Iu, shift_count_down), mode); } if (bits != bf_bits) { res = new_r_And(current_ir_graph, block, res, - new_r_Const(current_ir_graph, block, mode, new_tarval_from_long(mask, mode)), mode); + new_Const_long(mode, mask), mode); } } @@ -447,7 +431,7 @@ static void lower_bitfields_stores(ir_node *store) { dbg_info *db; /* check bitfield access */ - if (get_irn_op(sel) != op_Sel) + if (!is_Sel(sel)) return; ent = get_Sel_entity(sel); @@ -491,20 +475,20 @@ static void lower_bitfields_stores(ir_node *store) { if (neg_mask) { /* there are some bits, normal case */ - irn = new_r_Load(current_ir_graph, block, mem, ptr, mode); + irn = new_r_Load(current_ir_graph, block, mem, ptr, mode, 0); mem = new_r_Proj(current_ir_graph, block, irn, mode_M, pn_Load_M); irn = new_r_Proj(current_ir_graph, block, irn, mode, pn_Load_res); irn = new_r_And(current_ir_graph, block, irn, - new_r_Const(current_ir_graph, block, mode, new_tarval_from_long(neg_mask, mode)), mode); + new_Const_long(mode, neg_mask), mode); if (bit_offset > 0) { value = new_r_Shl(current_ir_graph, block, value, - new_r_Const(current_ir_graph, block, mode_Iu, new_tarval_from_long(bit_offset, mode_Iu)), mode); + new_Const_long(mode_Iu, bit_offset), mode); } value = new_r_And(current_ir_graph, block, value, - new_r_Const(current_ir_graph, block, mode, new_tarval_from_long(mask, mode)), mode); + new_Const_long(mode, mask), mode); value = new_r_Or(current_ir_graph, block, value, irn, mode); } @@ -568,9 +552,8 @@ static void lower_bf_access(ir_node *irn, void *env) { { long proj = get_Proj_proj(irn); ir_node *pred = get_Proj_pred(irn); - ir_op *op = get_irn_op(pred); - if ((proj == pn_Load_res) && (op == op_Load)) + if (proj == pn_Load_res && is_Load(pred)) lower_bitfields_loads(irn, pred); break; } @@ -598,7 +581,6 @@ void lower_highlevel_graph(ir_graph *irg, int lower_bitfields) { /* Finally: lower SymConst-Size and Sel nodes, Casts, unaligned Load/Stores. */ irg_walk_graph(irg, NULL, lower_irnode, NULL); - set_irg_phase_low(irg); } /* lower_highlevel_graph */ /*