m68k: cfa_offset VS cfa_store_offset

Bernardo Innocenti bernie@develer.com
Fri Sep 5 22:22:00 GMT 2003


Andreas Schwab wrote:
> Bernardo Innocenti <bernie@develer.com> writes:
> 
> 
>>Hello,
>>
>>I noticed something weird in m68k_output_function_prologue().
>>There are two different variables tracking the cfa offset,
>>but both seem to be bearing exactly the same value.
>>
>>Since they're also the same type, I was wondering if we could
>>just get rid of one of them...
>>
>>But how did that come to be? Perhaps it had some meaning before
>>other changes and simplifications made it useless?
> 
> 
> I'm pretty sure I've copied it from i386.c, see revision 1.4 of that file.

Unless I'm misreading that (very simple) code snippet, it still
seems the two separate variables were useless even there.

That code is long gone from i386.c, but here's the original diff:


diff -u -3 -p -r1.3 -r1.4
--- gcc/config/i386/i386.c	28 Aug 1997 20:04:19 -0000	1.3
+++ gcc/config/i386/i386.c	16 Sep 1997 02:07:33 -0000	1.4
@@ -1866,6 +1866,7 @@ function_prologue (file, size)
   int pic_reg_used = flag_pic && (current_function_uses_pic_offset_table
 				  || current_function_uses_const_pool);
   long tsize = get_frame_size ();
+  int cfa_offset = INCOMING_FRAME_SP_OFFSET, cfa_store_offset = cfa_offset;
 
   /* pic references don't explicitly mention pic_offset_table_rtx */
   if (TARGET_SCHEDULE_PROLOGUE)
@@ -1881,13 +1882,34 @@ function_prologue (file, size)
   if (frame_pointer_needed)
     {
       output_asm_insn ("push%L1 %1", xops); 
+      if (dwarf2out_do_frame ())
+	{
+	  char *l = (char *) dwarf2out_cfi_label ();
+	  cfa_store_offset += 4;
+	  cfa_offset = cfa_store_offset;
+	  dwarf2out_def_cfa (l, STACK_POINTER_REGNUM, cfa_offset);
+	  dwarf2out_reg_save (l, FRAME_POINTER_REGNUM, -cfa_store_offset);
+	}
       output_asm_insn (AS2 (mov%L0,%0,%1), xops); 
+      if (dwarf2out_do_frame ())
+	dwarf2out_def_cfa ("", FRAME_POINTER_REGNUM, cfa_offset);
     }
 
   if (tsize == 0)
     ;
   else if (! TARGET_STACK_PROBE || tsize < CHECK_STACK_LIMIT)
-    output_asm_insn (AS2 (sub%L0,%2,%0), xops);
+    {
+      output_asm_insn (AS2 (sub%L0,%2,%0), xops);
+      if (dwarf2out_do_frame ())
+	{
+	  cfa_store_offset += tsize;
+	  if (! frame_pointer_needed)
+	    {
+	      cfa_offset = cfa_store_offset;
+	      dwarf2out_def_cfa ("", STACK_POINTER_REGNUM, cfa_offset);
+	    }
+	}
+    }
   else 
     {
       xops[3] = gen_rtx (REG, SImode, 0);
@@ -1913,6 +1935,17 @@ function_prologue (file, size)
       {
 	xops[0] = gen_rtx (REG, SImode, regno);
 	output_asm_insn ("push%L0 %0", xops);
+	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, regno, -cfa_store_offset);
+	  }
       }
 
   if (pic_reg_used && TARGET_DEEP_BRANCH_PREDICTION)


-- 
  // Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/  http://www.develer.com/

Please don't send Word attachments - http://www.gnu.org/philosophy/no-word-attachments.html





More information about the Gcc mailing list