m68k.c (output_function_prologue): Add dwarf2 support.
authorAndreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Mon, 22 Sep 1997 17:46:38 +0000 (17:46 +0000)
committerJeff Law <law@gcc.gnu.org>
Mon, 22 Sep 1997 17:46:38 +0000 (11:46 -0600)
        * m68k.c (output_function_prologue): Add dwarf2 support.

        * m68k.h (INCOMING_RETURN_ADDR_RTX, DWARF_FRAME_REGNUM,
        INCOMING_FRAME_SP_OFFSET): New definitions.

From-SVN: r15631

gcc/ChangeLog
gcc/config/m68k/m68k.c
gcc/config/m68k/m68k.h

index e421b20bf27badbd9ca4bb08dd65c8619a18dc5b..3ba7d13f2277c5f5e83e4148c4eb4779246356ca 100644 (file)
@@ -1,3 +1,10 @@
+1997-09-21  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+       * m68k.c (output_function_prologue): Add dwarf2 support.
+
+       * m68k.h (INCOMING_RETURN_ADDR_RTX, DWARF_FRAME_REGNUM,
+       INCOMING_FRAME_SP_OFFSET): New definitions.
 Mon Sep 22 11:36:42 1997  David S. Miller  <davem@tanya.rutgers.edu>
 
        * combine.c (try_combine): Use NULL_RTX instead of '0' where
index 781e11cf65cb3e31cf6f471e127cfe5b0556fc6d..e8e08f9cb821faeb4edebdf58c1cd2266926c0f0 100644 (file)
@@ -164,6 +164,7 @@ output_function_prologue (stream, size)
   int num_saved_regs = 0;
   extern char call_used_regs[];
   int fsize = (size + 3) & -4;
+  int cfa_offset = INCOMING_FRAME_SP_OFFSET, cfa_store_offset = cfa_offset;
   
 
   if (frame_pointer_needed)
@@ -212,6 +213,15 @@ output_function_prologue (stream, size)
                       reg_names[FRAME_POINTER_REGNUM], -fsize);
 #endif
        }
+      if (dwarf2out_do_frame ())
+       {
+         char *l = (char *) dwarf2out_cfi_label ();
+         cfa_store_offset += 4;
+         cfa_offset = cfa_store_offset;
+         dwarf2out_def_cfa (l, FRAME_POINTER_REGNUM, cfa_offset);
+         dwarf2out_reg_save (l, FRAME_POINTER_REGNUM, -cfa_store_offset);
+         cfa_store_offset += fsize;
+       }
     }
   else if (fsize)
     {
@@ -282,6 +292,12 @@ output_function_prologue (stream, size)
          asm_fprintf (stream, "\taddl %0I%d,%Rsp\n", - (fsize + 4));
 #endif
        }
+      if (dwarf2out_do_frame ())
+       {
+         cfa_store_offset += fsize;
+         cfa_offset = cfa_store_offset;
+         dwarf2out_def_cfa ("", STACK_POINTER_REGNUM, cfa_offset);
+       }
     }
 #ifdef SUPPORT_SUN_FPA
   for (regno = 24; regno < 56; regno++)
@@ -294,13 +310,27 @@ output_function_prologue (stream, size)
        asm_fprintf (stream, "\tfpmoved %s,%Rsp@-\n",
                     reg_names[regno]);
 #endif
