From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2050) id 3E3343858012; Tue, 25 May 2021 06:07:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E3343858012 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: qu To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1027] C-SKY: Separate FRAME_POINTER_REGNUM into FRAME_POINTER_REGNUM and HARD_FRAME_POINTER_REGNUM. X-Act-Checkin: gcc X-Git-Author: Geng Qi X-Git-Refname: refs/heads/master X-Git-Oldrev: 62fa9cb24a8cfb197717c809c20e69161f464720 X-Git-Newrev: d19a00c60c15c253282f72299315261ecaa9c92f Message-Id: <20210525060752.3E3343858012@sourceware.org> Date: Tue, 25 May 2021 06:07:52 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 May 2021 06:07:52 -0000 https://gcc.gnu.org/g:d19a00c60c15c253282f72299315261ecaa9c92f commit r12-1027-gd19a00c60c15c253282f72299315261ecaa9c92f Author: Geng Qi Date: Mon May 24 20:22:55 2021 +0800 C-SKY: Separate FRAME_POINTER_REGNUM into FRAME_POINTER_REGNUM and HARD_FRAME_POINTER_REGNUM. gcc/ChangeLog: * config/csky/csky.h (FRAME_POINTER_REGNUM): Use HARD_FRAME_POINTER_REGNUM and FRAME_POINTER_REGNUM instead of the signle definition. The signle definition may not work well at simplify_subreg_regno(). (HARD_FRAME_POINTER_REGNUM): New. (ELIMINABLE_REGS): Add for HARD_FRAME_POINTER_REGNUM. * config/csky/csky.c (get_csky_live_regs, csky_can_eliminate, csky_initial_elimination_offset, csky_expand_prologue, csky_expand_epilogue): Add for HARD_FRAME_POINTER_REGNUM. Diff: --- gcc/config/csky/csky.c | 15 +++++++++------ gcc/config/csky/csky.h | 7 +++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gcc/config/csky/csky.c b/gcc/config/csky/csky.c index 1a6cfd70ef7..7f2af82749b 100644 --- a/gcc/config/csky/csky.c +++ b/gcc/config/csky/csky.c @@ -1751,12 +1751,12 @@ get_csky_live_regs (int *count) save = true; /* Frame pointer marked used. */ - else if (frame_pointer_needed && reg == FRAME_POINTER_REGNUM) + else if (frame_pointer_needed && reg == HARD_FRAME_POINTER_REGNUM) save = true; /* This is required for CK801/802 where FP is a fixed reg, otherwise we end up with no FP value available to the DWARF-2 unwinder. */ - else if (crtl->calls_eh_return && reg == FRAME_POINTER_REGNUM) + else if (crtl->calls_eh_return && reg == HARD_FRAME_POINTER_REGNUM) save = true; /* CK801/802 also need special handling for LR because it's clobbered @@ -1832,6 +1832,8 @@ csky_layout_stack_frame (void) static bool csky_can_eliminate (const int from ATTRIBUTE_UNUSED, const int to) { + if (to == FRAME_POINTER_REGNUM) + return from != ARG_POINTER_REGNUM; if (to == STACK_POINTER_REGNUM) return !frame_pointer_needed; return true; @@ -1852,6 +1854,7 @@ csky_initial_elimination_offset (int from, int to) switch (from) { case FRAME_POINTER_REGNUM: + case HARD_FRAME_POINTER_REGNUM: offset = cfun->machine->reg_offset; break; @@ -1866,7 +1869,7 @@ csky_initial_elimination_offset (int from, int to) /* If we are asked for the offset to the frame pointer instead, then subtract the difference between the frame pointer and stack pointer. */ - if (to == FRAME_POINTER_REGNUM) + if (to == FRAME_POINTER_REGNUM || to == HARD_FRAME_POINTER_REGNUM) offset -= cfun->machine->reg_offset; return offset; } @@ -5785,7 +5788,7 @@ csky_expand_prologue (void) of the register save area. */ if (frame_pointer_needed) { - insn = emit_insn (gen_movsi (frame_pointer_rtx, stack_pointer_rtx)); + insn = emit_insn (gen_movsi (hard_frame_pointer_rtx, stack_pointer_rtx)); RTX_FRAME_RELATED_P (insn) = 1; } @@ -5848,7 +5851,7 @@ csky_expand_epilogue (void) /* Restore the SP to the base of the register save area. */ if (frame_pointer_needed) { - insn = emit_move_insn (stack_pointer_rtx, frame_pointer_rtx); + insn = emit_move_insn (stack_pointer_rtx, hard_frame_pointer_rtx); RTX_FRAME_RELATED_P (insn) = 1; } else @@ -6004,7 +6007,7 @@ csky_set_eh_return_address (rtx source, rtx scratch) if (frame_pointer_needed) { - basereg = frame_pointer_rtx; + basereg = hard_frame_pointer_rtx; delta = 0; } else diff --git a/gcc/config/csky/csky.h b/gcc/config/csky/csky.h index 1fd72d0f3ee..f2b0d1cd110 100644 --- a/gcc/config/csky/csky.h +++ b/gcc/config/csky/csky.h @@ -342,7 +342,8 @@ extern int csky_arch_isa_features[]; #define STACK_POINTER_REGNUM CSKY_SP_REGNUM /* Base register for access to local variables of the function. */ -#define FRAME_POINTER_REGNUM 8 +#define FRAME_POINTER_REGNUM 36 +#define HARD_FRAME_POINTER_REGNUM 8 /* Base register for access to arguments of the function. This is a fake register that is always eliminated. */ @@ -370,7 +371,9 @@ extern int csky_arch_isa_features[]; #define ELIMINABLE_REGS \ {{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM },\ { ARG_POINTER_REGNUM, FRAME_POINTER_REGNUM },\ - { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM }} + { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM },\ + { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM },\ + { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM }} /* Define the offset between two registers, one to be eliminated, and the other its replacement, at the start of a routine. */