This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: MN10300: Include saved registers in stack usage
- From: nick clifton <nickc at redhat dot com>
- To: Jeff Law <law at redhat dot com>, aoliva at redhat dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 06 Feb 2014 15:37:32 +0000
- Subject: Re: RFA: MN10300: Include saved registers in stack usage
- Authentication-results: sourceware.org; auth=none
- References: <87fvnx4z57 dot fsf at redhat dot com> <52F27362 dot 60303 at redhat dot com>
Hi Jeff,
According to our coding conventions, the ability to build with something
other than gcc is still desirable. You could argue that you're unlikely
to be bootstrapping on a mn103 with something other than GCC and if
you're building a cross, you could start by first building gcc native.
However, it's pretty easy to avoid the headaches and just provide a
popcount routine.
OK, here is a version of the patch with a homebrew popcount() function
in it. OK to apply ?
Cheers
Nick
Index: gcc/config/mn10300/mn10300.c
===================================================================
--- gcc/config/mn10300/mn10300.c (revision 207529)
+++ gcc/config/mn10300/mn10300.c (working copy)
@@ -741,17 +741,32 @@
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;
+ mask = mn10300_get_live_callee_saved_regs (NULL);
+ /* If we use any of the callee-saved registers, save them now. */
+ mn10300_gen_multiple_store (mask);
+
if (flag_stack_usage_info)
- current_function_static_stack_size = size;
+ current_function_static_stack_size = size + popcount (mask) * 4;
- /* If we use any of the callee-saved registers, save them now. */
- mn10300_gen_multiple_store (mn10300_get_live_callee_saved_regs (NULL));
-
if (TARGET_AM33_2 && fp_regs_to_save ())
{
int num_regs_to_save = fp_regs_to_save (), i;
@@ -767,6 +782,9 @@
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