dwarf2 EH unwinding
Andreas Schwab
schwab@issan.informatik.uni-dortmund.de
Mon Sep 22 02:53:00 GMT 1997
|> There's no reason to change the CFA rule twice for the same PC. You can
|> drop the first one and use l for the second.
Ah yes, i see. Here is an updated patch that also fixes a bug with
DWARF_FRAME_REGNUM. It seems to work quite well now, except for the
problem with the register sizes.
1997-09-21 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* config/m68k/m68k.c (output_function_prologue): Add dwarf2 support.
* config/m68k/m68k.h (INCOMING_RETURN_ADDR_RTX,
DWARF_FRAME_REGNUM, INCOMING_FRAME_SP_OFFSET): New definitions.
*** egcs-970917/gcc/config/m68k/m68k.c.~1~ Wed Jul 23 18:32:34 1997
--- egcs-970917/gcc/config/m68k/m68k.c Sat Sep 20 00:01:29 1997
*************** output_function_prologue (stream, size)
*** 164,169 ****
--- 164,170 ----
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)
*************** output_function_prologue (stream, size)
*** 212,217 ****
--- 213,227 ----
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)
{
*************** output_function_prologue (stream, size)
*** 282,287 ****
--- 292,303 ----
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++)
*************** output_function_prologue (stream, size)
*** 294,306 ****
asm_fprintf (stream, "\tfpmoved %s,%Rsp@-\n",
reg_names[regno]);
#endif
}
#endif
if (TARGET_68881)
{
for (regno = 16; regno < 24; regno++)
if (regs_ever_live[regno] && ! call_used_regs[regno])
! mask |= 1 << (regno - 16);
if ((mask & 0xff) != 0)
{
#ifdef MOTOROLA
--- 310,336 ----
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);
! num_saved_regs++;
! }
if ((mask & 0xff) != 0)
{
#ifdef MOTOROLA
*************** output_function_prologue (stream, size)
*** 308,315 ****
--- 338,361 ----
#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])
*************** output_function_prologue (stream, size)
*** 347,359 ****
/* Undo the work from above. */
for (i = 0; i< 16; i++)
if (mask & (1 << i))
! asm_fprintf (stream,
#ifdef MOTOROLA
! "\t%Omove.l %s,-(%Rsp)\n",
#else
! "\tmovel %s,%Rsp@-\n",
#endif
! reg_names[15 - i]);
}
else if (mask)
{
--- 393,418 ----
/* Undo the work from above. */
for (i = 0; i< 16; i++)
if (mask & (1 << i))
! {
! asm_fprintf (stream,
#ifdef MOTOROLA
! "\t%Omove.l %s,-(%Rsp)\n",
#else
! "\tmovel %s,%Rsp@-\n",
#endif
! 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)
{
*************** output_function_prologue (stream, size)
*** 392,397 ****
--- 451,475 ----
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)
{
*** egcs-970917/gcc/config/m68k/m68k.h.~1~ Sat Sep 13 01:41:31 1997
--- egcs-970917/gcc/config/m68k/m68k.h Sun Sep 21 01:05:07 1997
*************** __transfer_from_trampoline () \
*** 1792,1797 ****
--- 1792,1809 ----
#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. */
More information about the Gcc
mailing list