This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Commit: V850 tidy ups


Hi Guys,

  I am applying the patch below to tidy up the v850 backend a little and
  fix a few minor bugs.  

Cheers
  Nick

gcc/ChangeLog
2012-09-07  Nick Clifton  <nickc@redhat.com>

	* config/v850/v850.h (DBX_DEBUGGING_INFO): Define.
	(ASM_GENERATE_INTERNAL_LABEL): Define if not already provided.
	* config/v850/v850.c (compute_register_save_size): Always include
	the link pointer.
	(increment_stack): New function - emits insns to increment or
	decrement the stack pointer.
	(expand_prologue, expand_epilogue): Use it.
	(expand_prologue): Set the function stack size, if requested.
	(v850_debug_unwind_info): New function.
	(TARGET_DEBUG_UNWIND_INFO): Define.

Index: gcc/config/v850/v850.c
===================================================================
--- gcc/config/v850/v850.c	(revision 191074)
+++ gcc/config/v850/v850.c	(working copy)
@@ -1448,13 +1448,13 @@
   int call_p = df_regs_ever_live_p (LINK_POINTER_REGNUM);
   long reg_saved = 0;
 
-  /* Count the return pointer if we need to save it.  */
-  if (crtl->profile && !call_p)
+  /* Always save the link pointer - we cannot rely upon df_regs_ever_live_p.  */
+  if (!call_p)
     {
       df_set_regs_ever_live (LINK_POINTER_REGNUM, true);
       call_p = 1;
     }
- 
+
   /* Count space for the register saves.  */
   if (interrupt_handler)
     {
@@ -1589,6 +1589,27 @@
   return ((save_func_len + restore_func_len) < (save_normal_len + restore_normal_len));
 }
 
+static void
+increment_stack (unsigned int amount)
+{
+  rtx inc;
+
+  if (amount == 0)
+    return;
+
+  inc = GEN_INT (amount);
+
+  if (! CONST_OK_FOR_K (amount))
+    {
+      rtx reg = gen_rtx_REG (Pmode, 12);
+
+      emit_move_insn (reg, inc);
+      inc = reg;
+    }
+
+  emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, inc));
+}
+
 void
 expand_prologue (void)
 {
@@ -1605,6 +1626,9 @@
 
   actual_fsize = compute_frame_size (size, &reg_saved);
 
+  if (flag_stack_usage_info)
+    current_function_static_stack_size = actual_fsize;
+
   /* Save/setup global registers for interrupt functions right now.  */
   if (interrupt_handler)
     {
@@ -1710,9 +1734,7 @@
 	  offset = init_stack_alloc - 4;
 	  
 	  if (init_stack_alloc)
-	    emit_insn (gen_addsi3 (stack_pointer_rtx,
-				   stack_pointer_rtx,
-				   GEN_INT (- (signed) init_stack_alloc)));
+	    increment_stack (- (signed) init_stack_alloc);
 	  
 	  /* Save the return pointer first.  */
 	  if (num_save > 0 && REGNO (save_regs[num_save-1]) == LINK_POINTER_REGNUM)
@@ -1743,16 +1765,8 @@
   if (actual_fsize > init_stack_alloc)
     {
       int diff = actual_fsize - init_stack_alloc;
-      if (CONST_OK_FOR_K (-diff))
-	emit_insn (gen_addsi3 (stack_pointer_rtx,
-			       stack_pointer_rtx,
-			       GEN_INT (-diff)));
-      else
-	{
-	  rtx reg = gen_rtx_REG (Pmode, 12);
-	  emit_move_insn (reg, GEN_INT (-diff));
-	  emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx, reg));
-	}
+
+      increment_stack (- diff);
     }
 
   /* If we need a frame pointer, set it up now.  */
@@ -1837,25 +1851,10 @@
 	      rtx insn;
 
 	      actual_fsize -= alloc_stack;
-	      if (actual_fsize)
-		{
-		  if (CONST_OK_FOR_K (actual_fsize))
-		    emit_insn (gen_addsi3 (stack_pointer_rtx,
-					   stack_pointer_rtx,
-					   GEN_INT (actual_fsize)));
-		  else
-		    {
-		      rtx reg = gen_rtx_REG (Pmode, 12);
-		      emit_move_insn (reg, GEN_INT (actual_fsize));
-		      emit_insn (gen_addsi3 (stack_pointer_rtx,
-					     stack_pointer_rtx,
-					     reg));
-		    }
-		}
+	      increment_stack (actual_fsize);
 
 	      insn = emit_jump_insn (restore_all);
 	      INSN_CODE (insn) = code;
-
 	    }
 	  else
 	    restore_all = NULL_RTX;
@@ -1878,25 +1877,8 @@
 
       /* Deallocate the rest of the stack if it is > 32K.  */
       if ((unsigned int) actual_fsize > init_stack_free)
-	{
-	  int diff;
+	increment_stack (actual_fsize - init_stack_free);
 
-	  diff = actual_fsize - init_stack_free;
-
-	  if (CONST_OK_FOR_K (diff))
-	    emit_insn (gen_addsi3 (stack_pointer_rtx,
-				   stack_pointer_rtx,
-				   GEN_INT (diff)));
-	  else
-	    {
-	      rtx reg = gen_rtx_REG (Pmode, 12);
-	      emit_move_insn (reg, GEN_INT (diff));
-	      emit_insn (gen_addsi3 (stack_pointer_rtx,
-				     stack_pointer_rtx,
-				     reg));
-	    }
-	}
-
       /* Special case interrupt functions that save all registers
 	 for a call.  */
       if (interrupt_handler && ((1L << LINK_POINTER_REGNUM) & reg_saved) != 0)
@@ -1936,10 +1918,7 @@
 	    }
 
 	  /* Cut back the remainder of the stack.  */
-	  if (init_stack_free)
-	    emit_insn (gen_addsi3 (stack_pointer_rtx,
-				   stack_pointer_rtx,
-				   GEN_INT (init_stack_free)));
+	  increment_stack (init_stack_free);
 	}
 
       /* And return or use reti for interrupt handlers.  */
@@ -3088,6 +3067,15 @@
   { NULL,                0, 0, false, false, false, NULL, false }
 };
 
+static enum unwind_info_type
+v850_debug_unwind_info (void)
+{
+  return UI_NONE;
+}
+
+#undef  TARGET_DEBUG_UNWIND_INFO
+#define TARGET_DEBUG_UNWIND_INFO	v850_debug_unwind_info
+
 /* Initialize the GCC target structure.  */
 
 #undef  TARGET_MEMORY_MOVE_COST
Index: gcc/config/v850/v850.h
===================================================================
--- gcc/config/v850/v850.h	(revision 191074)
+++ gcc/config/v850/v850.h	(working copy)
@@ -786,9 +786,15 @@
 #define DEFAULT_GDB_EXTENSIONS 1
 
 /* Use stabs debugging info by default.  */
-#undef PREFERRED_DEBUGGING_TYPE
-#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
+#undef  PREFERRED_DEBUGGING_TYPE
+#define PREFERRED_DEBUGGING_TYPE  DBX_DEBUG
+#define DBX_DEBUGGING_INFO        1
 
+#ifndef ASM_GENERATE_INTERNAL_LABEL
+#define ASM_GENERATE_INTERNAL_LABEL(STRING, PREFIX, NUM)  \
+  sprintf (STRING, "*.%s%u", PREFIX, (unsigned int)(NUM))
+#endif
+
 /* Specify the machine mode that this machine uses
    for the index in the tablejump instruction.  */
 #define CASE_VECTOR_MODE (TARGET_BIG_SWITCH ? SImode : HImode)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]