From: Christoph Mallon Date: Thu, 29 Nov 2012 12:22:25 +0000 (+0100) Subject: beemit: Provide be_set_emitter() replacing identical functions in all backends. X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=0f422870067627f102705b5f3e850f37c5abc1b7;p=libfirm beemit: Provide be_set_emitter() replacing identical functions in all backends. Also use one common be_emit_nothing(). --- diff --git a/ir/be/TEMPLATE/TEMPLATE_emitter.c b/ir/be/TEMPLATE/TEMPLATE_emitter.c index 1517fca01..73c9f4960 100644 --- a/ir/be/TEMPLATE/TEMPLATE_emitter.c +++ b/ir/be/TEMPLATE/TEMPLATE_emitter.c @@ -219,21 +219,6 @@ static void emit_be_Return(const ir_node *node) TEMPLATE_emitf(node, "ret"); } -static void emit_nothing(const ir_node *node) -{ - (void) node; -} - -/** - * The type of a emitter function. - */ -typedef void (emit_func)(const ir_node *node); - -static inline void set_emitter(ir_op *op, emit_func func) -{ - op->ops.generic = (op_func)func; -} - /** * Enters the emitter functions for handled nodes into the generic * pointer of an opcode. @@ -247,14 +232,14 @@ static void TEMPLATE_register_emitters(void) TEMPLATE_register_spec_emitters(); /* custom emitters not provided by the spec */ - set_emitter(op_TEMPLATE_Jmp, emit_TEMPLATE_Jmp); - set_emitter(op_be_IncSP, emit_be_IncSP); - set_emitter(op_be_Return, emit_be_Return); - set_emitter(op_be_Start, emit_be_Start); + be_set_emitter(op_TEMPLATE_Jmp, emit_TEMPLATE_Jmp); + be_set_emitter(op_be_IncSP, emit_be_IncSP); + be_set_emitter(op_be_Return, emit_be_Return); + be_set_emitter(op_be_Start, emit_be_Start); /* no need to emit anything for the following nodes */ - set_emitter(op_Phi, emit_nothing); - set_emitter(op_be_Keep, emit_nothing); + be_set_emitter(op_Phi, be_emit_nothing); + be_set_emitter(op_be_Keep, be_emit_nothing); } typedef void (*emit_func_ptr) (const ir_node *); diff --git a/ir/be/amd64/amd64_emitter.c b/ir/be/amd64/amd64_emitter.c index e1489a0b0..290ad1d36 100644 --- a/ir/be/amd64/amd64_emitter.c +++ b/ir/be/amd64/amd64_emitter.c @@ -193,14 +193,6 @@ unknown: * ***********************************************************************************/ -/** - * Default emitter for anything that we don't want to generate code for. - */ -static void emit_nothing(const ir_node *node) -{ - (void) node; -} - /** * Emit a SymConst. */ @@ -461,19 +453,6 @@ static void emit_amd64_binop(const ir_node *irn) emit_amd64_binop_op(irn, second_op); } -/** - * The type of a emitter function. - */ -typedef void (emit_func)(const ir_node *irn); - -/** - * Set a node emitter. Make it a bit more type safe. - */ -static inline void set_emitter(ir_op *op, emit_func arm_emit_node) -{ - op->ops.generic = (op_func)arm_emit_node; -} - /** * Enters the emitter functions for handled nodes into the generic * pointer of an opcode. @@ -486,23 +465,22 @@ static void amd64_register_emitters(void) /* register all emitter functions defined in spec */ amd64_register_spec_emitters(); - set_emitter(op_amd64_SymConst, emit_amd64_SymConst); - set_emitter(op_amd64_Jmp, emit_amd64_Jmp); - set_emitter(op_amd64_Jcc, emit_amd64_Jcc); - set_emitter(op_amd64_Conv, emit_amd64_Conv); - set_emitter(op_amd64_FrameAddr, emit_amd64_FrameAddr); - set_emitter(op_be_Return, emit_be_Return); - set_emitter(op_be_Call, emit_be_Call); - set_emitter(op_be_Copy, emit_be_Copy); - set_emitter(op_be_IncSP, emit_be_IncSP); - set_emitter(op_be_Perm, emit_be_Perm); - - set_emitter(op_amd64_Add, emit_amd64_binop); - set_emitter(op_amd64_Sub, emit_amd64_binop); - - set_emitter(op_be_Start, emit_nothing); - set_emitter(op_be_Keep, emit_nothing); - set_emitter(op_Phi, emit_nothing); + be_set_emitter(op_amd64_Add, emit_amd64_binop); + be_set_emitter(op_amd64_Conv, emit_amd64_Conv); + be_set_emitter(op_amd64_FrameAddr, emit_amd64_FrameAddr); + be_set_emitter(op_amd64_Jcc, emit_amd64_Jcc); + be_set_emitter(op_amd64_Jmp, emit_amd64_Jmp); + be_set_emitter(op_amd64_Sub, emit_amd64_binop); + be_set_emitter(op_amd64_SymConst, emit_amd64_SymConst); + be_set_emitter(op_be_Call, emit_be_Call); + be_set_emitter(op_be_Copy, emit_be_Copy); + be_set_emitter(op_be_IncSP, emit_be_IncSP); + be_set_emitter(op_be_Perm, emit_be_Perm); + be_set_emitter(op_be_Return, emit_be_Return); + + be_set_emitter(op_Phi, be_emit_nothing); + be_set_emitter(op_be_Keep, be_emit_nothing); + be_set_emitter(op_be_Start, be_emit_nothing); } typedef void (*emit_func_ptr) (const ir_node *); diff --git a/ir/be/arm/arm_emitter.c b/ir/be/arm/arm_emitter.c index 3176b525b..47cb4d859 100644 --- a/ir/be/arm/arm_emitter.c +++ b/ir/be/arm/arm_emitter.c @@ -719,24 +719,6 @@ static void emit_arm_Jmp(const ir_node *node) } } -static void emit_nothing(const ir_node *irn) -{ - (void) irn; -} - -/** - * The type of a emitter function. - */ -typedef void (emit_func)(const ir_node *irn); - -/** - * Set a node emitter. Make it a bit more type safe. - */ -static inline void set_emitter(ir_op *op, emit_func arm_emit_node) -{ - op->ops.generic = (op_func)arm_emit_node; -} - /** * Enters the emitter functions for handled nodes into the generic * pointer of an opcode. @@ -750,24 +732,24 @@ static void arm_register_emitters(void) arm_register_spec_emitters(); /* custom emitter */ - set_emitter(op_arm_B, emit_arm_B); - set_emitter(op_arm_CopyB, emit_arm_CopyB); - set_emitter(op_arm_fConst, emit_arm_fConst); - set_emitter(op_arm_FrameAddr, emit_arm_FrameAddr); - set_emitter(op_arm_Jmp, emit_arm_Jmp); - set_emitter(op_arm_SwitchJmp, emit_arm_SwitchJmp); - set_emitter(op_arm_SymConst, emit_arm_SymConst); - set_emitter(op_be_Copy, emit_be_Copy); - set_emitter(op_be_CopyKeep, emit_be_Copy); - set_emitter(op_be_IncSP, emit_be_IncSP); - set_emitter(op_be_MemPerm, emit_be_MemPerm); - set_emitter(op_be_Perm, emit_be_Perm); - set_emitter(op_be_Return, emit_be_Return); - set_emitter(op_be_Start, emit_be_Start); + be_set_emitter(op_arm_B, emit_arm_B); + be_set_emitter(op_arm_CopyB, emit_arm_CopyB); + be_set_emitter(op_arm_FrameAddr, emit_arm_FrameAddr); + be_set_emitter(op_arm_Jmp, emit_arm_Jmp); + be_set_emitter(op_arm_SwitchJmp, emit_arm_SwitchJmp); + be_set_emitter(op_arm_SymConst, emit_arm_SymConst); + be_set_emitter(op_arm_fConst, emit_arm_fConst); + be_set_emitter(op_be_Copy, emit_be_Copy); + be_set_emitter(op_be_CopyKeep, emit_be_Copy); + be_set_emitter(op_be_IncSP, emit_be_IncSP); + be_set_emitter(op_be_MemPerm, emit_be_MemPerm); + be_set_emitter(op_be_Perm, emit_be_Perm); + be_set_emitter(op_be_Return, emit_be_Return); + be_set_emitter(op_be_Start, emit_be_Start); /* no need to emit anything for the following nodes */ - set_emitter(op_Phi, emit_nothing); - set_emitter(op_be_Keep, emit_nothing); + be_set_emitter(op_Phi, be_emit_nothing); + be_set_emitter(op_be_Keep, be_emit_nothing); } /** diff --git a/ir/be/beemitter.c b/ir/be/beemitter.c index a08461d15..9d03a4922 100644 --- a/ir/be/beemitter.c +++ b/ir/be/beemitter.c @@ -108,3 +108,8 @@ void be_emit_finish_line_gas(const ir_node *node) be_emit_cstring(" */\n"); be_emit_write_line(); } + +void be_emit_nothing(ir_node const *const node) +{ + (void)node; +} diff --git a/ir/be/beemitter.h b/ir/be/beemitter.h index 7be1320ac..0b0dcfcfe 100644 --- a/ir/be/beemitter.h +++ b/ir/be/beemitter.h @@ -33,6 +33,7 @@ #include "firm_types.h" #include "obst.h" #include "be.h" +#include "irop_t.h" /* don't use the following vars directly, they're only here for the inlines */ extern FILE *emit_file; @@ -120,4 +121,16 @@ void be_emit_finish_line_gas(const ir_node *node); */ void be_emit_pad_comment(void); +/** + * The type of a emitter function. + */ +typedef void emit_func(ir_node const *node); + +static inline void be_set_emitter(ir_op *const op, emit_func *const func) +{ + set_generic_function_ptr(op, func); +} + +void be_emit_nothing(ir_node const *node); + #endif diff --git a/ir/be/ia32/ia32_emitter.c b/ir/be/ia32/ia32_emitter.c index b758c2f2c..d0ae47cac 100644 --- a/ir/be/ia32/ia32_emitter.c +++ b/ir/be/ia32/ia32_emitter.c @@ -1376,11 +1376,6 @@ static void emit_be_Return(const ir_node *node) } } -static void emit_Nothing(const ir_node *node) -{ - (void) node; -} - /** * Enters the emitter functions for handled nodes into the generic @@ -1388,11 +1383,11 @@ static void emit_Nothing(const ir_node *node) */ static void ia32_register_emitters(void) { -#define IA32_EMIT(a) op_ia32_##a->ops.generic = (op_func)emit_ia32_##a -#define EMIT(a) op_##a->ops.generic = (op_func)emit_##a -#define IGN(a) op_##a->ops.generic = (op_func)emit_Nothing -#define BE_EMIT(a) op_be_##a->ops.generic = (op_func)emit_be_##a -#define BE_IGN(a) op_be_##a->ops.generic = (op_func)emit_Nothing +#define IA32_EMIT(a) be_set_emitter(op_ia32_##a, emit_ia32_##a) +#define EMIT(a) be_set_emitter(op_##a, emit_##a) +#define IGN(a) be_set_emitter(op_##a, be_emit_nothing) +#define BE_EMIT(a) be_set_emitter(op_be_##a, emit_be_##a) +#define BE_IGN(a) be_set_emitter(op_be_##a, be_emit_nothing) /* first clear the generic function pointer for all ops */ ir_clear_opcodes_generic_func(); @@ -1488,9 +1483,7 @@ static void ia32_emit_node(ir_node *node) (*func) (node); } else { - emit_Nothing(node); - ir_fprintf(stderr, "Error: No emit handler for node %+F (%+G, graph %+F)\n", node, node, get_irn_irg(node)); - abort(); + panic("no emit handler for node %+F (%+G, graph %+F)\n", node, node, get_irn_irg(node)); } if (sp_relative) { @@ -3451,146 +3444,133 @@ static void bemit_fxch(const ir_node *node) bemit_fop_reg(node, 0xD9, 0xC8); } -/** - * The type of a emitter function. - */ -typedef void (*emit_func) (const ir_node *); - -/** - * Set a node emitter. Make it a bit more type safe. - */ -static void register_emitter(ir_op *op, emit_func func) -{ - op->ops.generic = (op_func) func; -} - static void ia32_register_binary_emitters(void) { /* first clear the generic function pointer for all ops */ ir_clear_opcodes_generic_func(); /* benode emitter */ - register_emitter(op_be_Copy, bemit_copy); - register_emitter(op_be_CopyKeep, bemit_copy); - register_emitter(op_be_IncSP, bemit_incsp); - register_emitter(op_be_Perm, bemit_perm); - register_emitter(op_be_Return, bemit_return); - register_emitter(op_ia32_Adc, bemit_adc); - register_emitter(op_ia32_Add, bemit_add); - register_emitter(op_ia32_AddMem, bemit_addmem); - register_emitter(op_ia32_AddMem8Bit, bemit_addmem8bit); - register_emitter(op_ia32_And, bemit_and); - register_emitter(op_ia32_AndMem, bemit_andmem); - register_emitter(op_ia32_AndMem8Bit, bemit_andmem8bit); - register_emitter(op_ia32_Asm, emit_ia32_Asm); // TODO implement binary emitter - register_emitter(op_ia32_Breakpoint, bemit_int3); - register_emitter(op_ia32_Bsf, bemit_bsf); - register_emitter(op_ia32_Bsr, bemit_bsr); - register_emitter(op_ia32_Bswap, bemit_bswap); - register_emitter(op_ia32_Bt, bemit_bt); - register_emitter(op_ia32_CMovcc, bemit_cmovcc); - register_emitter(op_ia32_Call, bemit_call); - register_emitter(op_ia32_Cltd, bemit_cltd); - register_emitter(op_ia32_Cmc, bemit_cmc); - register_emitter(op_ia32_Cmp, bemit_cmp); - register_emitter(op_ia32_Cmp8Bit, bemit_cmp8bit); - register_emitter(op_ia32_Const, bemit_mov_const); - register_emitter(op_ia32_Conv_I2I, bemit_conv_i2i); - register_emitter(op_ia32_Conv_I2I8Bit, bemit_conv_i2i); - register_emitter(op_ia32_CopyB_i, bemit_copybi); - register_emitter(op_ia32_Cwtl, bemit_cwtl); - register_emitter(op_ia32_Dec, bemit_dec); - register_emitter(op_ia32_DecMem, bemit_decmem); - register_emitter(op_ia32_Div, bemit_div); - register_emitter(op_ia32_FldCW, bemit_fldcw); - register_emitter(op_ia32_FnstCW, bemit_fnstcw); - register_emitter(op_ia32_FtstFnstsw, bemit_ftstfnstsw); - register_emitter(op_ia32_FucomFnstsw, bemit_fucomfnstsw); - register_emitter(op_ia32_Fucomi, bemit_fucomi); - register_emitter(op_ia32_FucomppFnstsw, bemit_fucomppfnstsw); - register_emitter(op_ia32_IDiv, bemit_idiv); - register_emitter(op_ia32_IJmp, bemit_ijmp); - register_emitter(op_ia32_IMul, bemit_imul); - register_emitter(op_ia32_IMul1OP, bemit_imul1op); - register_emitter(op_ia32_Inc, bemit_inc); - register_emitter(op_ia32_IncMem, bemit_incmem); - register_emitter(op_ia32_Jcc, bemit_ia32_jcc); - register_emitter(op_ia32_Jmp, bemit_jump); - register_emitter(op_ia32_LdTls, bemit_ldtls); - register_emitter(op_ia32_Lea, bemit_lea); - register_emitter(op_ia32_Leave, bemit_leave); - register_emitter(op_ia32_Load, bemit_load); - register_emitter(op_ia32_Minus64Bit, bemit_minus64bit); - register_emitter(op_ia32_Mul, bemit_mul); - register_emitter(op_ia32_Neg, bemit_neg); - register_emitter(op_ia32_NegMem, bemit_negmem); - register_emitter(op_ia32_Not, bemit_not); - register_emitter(op_ia32_NotMem, bemit_notmem); - register_emitter(op_ia32_Or, bemit_or); - register_emitter(op_ia32_OrMem, bemit_ormem); - register_emitter(op_ia32_OrMem8Bit, bemit_ormem8bit); - register_emitter(op_ia32_Pop, bemit_pop); - register_emitter(op_ia32_PopEbp, bemit_pop); - register_emitter(op_ia32_PopMem, bemit_popmem); - register_emitter(op_ia32_Popcnt, bemit_popcnt); - register_emitter(op_ia32_Push, bemit_push); - register_emitter(op_ia32_RepPrefix, bemit_rep); - register_emitter(op_ia32_Rol, bemit_rol); - register_emitter(op_ia32_RolMem, bemit_rolmem); - register_emitter(op_ia32_Ror, bemit_ror); - register_emitter(op_ia32_RorMem, bemit_rormem); - register_emitter(op_ia32_Sahf, bemit_sahf); - register_emitter(op_ia32_Sar, bemit_sar); - register_emitter(op_ia32_SarMem, bemit_sarmem); - register_emitter(op_ia32_Sbb, bemit_sbb); - register_emitter(op_ia32_Sbb0, bemit_sbb0); - register_emitter(op_ia32_Setcc, bemit_setcc); - register_emitter(op_ia32_Shl, bemit_shl); - register_emitter(op_ia32_ShlD, bemit_shld); - register_emitter(op_ia32_ShlMem, bemit_shlmem); - register_emitter(op_ia32_Shr, bemit_shr); - register_emitter(op_ia32_ShrD, bemit_shrd); - register_emitter(op_ia32_ShrMem, bemit_shrmem); - register_emitter(op_ia32_Stc, bemit_stc); - register_emitter(op_ia32_Store, bemit_store); - register_emitter(op_ia32_Store8Bit, bemit_store); - register_emitter(op_ia32_Sub, bemit_sub); - register_emitter(op_ia32_SubMem, bemit_submem); - register_emitter(op_ia32_SubMem8Bit, bemit_submem8bit); - register_emitter(op_ia32_SubSP, bemit_subsp); - register_emitter(op_ia32_SwitchJmp, bemit_switchjmp); - register_emitter(op_ia32_Test, bemit_test); - register_emitter(op_ia32_Test8Bit, bemit_test8bit); - register_emitter(op_ia32_Xor, bemit_xor); - register_emitter(op_ia32_Xor0, bemit_xor0); - register_emitter(op_ia32_XorMem, bemit_xormem); - register_emitter(op_ia32_XorMem8Bit, bemit_xormem8bit); - register_emitter(op_ia32_fabs, bemit_fabs); - register_emitter(op_ia32_fadd, bemit_fadd); - register_emitter(op_ia32_fchs, bemit_fchs); - register_emitter(op_ia32_fdiv, bemit_fdiv); - register_emitter(op_ia32_ffreep, bemit_ffreep); - register_emitter(op_ia32_fild, bemit_fild); - register_emitter(op_ia32_fist, bemit_fist); - register_emitter(op_ia32_fisttp, bemit_fisttp); - register_emitter(op_ia32_fld, bemit_fld); - register_emitter(op_ia32_fld1, bemit_fld1); - register_emitter(op_ia32_fldz, bemit_fldz); - register_emitter(op_ia32_fmul, bemit_fmul); - register_emitter(op_ia32_fpop, bemit_fpop); - register_emitter(op_ia32_fpush, bemit_fpush); - register_emitter(op_ia32_fpushCopy, bemit_fpushcopy); - register_emitter(op_ia32_fst, bemit_fst); - register_emitter(op_ia32_fsub, bemit_fsub); - register_emitter(op_ia32_fxch, bemit_fxch); + be_set_emitter(op_be_Copy, bemit_copy); + be_set_emitter(op_be_CopyKeep, bemit_copy); + be_set_emitter(op_be_IncSP, bemit_incsp); + be_set_emitter(op_be_Perm, bemit_perm); + be_set_emitter(op_be_Return, bemit_return); + be_set_emitter(op_ia32_Adc, bemit_adc); + be_set_emitter(op_ia32_Add, bemit_add); + be_set_emitter(op_ia32_AddMem, bemit_addmem); + be_set_emitter(op_ia32_AddMem8Bit, bemit_addmem8bit); + be_set_emitter(op_ia32_And, bemit_and); + be_set_emitter(op_ia32_AndMem, bemit_andmem); + be_set_emitter(op_ia32_AndMem8Bit, bemit_andmem8bit); + be_set_emitter(op_ia32_Asm, emit_ia32_Asm); // TODO implement binary emitter + be_set_emitter(op_ia32_Breakpoint, bemit_int3); + be_set_emitter(op_ia32_Bsf, bemit_bsf); + be_set_emitter(op_ia32_Bsr, bemit_bsr); + be_set_emitter(op_ia32_Bswap, bemit_bswap); + be_set_emitter(op_ia32_Bt, bemit_bt); + be_set_emitter(op_ia32_CMovcc, bemit_cmovcc); + be_set_emitter(op_ia32_Call, bemit_call); + be_set_emitter(op_ia32_Cltd, bemit_cltd); + be_set_emitter(op_ia32_Cmc, bemit_cmc); + be_set_emitter(op_ia32_Cmp, bemit_cmp); + be_set_emitter(op_ia32_Cmp8Bit, bemit_cmp8bit); + be_set_emitter(op_ia32_Const, bemit_mov_const); + be_set_emitter(op_ia32_Conv_I2I, bemit_conv_i2i); + be_set_emitter(op_ia32_Conv_I2I8Bit, bemit_conv_i2i); + be_set_emitter(op_ia32_CopyB_i, bemit_copybi); + be_set_emitter(op_ia32_Cwtl, bemit_cwtl); + be_set_emitter(op_ia32_Dec, bemit_dec); + be_set_emitter(op_ia32_DecMem, bemit_decmem); + be_set_emitter(op_ia32_Div, bemit_div); + be_set_emitter(op_ia32_FldCW, bemit_fldcw); + be_set_emitter(op_ia32_FnstCW, bemit_fnstcw); + be_set_emitter(op_ia32_FtstFnstsw, bemit_ftstfnstsw); + be_set_emitter(op_ia32_FucomFnstsw, bemit_fucomfnstsw); + be_set_emitter(op_ia32_Fucomi, bemit_fucomi); + be_set_emitter(op_ia32_FucomppFnstsw, bemit_fucomppfnstsw); + be_set_emitter(op_ia32_IDiv, bemit_idiv); + be_set_emitter(op_ia32_IJmp, bemit_ijmp); + be_set_emitter(op_ia32_IMul, bemit_imul); + be_set_emitter(op_ia32_IMul1OP, bemit_imul1op); + be_set_emitter(op_ia32_Inc, bemit_inc); + be_set_emitter(op_ia32_IncMem, bemit_incmem); + be_set_emitter(op_ia32_Jcc, bemit_ia32_jcc); + be_set_emitter(op_ia32_Jmp, bemit_jump); + be_set_emitter(op_ia32_LdTls, bemit_ldtls); + be_set_emitter(op_ia32_Lea, bemit_lea); + be_set_emitter(op_ia32_Leave, bemit_leave); + be_set_emitter(op_ia32_Load, bemit_load); + be_set_emitter(op_ia32_Minus64Bit, bemit_minus64bit); + be_set_emitter(op_ia32_Mul, bemit_mul); + be_set_emitter(op_ia32_Neg, bemit_neg); + be_set_emitter(op_ia32_NegMem, bemit_negmem); + be_set_emitter(op_ia32_Not, bemit_not); + be_set_emitter(op_ia32_NotMem, bemit_notmem); + be_set_emitter(op_ia32_Or, bemit_or); + be_set_emitter(op_ia32_OrMem, bemit_ormem); + be_set_emitter(op_ia32_OrMem8Bit, bemit_ormem8bit); + be_set_emitter(op_ia32_Pop, bemit_pop); + be_set_emitter(op_ia32_PopEbp, bemit_pop); + be_set_emitter(op_ia32_PopMem, bemit_popmem); + be_set_emitter(op_ia32_Popcnt, bemit_popcnt); + be_set_emitter(op_ia32_Push, bemit_push); + be_set_emitter(op_ia32_RepPrefix, bemit_rep); + be_set_emitter(op_ia32_Rol, bemit_rol); + be_set_emitter(op_ia32_RolMem, bemit_rolmem); + be_set_emitter(op_ia32_Ror, bemit_ror); + be_set_emitter(op_ia32_RorMem, bemit_rormem); + be_set_emitter(op_ia32_Sahf, bemit_sahf); + be_set_emitter(op_ia32_Sar, bemit_sar); + be_set_emitter(op_ia32_SarMem, bemit_sarmem); + be_set_emitter(op_ia32_Sbb, bemit_sbb); + be_set_emitter(op_ia32_Sbb0, bemit_sbb0); + be_set_emitter(op_ia32_Setcc, bemit_setcc); + be_set_emitter(op_ia32_Shl, bemit_shl); + be_set_emitter(op_ia32_ShlD, bemit_shld); + be_set_emitter(op_ia32_ShlMem, bemit_shlmem); + be_set_emitter(op_ia32_Shr, bemit_shr); + be_set_emitter(op_ia32_ShrD, bemit_shrd); + be_set_emitter(op_ia32_ShrMem, bemit_shrmem); + be_set_emitter(op_ia32_Stc, bemit_stc); + be_set_emitter(op_ia32_Store, bemit_store); + be_set_emitter(op_ia32_Store8Bit, bemit_store); + be_set_emitter(op_ia32_Sub, bemit_sub); + be_set_emitter(op_ia32_SubMem, bemit_submem); + be_set_emitter(op_ia32_SubMem8Bit, bemit_submem8bit); + be_set_emitter(op_ia32_SubSP, bemit_subsp); + be_set_emitter(op_ia32_SwitchJmp, bemit_switchjmp); + be_set_emitter(op_ia32_Test, bemit_test); + be_set_emitter(op_ia32_Test8Bit, bemit_test8bit); + be_set_emitter(op_ia32_Xor, bemit_xor); + be_set_emitter(op_ia32_Xor0, bemit_xor0); + be_set_emitter(op_ia32_XorMem, bemit_xormem); + be_set_emitter(op_ia32_XorMem8Bit, bemit_xormem8bit); + be_set_emitter(op_ia32_fabs, bemit_fabs); + be_set_emitter(op_ia32_fadd, bemit_fadd); + be_set_emitter(op_ia32_fchs, bemit_fchs); + be_set_emitter(op_ia32_fdiv, bemit_fdiv); + be_set_emitter(op_ia32_ffreep, bemit_ffreep); + be_set_emitter(op_ia32_fild, bemit_fild); + be_set_emitter(op_ia32_fist, bemit_fist); + be_set_emitter(op_ia32_fisttp, bemit_fisttp); + be_set_emitter(op_ia32_fld, bemit_fld); + be_set_emitter(op_ia32_fld1, bemit_fld1); + be_set_emitter(op_ia32_fldz, bemit_fldz); + be_set_emitter(op_ia32_fmul, bemit_fmul); + be_set_emitter(op_ia32_fpop, bemit_fpop); + be_set_emitter(op_ia32_fpush, bemit_fpush); + be_set_emitter(op_ia32_fpushCopy, bemit_fpushcopy); + be_set_emitter(op_ia32_fst, bemit_fst); + be_set_emitter(op_ia32_fsub, bemit_fsub); + be_set_emitter(op_ia32_fxch, bemit_fxch); /* ignore the following nodes */ - register_emitter(op_ia32_ProduceVal, emit_Nothing); - register_emitter(op_ia32_Unknown, emit_Nothing); - register_emitter(op_be_Keep, emit_Nothing); - register_emitter(op_be_Start, emit_Nothing); - register_emitter(op_Phi, emit_Nothing); - register_emitter(op_Start, emit_Nothing); + be_set_emitter(op_Phi, be_emit_nothing); + be_set_emitter(op_Start, be_emit_nothing); + be_set_emitter(op_be_Keep, be_emit_nothing); + be_set_emitter(op_be_Start, be_emit_nothing); + be_set_emitter(op_ia32_ProduceVal, be_emit_nothing); + be_set_emitter(op_ia32_Unknown, be_emit_nothing); } static void gen_binary_block(ir_node *block) diff --git a/ir/be/scripts/generate_emitter.pl b/ir/be/scripts/generate_emitter.pl index 8f1181aca..c47759dfd 100755 --- a/ir/be/scripts/generate_emitter.pl +++ b/ir/be/scripts/generate_emitter.pl @@ -100,7 +100,7 @@ foreach my $op (keys(%nodes)) { $line = "static void emit_${arch}_${op}(const ir_node *node)"; - push(@obst_register, " ${arch}_register_emitter(op_${arch}_${op}, emit_${arch}_${op});\n"); + push(@obst_register, "\tbe_set_emitter(op_${arch}_${op}, emit_${arch}_${op});\n"); if($n{"emit"} eq "") { push(@obst_func, $line."\n"); @@ -192,14 +192,6 @@ print OUT @obst_func; print OUT<ops.generic == NULL); - op->ops.generic = (op_func)func; -} - /** * Enters the emitter functions for handled nodes into the generic * pointer of an opcode. diff --git a/ir/be/sparc/sparc_emitter.c b/ir/be/sparc/sparc_emitter.c index e0b8fb72a..5d3694ce7 100644 --- a/ir/be/sparc/sparc_emitter.c +++ b/ir/be/sparc/sparc_emitter.c @@ -1266,18 +1266,6 @@ static void emit_be_Copy(const ir_node *node) } } -static void emit_nothing(const ir_node *irn) -{ - (void) irn; -} - -typedef void (*emit_func) (const ir_node *); - -static inline void set_emitter(ir_op *op, emit_func sparc_emit_node) -{ - op->ops.generic = (op_func)sparc_emit_node; -} - /** * Enters the emitter functions for handled nodes into the generic * pointer of an opcode. @@ -1290,27 +1278,27 @@ static void sparc_register_emitters(void) sparc_register_spec_emitters(); /* custom emitter */ - set_emitter(op_be_Copy, emit_be_Copy); - set_emitter(op_be_CopyKeep, emit_be_Copy); - set_emitter(op_be_IncSP, emit_be_IncSP); - set_emitter(op_be_MemPerm, emit_be_MemPerm); - set_emitter(op_be_Perm, emit_be_Perm); - set_emitter(op_sparc_Ba, emit_sparc_Ba); - set_emitter(op_sparc_Bicc, emit_sparc_Bicc); - set_emitter(op_sparc_Call, emit_sparc_Call); - set_emitter(op_sparc_fbfcc, emit_sparc_fbfcc); - set_emitter(op_sparc_FrameAddr, emit_sparc_FrameAddr); - set_emitter(op_sparc_SubSP, emit_sparc_SubSP); - set_emitter(op_sparc_Restore, emit_sparc_Restore); - set_emitter(op_sparc_Return, emit_sparc_Return); - set_emitter(op_sparc_SDiv, emit_sparc_SDiv); - set_emitter(op_sparc_SwitchJmp, emit_sparc_SwitchJmp); - set_emitter(op_sparc_UDiv, emit_sparc_UDiv); + be_set_emitter(op_be_Copy, emit_be_Copy); + be_set_emitter(op_be_CopyKeep, emit_be_Copy); + be_set_emitter(op_be_IncSP, emit_be_IncSP); + be_set_emitter(op_be_MemPerm, emit_be_MemPerm); + be_set_emitter(op_be_Perm, emit_be_Perm); + be_set_emitter(op_sparc_Ba, emit_sparc_Ba); + be_set_emitter(op_sparc_Bicc, emit_sparc_Bicc); + be_set_emitter(op_sparc_Call, emit_sparc_Call); + be_set_emitter(op_sparc_FrameAddr, emit_sparc_FrameAddr); + be_set_emitter(op_sparc_Restore, emit_sparc_Restore); + be_set_emitter(op_sparc_Return, emit_sparc_Return); + be_set_emitter(op_sparc_SDiv, emit_sparc_SDiv); + be_set_emitter(op_sparc_SubSP, emit_sparc_SubSP); + be_set_emitter(op_sparc_SwitchJmp, emit_sparc_SwitchJmp); + be_set_emitter(op_sparc_UDiv, emit_sparc_UDiv); + be_set_emitter(op_sparc_fbfcc, emit_sparc_fbfcc); /* no need to emit anything for the following nodes */ - set_emitter(op_be_Keep, emit_nothing); - set_emitter(op_sparc_Start, emit_nothing); - set_emitter(op_Phi, emit_nothing); + be_set_emitter(op_Phi, be_emit_nothing); + be_set_emitter(op_be_Keep, be_emit_nothing); + be_set_emitter(op_sparc_Start, be_emit_nothing); } /** @@ -1321,7 +1309,7 @@ static void sparc_emit_node(const ir_node *node) ir_op *op = get_irn_op(node); if (op->ops.generic) { - emit_func func = (emit_func) op->ops.generic; + emit_func *func = (emit_func*)op->ops.generic; be_dwarf_location(get_irn_dbg_info(node)); (*func) (node); } else {