From 81f1a041542f3d40f136fca8e0bfac8b3f53fce7 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Fri, 7 Sep 2007 13:38:03 +0000 Subject: [PATCH] Add an xZero for generating SSE 0.0 [r15707] --- ir/be/ia32/ia32_spec.pl | 9 +++++++++ ir/be/ia32/ia32_transform.c | 40 ++++++++++++++++++++----------------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/ir/be/ia32/ia32_spec.pl b/ir/be/ia32/ia32_spec.pl index bd438ffe5..a5e561547 100644 --- a/ir/be/ia32/ia32_spec.pl +++ b/ir/be/ia32/ia32_spec.pl @@ -1299,6 +1299,15 @@ int => { # |_____/_____/|______| |_| |_|\___/ \__,_|\__| |_| |_|\___/ \__,_|\___||___/ # #-----------------------------------------------------------------------------# +xZero => { + irn_flags => "R", + reg_req => { out => [ "xmm" ] }, + emit => '. xorp%XSD %D1, %D1', + latency => 3, + units => [ "SSE" ], + mode => "mode_E", +}, + # commutative operations xAdd => { diff --git a/ir/be/ia32/ia32_transform.c b/ir/be/ia32/ia32_transform.c index cf0af8b76..f55194490 100644 --- a/ir/be/ia32/ia32_transform.c +++ b/ir/be/ia32/ia32_transform.c @@ -181,12 +181,12 @@ static ir_type *get_prim_type(pmap *types, ir_mode *mode) } /** - * Get an entity that is initialized with a tarval + * Get an atomic entity that is initialized with a tarval */ -static ir_entity *get_entity_for_tv(ia32_code_gen_t *cg, ir_node *cnst) +static ir_entity *ia32_get_entity_for_tv(ia32_isa_t *isa, ir_node *cnst) { tarval *tv = get_Const_tarval(cnst); - pmap_entry *e = pmap_find(cg->isa->tv_ent, tv); + pmap_entry *e = pmap_find(isa->tv_ent, tv); ir_entity *res; ir_graph *rem; @@ -194,7 +194,7 @@ static ir_entity *get_entity_for_tv(ia32_code_gen_t *cg, ir_node *cnst) ir_mode *mode = get_irn_mode(cnst); ir_type *tp = get_Const_type(cnst); if (tp == firm_unknown_type) - tp = get_prim_type(cg->isa->types, mode); + tp = get_prim_type(isa->types, mode); res = new_entity(get_glob_type(), unique_id(".LC%u"), tp); @@ -210,7 +210,7 @@ static ir_entity *get_entity_for_tv(ia32_code_gen_t *cg, ir_node *cnst) set_atomic_ent_value(res, new_Const_type(tv, tp)); current_ir_graph = rem; - pmap_insert(cg->isa->tv_ent, tv, res); + pmap_insert(isa->tv_ent, tv, res); } else { res = e->value; } @@ -264,10 +264,24 @@ static ir_node *gen_Const(ir_node *node) { ir_node *nomem = new_NoMem(); ir_node *load; ir_entity *floatent; + cnst_classify_t clss = classify_Const(node); - if (! USE_SSE2(env_cg)) { - cnst_classify_t clss = classify_Const(node); + if (USE_SSE2(env_cg)) { + if (clss == CNST_NULL) { + load = new_rd_ia32_xZero(dbgi, irg, block); + set_ia32_ls_mode(load, mode); + res = load; + } else { + floatent = ia32_get_entity_for_tv(env_cg->isa, node); + load = new_rd_ia32_xLoad(dbgi, irg, block, noreg, noreg, nomem, + mode); + set_ia32_op_type(load, ia32_AddrModeS); + set_ia32_am_sc(load, floatent); + set_ia32_flags(load, get_ia32_flags(load) | arch_irn_flags_rematerializable); + res = new_r_Proj(irg, block, load, mode_xmm, pn_ia32_xLoad_res); + } + } else { if (clss == CNST_NULL) { load = new_rd_ia32_vfldz(dbgi, irg, block); res = load; @@ -275,7 +289,7 @@ static ir_node *gen_Const(ir_node *node) { load = new_rd_ia32_vfld1(dbgi, irg, block); res = load; } else { - floatent = get_entity_for_tv(env_cg, node); + floatent = ia32_get_entity_for_tv(env_cg->isa, node); load = new_rd_ia32_vfld(dbgi, irg, block, noreg, noreg, nomem, mode); set_ia32_op_type(load, ia32_AddrModeS); @@ -284,16 +298,6 @@ static ir_node *gen_Const(ir_node *node) { res = new_r_Proj(irg, block, load, mode_vfp, pn_ia32_vfld_res); } set_ia32_ls_mode(load, mode); - } else { - floatent = get_entity_for_tv(env_cg, node); - - load = new_rd_ia32_xLoad(dbgi, irg, block, noreg, noreg, nomem, - mode); - set_ia32_op_type(load, ia32_AddrModeS); - set_ia32_am_sc(load, floatent); - set_ia32_flags(load, get_ia32_flags(load) | arch_irn_flags_rematerializable); - - res = new_r_Proj(irg, block, load, mode_xmm, pn_ia32_xLoad_res); } SET_IA32_ORIG_NODE(load, ia32_get_old_node_name(env_cg, node)); -- 2.20.1