public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] xtensa: Make register A0 allocable for the CALL0 ABI
       [not found] <faee7f9c-aef5-33e7-5f22-a52464ee4c35.ref@yahoo.co.jp>
@ 2022-10-21  2:58 ` Takayuki 'January June' Suwa
  2022-10-21  5:49   ` Max Filippov
  0 siblings, 1 reply; 4+ messages in thread
From: Takayuki 'January June' Suwa @ 2022-10-21  2:58 UTC (permalink / raw)
  To: GCC Patches; +Cc: Max Filippov

This patch offers an additional allocable register by RA for the CALL0
ABI.

> Register a0 holds the return address upon entry to a function, but
> unlike the windowed register ABI, it is not reserved for this purpose
> and may hold other values after the return address has been saved.
  - Xtensa ISA Reference Manual,
                   8.1.2 "CALL0 Register Usage and Stack Layout" [p.589]

gcc/ChangeLog:

	* config/xtensa/xtensa.cc (xtensa_conditional_register_usage):
	Remove register A0 from FIXED_REGS if the CALL0 ABI.
---
 gcc/config/xtensa/xtensa.cc | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc
index 950eb5a59be..f30725113dc 100644
--- a/gcc/config/xtensa/xtensa.cc
+++ b/gcc/config/xtensa/xtensa.cc
@@ -4970,6 +4970,13 @@ xtensa_conditional_register_usage (void)
   /* Remove hard FP register from the preferred reload registers set.  */
   CLEAR_HARD_REG_BIT (reg_class_contents[(int)RL_REGS],
 		      HARD_FRAME_POINTER_REGNUM);
+
+  /* Register A0 holds the return address upon entry to a function
+     for the CALL0 ABI, but unlike the windowed register ABI, it is
+     not reserved for this purpose and may hold other values after
+     the return address has been saved.  */
+  if (!TARGET_WINDOWED_ABI)
+    fixed_regs[A0_REG] = 0;
 }
 
 /* Map hard register number to register class */
-- 
2.30.2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xtensa: Make register A0 allocable for the CALL0 ABI
  2022-10-21  2:58 ` [PATCH] xtensa: Make register A0 allocable for the CALL0 ABI Takayuki 'January June' Suwa
@ 2022-10-21  5:49   ` Max Filippov
  2022-10-21 22:46     ` [PATCH v2] " Takayuki 'January June' Suwa
  0 siblings, 1 reply; 4+ messages in thread
From: Max Filippov @ 2022-10-21  5:49 UTC (permalink / raw)
  To: Takayuki 'January June' Suwa; +Cc: GCC Patches

Hi Suwa-san,

On Thu, Oct 20, 2022 at 7:58 PM Takayuki 'January June' Suwa
<jjsuwa_sys3175@yahoo.co.jp> wrote:
>
> This patch offers an additional allocable register by RA for the CALL0
> ABI.
>
> > Register a0 holds the return address upon entry to a function, but
> > unlike the windowed register ABI, it is not reserved for this purpose
> > and may hold other values after the return address has been saved.
>   - Xtensa ISA Reference Manual,
>                    8.1.2 "CALL0 Register Usage and Stack Layout" [p.589]
>
> gcc/ChangeLog:
>
>         * config/xtensa/xtensa.cc (xtensa_conditional_register_usage):
>         Remove register A0 from FIXED_REGS if the CALL0 ABI.
> ---
>  gcc/config/xtensa/xtensa.cc | 7 +++++++
>  1 file changed, 7 insertions(+)

This change results in the following new regressions:

FAIL: gcc.c-torture/execute/20040709-1.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
FAIL: gcc.c-torture/execute/20040709-2.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
FAIL: gcc.c-torture/execute/20190820-1.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
FAIL: gcc.c-torture/execute/loop-15.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
FAIL: gcc.dg/torture/pr101031.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
FAIL: gcc.dg/torture/pr101972.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
FAIL: gcc.dg/torture/pr99954.c   -O3 -fomit-frame-pointer
-funroll-loops -fpeel-loops -ftracer -finline-functions  execution
test
FAIL: g++.dg/coroutines/torture/co-yield-04-complex-local-state.C
-O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer
-finline-functions  execution test
FAIL: g++.dg/coroutines/torture/local-var-05-awaitable.C   -O3
-fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer
-finline-functions  execution test

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] xtensa: Make register A0 allocable for the CALL0 ABI
  2022-10-21  5:49   ` Max Filippov
@ 2022-10-21 22:46     ` Takayuki 'January June' Suwa
  2022-10-22  7:26       ` Max Filippov
  0 siblings, 1 reply; 4+ messages in thread
From: Takayuki 'January June' Suwa @ 2022-10-21 22:46 UTC (permalink / raw)
  To: GCC Patches; +Cc: Max Filippov

