]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
xtensa: Prepend "(use A0_REG)" to sibling call CALL_INSN_FUNCTION_USAGE instead of...
authorTakayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
Fri, 31 May 2024 10:24:48 +0000 (19:24 +0900)
committerMax Filippov <jcmvbkbc@gmail.com>
Fri, 31 May 2024 21:41:01 +0000 (14:41 -0700)
No functional changes.

gcc/ChangeLog:

* config/xtensa/xtensa-protos.h (xtensa_expand_call):
Add the third argument as boolean.
(xtensa_expand_epilogue): Remove the first argument.
* config/xtensa/xtensa.cc (xtensa_expand_call):
Add the third argument "sibcall_p", and modify in order to prepend
"(use A0_REG)" to CALL_INSN_FUNCTION_USAGE if the argument is true.
(xtensa_expand_epilogue): Remove the first argument "sibcall_p" and
its conditional clause.
* config/xtensa/xtensa.md (call, call_value, sibcall, sibcall_value):
Append a boolean value to the argument of xtensa_expand_call()
indicating whether it is sibling call or not.
(epilogue): Remove the boolean argument from xtensa_expand_epilogue(),
and then append emitting "(return)".
(sibcall_epilogue): Remove the boolean argument from
xtensa_expand_epilogue().

gcc/config/xtensa/xtensa-protos.h
gcc/config/xtensa/xtensa.cc
gcc/config/xtensa/xtensa.md

index 834f15e0e48b1502addda5c10da28e5e641267e7..77553b0453f14e6c311a888737c1851594413821 100644 (file)
@@ -53,7 +53,7 @@ extern void xtensa_expand_atomic (enum rtx_code, rtx, rtx, rtx, bool);
 extern void xtensa_emit_loop_end (rtx_insn *, rtx *);
 extern char *xtensa_emit_branch (bool, rtx *);
 extern char *xtensa_emit_movcc (bool, bool, bool, rtx *);
-extern void xtensa_expand_call (int, rtx *);
+extern void xtensa_expand_call (int, rtx *, bool);
 extern char *xtensa_emit_call (int, rtx *);
 extern char *xtensa_emit_sibcall (int, rtx *);
 extern bool xtensa_tls_referenced_p (rtx);
@@ -76,7 +76,7 @@ extern void xtensa_setup_frame_addresses (void);
 extern int xtensa_debugger_regno (int);
 extern long compute_frame_size (poly_int64);
 extern void xtensa_expand_prologue (void);
-extern void xtensa_expand_epilogue (bool);
+extern void xtensa_expand_epilogue (void);
 extern void xtensa_adjust_reg_alloc_order (void);
 extern enum reg_class xtensa_regno_to_class (int regno);
 extern HOST_WIDE_INT xtensa_initial_elimination_offset (int from, int to);
index 301448c65e2ce02b14ea8b323d3614c6e733e62a..45dc1be3ff52fbf10f7c8d6207ad22c42a1b1379 100644 (file)
@@ -2239,7 +2239,7 @@ xtensa_emit_movcc (bool inverted, bool isfp, bool isbool, rtx *operands)
 
 
 void
-xtensa_expand_call (int callop, rtx *operands)
+xtensa_expand_call (int callop, rtx *operands, bool sibcall_p)
 {
   rtx call;
   rtx_insn *call_insn;
@@ -2281,6 +2281,14 @@ xtensa_expand_call (int callop, rtx *operands)
       CALL_INSN_FUNCTION_USAGE (call_insn) =
        gen_rtx_EXPR_LIST (Pmode, clob, CALL_INSN_FUNCTION_USAGE (call_insn));
     }
+  else if (sibcall_p)
+    {
+      /* Sibling call requires a return address to the caller, similar to
+        "return" insn.  */
+      rtx use = gen_rtx_USE (VOIDmode, gen_rtx_REG (SImode, A0_REG));
+      CALL_INSN_FUNCTION_USAGE (call_insn) =
+       gen_rtx_EXPR_LIST (Pmode, use, CALL_INSN_FUNCTION_USAGE (call_insn));
+    }
 }
 
 
@@ -3671,7 +3679,7 @@ xtensa_expand_prologue (void)
 }
 
 void
-xtensa_expand_epilogue (bool sibcall_p)
+xtensa_expand_epilogue (void)
 {
   if (!TARGET_WINDOWED_ABI)
     {
@@ -3736,10 +3744,6 @@ xtensa_expand_epilogue (bool sibcall_p)
                                  stack_pointer_rtx,
                                  EH_RETURN_STACKADJ_RTX));
     }
-  if (sibcall_p)
-    emit_use (gen_rtx_REG (SImode, A0_REG));
-  else
-    emit_jump_insn (gen_return ());
 }
 
 void
index 03e816b8a1202f5b9f22c85743df6f705c8e4e91..ef826b63e441ff414a5ea9f49a7d684c77cc14aa 100644 (file)
         (match_operand 1 "" ""))]
   ""
 {
-  xtensa_expand_call (0, operands);
+  xtensa_expand_call (0, operands, false);
   DONE;
 })
 
              (match_operand 2 "" "")))]
   ""
 {
-  xtensa_expand_call (1, operands);
+  xtensa_expand_call (1, operands, false);
   DONE;
 })
 
         (match_operand 1 "" ""))]
   "!TARGET_WINDOWED_ABI"
 {
-  xtensa_expand_call (0, operands);
+  xtensa_expand_call (0, operands, true);
   DONE;
 })
 
              (match_operand 2 "" "")))]
   "!TARGET_WINDOWED_ABI"
 {
-  xtensa_expand_call (1, operands);
+  xtensa_expand_call (1, operands, true);
   DONE;
 })
 
   [(return)]
   ""
 {
-  xtensa_expand_epilogue (false);
+  xtensa_expand_epilogue ();
+  emit_jump_insn (gen_return ());
   DONE;
 })
 
   [(return)]
   "!TARGET_WINDOWED_ABI"
 {
-  xtensa_expand_epilogue (true);
+  xtensa_expand_epilogue ();
   DONE;
 })