OSDN Git Service

* config/sh/linux-unwind.h (SH_DWARF_FRAME_XD0): Remove for SH5.
authorkkojima <kkojima@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Jun 2005 23:57:25 +0000 (23:57 +0000)
committerkkojima <kkojima@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 6 Jun 2005 23:57:25 +0000 (23:57 +0000)
(SH_DWARF_FRAME_PR, SH_DWARF_FRAME_GBR, SH_DWARF_FRAME_MACL)
(SH_DWARF_FRAME_MACH, SH_DWARF_FRAME_PC, SH_DWARF_FRAME_FPUL):
Likewise.
(SH_DWARF_FRAME_FP0, SH_DWARF_FRAME_FPSCR): Define to the correct
dwarf register number for SHmedia.
(shmedia_fallback_frame_state): New.
(MD_FALLBACK_FRAME_STATE_FOR): Define to it for SH5.

* config/sh/linux.h (FUNCTION_PROFILER): Provide SHMEDIA version.

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

gcc/ChangeLog
gcc/config/sh/linux-unwind.h
gcc/config/sh/linux.h

index 7d5f07c..c573cea 100644 (file)
@@ -1,3 +1,16 @@
+2005-06-06  Kaz Kojima  <kkojima@gcc.gnu.org>
+
+       * config/sh/linux-unwind.h (SH_DWARF_FRAME_XD0): Remove for SH5.
+       (SH_DWARF_FRAME_PR, SH_DWARF_FRAME_GBR, SH_DWARF_FRAME_MACL)
+       (SH_DWARF_FRAME_MACH, SH_DWARF_FRAME_PC, SH_DWARF_FRAME_FPUL):
+       Likewise.
+       (SH_DWARF_FRAME_FP0, SH_DWARF_FRAME_FPSCR): Define to the correct
+       dwarf register number for SHmedia.
+       (shmedia_fallback_frame_state): New.
+       (MD_FALLBACK_FRAME_STATE_FOR): Define to it for SH5.
+
+       * config/sh/linux.h (FUNCTION_PROFILER): Provide SHMEDIA version.
+
 2005-06-06  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        * c-lex.c (lex_string): Use XOBFINISH.
index 6ca9d56..ab149d3 100644 (file)
@@ -35,18 +35,11 @@ Boston, MA 02111-1307, USA.  */
 
 # if defined (__SH5__)
 #define SH_DWARF_FRAME_GP0     0
-#define SH_DWARF_FRAME_FP0     (__SH5__ == 32 ? 245 : 77)
-#define SH_DWARF_FRAME_XD0     289
+#define SH_DWARF_FRAME_FP0     77
 #define SH_DWARF_FRAME_BT0     68
-#define SH_DWARF_FRAME_PR      241
 #define SH_DWARF_FRAME_PR_MEDIA        18
-#define SH_DWARF_FRAME_GBR     238
-#define SH_DWARF_FRAME_MACH    239
-#define SH_DWARF_FRAME_MACL    240
-#define SH_DWARF_FRAME_PC      64
 #define SH_DWARF_FRAME_SR      65
-#define SH_DWARF_FRAME_FPUL    244
-#define SH_DWARF_FRAME_FPSCR   243
+#define SH_DWARF_FRAME_FPSCR   76
 #else
 #define SH_DWARF_FRAME_GP0     0
 #define SH_DWARF_FRAME_FP0     25
@@ -62,7 +55,88 @@ Boston, MA 02111-1307, USA.  */
 #endif /* defined (__SH5__) */
 
 #if defined (__SH5__)
