X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fia32%2Fia32_fpu.c;h=f021561ac502e6af3877ae6c91ea660e19fde0f0;hb=ffe5947b77003cda3595c5476153f86764b0ba47;hp=3d0c4b274ee8b8c66459982f8d4b6e9c0bce9cde;hpb=8ce557f8a7ef7f24e2a4c405e1279a43380b24df;p=libfirm diff --git a/ir/be/ia32/ia32_fpu.c b/ir/be/ia32/ia32_fpu.c index 3d0c4b274..f021561ac 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,12 +68,11 @@ 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, mode, tv); + cnst = new_r_Const(cnst_irg, tv); set_atomic_ent_value(ent, cnst); return ent; @@ -92,9 +91,9 @@ static ir_node *create_fpu_mode_spill(void *env, ir_node *state, int force, ir_node *spill = NULL; /* 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,7 +101,7 @@ 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); @@ -115,7 +114,7 @@ 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; @@ -149,11 +148,11 @@ static ir_node *create_fpu_mode_reload(void *env, ir_node *state, ir_node *noreg = ia32_new_NoReg_gp(cg); ir_node *reload = NULL; - if(ia32_cg_config.use_unsafe_floatconv) { - if(fpcw_round == NULL) { + if (ia32_cg_config.use_unsafe_floatconv) { + if (fpcw_round == NULL) { create_fpcw_entities(); } - if(spill != NULL) { + if (spill != NULL) { reload = create_fldcw_ent(cg, block, fpcw_round); } else { reload = create_fldcw_ent(cg, block, fpcw_truncate); @@ -162,7 +161,7 @@ static ir_node *create_fpu_mode_reload(void *env, ir_node *state, 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) { /* do ssa construction for the fpu modes */ - rewire_fpu_mode_nodes(cg->birg); + rewire_fpu_mode_nodes(cg->irg); /* ensure correct fpu mode for operations */ - be_assure_state(cg->birg, &ia32_fp_cw_regs[REG_FPCW], + be_assure_state(cg->irg, &ia32_fp_cw_regs[REG_FPCW], cg, create_fpu_mode_spill, create_fpu_mode_reload); }