public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Fix the V calling convention
@ 2022-09-01  3:27 Palmer Dabbelt
  2022-09-01  3:27 ` Palmer Dabbelt
  2022-09-02  7:54 ` Kito Cheng
  0 siblings, 2 replies; 3+ messages in thread
From: Palmer Dabbelt @ 2022-09-01  3:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: Palmer Dabbelt

The V registers are always clobbered on calls.

gcc/ChangeLog

	* config/riscv/riscv.cc (riscv_conditional_register_usage):
	Always mark the V registers as clobbered on calls.
---
 gcc/config/riscv/riscv.cc | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 675d92c0961..c18e61f4a03 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -5442,11 +5442,18 @@ riscv_conditional_register_usage (void)
   if (!TARGET_VECTOR)
     {
       for (int regno = V_REG_FIRST; regno <= V_REG_LAST; regno++)
-	fixed_regs[regno] = call_used_regs[regno] = 1;
+	fixed_regs[regno] = 1;
 
-      fixed_regs[VTYPE_REGNUM] = call_used_regs[VTYPE_REGNUM] = 1;
-      fixed_regs[VL_REGNUM] = call_used_regs[VL_REGNUM] = 1;
+      fixed_regs[VTYPE_REGNUM] = 1;
+      fixed_regs[VL_REGNUM] = 1;
     }
+
+  /* The standard ABIs all clobber the entire vector state on calls.  */
+  for (int regno = V_REG_FIRST; regno <= V_REG_LAST; regno++)
+    call_used_regs[regno] = 1;
+
+  call_used_regs[VTYPE_REGNUM] = 1;
+  call_used_regs[VL_REGNUM] = 1;
 }
 
 /* Return a register priority for hard reg REGNO.  */
-- 
2.34.1


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

* [PATCH] RISC-V: Fix the V calling convention
  2022-09-01  3:27 [PATCH] RISC-V: Fix the V calling convention Palmer Dabbelt
@ 2022-09-01  3:27 ` Palmer Dabbelt
  2022-09-02  7:54 ` Kito Cheng
  1 sibling, 0 replies; 3+ messages in thread
From: Palmer Dabbelt @ 2022-09-01  3:27 UTC (permalink / raw)
  To: gcc-patches

The V registers are always clobbered on calls.

gcc/ChangeLog

	* config/riscv/riscv.cc (riscv_conditional_register_usage):
	Always mark the V registers as clobbered on calls.
---
 gcc/config/riscv/riscv.cc | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 675d92c0961..c18e61f4a03 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -5442,11 +5442,18 @@ riscv_conditional_register_usage (void)
   if (!TARGET_VECTOR)
     {
       for (int regno = V_REG_FIRST; regno <= V_REG_LAST; regno++)
-	fixed_regs[regno] = call_used_regs[regno] = 1;
+	fixed_regs[regno] = 1;
 
-      fixed_regs[VTYPE_REGNUM] = call_used_regs[VTYPE_REGNUM] = 1;
-      fixed_regs[VL_REGNUM] = call_used_regs[VL_REGNUM] = 1;
+      fixed_regs[VTYPE_REGNUM] = 1;
+      fixed_regs[VL_REGNUM] = 1;
     }
+
+  /* The standard ABIs all clobber the entire vector state on calls.  */
+  for (int regno = V_REG_FIRST; regno <= V_REG_LAST; regno++)
+    call_used_regs[regno] = 1;
+
+  call_used_regs[VTYPE_REGNUM] = 1;
+  call_used_regs[VL_REGNUM] = 1;
 }
 
 /* Return a register priority for hard reg REGNO.  */
-- 
2.34.1


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

* Re: [PATCH] RISC-V: Fix the V calling convention
  2022-09-01  3:27 [PATCH] RISC-V: Fix the V calling convention Palmer Dabbelt
  2022-09-01  3:27 ` Palmer Dabbelt
@ 2022-09-02  7:54 ` Kito Cheng
  1 sibling, 0 replies; 3+ messages in thread
From: Kito Cheng @ 2022-09-02  7:54 UTC (permalink / raw)
  To: Palmer Dabbelt; +Cc: GCC Patches

CALL_USED_REGISTERS already set those registers to 1, but I think it
is worth doing some clean up like this to prevent confusion.

On Thu, Sep 1, 2022 at 11:28 AM Palmer Dabbelt <palmer@rivosinc.com> wrote:
>
> The V registers are always clobbered on calls.
>
> gcc/ChangeLog
>
>         * config/riscv/riscv.cc (riscv_conditional_register_usage):
>         Always mark the V registers as clobbered on calls.
> ---
>  gcc/config/riscv/riscv.cc | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
> index 675d92c0961..c18e61f4a03 100644
> --- a/gcc/config/riscv/riscv.cc
> +++ b/gcc/config/riscv/riscv.cc
> @@ -5442,11 +5442,18 @@ riscv_conditional_register_usage (void)
>    if (!TARGET_VECTOR)
>      {
>        for (int regno = V_REG_FIRST; regno <= V_REG_LAST; regno++)
> -       fixed_regs[regno] = call_used_regs[regno] = 1;
> +       fixed_regs[regno] = 1;
>
> -      fixed_regs[VTYPE_REGNUM] = call_used_regs[VTYPE_REGNUM] = 1;
> -      fixed_regs[VL_REGNUM] = call_used_regs[VL_REGNUM] = 1;
> +      fixed_regs[VTYPE_REGNUM] = 1;
> +      fixed_regs[VL_REGNUM] = 1;
>      }

So we only need the above change I think.

> +
> +  /* The standard ABIs all clobber the entire vector state on calls.  */
> +  for (int regno = V_REG_FIRST; regno <= V_REG_LAST; regno++)
> +    call_used_regs[regno] = 1;
> +
> +  call_used_regs[VTYPE_REGNUM] = 1;
> +  call_used_regs[VL_REGNUM] = 1;
>  }
>
>  /* Return a register priority for hard reg REGNO.  */
> --
> 2.34.1
>

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

end of thread, other threads:[~2022-09-02  7:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-01  3:27 [PATCH] RISC-V: Fix the V calling convention Palmer Dabbelt
2022-09-01  3:27 ` Palmer Dabbelt
2022-09-02  7:54 ` Kito Cheng

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).