This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
S/390: Generate smaller trampolines
- From: Ulrich Weigand <weigand at i1 dot informatik dot uni-erlangen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 11 Oct 2004 20:29:40 +0200 (CEST)
- Subject: S/390: Generate smaller trampolines
Hello,
this cleans up trampoline code generation a bit; we now generate the
same code as libffi does (which is 4 bytes shorter).
Bootstrapped/regtested on s390-ibm-linux and s390x-ibm-linux,
committed to mainline.
Bye,
Ulrich
ChangeLog:
* config/s390/s390.c (s390_trampoline_template): Generate shorter
trampoline code.
(s390_trampoline_instantiate): Adapt.
* config/s390/s390.h (TRAMPOLINE_SIZE): Adapt to new code.
Index: gcc/config/s390/s390.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.c,v
retrieving revision 1.190
diff -c -p -r1.190 s390.c
*** gcc/config/s390/s390.c 11 Oct 2004 14:33:23 -0000 1.190
--- gcc/config/s390/s390.c 11 Oct 2004 15:04:41 -0000
*************** s390_expand_builtin (tree exp, rtx targe
*** 7825,7847 ****
void
s390_trampoline_template (FILE *file)
{
if (TARGET_64BIT)
{
! fprintf (file, "larl\t%s,0f\n", reg_names[1]);
! fprintf (file, "lg\t%s,0(%s)\n", reg_names[0], reg_names[1]);
! fprintf (file, "lg\t%s,8(%s)\n", reg_names[1], reg_names[1]);
! fprintf (file, "br\t%s\n", reg_names[1]);
! fprintf (file, "0:\t.quad\t0\n");
! fprintf (file, ".quad\t0\n");
}
else
{
! fprintf (file, "basr\t%s,0\n", reg_names[1]);
! fprintf (file, "l\t%s,10(%s)\n", reg_names[0], reg_names[1]);
! fprintf (file, "l\t%s,14(%s)\n", reg_names[1], reg_names[1]);
! fprintf (file, "br\t%s\n", reg_names[1]);
! fprintf (file, ".long\t0\n");
! fprintf (file, ".long\t0\n");
}
}
--- 7825,7847 ----
void
s390_trampoline_template (FILE *file)
{
+ rtx op[2];
+ op[0] = gen_rtx_REG (Pmode, 0);
+ op[1] = gen_rtx_REG (Pmode, 1);
+
if (TARGET_64BIT)
{
! output_asm_insn ("basr\t%1,0", op);
! output_asm_insn ("lmg\t%0,%1,14(%1)", op);
! output_asm_insn ("br\t%1", op);
! ASM_OUTPUT_SKIP (file, (HOST_WIDE_INT)(TRAMPOLINE_SIZE - 10));
}
else
{
! output_asm_insn ("basr\t%1,0", op);
! output_asm_insn ("lm\t%0,%1,6(%1)", op);
! output_asm_insn ("br\t%1", op);
! ASM_OUTPUT_SKIP (file, (HOST_WIDE_INT)(TRAMPOLINE_SIZE - 8));
}
}
*************** s390_initialize_trampoline (rtx addr, rt
*** 7854,7863 ****
{
emit_move_insn (gen_rtx_MEM (Pmode,
memory_address (Pmode,
! plus_constant (addr, (TARGET_64BIT ? 20 : 12) ))), cxt);
emit_move_insn (gen_rtx_MEM (Pmode,
memory_address (Pmode,
! plus_constant (addr, (TARGET_64BIT ? 28 : 16) ))), fnaddr);
}
/* Return rtx for 64-bit constant formed from the 32-bit subwords
--- 7854,7863 ----
{
emit_move_insn (gen_rtx_MEM (Pmode,
memory_address (Pmode,
! plus_constant (addr, (TARGET_64BIT ? 16 : 8)))), cxt);
emit_move_insn (gen_rtx_MEM (Pmode,
memory_address (Pmode,
! plus_constant (addr, (TARGET_64BIT ? 24 : 12)))), fnaddr);
}
/* Return rtx for 64-bit constant formed from the 32-bit subwords
Index: gcc/config/s390/s390.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/s390/s390.h,v
retrieving revision 1.125
diff -c -p -r1.125 s390.h
*** gcc/config/s390/s390.h 8 Oct 2004 16:28:48 -0000 1.125
--- gcc/config/s390/s390.h 11 Oct 2004 15:04:41 -0000
*************** CUMULATIVE_ARGS;
*** 730,736 ****
/* Trampolines for nested functions. */
! #define TRAMPOLINE_SIZE (TARGET_64BIT ? 36 : 20)
#define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, CXT) \
s390_initialize_trampoline ((ADDR), (FNADDR), (CXT))
--- 730,736 ----
/* Trampolines for nested functions. */
! #define TRAMPOLINE_SIZE (TARGET_64BIT ? 32 : 16)
#define INITIALIZE_TRAMPOLINE(ADDR, FNADDR, CXT) \
s390_initialize_trampoline ((ADDR), (FNADDR), (CXT))
--
Dr. Ulrich Weigand
weigand@informatik.uni-erlangen.de