diff mbox

RFA: Add support for -fstack-usage to various ports

Message ID 87wpyuh9c0.fsf@redhat.com
State New
Headers show

Commit Message

Nick Clifton June 23, 2015, 12:56 p.m. UTC
Hi Guys,

  The patch below adds support for the -fstack-usage option to the BFIN,
  FT32, H8300, IQ2000 and M32C ports.  It also adjusts the expected
  output in the gcc.dg/stack-usage-1.c test for the V850 and MN10300 to
  match the actual results generated by these toolchains.

  Tested with no regressions on bfin-elf, ft32-elf, h8300-elf,
  iq2000-elf, m32c-elf, mn10300-elf and v850-elf toolchains.

  OK to apply ?

Cheers
  Nick

gcc/ChangeLog
2015-06-23  Nick Clifton  <nickc@redhat.com>

	* config/bfin/bfin.c (bfin_expand_prologue): Set
	current_function_static_stack_size if flag_stack_usage_info is
        set. 
	* config/ft32/ft32.c (ft32_expand_prologue): Likewise.
	* config/h8300/h8300.c (h8300_expand_prologue): Likewise.
	* config/iq2000/iq2000.c (iq2000_expand_prologue): Likewise.
	* config/m32c/m32c.c (m32c_emit_prologue): Likewise.

gcc/testsuite/ChangeLog
2015-06-23  Nick Clifton  <nickc@redhat.com>

	* gcc.dg/stack-usage-1.c: Add SIZE values for V850, MN10300,
	H8300 and M32R targets.

Comments

Jeff Law June 23, 2015, 1:47 p.m. UTC | #1
On 06/23/2015 06:56 AM, Nick Clifton wrote:
> Hi Guys,
>
>    The patch below adds support for the -fstack-usage option to the BFIN,
>    FT32, H8300, IQ2000 and M32C ports.  It also adjusts the expected
>    output in the gcc.dg/stack-usage-1.c test for the V850 and MN10300 to
>    match the actual results generated by these toolchains.
>
>    Tested with no regressions on bfin-elf, ft32-elf, h8300-elf,
>    iq2000-elf, m32c-elf, mn10300-elf and v850-elf toolchains.
>
>    OK to apply ?
>
> Cheers
>    Nick
>
> gcc/ChangeLog
> 2015-06-23  Nick Clifton  <nickc@redhat.com>
>
> 	* config/bfin/bfin.c (bfin_expand_prologue): Set
> 	current_function_static_stack_size if flag_stack_usage_info is
>          set.
> 	* config/ft32/ft32.c (ft32_expand_prologue): Likewise.
> 	* config/h8300/h8300.c (h8300_expand_prologue): Likewise.
> 	* config/iq2000/iq2000.c (iq2000_expand_prologue): Likewise.
> 	* config/m32c/m32c.c (m32c_emit_prologue): Likewise.
>
> gcc/testsuite/ChangeLog
> 2015-06-23  Nick Clifton  <nickc@redhat.com>
>
> 	* gcc.dg/stack-usage-1.c: Add SIZE values for V850, MN10300,
> 	H8300 and M32R targets.
OK.
jeff
diff mbox

Patch

Index: gcc/config/bfin/bfin.c
===================================================================
--- gcc/config/bfin/bfin.c	(revision 224834)
+++ gcc/config/bfin/bfin.c	(working copy)
@@ -1090,6 +1090,9 @@ 
   tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (current_function_decl));
   bool all = lookup_attribute ("saveall", attrs) != NULL_TREE;
 
+  if (flag_stack_usage_info)
+    current_function_static_stack_size = frame_size;
+
   if (fkind != SUBROUTINE)
     {
       expand_interrupt_handler_prologue (spreg, fkind, all);
Index: gcc/config/ft32/ft32.c
===================================================================
--- gcc/config/ft32/ft32.c	(revision 224834)
+++ gcc/config/ft32/ft32.c	(working copy)
@@ -456,6 +456,9 @@ 
 
   ft32_compute_frame ();
 
+  if (flag_stack_usage_info)
+    current_function_static_stack_size = cfun->machine->size_for_adjusting_sp;
+
   if (!must_link () && (cfun->machine->callee_saved_reg_size == 4))
     {
       insn =
Index: gcc/config/h8300/h8300.c
===================================================================
--- gcc/config/h8300/h8300.c	(revision 224834)
+++ gcc/config/h8300/h8300.c	(working copy)
@@ -896,6 +896,12 @@ 
 
   /* Leave room for locals.  */
   h8300_emit_stack_adjustment (-1, round_frame_size (get_frame_size ()), true);
+
+  if (flag_stack_usage_info)
+    current_function_static_stack_size
+      = round_frame_size (get_frame_size ())
+      + (__builtin_popcount (saved_regs) * UNITS_PER_WORD)
+      + (frame_pointer_needed ? UNITS_PER_WORD : 0);
 }
 
 /* Return nonzero if we can use "rts" for the function currently being
Index: gcc/config/iq2000/iq2000.c
===================================================================
--- gcc/config/iq2000/iq2000.c	(revision 224834)
+++ gcc/config/iq2000/iq2000.c	(working copy)
@@ -2072,6 +2072,9 @@ 
 	}
     }
 
+  if (flag_stack_usage_info)
+    current_function_static_stack_size = cfun->machine->total_size;
+
   emit_insn (gen_blockage ());
 }
 
Index: gcc/config/m32c/m32c.c
===================================================================
--- gcc/config/m32c/m32c.c	(revision 224834)
+++ gcc/config/m32c/m32c.c	(working copy)
@@ -4123,6 +4123,9 @@ 
       && !m32c_function_needs_enter ())
     cfun->machine->use_rts = 1;
 
+  if (flag_stack_usage_info)
+    current_function_static_stack_size = frame_size;
+  
   if (frame_size > 254)
     {
       extra_frame_size = frame_size - 254;
Index: gcc/config/m32r/m32r.c
===================================================================
--- gcc/config/m32r/m32r.c	(revision 224834)
+++ gcc/config/m32r/m32r.c	(working copy)
@@ -1665,6 +1665,9 @@ 
   if (! current_frame_info.initialized)
     m32r_compute_frame_size (get_frame_size ());
 
+  if (flag_stack_usage_info)
+    current_function_static_stack_size = current_frame_info.total_size;
+
   gmask = current_frame_info.gmask;
 
   /* These cases shouldn't happen.  Catch them now.  */
Index: gcc/testsuite/gcc.dg/stack-usage-1.c
===================================================================
--- gcc/testsuite/gcc.dg/stack-usage-1.c	(revision 224834)
+++ gcc/testsuite/gcc.dg/stack-usage-1.c	(working copy)
@@ -81,6 +81,14 @@ 
 #  define SIZE 254
 #elif defined (__nios2__)
 #  define SIZE 252
+#elif defined (__v850__)
+#define SIZE 260
+#elif defined (__mn10300__)
+#define SIZE 252
+#elif defined (__H8300SX__) || defined (__H8300S__) || defined (__H8300H__) || defined (__H8300__) 
+#define SIZE 252
+#elif defined (__M32R__)
+#define SIZE 252
 #else
 #  define SIZE 256
 #endif