-/* MD_FALLBACK_FRAME_STATE_FOR is not yet defined for SHMEDIA.  */
+
+#define MD_FALLBACK_FRAME_STATE_FOR shmedia_fallback_frame_state
+
+static _Unwind_Reason_Code
+shmedia_fallback_frame_state (struct _Unwind_Context *context,
+                             _Unwind_FrameState *fs)
+{
+  unsigned char *pc = context->ra;
+  struct sigcontext *sc;
+  long new_cfa;
+  int i, r;
+
+  /* movi 0x10,r9; shori 0x77,r9; trapa        r9; nop (sigreturn)  */
+  /* movi 0x10,r9; shori 0xad,r9; trapa        r9; nop (rt_sigreturn)  */
+  if ((*(unsigned long *) (pc-1)  == 0xcc004090)
+      && (*(unsigned long *) (pc+3)  == 0xc801dc90)
+      && (*(unsigned long *) (pc+7)  == 0x6c91fff0)
+      && (*(unsigned long *) (pc+11)  == 0x6ff0fff0))
+    sc = context->cfa;
+  else if ((*(unsigned long *) (pc-1)  == 0xcc004090)
+          && (*(unsigned long *) (pc+3)  == 0xc802b490)
+          && (*(unsigned long *) (pc+7)  == 0x6c91fff0)
+          && (*(unsigned long *) (pc+11)  == 0x6ff0fff0))
+    {
+      struct rt_sigframe {
+       struct siginfo *pinfo;
+       void *puc;
+       struct siginfo info;
+       struct ucontext uc;
+      } *rt_ = context->cfa;
+      sc = (struct sigcontext *) &rt_->uc.uc_mcontext;
+    }
+  else
+    return _URC_END_OF_STACK;
+
+  new_cfa = sc->sc_regs[15];
+  fs->cfa_how = CFA_REG_OFFSET;
+  fs->cfa_reg = 15;
+  fs->cfa_offset = new_cfa - (long) context->cfa;
+
+  for (i = 0; i < 63; i++)
+    {
+      if (i == 15)
+       continue;
+
+      fs->regs.reg[i].how = REG_SAVED_OFFSET;
+      fs->regs.reg[i].loc.offset
+       = (long)&(sc->sc_regs[i]) - new_cfa;
+    }
+
+  fs->regs.reg[SH_DWARF_FRAME_SR].how = REG_SAVED_OFFSET;
+  fs->regs.reg[SH_DWARF_FRAME_SR].loc.offset
+    = (long)&(sc->sc_sr) - new_cfa;
+
+  r = SH_DWARF_FRAME_BT0;
+  for (i = 0; i < 8; i++)
+    {
+      fs->regs.reg[r+i].how = REG_SAVED_OFFSET;
+      fs->regs.reg[r+i].loc.offset
+       = (long)&(sc->sc_tregs[i]) - new_cfa;
+    }
+
+  r = SH_DWARF_FRAME_FP0;
+  for (i = 0; i < 32; i++)
+    {
+      fs->regs.reg[r+i].how = REG_SAVED_OFFSET;
+      fs->regs.reg[r+i].loc.offset
+       = (long)&(sc->sc_fpregs[i]) - new_cfa;
+    }
+
+  fs->regs.reg[SH_DWARF_FRAME_FPSCR].how = REG_SAVED_OFFSET;
+  fs->regs.reg[SH_DWARF_FRAME_FPSCR].loc.offset
+    = (long)&(sc->sc_fpscr) - new_cfa;
+
+  /* We use the slot for the zero register to save return address.  */
+  fs->regs.reg[63].how = REG_SAVED_OFFSET;
+  fs->regs.reg[63].loc.offset
+    = (long)&(sc->sc_pc) - new_cfa;
+  fs->retaddr_column = 63;
+  return _URC_NO_REASON;
+}
+
 #else /* defined (__SH5__) */
 
 #define MD_FALLBACK_FRAME_STATE_FOR sh_fallback_frame_state
