These four patches has been merged.

On 5/24/21 8:22 PM, Geng Qi wrote:
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().
        (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.
---
  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 1a6cfd7..7f2af82 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 1fd72d0..f2b0d1c 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.  */

Reply via email to