Add static size report when using -fstack-usage for ARM targets

Thomas Klein th.r.klein@web.de
Mon Nov 22 08:49:00 GMT 2010


Hello

With GCC 4.6 a new switch -fstack-usage has been added.
Some target architectures have support for this.
To give ARM targets support for this feature only a few lines of code 
are missing.
Is it possible to add this or something similar?

regards
   Thomas


2010-11-21  Thomas Klein <th.r.klein@web.de>

     * config/arm/arm.c (arm_expand_prologue): Report the static  ..
     * config/arm/arm.c (thumb1_expand_prologue): .. stack size if 
-fstack-usage is used.

Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c        (revision 167002)
+++ gcc/config/arm/arm.c        (working copy)
@@ -15722,6 +15722,13 @@ arm_expand_prologue (void)
         }
      }

+  if (flag_stack_usage)
+    {
+      HOST_WIDE_INT stack_size = saved_regs;
Hello

With GCC 4.6 a new switch -fstack-usage has been added.
Some target architectures have support for this.
To give ARM targets support for this feature only a few lines of code 
are missing.
Is it possible to add this or something similar?

Regards
   Thomas


2010-11-21  Thomas Klein <th.r.klein@web.de>

     * config/arm/arm.c (arm_expand_prologue): Report the static  ..
     * config/arm/arm.c (thumb1_expand_prologue): .. stack size if 
-fstack-usage is used.

Index: gcc/config/arm/arm.c
===================================================================
--- gcc/config/arm/arm.c        (revision 167002)
+++ gcc/config/arm/arm.c        (working copy)
@@ -15722,6 +15722,13 @@ arm_expand_prologue (void)
         }
      }

+  if (flag_stack_usage)
+    {
+      HOST_WIDE_INT stack_size = saved_regs;
+      current_function_static_stack_size = stack_size;
+    }
+
+
    if (offsets->outgoing_args != offsets->saved_args + saved_regs)
      {
        /* This add can produce multiple insns for a large constant, so we
@@ -15733,6 +15740,12 @@ arm_expand_prologue (void)

        insn = emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
                                     amount));
+      if (flag_stack_usage)
+        {
+           HOST_WIDE_INT stack_size = offsets->outgoing_args - 
(offsets->saved_args + saved_regs);
+           current_function_static_stack_size += stack_size;
+        }
+
        do
         {
           last = last ? NEXT_INSN (last) : get_insns ();
@@ -20535,6 +20548,10 @@ thumb1_expand_prologue (void)
                     stack_pointer_rtx);

    amount = offsets->outgoing_args - offsets->saved_regs;
+  if (flag_stack_usage)
+    {
+       current_function_static_stack_size = amount;
+    }
    amount -= 4 * thumb1_extra_regs_pushed (offsets, true);
    if (amount)
      {
+      current_function_static_stack_size = stack_size;
+    }
+
+
    if (offsets->outgoing_args != offsets->saved_args + saved_regs)
      {
        /* This add can produce multiple insns for a large constant, so we
@@ -15733,6 +15740,12 @@ arm_expand_prologue (void)

        insn = emit_insn (gen_addsi3 (stack_pointer_rtx, stack_pointer_rtx,
                                     amount));
+      if (flag_stack_usage)
+        {
+           HOST_WIDE_INT stack_size = offsets->outgoing_args - 
(offsets->saved_args + saved_regs);
+           current_function_static_stack_size += stack_size;
+        }
+
        do
         {
           last = last ? NEXT_INSN (last) : get_insns ();
@@ -20535,6 +20548,10 @@ thumb1_expand_prologue (void)
                     stack_pointer_rtx);

    amount = offsets->outgoing_args - offsets->saved_regs;
+  if (flag_stack_usage)
+    {
+       current_function_static_stack_size = amount;
+    }
    amount -= 4 * thumb1_extra_regs_pushed (offsets, true);
    if (amount)
      {



More information about the Gcc mailing list