index fe48d0c..51d52eb 100644 (file)
@@ -68,29 +68,56 @@ Boston, MA 02111-1307, USA.  */
 #undef FUNCTION_PROFILER
 #define FUNCTION_PROFILER(STREAM,LABELNO)                              \
   do {                                                                 \
-    if (flag_pic)                                                      \
+    if (TARGET_SHMEDIA)                                                        \
       {                                                                        \
-       fprintf (STREAM, "\tmov.l\t3f,r1\n");                           \
-       fprintf (STREAM, "\tmova\t3f,r0\n");                            \
-       fprintf (STREAM, "\tadd\tr1,r0\n");                             \
-       fprintf (STREAM, "\tmov.l\t1f,r1\n");                           \
-       fprintf (STREAM, "\tmov.l\t@(r0,r1),r1\n");                     \
+       fprintf (STREAM, "\tpt\t1f,tr1\n");                             \
+       fprintf (STREAM, "\taddi.l\tr15,-8,r15\n");                     \
+       fprintf (STREAM, "\tst.l\tr15,0,r18\n");                        \
+       if (flag_pic)                                                   \
+         {                                                             \
+           char *gofs = "(datalabel _GLOBAL_OFFSET_TABLE_-(0f-.))";    \
+           fprintf (STREAM, "\tmovi\t((%s>>16)&0xffff),r21\n", gofs);  \
+           fprintf (STREAM, "\tshori\t(%s & 0xffff),r21\n", gofs);     \
+           fprintf (STREAM, "0:\tptrel/u\tr21,tr0\n");                 \
+           fprintf (STREAM, "\tmovi\t((mcount@GOTPLT)&0xffff),r22\n"); \
+           fprintf (STREAM, "\tgettr\ttr0,r21\n");                     \
+           fprintf (STREAM, "\tadd.l\tr21,r22,r21\n");                 \
+           fprintf (STREAM, "\tld.l\tr21,0,r21\n");                    \
+           fprintf (STREAM, "\tptabs\tr21,tr0\n");                     \
+         }                                                             \
+       else                                                            \
+         fprintf (STREAM, "\tpt\tmcount,tr0\n");                       \
+       fprintf (STREAM, "\tgettr\ttr1,r18\n");                         \
+       fprintf (STREAM, "\tblink\ttr0,r63\n");                         \
+       fprintf (STREAM, "1:\tld.l\tr15,0,r18\n");                      \
+       fprintf (STREAM, "\taddi.l\tr15,8,r15\n");                      \
       }                                                                        \
     else                                                               \
-      fprintf (STREAM, "\tmov.l\t1f,r1\n");                            \
-    fprintf (STREAM, "\tsts.l\tpr,@-r15\n");                           \
-    fprintf (STREAM, "\tmova\t2f,r0\n");                               \
-    fprintf (STREAM, "\tjmp\t@r1\n");                                  \
-    fprintf (STREAM, "\tlds\tr0,pr\n");                                        \
-    fprintf (STREAM, "\t.align\t2\n");                                 \
-    if (flag_pic)                                                      \
       {                                                                        \
-       fprintf (STREAM, "1:\t.long\tmcount@GOT\n");                    \
-       fprintf (STREAM, "3:\t.long\t_GLOBAL_OFFSET_TABLE_\n");         \
+       if (flag_pic)                                                   \
+         {                                                             \
+           fprintf (STREAM, "\tmov.l\t3f,r1\n");                       \
+           fprintf (STREAM, "\tmova\t3f,r0\n");                        \
+           fprintf (STREAM, "\tadd\tr1,r0\n");                         \
+           fprintf (STREAM, "\tmov.l\t1f,r1\n");                       \
+           fprintf (STREAM, "\tmov.l\t@(r0,r1),r1\n");                 \
+         }                                                             \
+       else                                                            \
+         fprintf (STREAM, "\tmov.l\t1f,r1\n");                         \
+       fprintf (STREAM, "\tsts.l\tpr,@-r15\n");                        \
+       fprintf (STREAM, "\tmova\t2f,r0\n");                            \
+       fprintf (STREAM, "\tjmp\t@r1\n");                               \
+       fprintf (STREAM, "\tlds\tr0,pr\n");                             \
+       fprintf (STREAM, "\t.align\t2\n");                              \
+       if (flag_pic)                                                   \
+         {                                                             \
+           fprintf (STREAM, "1:\t.long\tmcount@GOT\n");                \
+           fprintf (STREAM, "3:\t.long\t_GLOBAL_OFFSET_TABLE_\n");     \
+         }                                                             \
+       else                                                            \
+         fprintf (STREAM, "1:\t.long\tmcount\n");                      \
+       fprintf (STREAM, "2:\tlds.l\t@r15+,pr\n");                      \
       }                                                                        \
-    else                                                               \
-      fprintf (STREAM, "1:\t.long\tmcount\n");                         \
-    fprintf (STREAM, "2:\tlds.l\t@r15+,pr\n");                         \
   } while (0)
 
 #define MD_UNWIND_SUPPORT "config/sh/linux-unwind.h"