From dbbdb385c4ec0ee9f2500ab53b81ae0e79ad9b5c Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 22 Sep 2009 08:14:24 -0700 Subject: [PATCH] mmix.c (TARGET_ASM_TRAMPOLINE_TEMPLATE): New. * gcc/config/mmix/mmix.c (TARGET_ASM_TRAMPOLINE_TEMPLATE): New. (TARGET_TRAMPOLINE_INIT): New. (mmix_trampoline_size): Remove. (mmix_asm_trampoline_template): Rename from mmix_trampoline_template; make static. Remove out-of-date tetra vs octa comment. (mmix_trampoline_init): Rename from mmix_initialize_trampoline; make static; update for hook parameters. * config/mmix/mmix.h (TRAMPOLINE_TEMPLATE): Remove. (INITIALIZE_TRAMPOLINE): Remove. (TRAMPOLINE_SIZE): Use a constant instead of mmix_trampoline_size. (TRAMPOLINE_ALIGNMENT): New. * gcc/config/mmix/mmix-protos.h: Update. From-SVN: r152002 --- gcc/ChangeLog | 13 +++++++++ gcc/config/mmix/mmix-protos.h | 3 --- gcc/config/mmix/mmix.c | 51 +++++++++++++++++++---------------- gcc/config/mmix/mmix.h | 9 ++----- 4 files changed, 43 insertions(+), 33 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f0a2c75d1779..efcf989ebc1a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -163,6 +163,19 @@ (INITIALIZE_TRAMPOLINE): Move code to mips_trampoline_init; update for hook parameters. + * gcc/config/mmix/mmix.c (TARGET_ASM_TRAMPOLINE_TEMPLATE): New. + (TARGET_TRAMPOLINE_INIT): New. + (mmix_trampoline_size): Remove. + (mmix_asm_trampoline_template): Rename from mmix_trampoline_template; + make static. Remove out-of-date tetra vs octa comment. + (mmix_trampoline_init): Rename from mmix_initialize_trampoline; + make static; update for hook parameters. + * config/mmix/mmix.h (TRAMPOLINE_TEMPLATE): Remove. + (INITIALIZE_TRAMPOLINE): Remove. + (TRAMPOLINE_SIZE): Use a constant instead of mmix_trampoline_size. + (TRAMPOLINE_ALIGNMENT): New. + * gcc/config/mmix/mmix-protos.h: Update. + 2009-09-22 Jakub Jelinek * config/rs6000/rs6000.c (bdesc_2arg): Fix CODE_FOR_vector_gt* codes diff --git a/gcc/config/mmix/mmix-protos.h b/gcc/config/mmix/mmix-protos.h index e839d864697a..957164b468b3 100644 --- a/gcc/config/mmix/mmix-protos.h +++ b/gcc/config/mmix/mmix-protos.h @@ -25,8 +25,6 @@ extern int mmix_initial_elimination_offset (int, int); extern int mmix_starting_frame_offset (void); extern int mmix_function_arg_regno_p (int, int); extern void mmix_function_profiler (FILE *, int); -extern void mmix_trampoline_template (FILE *); -extern int mmix_trampoline_size; extern int mmix_reversible_cc_mode (enum machine_mode); extern int mmix_register_move_cost (enum machine_mode, enum reg_class, enum reg_class); @@ -80,7 +78,6 @@ extern rtx mmix_dynamic_chain_address (rtx); extern rtx mmix_return_addr_rtx (int, rtx); extern rtx mmix_eh_return_stackadj_rtx (void); extern rtx mmix_eh_return_handler_rtx (void); -extern void mmix_initialize_trampoline (rtx, rtx, rtx); extern int mmix_constant_address_p (rtx); extern int mmix_legitimate_constant_p (rtx); extern void mmix_print_operand (FILE *, rtx, int); diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index 8521f374f810..b589db96ea68 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -141,6 +141,8 @@ static enum machine_mode mmix_promote_function_mode (const_tree, static bool mmix_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode, const_tree, bool); static bool mmix_frame_pointer_required (void); +static void mmix_asm_trampoline_template (FILE *); +static void mmix_trampoline_init (rtx, tree, rtx); /* Target structure macros. Listed by node. See `Using and Porting GCC' for a general description. */ @@ -212,6 +214,11 @@ static bool mmix_frame_pointer_required (void); #undef TARGET_FRAME_POINTER_REQUIRED #define TARGET_FRAME_POINTER_REQUIRED mmix_frame_pointer_required +#undef TARGET_ASM_TRAMPOLINE_TEMPLATE +#define TARGET_ASM_TRAMPOLINE_TEMPLATE mmix_asm_trampoline_template +#undef TARGET_TRAMPOLINE_INIT +#define TARGET_TRAMPOLINE_INIT mmix_trampoline_init + struct gcc_target targetm = TARGET_INITIALIZER; /* Functions that are expansions for target macros. @@ -886,46 +893,44 @@ mmix_setup_incoming_varargs (CUMULATIVE_ARGS *args_so_farp, internal_error ("MMIX Internal: Last named vararg would not fit in a register"); } -/* TRAMPOLINE_SIZE. */ -/* Four 4-byte insns plus two 8-byte values. */ -int mmix_trampoline_size = 32; +/* TARGET_ASM_TRAMPOLINE_TEMPLATE. */ - -/* TRAMPOLINE_TEMPLATE. */ - -void -mmix_trampoline_template (FILE *stream) +static void +mmix_asm_trampoline_template (FILE *stream) { /* Read a value into the static-chain register and jump somewhere. The static chain is stored at offset 16, and the function address is stored at offset 24. */ - /* FIXME: GCC copies this using *intsize* (tetra), when it should use - register size (octa). */ + fprintf (stream, "\tGETA $255,1F\n\t"); - fprintf (stream, "LDOU %s,$255,0\n\t", - reg_names[MMIX_STATIC_CHAIN_REGNUM]); + fprintf (stream, "LDOU %s,$255,0\n\t", reg_names[MMIX_STATIC_CHAIN_REGNUM]); fprintf (stream, "LDOU $255,$255,8\n\t"); fprintf (stream, "GO $255,$255,0\n"); fprintf (stream, "1H\tOCTA 0\n\t"); fprintf (stream, "OCTA 0\n"); } -/* INITIALIZE_TRAMPOLINE. */ +/* TARGET_TRAMPOLINE_INIT. */ /* Set the static chain and function pointer field in the trampoline. We also SYNCID here to be sure (doesn't matter in the simulator, but some day it will). */ -void -mmix_initialize_trampoline (rtx trampaddr, rtx fnaddr, rtx static_chain) +static void +mmix_trampoline_init (rtx m_tramp, tree fndecl, rtx static_chain) { - emit_move_insn (gen_rtx_MEM (DImode, plus_constant (trampaddr, 16)), - static_chain); - emit_move_insn (gen_rtx_MEM (DImode, - plus_constant (trampaddr, 24)), - fnaddr); - emit_insn (gen_sync_icache (validize_mem (gen_rtx_MEM (DImode, - trampaddr)), - GEN_INT (mmix_trampoline_size - 1))); + rtx fnaddr = XEXP (DECL_RTL (fndecl), 0); + rtx mem; + + emit_block_move (m_tramp, assemble_trampoline_template (), + GEN_INT (2*UNITS_PER_WORD), BLOCK_OP_NORMAL); + + mem = adjust_address (m_tramp, DImode, 2*UNITS_PER_WORD); + emit_move_insn (mem, static_chain); + mem = adjust_address (m_tramp, DImode, 3*UNITS_PER_WORD); + emit_move_insn (mem, fnaddr); + + mem = adjust_address (m_tramp, DImode, 0); + emit_insn (gen_sync_icache (mem, GEN_INT (TRAMPOLINE_SIZE - 1))); } /* We must exclude constant addresses that have an increment that is not a diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h index 41466545e21b..1e76e4609392 100644 --- a/gcc/config/mmix/mmix.h +++ b/gcc/config/mmix/mmix.h @@ -651,13 +651,8 @@ typedef struct { int regs; int lib; } CUMULATIVE_ARGS; /* Node: Trampolines */ -#define TRAMPOLINE_TEMPLATE(FILE) \ - mmix_trampoline_template (FILE) - -#define TRAMPOLINE_SIZE mmix_trampoline_size -#define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, STATIC_CHAIN) \ - mmix_initialize_trampoline (ADDR, FNADDR, STATIC_CHAIN) - +#define TRAMPOLINE_SIZE (4*UNITS_PER_WORD) +#define TRAMPOLINE_ALIGNMENT BITS_PER_WORD /* Node: Addressing Modes */