OSDN Git Service

gcc/
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 9 Aug 2008 18:11:19 +0000 (18:11 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 9 Aug 2008 18:11:19 +0000 (18:11 +0000)
* config/mips/mips.h (STATIC_CHAIN_REGNUM): Remap to $15.
(FUNCTION_PROFILER): Save the static chain pointer into $2
beforehand and restore it aftewards.
(TRAMPOLINE_TEMPLATE): Adjust accordingly.  Load the target
address directly into $25 and call the function through $25;
do not clobber $3.  Pad the DImode version to cover the space
left by the deleted $25 <- $3 move.
(TRAMPOLINE_SIZE): Adjust the size of the SImode version after
the removal of the $25 <- $3 move.
(INITIALIZE_TRAMPOLINE): Update offsets accordingly.
* config/mips/sdemtk.h (FUNCTION_PROFILER): As for mips.h.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138909 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/mips/mips.h
gcc/config/mips/sdemtk.h

index 4972a7b..608a3f7 100644 (file)
@@ -1,4 +1,18 @@
 2008-08-09  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       * config/mips/mips.h (STATIC_CHAIN_REGNUM): Remap to $15.
+       (FUNCTION_PROFILER): Save the static chain pointer into $2
+       beforehand and restore it aftewards.
+       (TRAMPOLINE_TEMPLATE): Adjust accordingly.  Load the target
+       address directly into $25 and call the function through $25;
+       do not clobber $3.  Pad the DImode version to cover the space
+       left by the deleted $25 <- $3 move.
+       (TRAMPOLINE_SIZE): Adjust the size of the SImode version after
+       the removal of the $25 <- $3 move.
+       (INITIALIZE_TRAMPOLINE): Update offsets accordingly.
+       * config/mips/sdemtk.h (FUNCTION_PROFILER): As for mips.h.
+
+2008-08-09  Richard Sandiford  <rdsandiford@googlemail.com>
            Daniel Jacobowitz  <dan@codesourcery.com>
 
        * config/mips/mips.h (FUNCTION_NAME_ALREADY_DECLARED): Delete.
index 815a529..2d55104 100644 (file)
@@ -1657,7 +1657,7 @@ enum mips_code_readable_setting {
 #define FRAME_POINTER_REQUIRED (mips_frame_pointer_required ())
 
 /* Register in which static-chain is passed to a function.  */
-#define STATIC_CHAIN_REGNUM (GP_REG_FIRST + 2)
+#define STATIC_CHAIN_REGNUM (GP_REG_FIRST + 15)
 
 /* Registers used as temporaries in prologue/epilogue code.  If we're
    generating mips16 code, these registers must come from the core set
@@ -2181,6 +2181,10 @@ typedef struct mips_args {
   fprintf (FILE, "\t.set\tnoat\n");                                    \
   fprintf (FILE, "\tmove\t%s,%s\t\t# save current return address\n",   \
           reg_names[GP_REG_FIRST + 1], reg_names[GP_REG_FIRST + 31]);  \
+  /* _mcount treats $2 as the static chain register.  */               \
+  if (cfun->static_chain_decl != NULL)                                 \
+    fprintf (FILE, "\tmove\t%s,%s\n", reg_names[2],                    \
+            reg_names[STATIC_CHAIN_REGNUM]);                           \
   if (!TARGET_NEWABI)                                                  \
     {                                                                  \
       fprintf (FILE,                                                   \
@@ -2192,6 +2196,10 @@ typedef struct mips_args {
     }                                                                  \
   fprintf (FILE, "\tjal\t_mcount\n");                                   \
   fprintf (FILE, "\t.set\tat\n");                                      \
+  /* _mcount treats $2 as the static chain register.  */               \
+  if (cfun->static_chain_decl != NULL)                                 \
+    fprintf (FILE, "\tmove\t%s,%s\n", reg_names[STATIC_CHAIN_REGNUM],  \
+            reg_names[2]);                                             \
 }
 
 /* The profiler preserves all interesting registers, including $31.  */
@@ -2231,20 +2239,19 @@ typedef struct mips_args {
   fprintf (STREAM, "\t.word\t0x00000000\t\t# nop\n");                  \
   if (ptr_mode == DImode)                                              \
     {                                                                  \
-      fprintf (STREAM, "\t.word\t0xdfe30014\t\t# ld     $3,20($31)\n");        \
-      fprintf (STREAM, "\t.word\t0xdfe2001c\t\t# ld     $2,28($31)\n");        \
-      fprintf (STREAM, "\t.word\t0x0060c82d\t\t# dmove  $25,$3\n");    \
+      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\t0x8fe30014\t\t# lw     $3,20($31)\n");        \
-      fprintf (STREAM, "\t.word\t0x8fe20018\t\t# lw     $2,24($31)\n");        \
-      fprintf (STREAM, "\t.word\t0x0060c821\t\t# move   $25,$3\n");    \
+      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\t0x00600008\t\t# jr     $3\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"); \
     }                                                                  \
@@ -2259,7 +2266,7 @@ typedef struct mips_args {
 /* A C expression for the size in bytes of the trampoline, as an
    integer.  */
 
-#define TRAMPOLINE_SIZE (32 + GET_MODE_SIZE (ptr_mode) * 2)
+#define TRAMPOLINE_SIZE (ptr_mode == DImode ? 48 : 36)
 
 /* Alignment required for trampolines, in bits.  */
 
@@ -2289,7 +2296,7 @@ typedef struct mips_args {
 {                                                                          \
   rtx func_addr, chain_addr, end_addr;                                      \
                                                                            \
-  func_addr = plus_constant (ADDR, 32);                                            \
+  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);              \
index a73e7d2..f6b6097 100644 (file)
@@ -94,12 +94,20 @@ extern void mips_sync_icache (void *beg, unsigned long len);
 #define FUNCTION_PROFILER(FILE, LABELNO)                               \
   {                                                                    \
     fprintf (FILE, "\t.set\tnoat\n");                                  \
+    /* _mcount treats $2 as the static chain register.  */             \
+    if (cfun->static_chain_decl != NULL)                               \
+      fprintf (FILE, "\tmove\t%s,%s\n", reg_names[2],                  \
+              reg_names[STATIC_CHAIN_REGNUM]);                         \
     /* MIPS16 code passes saved $ra in $v1 instead of $at.  */         \
     fprintf (FILE, "\tmove\t%s,%s\n",                                  \
             reg_names[GP_REG_FIRST + (TARGET_MIPS16 ? 3 : 1)],         \
             reg_names[GP_REG_FIRST + 31]);                             \
     fprintf (FILE, "\tjal\t_mcount\n");                                        \
     fprintf (FILE, "\t.set\tat\n");                                    \
+    /* _mcount treats $2 as the static chain register.  */             \
+    if (cfun->static_chain_decl != NULL)                               \
+      fprintf (FILE, "\tmove\t%s,%s\n", reg_names[STATIC_CHAIN_REGNUM],        \
+              reg_names[2]);                                           \
   }
 
 /* ...nor does the call sequence preserve $31.  */