This patch offers an additional allocable register by RA for the CALL0
ABI.

> Register a0 holds the return address upon entry to a function, but
> unlike the windowed register ABI, it is not reserved for this purpose
> and may hold other values after the return address has been saved.
  - Xtensa ISA Reference Manual,
                   8.1.2 "CALL0 Register Usage and Stack Layout" [p.589]

gcc/ChangeLog:

	* config/xtensa/xtensa.cc (xtensa_conditional_register_usage):
	Remove register A0 from FIXED_REGS if the CALL0 ABI.
	(xtensa_expand_epilogue): Change to emit '(use (reg:SI A0_REG))'
	unconditionally after restoring callee-saved registers for
	sibling-call functions, in order to prevent misleading that
	register A0 is free to use.
---
 gcc/config/xtensa/xtensa.cc | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/gcc/config/xtensa/xtensa.cc b/gcc/config/xtensa/xtensa.cc
index 950eb5a59be..94a98c25f8c 100644
--- a/gcc/config/xtensa/xtensa.cc
+++ b/gcc/config/xtensa/xtensa.cc
@@ -3471,15 +3471,14 @@ xtensa_expand_epilogue (bool sibcall_p)
 	  if (xtensa_call_save_reg(regno))
 	    {
 	      rtx x = gen_rtx_PLUS (Pmode, stack_pointer_rtx, GEN_INT (offset));
-	      rtx reg;
 
 	      offset -= UNITS_PER_WORD;
-	      emit_move_insn (reg = gen_rtx_REG (SImode, regno),
+	      emit_move_insn (gen_rtx_REG (SImode, regno),
 			      gen_frame_mem (SImode, x));
-	      if (regno == A0_REG && sibcall_p)
-		emit_use (reg);
 	    }
 	}
+      if (sibcall_p)
+	emit_use (gen_rtx_REG (SImode, A0_REG));
 
       if (cfun->machine->current_frame_size > 0)
 	{
@@ -4970,6 +4969,13 @@ xtensa_conditional_register_usage (void)
   /* Remove hard FP register from the preferred reload registers set.  */
   CLEAR_HARD_REG_BIT (reg_class_contents[(int)RL_REGS],
 		      HARD_FRAME_POINTER_REGNUM);
+
+  /* Register A0 holds the return address upon entry to a function
+     for the CALL0 ABI, but unlike the windowed register ABI, it is
+     not reserved for this purpose and may hold other values after
+     the return address has been saved.  */
+  if (!TARGET_WINDOWED_ABI)
+    fixed_regs[A0_REG] = 0;
 }
 
 /* Map hard register number to register class */
-- 
2.30.2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] xtensa: Make register A0 allocable for the CALL0 ABI
  2022-10-21 22:46     ` [PATCH v2] " Takayuki 'January June' Suwa
@ 2022-10-22  7:26       ` Max Filippov
  0 siblings, 0 replies; 4+ messages in thread
From: Max Filippov @ 2022-10-22  7:26 UTC (permalink / raw)
  To: Takayuki 'January June' Suwa; +Cc: GCC Patches

On Fri, Oct 21, 2022 at 3:46 PM Takayuki 'January June' Suwa
<jjsuwa_sys3175@yahoo.co.jp> wrote:
>
> This patch offers an additional allocable register by RA for the CALL0
> ABI.
>
> > Register a0 holds the return address upon entry to a function, but
> > unlike the windowed register ABI, it is not reserved for this purpose
> > and may hold other values after the return address has been saved.
>   - Xtensa ISA Reference Manual,
>                    8.1.2 "CALL0 Register Usage and Stack Layout" [p.589]
>
> gcc/ChangeLog:
>
>         * config/xtensa/xtensa.cc (xtensa_conditional_register_usage):
>         Remove register A0 from FIXED_REGS if the CALL0 ABI.
>         (xtensa_expand_epilogue): Change to emit '(use (reg:SI A0_REG))'
>         unconditionally after restoring callee-saved registers for
>         sibling-call functions, in order to prevent misleading that
>         register A0 is free to use.
> ---
>  gcc/config/xtensa/xtensa.cc | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)

Regtested for target=xtensa-linux-uclibc, no new regressions.
Committed to master.

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-22  7:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <faee7f9c-aef5-33e7-5f22-a52464ee4c35.ref@yahoo.co.jp>
2022-10-21  2:58 ` [PATCH] xtensa: Make register A0 allocable for the CALL0 ABI Takayuki 'January June' Suwa
2022-10-21  5:49   ` Max Filippov
2022-10-21 22:46     ` [PATCH v2] " Takayuki 'January June' Suwa
2022-10-22  7:26       ` Max Filippov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).