Commit a6c7e777 by Monk Chiang Committed by Chung-Ju Wu

[NDS32] Refine prologue and epilogue code generation.

gcc/
	* config/nds32/nds32.c (nds32_compute_stack_frame,
	nds32_emit_stack_push_multiple, nds32_emit_stack_pop_multiple,
	nds32_emit_stack_v3push, nds32_emit_stack_v3pop,
	nds32_emit_adjust_frame, nds32_expand_prologue, nds32_expand_epilogue,
	nds32_expand_prologue_v3push, nds32_expand_epilogue_v3pop): Refine.
	* config/nds32/nds32.h (NDS32_FIRST_CALLEE_SAVE_GPR_REGNUM,
	NDS32_LAST_CALLEE_SAVE_GPR_REGNUM, NDS32_V3PUSH_AVAILABLE_P): New.
	* config/nds32/nds32.md (prologue, epilogue): Use macro
	NDS32_V3PUSH_AVAILABLE_P to do checking.

Co-Authored-By: Chung-Ju Wu <jasonwucj@gmail.com>
Co-Authored-By: Kito Cheng <kito.cheng@gmail.com>

From-SVN: r258442
parent 1fdffa31
2018-03-11 Monk Chiang <sh.chiang04@gmail.com>
Kito Cheng <kito.cheng@gmail.com>
Chung-Ju Wu <jasonwucj@gmail.com>
* config/nds32/nds32.c (nds32_compute_stack_frame,
nds32_emit_stack_push_multiple, nds32_emit_stack_pop_multiple,
nds32_emit_stack_v3push, nds32_emit_stack_v3pop,
nds32_emit_adjust_frame, nds32_expand_prologue, nds32_expand_epilogue,
nds32_expand_prologue_v3push, nds32_expand_epilogue_v3pop): Refine.
* config/nds32/nds32.h (NDS32_FIRST_CALLEE_SAVE_GPR_REGNUM,
NDS32_LAST_CALLEE_SAVE_GPR_REGNUM, NDS32_V3PUSH_AVAILABLE_P): New.
* config/nds32/nds32.md (prologue, epilogue): Use macro
NDS32_V3PUSH_AVAILABLE_P to do checking.
2018-03-11 Jakub Jelinek <jakub@redhat.com> 2018-03-11 Jakub Jelinek <jakub@redhat.com>
PR debug/58150 PR debug/58150
......
...@@ -130,6 +130,10 @@ enum nds32_16bit_address_type ...@@ -130,6 +130,10 @@ enum nds32_16bit_address_type
/* Define the last integer register number. */ /* Define the last integer register number. */
#define NDS32_LAST_GPR_REGNUM 31 #define NDS32_LAST_GPR_REGNUM 31
#define NDS32_FIRST_CALLEE_SAVE_GPR_REGNUM 6
#define NDS32_LAST_CALLEE_SAVE_GPR_REGNUM \
(TARGET_REDUCED_REGS ? 10 : 14)
/* Define double word alignment bits. */ /* Define double word alignment bits. */
#define NDS32_DOUBLE_WORD_ALIGNMENT 64 #define NDS32_DOUBLE_WORD_ALIGNMENT 64
...@@ -196,6 +200,19 @@ enum nds32_16bit_address_type ...@@ -196,6 +200,19 @@ enum nds32_16bit_address_type
#define NDS32_REQUIRED_CALLEE_SAVED_P(regno) \ #define NDS32_REQUIRED_CALLEE_SAVED_P(regno) \
((!call_used_regs[regno]) && (df_regs_ever_live_p (regno))) ((!call_used_regs[regno]) && (df_regs_ever_live_p (regno)))
/* This macro is to check if the push25/pop25 are available to be used
for code generation. Because pop25 also performs return behavior,
the instructions may not be available for some cases.
If we want to use push25/pop25, all the following conditions must
be satisfied:
1. TARGET_V3PUSH is set.
2. Current function is not an ISR function.
3. Current function is not a variadic function.*/
#define NDS32_V3PUSH_AVAILABLE_P \
(TARGET_V3PUSH \
&& !nds32_isr_function_p (current_function_decl) \
&& (cfun->machine->va_args_size == 0))
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* A C structure for machine-specific, per-function data. /* A C structure for machine-specific, per-function data.
......
...@@ -2093,11 +2093,8 @@ create_template: ...@@ -2093,11 +2093,8 @@ create_template:
"" ""
{ {
/* Note that only under V3/V3M ISA, we could use v3push prologue. /* Note that only under V3/V3M ISA, we could use v3push prologue.
In addition, we do not want to use v3push for isr function In addition, we need to check if v3push is indeed available. */
and variadic function. */ if (NDS32_V3PUSH_AVAILABLE_P)
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 ();
...@@ -2108,11 +2105,8 @@ create_template: ...@@ -2108,11 +2105,8 @@ create_template:
"" ""
{ {
/* Note that only under V3/V3M ISA, we could use v3pop epilogue. /* Note that only under V3/V3M ISA, we could use v3pop epilogue.
In addition, we do not want to use v3pop for isr function In addition, we need to check if v3push is indeed available. */
and variadic function. */ if (NDS32_V3PUSH_AVAILABLE_P)
if (TARGET_V3PUSH
&& !nds32_isr_function_p (current_function_decl)
&& (cfun->machine->va_args_size == 0))
nds32_expand_epilogue_v3pop (false); nds32_expand_epilogue_v3pop (false);
else else
nds32_expand_epilogue (false); nds32_expand_epilogue (false);
...@@ -2125,10 +2119,7 @@ create_template: ...@@ -2125,10 +2119,7 @@ create_template:
/* Pass true to indicate that this is sibcall epilogue and /* Pass true to indicate that this is sibcall epilogue and
exit from a function without the final branch back to the exit from a function without the final branch back to the
calling function. */ calling function. */
if (TARGET_V3PUSH && !nds32_isr_function_p (current_function_decl)) nds32_expand_epilogue (true);
nds32_expand_epilogue_v3pop (true);
else
nds32_expand_epilogue (true);
DONE; DONE;
}) })
......
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