+       if (dwarf2out_do_frame ())
+         {
+           char *l = (char *) dwarf2out_cfi_label ();
+           cfa_store_offset += 8;
+           if (! frame_pointer_needed)
+             {
+               cfa_offset = cfa_store_offset;
+               dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, cfa_offset);
+             }
+           dwarf2out_reg_save (l, regno, -cfa_store_offset);
+         }
       }
 #endif
   if (TARGET_68881)
     {
       for (regno = 16; regno < 24; regno++)
        if (regs_ever_live[regno] && ! call_used_regs[regno])
-          mask |= 1 << (regno - 16);
+         {
+           mask |= 1 << (regno - 16);
+           num_saved_regs++;
+         }
       if ((mask & 0xff) != 0)
        {
 #ifdef MOTOROLA
@@ -308,8 +338,24 @@ output_function_prologue (stream, size)
 #else
          asm_fprintf (stream, "\tfmovem %0I0x%x,%Rsp@-\n", mask & 0xff);
 #endif
+         if (dwarf2out_do_frame ())
+           {
+             char *l = (char *) dwarf2out_cfi_label ();
+             int n_regs;
+             cfa_store_offset += num_saved_regs * 12;
+             if (! frame_pointer_needed)
+               {
+                 cfa_offset = cfa_store_offset;
+                 dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, cfa_offset);
+               }
+             for (regno = 16, n_regs = 0; regno < 24; regno++)
+               if (mask & (1 << (regno - 16)))
+                 dwarf2out_reg_save (l, regno,
+                                     -cfa_store_offset + n_regs++ * 12);
+           }
        }
       mask = 0;
+      num_saved_regs = 0;
     }
   for (regno = 0; regno < 16; regno++)
     if (regs_ever_live[regno] && ! call_used_regs[regno])
@@ -347,13 +393,26 @@ output_function_prologue (stream, size)
       /* Undo the work from above. */
       for (i = 0; i< 16; i++)
         if (mask & (1 << i))
-          asm_fprintf (stream,
+         {
+           asm_fprintf (stream,
 #ifdef MOTOROLA
-                      "\t%Omove.l %s,-(%Rsp)\n",
+                        "\t%Omove.l %s,-(%Rsp)\n",
 #else
-                      "\tmovel %s,%Rsp@-\n",
+                        "\tmovel %s,%Rsp@-\n",
 #endif
-                      reg_names[15 - i]);
+                        reg_names[15 - i]);
+           if (dwarf2out_do_frame ())
+             {
+               char *l = (char *) dwarf2out_cfi_label ();
+               cfa_store_offset += 4;
+               if (! frame_pointer_needed)
+                 {
+                   cfa_offset = cfa_store_offset;
+                   dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, cfa_offset);
+                 }
+               dwarf2out_reg_save (l, 15 - i, -cfa_store_offset);
+             }
+         }
     }
   else if (mask)
     {
@@ -392,6 +451,21 @@ output_function_prologue (stream, size)
          asm_fprintf (stream, "\tmoveml %0I0x%x,%Rsp@-\n", mask);
 #endif
        }
+      if (dwarf2out_do_frame ())
+       {
+         char *l = (char *) dwarf2out_cfi_label ();
+         int n_regs;
+         cfa_store_offset += num_saved_regs * 4;
+         if (! frame_pointer_needed)
+           {
+             cfa_offset = cfa_store_offset;
+             dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, cfa_offset);
+           }
+         for (regno = 0, n_regs = 0; regno < 16; regno++)
+           if (mask & (1 << (15 - regno)))
+             dwarf2out_reg_save (l, regno,
+                                 -cfa_store_offset + n_regs++ * 4);
+       }
     }
   if (flag_pic && current_function_uses_pic_offset_table)
     {
index 0ac38cb77971d4355129f72019cbeee3a105cef5..6004aaaa8030f62508e7eb70c0b8323e1c4c83ea 100644 (file)
@@ -1792,6 +1792,18 @@ __transfer_from_trampoline ()                                    \
 
 #define DBX_REGISTER_NUMBER(REGNO) ((REGNO) < 16 ? (REGNO) : (REGNO) + 2)
 
+/* Before the prologue, RA is at 0(%sp).  */
+#define INCOMING_RETURN_ADDR_RTX \
+  gen_rtx (MEM, VOIDmode, gen_rtx (REG, VOIDmode, STACK_POINTER_REGNUM))
+
+/* We must not use the DBX register numbers for the DWARF 2 CFA column
+   numbers because that maps to numbers beyond FIRST_PSEUDO_REGISTER.
+   Instead use the identity mapping.  */
+#define DWARF_FRAME_REGNUM(REG) REG
+
+/* Before the prologue, the top of the frame is at 4(%sp).  */
+#define INCOMING_FRAME_SP_OFFSET 4
+
 /* This is how to output the definition of a user-level label named NAME,
    such as the label on a static function or variable NAME.  */