Commit a1d29c8c by Richard Henderson Committed by Richard Henderson

mips.c (TARGET_ASM_TRAMPOLINE_TEMPLATE, [...]): New.

        * config/mips/mips.c (TARGET_ASM_TRAMPOLINE_TEMPLATE,
        mips_asm_trampoline_template, TARGET_TRAMPOLINE_INIT,
        mips_trampoline_init): New.
        * config/mips/mips.h (TRAMPOLINE_TEMPLATE): Move code to
        mips_asm_trampoline_template.
        (INITIALIZE_TRAMPOLINE): Move code to mips_trampoline_init;
        update for hook parameters.

From-SVN: r152001
parent 87138d8d
...@@ -155,6 +155,14 @@ ...@@ -155,6 +155,14 @@
update for hook parameters. update for hook parameters.
* config/mep/mep-protos.h (mep_init_trampoline): Remove. * config/mep/mep-protos.h (mep_init_trampoline): Remove.
* config/mips/mips.c (TARGET_ASM_TRAMPOLINE_TEMPLATE,
mips_asm_trampoline_template, TARGET_TRAMPOLINE_INIT,
mips_trampoline_init): New.
* config/mips/mips.h (TRAMPOLINE_TEMPLATE): Move code to
mips_asm_trampoline_template.
(INITIALIZE_TRAMPOLINE): Move code to mips_trampoline_init;
update for hook parameters.
2009-09-22 Jakub Jelinek <jakub@redhat.com> 2009-09-22 Jakub Jelinek <jakub@redhat.com>
* config/rs6000/rs6000.c (bdesc_2arg): Fix CODE_FOR_vector_gt* codes * config/rs6000/rs6000.c (bdesc_2arg): Fix CODE_FOR_vector_gt* codes
......
...@@ -15874,6 +15874,66 @@ mips_final_postscan_insn (FILE *file ATTRIBUTE_UNUSED, rtx insn, ...@@ -15874,6 +15874,66 @@ mips_final_postscan_insn (FILE *file ATTRIBUTE_UNUSED, rtx insn,
mips_pop_asm_switch (&mips_noat); mips_pop_asm_switch (&mips_noat);
} }
/* Implement TARGET_ASM_TRAMPOLINE_TEMPLATE. */
static void
mips_asm_trampoline_template (FILE *f)
{
if (ptr_mode == DImode)
fprintf (f, "\t.word\t0x03e0082d\t\t# dmove $1,$31\n");
else
fprintf (f, "\t.word\t0x03e00821\t\t# move $1,$31\n");
fprintf (f, "\t.word\t0x04110001\t\t# bgezal $0,.+8\n");
fprintf (f, "\t.word\t0x00000000\t\t# nop\n");
if (ptr_mode == DImode)
{
fprintf (f, "\t.word\t0xdff90014\t\t# ld $25,20($31)\n");
fprintf (f, "\t.word\t0xdfef001c\t\t# ld $15,28($31)\n");
}
else
{
fprintf (f, "\t.word\t0x8ff90010\t\t# lw $25,16($31)\n");
fprintf (f, "\t.word\t0x8fef0014\t\t# lw $15,20($31)\n");
}
fprintf (f, "\t.word\t0x03200008\t\t# jr $25\n");
if (ptr_mode == DImode)
{
fprintf (f, "\t.word\t0x0020f82d\t\t# dmove $31,$1\n");
fprintf (f, "\t.word\t0x00000000\t\t# <padding>\n");
fprintf (f, "\t.dword\t0x00000000\t\t# <function address>\n");
fprintf (f, "\t.dword\t0x00000000\t\t# <static chain value>\n");
}
else
{
fprintf (f, "\t.word\t0x0020f821\t\t# move $31,$1\n");
fprintf (f, "\t.word\t0x00000000\t\t# <function address>\n");
fprintf (f, "\t.word\t0x00000000\t\t# <static chain value>\n");
}
}
/* Implement TARGET_TRAMPOLINE_INIT. */
static void
mips_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
{
rtx fnaddr = XEXP (DECL_RTL (fndecl), 0);
rtx mem, addr, end_addr;
emit_block_move (m_tramp, assemble_trampoline_template (),
GEN_INT (TRAMPOLINE_SIZE), BLOCK_OP_NORMAL);
mem = adjust_address (m_tramp, ptr_mode, ptr_mode == DImode ? 32 : 28);
mips_emit_move (mem, force_reg (ptr_mode, fnaddr));
mem = adjust_address (mem, ptr_mode, GET_MODE_SIZE (ptr_mode));
mips_emit_move (mem, force_reg (ptr_mode, chain_value));
addr = force_reg (ptr_mode, XEXP (m_tramp, 0));
end_addr = gen_reg_rtx (ptr_mode);
emit_insn (gen_add3_insn (end_addr, addr, GEN_INT (TRAMPOLINE_SIZE)));
emit_insn (gen_clear_cache (addr, end_addr));
}
/* Initialize the GCC target structure. */ /* Initialize the GCC target structure. */
#undef TARGET_ASM_ALIGNED_HI_OP #undef TARGET_ASM_ALIGNED_HI_OP
#define TARGET_ASM_ALIGNED_HI_OP "\t.half\t" #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t"
...@@ -16054,6 +16114,11 @@ mips_final_postscan_insn (FILE *file ATTRIBUTE_UNUSED, rtx insn, ...@@ -16054,6 +16114,11 @@ mips_final_postscan_insn (FILE *file ATTRIBUTE_UNUSED, rtx insn,
#undef TARGET_CAN_ELIMINATE #undef TARGET_CAN_ELIMINATE
#define TARGET_CAN_ELIMINATE mips_can_eliminate #define TARGET_CAN_ELIMINATE mips_can_eliminate
#undef TARGET_ASM_TRAMPOLINE_TEMPLATE
#define TARGET_ASM_TRAMPOLINE_TEMPLATE mips_asm_trampoline_template
#undef TARGET_TRAMPOLINE_INIT
#define TARGET_TRAMPOLINE_INIT mips_trampoline_init
struct gcc_target targetm = TARGET_INITIALIZER; struct gcc_target targetm = TARGET_INITIALIZER;
#include "gt-mips.h" #include "gt-mips.h"
...@@ -2433,45 +2433,6 @@ typedef struct mips_args { ...@@ -2433,45 +2433,6 @@ typedef struct mips_args {
#define EXIT_IGNORE_STACK 1 #define EXIT_IGNORE_STACK 1
/* A C statement to output, on the stream FILE, assembler code for a
block of data that contains the constant parts of a trampoline.
This code should not include a label--the label is taken care of
automatically. */
#define TRAMPOLINE_TEMPLATE(STREAM) \
{ \
if (ptr_mode == DImode) \
fprintf (STREAM, "\t.word\t0x03e0082d\t\t# dmove $1,$31\n"); \
else \
fprintf (STREAM, "\t.word\t0x03e00821\t\t# move $1,$31\n"); \
fprintf (STREAM, "\t.word\t0x04110001\t\t# bgezal $0,.+8\n"); \
fprintf (STREAM, "\t.word\t0x00000000\t\t# nop\n"); \
if (ptr_mode == DImode) \
{ \
fprintf (STREAM, "\t.word\t0xdff90014\t\t# ld $25,20($31)\n"); \
fprintf (STREAM, "\t.word\t0xdfef001c\t\t# ld $15,28($31)\n"); \
} \
else \
{ \
fprintf (STREAM, "\t.word\t0x8ff90010\t\t# lw $25,16($31)\n"); \
fprintf (STREAM, "\t.word\t0x8fef0014\t\t# lw $15,20($31)\n"); \
} \
fprintf (STREAM, "\t.word\t0x03200008\t\t# jr $25\n"); \
if (ptr_mode == DImode) \
{ \
fprintf (STREAM, "\t.word\t0x0020f82d\t\t# dmove $31,$1\n"); \
fprintf (STREAM, "\t.word\t0x00000000\t\t# <padding>\n"); \
fprintf (STREAM, "\t.dword\t0x00000000\t\t# <function address>\n"); \
fprintf (STREAM, "\t.dword\t0x00000000\t\t# <static chain value>\n"); \
} \
else \
{ \
fprintf (STREAM, "\t.word\t0x0020f821\t\t# move $31,$1\n"); \
fprintf (STREAM, "\t.word\t0x00000000\t\t# <function address>\n"); \
fprintf (STREAM, "\t.word\t0x00000000\t\t# <static chain value>\n"); \
} \
}
/* A C expression for the size in bytes of the trampoline, as an /* A C expression for the size in bytes of the trampoline, as an
integer. */ integer. */
...@@ -2481,7 +2442,7 @@ typedef struct mips_args { ...@@ -2481,7 +2442,7 @@ typedef struct mips_args {
#define TRAMPOLINE_ALIGNMENT GET_MODE_BITSIZE (ptr_mode) #define TRAMPOLINE_ALIGNMENT GET_MODE_BITSIZE (ptr_mode)
/* INITIALIZE_TRAMPOLINE calls this library function to flush /* mips_trampoline_init calls this library function to flush
program and data caches. */ program and data caches. */
#ifndef CACHE_FLUSH_FUNC #ifndef CACHE_FLUSH_FUNC
...@@ -2495,25 +2456,6 @@ typedef struct mips_args { ...@@ -2495,25 +2456,6 @@ typedef struct mips_args {
LCT_NORMAL, VOIDmode, 3, ADDR, Pmode, SIZE, Pmode, \ LCT_NORMAL, VOIDmode, 3, ADDR, Pmode, SIZE, Pmode, \
GEN_INT (3), TYPE_MODE (integer_type_node)) GEN_INT (3), TYPE_MODE (integer_type_node))
/* A C statement to initialize the variable parts of a trampoline.
ADDR is an RTX for the address of the trampoline; FNADDR is an
RTX for the address of the nested function; STATIC_CHAIN is an
RTX for the static chain value that should be passed to the
function when it is called. */
#define INITIALIZE_TRAMPOLINE(ADDR, FUNC, CHAIN) \
{ \
rtx func_addr, chain_addr, end_addr; \
\
func_addr = plus_constant (ADDR, ptr_mode == DImode ? 32 : 28); \
chain_addr = plus_constant (func_addr, GET_MODE_SIZE (ptr_mode)); \
mips_emit_move (gen_rtx_MEM (ptr_mode, func_addr), FUNC); \
mips_emit_move (gen_rtx_MEM (ptr_mode, chain_addr), CHAIN); \
end_addr = gen_reg_rtx (Pmode); \
emit_insn (gen_add3_insn (end_addr, copy_rtx (ADDR), \
GEN_INT (TRAMPOLINE_SIZE))); \
emit_insn (gen_clear_cache (copy_rtx (ADDR), end_addr)); \
}
/* Addressing modes, and classification of registers for them. */ /* Addressing modes, and classification of registers for them. */
......
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