This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[m68k patch] Fix fpu related frame computation and its usage
- From: Gunther Nikl <gni at gecko dot de>
- To: Bernardo Innocenti <bernie at develer dot com>
- Cc: Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Tue, 21 Oct 2003 15:13:20 +0200
- Subject: [m68k patch] Fix fpu related frame computation and its usage
Hello!
While fixing the prologue and epilogue generation functions in m68k.c
I noticed that the fpu related frame information might be used without
computing it. This is another bug/regression from the patch that switched
to use the computed values from m68k_compute_frame_layout.
The attached patch ensures that the fpu frame information is always
valid and adapts its usage in m68k_output_function_prologue to match
m68k_output_function_epilogue. This patch needs
http://gcc.gnu.org/ml/gcc-patches/2003-10/msg01832.html
and
http://gcc.gnu.org/ml/gcc-patches/2003-10/msg01833.html
as prerequisite.
Gunther
-- cut --
2003-10-21 Gunther Nikl <gni@gecko.de>
* config/m68k/m68k.c (m68k_compute_frame_layout): Ensure fpu related
frame information is always valid.
(m68k_output_function_prologue): Remove superfluous TARGET_68881
test; fix formatting.
--- m68k.c.orig Tue Oct 21 14:54:03 2003
+++ m68k.c Tue Oct 21 14:54:07 2003
@@ -352,9 +352,10 @@ m68k_compute_frame_layout (void)
current_frame.reg_mask = mask;
current_frame.reg_rev_mask = rmask;
+ current_frame.foffset = 0;
+ mask = rmask = saved = 0;
if (TARGET_68881 /* || TARGET_CFV4E */)
{
- mask = rmask = saved = 0;
for (regno = 16; regno < 24; regno++)
if (m68k_save_reg (regno, interrupt_handler))
{
@@ -364,10 +365,10 @@ m68k_compute_frame_layout (void)
}
current_frame.foffset = saved * 12 /* (TARGET_CFV4E ? 8 : 12) */;
current_frame.offset += current_frame.foffset;
- current_frame.fpu_no = saved;
- current_frame.fpu_mask = mask;
- current_frame.fpu_rev_mask = rmask;
}
+ current_frame.fpu_no = saved;
+ current_frame.fpu_mask = mask;
+ current_frame.fpu_rev_mask = rmask;
/* Remember what function this frame refers to. */
current_frame.funcdef_no = current_function_funcdef_no;
@@ -606,28 +607,24 @@ m68k_output_function_prologue (FILE *str
}
} /* !frame_pointer_needed */
- if (TARGET_68881)
+ if (current_frame.fpu_mask)
{
- if (current_frame.fpu_mask)
- {
#ifdef MOTOROLA
- asm_fprintf (stream, "\tfmovm %I0x%x,-(%Rsp)\n", current_frame.fpu_mask);
+ asm_fprintf (stream, "\tfmovm %I0x%x,-(%Rsp)\n", current_frame.fpu_mask);
#else
- asm_fprintf (stream, "\tfmovem %I0x%x,%Rsp@-\n", current_frame.fpu_mask);
+ asm_fprintf (stream, "\tfmovem %I0x%x,%Rsp@-\n", current_frame.fpu_mask);
#endif
- if (dwarf2out_do_frame ())
- {
- char *l = (char *) dwarf2out_cfi_label ();
- int n_regs, regno;
+ if (dwarf2out_do_frame ())
+ {
+ char *l = (char *) dwarf2out_cfi_label ();
+ int n_regs, regno;
- cfa_offset += current_frame.fpu_no * 12;
- if (! frame_pointer_needed)
- dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, cfa_offset);
- for (regno = 16, n_regs = 0; regno < 24; regno++)
- if (current_frame.fpu_mask & (1 << (regno - 16)))
- dwarf2out_reg_save (l, regno,
- -cfa_offset + n_regs++ * 12);
- }
+ cfa_offset += current_frame.fpu_no * 12;
+ if (! frame_pointer_needed)
+ dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, cfa_offset);
+ for (regno = 16, n_regs = 0; regno < 24; regno++)
+ if (current_frame.fpu_mask & (1 << (regno - 16)))
+ dwarf2out_reg_save (l, regno, -cfa_offset + n_regs++ * 12);
}
}
@@ -713,8 +710,7 @@ m68k_output_function_prologue (FILE *str
dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, cfa_offset);
for (regno = 0, n_regs = 0; regno < 16; regno++)
if (current_frame.reg_mask & (1 << regno))
- dwarf2out_reg_save (l, regno,
- -cfa_offset + n_regs++ * 4);
+ dwarf2out_reg_save (l, regno, -cfa_offset + n_regs++ * 4);
}
}
if (!TARGET_SEP_DATA && flag_pic &&
-- cut --