h8300.h (TRAMPOLINE_TEMPLATE): Remove.
authorKazu Hirata <kazu@cs.umass.edu>
Tue, 31 Dec 2002 18:31:59 +0000 (18:31 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Tue, 31 Dec 2002 18:31:59 +0000 (18:31 +0000)
* config/h8300/h8300.h (TRAMPOLINE_TEMPLATE): Remove.
(TRAMPOLINE_SIZE): Support the normal mode.
(INITIALIZE_TRAMPOLINE): Emit the entire trampoline.

From-SVN: r60705

gcc/ChangeLog
gcc/config/h8300/h8300.h

index 473aab2f9aa2e992e8fce8de6c66c6831d592dc7..333647db26683e5ddefd25fa85c00494cea2d72a 100644 (file)
@@ -1,3 +1,9 @@
+2002-12-31  Kazu Hirata  <kazu@cs.umass.edu>
+
+       * config/h8300/h8300.h (TRAMPOLINE_TEMPLATE): Remove.
+       (TRAMPOLINE_SIZE): Support the normal mode.
+       (INITIALIZE_TRAMPOLINE): Emit the entire trampoline.
+
 2002-12-31  Mark Mitchell  <mark@codesourcery.com>
 
        * c-common.h (pending_lang_change): Declare.
index 2f9ba30b3cf98da076e3728aa84a4c8b205e8512..384ddd236775230c10193fde285ec4e7640c0e2a 100644 (file)
@@ -719,54 +719,58 @@ struct cum_arg
 
 #define EXIT_IGNORE_STACK 0
 
-/* Output assembler code for a block containing the constant parts
-   of a trampoline, leaving space for the variable parts.
+/* We emit the entire trampoline with INITIALIZE_TRAMPOLINE.
+   Depending on the pointer size, we use a different trampoline.
 
-   H8/300
+   Pmode == HImode
              vvvv context
    1 0000 7903xxxx             mov.w   #0x1234,r3
    2 0004 5A00xxxx             jmp     @0x1234
              ^^^^ function
 
-   H8/300H
+   Pmode == SImode
              vvvvvvvv context
    2 0000 7A03xxxxxxxx         mov.l   #0x12345678,er3
    3 0006 5Axxxxxx             jmp     @0x123456
            ^^^^^^ function
 */
 
-#define TRAMPOLINE_TEMPLATE(FILE)                              \
-  do                                                           \
-    {                                                          \
-      if (TARGET_H8300)                                                \
-       {                                                       \
-         fprintf (FILE, "\tmov.w       #0x1234,r3\n");         \
-         fprintf (FILE, "\tjmp @0x1234\n");                    \
-       }                                                       \
-      else                                                     \
-       {                                                       \
-         fprintf (FILE, "\tmov.l       #0x12345678,er3\n");    \
-         fprintf (FILE, "\tjmp @0x123456\n");                  \
-       }                                                       \
-    }                                                          \
-  while (0)
-
 /* Length in units of the trampoline for entering a nested function.  */
 
-#define TRAMPOLINE_SIZE (TARGET_H8300 ? 8 : 12)
+#define TRAMPOLINE_SIZE ((TARGET_H8300 || TARGET_NORMAL_MODE) ? 8 : 12)
 
-/* Emit RTL insns to initialize the variable parts of a trampoline.
+/* Emit RTL insns to build a trampoline.
    FNADDR is an RTX for the address of the function's pure code.
    CXT is an RTX for the static chain value for the function.  */
 
 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                          \
-{                                                                          \
-  emit_move_insn (gen_rtx_MEM (Pmode, plus_constant ((TRAMP), 2)), CXT);    \
-  emit_move_insn (gen_rtx_MEM (Pmode, plus_constant ((TRAMP), 6)), FNADDR); \
-  if (TARGET_H8300H || TARGET_H8300S)                                      \
-    emit_move_insn (gen_rtx_MEM (QImode, plus_constant ((TRAMP), 6)),      \
-                   GEN_INT (0x5A));                                        \
-}
+  do                                                                       \
+    {                                                                      \
+      if (Pmode == HImode)                                                 \
+       {                                                                   \
+         emit_move_insn (gen_rtx_MEM (HImode, (TRAMP)), GEN_INT (0x7903)); \
+         emit_move_insn (gen_rtx_MEM (Pmode, plus_constant ((TRAMP), 2)),  \
+                         (CXT));                                           \
+         emit_move_insn (gen_rtx_MEM (Pmode, plus_constant ((TRAMP), 4)),  \
+                         GEN_INT (0x5a00));                                \
+         emit_move_insn (gen_rtx_MEM (Pmode, plus_constant ((TRAMP), 6)),  \
+                         (FNADDR));                                        \
+       }                                                                   \
+      else                                                                 \
+       {                                                                   \
+         rtx tem = gen_reg_rtx (Pmode);                                    \
+                                                                           \
+         emit_move_insn (gen_rtx_MEM (HImode, (TRAMP)), GEN_INT (0x7a03)); \
+         emit_move_insn (gen_rtx_MEM (Pmode, plus_constant ((TRAMP), 2)),  \
+                         (CXT));                                           \
+         emit_move_insn (tem, (FNADDR));                                   \
+         emit_insn (gen_andsi3 (tem, tem, GEN_INT (0x00ffffff)));          \
+         emit_insn (gen_iorsi3 (tem, tem, GEN_INT (0x5a000000)));          \
+         emit_move_insn (gen_rtx_MEM (Pmode, plus_constant ((TRAMP), 6)),  \
+                         tem);                                             \
+       }                                                                   \
+    }                                                                      \
+  while (0)
 \f
 /* Addressing modes, and classification of registers for them.  */