From e7228c94cf04aec3a231acf138e9e4cac5b24447 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Tue, 14 Mar 2006 15:24:37 +0000 Subject: [PATCH] more that one entry can map the same op (needed for different modes) run local_optimize() to remove tuple [r7438] --- ir/lower/lower_intrinsics.c | 15 ++++++++++++--- ir/lower/lower_intrinsics.h | 10 +++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ir/lower/lower_intrinsics.c b/ir/lower/lower_intrinsics.c index 41d2b0ec5..09af1f4f8 100644 --- a/ir/lower/lower_intrinsics.c +++ b/ir/lower/lower_intrinsics.c @@ -66,15 +66,20 @@ static void call_mapper(ir_node *node, void *env) { else { if (0 <= op->code && op->code < ARR_LEN(wenv->i_map)) { const i_instr_record *r = wenv->i_map[op->code]; - if (r) { /* we have a mapper */ - wenv->nr_of_intrinsics += r->i_mapper(node, r->ctx) ? 1 : 0; + /* run all possible mapper */ + while (r) { + if (r->i_mapper(node, r->ctx)) { + ++wenv->nr_of_intrinsics; + break; + } + r = r->link; } } } } /* Go through all graphs and map calls to intrinsic functions. */ -unsigned lower_intrinsics(const i_record *list, int length) { +unsigned lower_intrinsics(i_record *list, int length) { int i, n_ops = get_irp_n_opcodes(); ir_graph *irg; pmap *c_map = pmap_create_ex(length); @@ -95,6 +100,7 @@ unsigned lower_intrinsics(const i_record *list, int length) { ir_op *op = list[i].i_instr.op; assert(0 <= op->code && op->code < ARR_LEN(i_map)); + list[i].i_instr.link = i_map[op->code]; i_map[op->code] = &list[i].i_instr; } } @@ -117,6 +123,9 @@ unsigned lower_intrinsics(const i_record *list, int length) { set_irg_doms_inconsistent(irg); set_irg_loopinfo_inconsistent(irg); + /* optimize it, tuple might be created */ + local_optimize_graph(irg); + nr_of_intrinsics += wenv.nr_of_intrinsics; } } diff --git a/ir/lower/lower_intrinsics.h b/ir/lower/lower_intrinsics.h index e413c48e3..77a6dbee5 100644 --- a/ir/lower/lower_intrinsics.h +++ b/ir/lower/lower_intrinsics.h @@ -44,6 +44,7 @@ typedef struct _i_call_record { entity *i_ent; /**< the entity representing an intrinsic call */ i_mapper_func i_mapper; /**< the mapper function to call */ void *ctx; /**< mapper context */ + void *link; /**< used in the construction algorithm, must be NULL */ } i_call_record; /** @@ -54,6 +55,7 @@ typedef struct _i_instr_record { ir_op *op; /**< the opcode that must be mapped. */ i_mapper_func i_mapper; /**< the mapper function to call */ void *ctx; /**< mapper context */ + void *link; /**< used in the construction algorithm, must be NULL */ } i_instr_record; /** @@ -77,7 +79,7 @@ typedef union _i_record { * * @return number of found intrinsics. */ -unsigned lower_intrinsics(const i_record *list, int length); +unsigned lower_intrinsics(i_record *list, int length); /** * A mapper for the integer absolute value: inttype abs(inttype v). @@ -138,7 +140,8 @@ typedef struct _runtime_rt { INTRINSIC_INSTR, op_Div, i_mapper_RuntimeCall, - &rt_Div + &rt_Div, + NULL }; @endcode * @@ -156,7 +159,8 @@ typedef struct _runtime_rt { INTRINSIC_INSTR, op_Conv, i_mapper_RuntimeCall, - &rt_Float2Double + &rt_Float2Double, + NULL }; @endcode */ -- 2.20.1