X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fia32%2Fia32_fpu.c;h=0642c0d88f0012be1f45783d23f6c8a9e239e33d;hb=a1e9069afa4fa1e16e2d176bcd7905d6a1ed4677;hp=a2f5cf44e4e6904ea7543405c04854e016198de4;hpb=4b734653b3f11a3182963369bb58980e4d5a62cb;p=libfirm diff --git a/ir/be/ia32/ia32_fpu.c b/ir/be/ia32/ia32_fpu.c index a2f5cf44e..0642c0d88 100644 --- a/ir/be/ia32/ia32_fpu.c +++ b/ir/be/ia32/ia32_fpu.c @@ -41,14 +41,14 @@ #include "array.h" #include "../beirgmod.h" -#include "../bearch_t.h" +#include "../bearch.h" #include "../besched.h" #include "../beabi.h" -#include "../benode_t.h" +#include "../benode.h" #include "../bestate.h" #include "../beutil.h" #include "../bessaconstr.h" -#include "../beirg_t.h" +#include "../beirg.h" static ir_entity *fpcw_round = NULL; static ir_entity *fpcw_truncate = NULL; @@ -56,7 +56,7 @@ static ir_entity *fpcw_truncate = NULL; static ir_entity *create_ent(int value, const char *name) { ir_mode *mode = mode_Hu; - ir_type *type = new_type_primitive(new_id_from_str("_fpcw_type"), mode); + ir_type *type = new_type_primitive(mode); ir_type *glob = get_glob_type(); ir_graph *cnst_irg; ir_entity *ent; @@ -68,9 +68,8 @@ static ir_entity *create_ent(int value, const char *name) tv = new_tarval_from_long(value, mode); ent = new_entity(glob, new_id_from_str(name), type); set_entity_ld_ident(ent, get_entity_ident(ent)); - set_entity_visibility(ent, visibility_local); - set_entity_variability(ent, variability_constant); - set_entity_allocation(ent, allocation_static); + set_entity_visibility(ent, ir_visibility_local); + add_entity_linkage(ent, IR_LINKAGE_CONSTANT); cnst_irg = get_const_code_irg(); cnst = new_r_Const(cnst_irg, tv); @@ -88,13 +87,13 @@ static void create_fpcw_entities(void) static ir_node *create_fpu_mode_spill(void *env, ir_node *state, int force, ir_node *after) { - ia32_code_gen_t *cg = env; ir_node *spill = NULL; + (void) env; /* we don't spill the fpcw in unsafe mode */ - if(ia32_cg_config.use_unsafe_floatconv) { + if (ia32_cg_config.use_unsafe_floatconv) { ir_node *block = get_nodes_block(state); - if(force == 1 || !is_ia32_ChangeCW(state)) { + if (force == 1 || !is_ia32_ChangeCW(state)) { ir_node *spill = new_bd_ia32_FnstCWNOP(NULL, block, state); sched_add_after(after, spill); return spill; @@ -102,10 +101,10 @@ static ir_node *create_fpu_mode_spill(void *env, ir_node *state, int force, return NULL; } - if(force == 1 || !is_ia32_ChangeCW(state)) { + if (force == 1 || !is_ia32_ChangeCW(state)) { ir_graph *irg = get_irn_irg(state); ir_node *block = get_nodes_block(state); - ir_node *noreg = ia32_new_NoReg_gp(cg); + ir_node *noreg = ia32_new_NoReg_gp(irg); ir_node *nomem = new_NoMem(); ir_node *frame = get_irg_frame(irg); @@ -115,17 +114,17 @@ static ir_node *create_fpu_mode_spill(void *env, ir_node *state, int force, set_ia32_ls_mode(spill, mode_Iu); set_ia32_use_frame(spill); - sched_add_after(after, spill); + sched_add_after(skip_Proj(after), spill); } return spill; } -static ir_node *create_fldcw_ent(ia32_code_gen_t *cg, ir_node *block, - ir_entity *entity) +static ir_node *create_fldcw_ent(ir_node *block, ir_entity *entity) { + ir_graph *irg = get_irn_irg(block); ir_node *nomem = new_NoMem(); - ir_node *noreg = ia32_new_NoReg_gp(cg); + ir_node *noreg = ia32_new_NoReg_gp(irg); ir_node *reload; reload = new_bd_ia32_FldCW(NULL, block, noreg, noreg, nomem); @@ -142,27 +141,27 @@ static ir_node *create_fpu_mode_reload(void *env, ir_node *state, ir_node *spill, ir_node *before, ir_node *last_state) { - ia32_code_gen_t *cg = env; - ir_graph *irg = get_irn_irg(state); - ir_node *block = get_nodes_block(before); - ir_node *frame = get_irg_frame(irg); - ir_node *noreg = ia32_new_NoReg_gp(cg); - ir_node *reload = NULL; - - if(ia32_cg_config.use_unsafe_floatconv) { - if(fpcw_round == NULL) { + ir_graph *irg = get_irn_irg(state); + ir_node *block = get_nodes_block(before); + ir_node *frame = get_irg_frame(irg); + ir_node *noreg = ia32_new_NoReg_gp(irg); + ir_node *reload = NULL; + (void) env; + + if (ia32_cg_config.use_unsafe_floatconv) { + if (fpcw_round == NULL) { create_fpcw_entities(); } - if(spill != NULL) { - reload = create_fldcw_ent(cg, block, fpcw_round); + if (spill != NULL) { + reload = create_fldcw_ent(block, fpcw_round); } else { - reload = create_fldcw_ent(cg, block, fpcw_truncate); + reload = create_fldcw_ent(block, fpcw_truncate); } sched_add_before(before, reload); return reload; } - if(spill != NULL) { + if (spill != NULL) { reload = new_bd_ia32_FldCW(NULL, block, frame, noreg, spill); set_ia32_op_type(reload, ia32_AddrModeS); set_ia32_ls_mode(reload, ia32_reg_classes[CLASS_ia32_fp_cw].mode); @@ -190,11 +189,11 @@ static ir_node *create_fpu_mode_reload(void *env, ir_node *state, set_ia32_use_frame(load); sched_add_before(before, load); - load_res = new_r_Proj(irg, block, load, mode_Iu, pn_ia32_Load_res); + load_res = new_r_Proj(load, mode_Iu, pn_ia32_Load_res); /* TODO: make the actual mode configurable in ChangeCW... */ or_const = new_bd_ia32_Immediate(NULL, get_irg_start_block(irg), - NULL, 0, 3072); + NULL, 0, 0, 3072); arch_set_irn_register(or_const, &ia32_gp_regs[REG_GP_NOREG]); or = new_bd_ia32_Or(NULL, block, noreg, noreg, nomem, load_res, or_const); @@ -229,77 +228,75 @@ static void collect_fpu_mode_nodes_walker(ir_node *node, void *data) collect_fpu_mode_nodes_env_t *env = data; const arch_register_t *reg; - if(!mode_is_data(get_irn_mode(node))) + if (!mode_is_data(get_irn_mode(node))) return; reg = arch_get_irn_register(node); - if(reg == &ia32_fp_cw_regs[REG_FPCW] && !is_ia32_ChangeCW(node)) { + if (reg == &ia32_fp_cw_regs[REG_FPCW] && !is_ia32_ChangeCW(node)) { ARR_APP1(ir_node*, env->state_nodes, node); } } -static -void rewire_fpu_mode_nodes(be_irg_t *birg) +static void rewire_fpu_mode_nodes(ir_graph *irg) { collect_fpu_mode_nodes_env_t env; be_ssa_construction_env_t senv; const arch_register_t *reg = &ia32_fp_cw_regs[REG_FPCW]; - ir_graph *irg = be_get_birg_irg(birg); ir_node *initial_value; ir_node **phis; - be_lv_t *lv = be_get_birg_liveness(birg); + be_lv_t *lv = be_get_irg_liveness(irg); int i, len; /* do ssa construction for the fpu modes */ env.state_nodes = NEW_ARR_F(ir_node*, 0); irg_walk_graph(irg, collect_fpu_mode_nodes_walker, NULL, &env); - initial_value = be_abi_get_ignore_irn(birg->abi, reg); + initial_value = be_abi_get_ignore_irn(be_get_irg_abi(irg), reg); /* nothing needs to be done, in fact we must not continue as for endless * loops noone is using the initial_value and it will point to a bad node * now */ - if(ARR_LEN(env.state_nodes) == 0) { + if (ARR_LEN(env.state_nodes) == 0) { DEL_ARR_F(env.state_nodes); return; } - be_ssa_construction_init(&senv, birg); + be_ssa_construction_init(&senv, irg); be_ssa_construction_add_copies(&senv, env.state_nodes, ARR_LEN(env.state_nodes)); be_ssa_construction_fix_users(&senv, initial_value); - if(lv != NULL) { + if (lv != NULL) { be_ssa_construction_update_liveness_phis(&senv, lv); be_liveness_update(lv, initial_value); len = ARR_LEN(env.state_nodes); - for(i = 0; i < len; ++i) { + for (i = 0; i < len; ++i) { be_liveness_update(lv, env.state_nodes[i]); } } else { - be_liveness_invalidate(birg->lv); + be_liveness_invalidate(be_get_irg_liveness(irg)); } /* set registers for the phis */ phis = be_ssa_construction_get_new_phis(&senv); len = ARR_LEN(phis); - for(i = 0; i < len; ++i) { + for (i = 0; i < len; ++i) { ir_node *phi = phis[i]; arch_set_irn_register(phi, reg); } be_ssa_construction_destroy(&senv); DEL_ARR_F(env.state_nodes); - be_liveness_invalidate(be_get_birg_liveness(birg)); + be_liveness_invalidate(be_get_irg_liveness(irg)); } -void ia32_setup_fpu_mode(ia32_code_gen_t *cg) +void ia32_setup_fpu_mode(ir_graph *irg) { /* do ssa construction for the fpu modes */ - rewire_fpu_mode_nodes(cg->birg); + rewire_fpu_mode_nodes(irg); /* ensure correct fpu mode for operations */ - be_assure_state(cg->birg, &ia32_fp_cw_regs[REG_FPCW], - cg, create_fpu_mode_spill, create_fpu_mode_reload); + be_assure_state(irg, &ia32_fp_cw_regs[REG_FPCW], + NULL, create_fpu_mode_spill, create_fpu_mode_reload); }