]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
mn10300.c (popcount): New function.
authorNick Clifton <nickc@redhat.com>
Mon, 10 Feb 2014 17:23:40 +0000 (17:23 +0000)
committerNick Clifton <nickc@gcc.gnu.org>
Mon, 10 Feb 2014 17:23:40 +0000 (17:23 +0000)
* config/mn10300/mn10300.c (popcount): New function.
(mn10300_expand_prologue): Include saved registers in stack usage
count.

From-SVN: r207665

gcc/ChangeLog
gcc/config/mn10300/mn10300.c

index 5f6252266aa750ad3319c5882f461baef7ceae0e..40af8d49a270fa3ffd8110e1cf38de6c5ccfd3b6 100644 (file)
@@ -1,3 +1,9 @@
+2014-02-10  Nick Clifton  <nickc@redhat.com>
+
+       * config/mn10300/mn10300.c (popcount): New function.
+       (mn10300_expand_prologue): Include saved registers in stack usage
+       count.
+
 2014-02-10  Jeff Law  <law@redhat.com>
 
        PR middle-end/52306
index a2133f21783c1148a5850fabced2e54f8738b7f5..eb0007767500676f74c52c7e389c234b140b4608 100644 (file)
@@ -741,16 +741,31 @@ mn10300_gen_multiple_store (unsigned int mask)
   F (emit_insn (x));
 }
 
+static inline unsigned int
+popcount (unsigned int mask)
+{
+  unsigned int count = 0;
+  
+  while (mask)
+    {
+      ++ count;
+      mask &= ~ (mask & - mask);
+    }
+  return count;
+}
+
 void
 mn10300_expand_prologue (void)
 {
   HOST_WIDE_INT size = mn10300_frame_size ();
+  unsigned int mask;
 
-  if (flag_stack_usage_info)
-    current_function_static_stack_size = size;
-
+  mask = mn10300_get_live_callee_saved_regs (NULL);
   /* If we use any of the callee-saved registers, save them now.  */
-  mn10300_gen_multiple_store (mn10300_get_live_callee_saved_regs (NULL));
+  mn10300_gen_multiple_store (mask);
+
+  if (flag_stack_usage_info)
+    current_function_static_stack_size = size + popcount (mask) * 4;
 
   if (TARGET_AM33_2 && fp_regs_to_save ())
     {
@@ -767,6 +782,9 @@ mn10300_expand_prologue (void)
       unsigned int strategy_size = (unsigned)-1, this_strategy_size;
       rtx reg;
 
+      if (flag_stack_usage_info)
+       current_function_static_stack_size += num_regs_to_save * 4;
+
       /* We have several different strategies to save FP registers.
         We can store them using SP offsets, which is beneficial if
         there are just a few registers to save, or we can use `a0' in