Commit 2da1e7c0 by Chung-Ju Wu Committed by Chung-Ju Wu

[NDS32] We need to make sure it is NOT a variadic function so that some…

[NDS32] We need to make sure it is NOT a variadic function so that some v3push/v3pop preparation can be applied.

  -- The rationale of such avoidance is that the 'pop25' instruction also
     contains return behavior and we have no chance to further adjust stack
     pointer before returning to caller, which is very important to
     variadic function.
  -- So we do not setup v3push/v3pop (push25/pop25) information for a
     variadic function.  It will use normal stack push/pop instead.

	* config/nds32/nds32.c (nds32_compute_stack_frame): Do not use
	v3push/v3pop for variadic function.
	* config/nds32/nds32.md (prologue, epilogue): Likewise.

From-SVN: r214857
parent 6f3d3f9c
2014-09-03 Chung-Ju Wu <jasonwucj@gmail.com> 2014-09-03 Chung-Ju Wu <jasonwucj@gmail.com>
* config/nds32/nds32.c (nds32_compute_stack_frame): Do not use
v3push/v3pop for variadic function.
* config/nds32/nds32.md (prologue, epilogue): Likewise.
2014-09-03 Chung-Ju Wu <jasonwucj@gmail.com>
* config/nds32/nds32-md-auxiliary.c (nds32_output_stack_push): * config/nds32/nds32-md-auxiliary.c (nds32_output_stack_push):
Check rtx for varargs implementation. Check rtx for varargs implementation.
(nds32_output_stack_pop): Likewise. (nds32_output_stack_pop): Likewise.
...@@ -215,7 +215,8 @@ nds32_compute_stack_frame (void) ...@@ -215,7 +215,8 @@ nds32_compute_stack_frame (void)
which means we do not have to save which means we do not have to save
any callee-saved registers. any callee-saved registers.
condition 2: Both $lp and $fp are NOT live in this function, condition 2: Both $lp and $fp are NOT live in this function,
which means we do not need to save them. which means we do not need to save them and there
is no outgoing size.
condition 3: There is no local_size, which means condition 3: There is no local_size, which means
we do not need to adjust $sp. */ we do not need to adjust $sp. */
if (lookup_attribute ("naked", DECL_ATTRIBUTES (current_function_decl)) if (lookup_attribute ("naked", DECL_ATTRIBUTES (current_function_decl))
...@@ -225,8 +226,11 @@ nds32_compute_stack_frame (void) ...@@ -225,8 +226,11 @@ nds32_compute_stack_frame (void)
&& !df_regs_ever_live_p (LP_REGNUM) && !df_regs_ever_live_p (LP_REGNUM)
&& cfun->machine->local_size == 0)) && cfun->machine->local_size == 0))
{ {
/* Set this function 'naked_p' and /* Set this function 'naked_p' and other functions can check this flag.
other functions can check this flag. */ Note that in nds32 port, the 'naked_p = 1' JUST means there is no
callee-saved, local size, and outgoing size.
The varargs space and ret instruction may still present in
the prologue/epilogue expanding. */
cfun->machine->naked_p = 1; cfun->machine->naked_p = 1;
/* No need to save $fp, $gp, and $lp. /* No need to save $fp, $gp, and $lp.
...@@ -250,8 +254,11 @@ nds32_compute_stack_frame (void) ...@@ -250,8 +254,11 @@ nds32_compute_stack_frame (void)
we need to make sure Rb is $r6 and Re is we need to make sure Rb is $r6 and Re is
located on $r6, $r8, $r10, or $r14. located on $r6, $r8, $r10, or $r14.
Some results above will be discarded and recomputed. Some results above will be discarded and recomputed.
Note that it is only available under V3/V3M ISA. */ Note that it is only available under V3/V3M ISA and we
if (TARGET_V3PUSH) DO NOT setup following stuff for isr or variadic function. */
if (TARGET_V3PUSH
&& !nds32_isr_function_p (current_function_decl)
&& (cfun->machine->va_args_size == 0))
{ {
/* Recompute: /* Recompute:
cfun->machine->fp_size cfun->machine->fp_size
......
...@@ -1971,8 +1971,12 @@ create_template: ...@@ -1971,8 +1971,12 @@ create_template:
(define_expand "prologue" [(const_int 0)] (define_expand "prologue" [(const_int 0)]
"" ""
{ {
/* Note that only under V3/V3M ISA, we could use v3push prologue. */ /* Note that only under V3/V3M ISA, we could use v3push prologue.
if (TARGET_V3PUSH) In addition, we do not want to use v3push for isr function
and variadic function. */
if (TARGET_V3PUSH
&& !nds32_isr_function_p (current_function_decl)
&& (cfun->machine->va_args_size == 0))
nds32_expand_prologue_v3push (); nds32_expand_prologue_v3push ();
else else
nds32_expand_prologue (); nds32_expand_prologue ();
...@@ -1982,8 +1986,12 @@ create_template: ...@@ -1982,8 +1986,12 @@ create_template:
(define_expand "epilogue" [(const_int 0)] (define_expand "epilogue" [(const_int 0)]
"" ""
{ {
/* Note that only under V3/V3M ISA, we could use v3pop epilogue. */ /* Note that only under V3/V3M ISA, we could use v3pop epilogue.
if (TARGET_V3PUSH) In addition, we do not want to use v3pop for isr function
and variadic function. */
if (TARGET_V3PUSH
&& !nds32_isr_function_p (current_function_decl)
&& (cfun->machine->va_args_size == 0))
nds32_expand_epilogue_v3pop (); nds32_expand_epilogue_v3pop ();
else else
nds32_expand_epilogue (); nds32_expand_epilogue ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment