From f5d56cf957f9235d43f4dc4cec511b042e0b18de Mon Sep 17 00:00:00 2001 From: Claudiu Zissulescu Date: Mon, 18 Mar 2019 10:28:45 +0100 Subject: [PATCH] [ARC] Enable code density frame option for elf targets. xxxx-xx-xx Claudiu Zissulescu * config/arc/arc.opt (mcode-density-frame): Get the inital value from TARGET_CODE_DENSITY_FRAME_DEFAULT. * config/arc/elf.h (TARGET_CODE_DENSITY_FRAME_DEFAULT): Define. * config/arc/linux.h (TARGET_CODE_DENSITY_FRAME_DEFAULT): Define. * config/arc/arc.md (pop_multi_fp_blink): Adjust constraints to match what the ops is doing. (push_multi_fp_blink): Likewise. * config/arc/arc.c (arc_override_options): Enable enter/leave when compiling for size and elf target. (arc_save_callee_enter): Adjust note to match what enter/leave operation does. From-SVN: r269758 --- gcc/ChangeLog | 14 ++++++++++++++ gcc/config/arc/arc.c | 5 ++++- gcc/config/arc/arc.md | 22 ++++++++++++---------- gcc/config/arc/arc.opt | 2 +- gcc/config/arc/elf.h | 4 ++++ gcc/config/arc/linux.h | 4 ++++ 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0ecd5c4f1e9..2da36e7030b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2019-03-18 Claudiu Zissulescu + + * config/arc/arc.opt (mcode-density-frame): Get the inital value + from TARGET_CODE_DENSITY_FRAME_DEFAULT. + * config/arc/elf.h (TARGET_CODE_DENSITY_FRAME_DEFAULT): Define. + * config/arc/linux.h (TARGET_CODE_DENSITY_FRAME_DEFAULT): Define. + * config/arc/arc.md (pop_multi_fp_blink): Adjust constraints to + match what the ops is doing. + (push_multi_fp_blink): Likewise. + * config/arc/arc.c (arc_override_options): Enable enter/leave when + compiling for size and elf target. + (arc_save_callee_enter): Adjust note to match what enter/leave + operation does. + 2019-03-18 Claudiu Zissulescu * config/arc/arc.md (tst_movb): Fix constraint. diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index f91a29c3a68..978d8450ab0 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -1294,6 +1294,9 @@ arc_override_options (void) if (arc_size_opt_level == 3) optimize_size = 1; + if (TARGET_V2 && optimize_size && (ATTRIBUTE_PCS == 2)) + TARGET_CODE_DENSITY_FRAME = 1; + if (flag_pic) target_flags |= MASK_NO_SDATA_SET; @@ -3140,7 +3143,7 @@ arc_save_callee_enter (unsigned int gmask, reg = gen_rtx_SET (stack_pointer_rtx, plus_constant (Pmode, stack_pointer_rtx, - nregs * UNITS_PER_WORD)); + -nregs * UNITS_PER_WORD)); RTX_FRAME_RELATED_P (reg) = 1; XVECEXP (insn, 0, indx++) = reg; off = nregs * UNITS_PER_WORD; diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md index 01a715ee167..e682983048a 100644 --- a/gcc/config/arc/arc.md +++ b/gcc/config/arc/arc.md @@ -6458,7 +6458,8 @@ core_3, archs4x, archs4xd, archs4xd_slow" (plus:SI (reg:SI SP_REG) (match_operand 1 "immediate_operand" ""))) (set (mem:SI (plus:SI (reg:SI SP_REG) - (match_dup 1))) + (match_operand 2 "immediate_operand" + ""))) (reg:SI 13))])] "TARGET_CODE_DENSITY" { @@ -6466,14 +6467,14 @@ core_3, archs4x, archs4xd, archs4xd_slow" rtx tmp = XVECEXP (operands[0], 0, len - 1); if (MEM_P (XEXP (tmp, 0))) { - operands[2] = XEXP (tmp, 1); - return "enter_s\\t{r13-%2} ; sp=sp-%1"; + operands[3] = XEXP (tmp, 1); + return "enter_s\\t{r13-%3} ; sp=sp+(%1)"; } else { tmp = XVECEXP (operands[0], 0, len - 3); - operands[2] = XEXP (tmp, 1); - return "enter_s\\t{r13-%2, fp} ; sp=sp-%1"; + operands[3] = XEXP (tmp, 1); + return "enter_s\\t{r13-%3, fp} ; sp=sp+(%1)"; } } [(set_attr "type" "call_no_delay_slot") @@ -6485,7 +6486,8 @@ core_3, archs4x, archs4xd, archs4xd_slow" (plus:SI (reg:SI SP_REG) (match_operand 1 "immediate_operand" ""))) (set (mem:SI (plus:SI (reg:SI SP_REG) - (match_dup 1))) + (match_operand 2 "immediate_operand" + ""))) (reg:SI RETURN_ADDR_REGNUM))])] "TARGET_CODE_DENSITY" { @@ -6493,14 +6495,14 @@ core_3, archs4x, archs4xd, archs4xd_slow" rtx tmp = XVECEXP (operands[0], 0, len - 1); if (MEM_P (XEXP (tmp, 0))) { - operands[2] = XEXP (tmp, 1); - return "enter_s\\t{r13-%2, blink} ; sp=sp-%1"; + operands[3] = XEXP (tmp, 1); + return "enter_s\\t{r13-%3, blink} ; sp=sp+(%1)"; } else { tmp = XVECEXP (operands[0], 0, len - 3); - operands[2] = XEXP (tmp, 1); - return "enter_s\\t{r13-%2, fp, blink} ; sp=sp-%1"; + operands[3] = XEXP (tmp, 1); + return "enter_s\\t{r13-%3, fp, blink} ; sp=sp+(%1)"; } } [(set_attr "type" "call_no_delay_slot") diff --git a/gcc/config/arc/arc.opt b/gcc/config/arc/arc.opt index 3e864ddcfe6..e4330135a01 100644 --- a/gcc/config/arc/arc.opt +++ b/gcc/config/arc/arc.opt @@ -537,5 +537,5 @@ Target Report Var(TARGET_BRANCH_INDEX) Init(DEFAULT_BRANCH_INDEX) Enable use of BI/BIH instructions when available. mcode-density-frame -Target Report Var(TARGET_CODE_DENSITY_FRAME) +Target Report Var(TARGET_CODE_DENSITY_FRAME) Init(TARGET_CODE_DENSITY_FRAME_DEFAULT) Enable ENTER_S and LEAVE_S opcodes for ARCv2. diff --git a/gcc/config/arc/elf.h b/gcc/config/arc/elf.h index 34d17b10bd3..297ac9b0ce0 100644 --- a/gcc/config/arc/elf.h +++ b/gcc/config/arc/elf.h @@ -87,3 +87,7 @@ along with GCC; see the file COPYING3. If not see fun = gen_rtx_SYMBOL_REF (Pmode, "__mcount"); \ emit_library_call (fun, LCT_NORMAL, VOIDmode); \ } + +/* Enter/Leave default value. */ +#undef TARGET_CODE_DENSITY_FRAME_DEFAULT +#define TARGET_CODE_DENSITY_FRAME_DEFAULT 0 diff --git a/gcc/config/arc/linux.h b/gcc/config/arc/linux.h index 6c8a7b46296..270ca907d87 100644 --- a/gcc/config/arc/linux.h +++ b/gcc/config/arc/linux.h @@ -133,3 +133,7 @@ along with GCC; see the file COPYING3. If not see fun = gen_rtx_SYMBOL_REF (Pmode, "_mcount"); \ emit_library_call (fun, LCT_NORMAL, VOIDmode, rt, Pmode); \ } + +/* Enter/Leave ops are default off for linux targets. */ +#undef TARGET_CODE_DENSITY_FRAME_DEFAULT +#define TARGET_CODE_DENSITY_FRAME_DEFAULT 0 -- 2.30.2