Commit 70d388f1 authored by Christian Würdig's avatar Christian Würdig
Browse files

fixed some dependencies

fixed Div/Mod mapper
parent 31b42d94
...@@ -132,12 +132,12 @@ static int map_Shl(ir_node *call, void *ctx) { ...@@ -132,12 +132,12 @@ static int map_Shl(ir_node *call, void *ctx) {
ir_node *l_res, *h_res; ir_node *l_res, *h_res;
/* h_res = SHLD a_h, a_l, cnt */ /* h_res = SHLD a_h, a_l, cnt */
l_res = new_rd_ia32_l_ShlD(dbg, irg, block, a_h, a_l, cnt, l_res_mode); h_res = new_rd_ia32_l_ShlD(dbg, irg, block, a_h, a_l, cnt, l_res_mode);
/* l_res = SHL a_l, cnt */ /* l_res = SHL a_l, cnt */
h_res = new_rd_ia32_l_Shl(dbg, irg, block, a_l, cnt, h_res_mode); l_res = new_rd_ia32_l_Shl(dbg, irg, block, a_l, cnt, h_res_mode);
add_irn_dep(h_res, l_res); add_irn_dep(l_res, h_res);
resolve_call(call, l_res, h_res, irg, block); resolve_call(call, l_res, h_res, irg, block);
return 1; return 1;
...@@ -311,10 +311,15 @@ static int map_Abs(ir_node *call, void *ctx) { ...@@ -311,10 +311,15 @@ static int map_Abs(ir_node *call, void *ctx) {
return 1; return 1;
} }
typedef enum {
IA32_INTRINSIC_DIV,
IA32_INTRINSIC_MOD,
} ia32_intrinsic_divmod_t;
/** /**
* Maps a Div/Mod (a_l, a_h, b_l, b_h) * Maps a Div/Mod (a_l, a_h, b_l, b_h)
*/ */
static int DivMod_mapper(ir_node *call, void *ctx, int need_mod) { static int DivMod_mapper(ir_node *call, void *ctx, ia32_intrinsic_divmod_t dmtp) {
ia32_intrinsic_env_t *env = ctx; ia32_intrinsic_env_t *env = ctx;
ir_graph *irg = current_ir_graph; ir_graph *irg = current_ir_graph;
dbg_info *dbg = get_irn_dbg_info(call); dbg_info *dbg = get_irn_dbg_info(call);
...@@ -405,13 +410,15 @@ static int DivMod_mapper(ir_node *call, void *ctx, int need_mod) { ...@@ -405,13 +410,15 @@ static int DivMod_mapper(ir_node *call, void *ctx, int need_mod) {
mem = new_r_Sync(irg, block, 2, op_mem); mem = new_r_Sync(irg, block, 2, op_mem);
/* perform division */ /* perform division */
switch (dmtp) {
case IA32_INTRINSIC_DIV:
fres = new_rd_ia32_l_vfdiv(dbg, irg, block, fa, fb, mode_D); fres = new_rd_ia32_l_vfdiv(dbg, irg, block, fa, fb, mode_D);
break;
if (need_mod) { case IA32_INTRINSIC_MOD:
/* we need modulo: mod = a - b * res */ fres = new_rd_ia32_l_vfprem(dbg, irg, block, fa, fb, mode_D);
break;
fres = new_rd_ia32_l_vfmul(dbg, irg, block, fb, fres, mode_D); default:
fres = new_rd_ia32_l_vfsub(dbg, irg, block, fa, fres, mode_D); assert(0);
} }
/* store back result, we use ent_a here */ /* store back result, we use ent_a here */
...@@ -443,11 +450,11 @@ static int DivMod_mapper(ir_node *call, void *ctx, int need_mod) { ...@@ -443,11 +450,11 @@ static int DivMod_mapper(ir_node *call, void *ctx, int need_mod) {
} }
static int map_Div(ir_node *call, void *ctx) { static int map_Div(ir_node *call, void *ctx) {
return DivMod_mapper(call, ctx, 0); return DivMod_mapper(call, ctx, IA32_INTRINSIC_DIV);
} }
static int map_Mod(ir_node *call, void *ctx) { static int map_Mod(ir_node *call, void *ctx) {
return DivMod_mapper(call, ctx, 1); return DivMod_mapper(call, ctx, IA32_INTRINSIC_MOD);
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment