diff mbox series

RISC-V: Reject 'd' extension with ILP32E ABI

Message ID 20240730213254.199844-1-patrick@rivosinc.com
State New
Headers show
Series RISC-V: Reject 'd' extension with ILP32E ABI | expand

Commit Message

Patrick O'Neill July 30, 2024, 9:32 p.m. UTC
Also add a testcase for -mabi=lp64d where 'd' is required.

gcc/ChangeLog:

	PR 116111
	* config/riscv/riscv.cc (riscv_option_override):

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/arch-41.c: New test.
	* gcc.target/riscv/pr116111.c: New test.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
---
 gcc/config/riscv/riscv.cc                 | 5 +++++
 gcc/testsuite/gcc.target/riscv/arch-41.c  | 7 +++++++
 gcc/testsuite/gcc.target/riscv/pr116111.c | 7 +++++++
 3 files changed, 19 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/riscv/arch-41.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/pr116111.c

Comments

Kito Cheng July 31, 2024, 12:22 a.m. UTC | #1
LGTM, although I thought for a few seconds whether to use sorry or
error, but I think we don't really feel sorry for that case, so just
error is fine :P

On Wed, Jul 31, 2024 at 5:33 AM Patrick O'Neill <patrick@rivosinc.com> wrote:
>
> Also add a testcase for -mabi=lp64d where 'd' is required.
>
> gcc/ChangeLog:
>
>         PR 116111
>         * config/riscv/riscv.cc (riscv_option_override):
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/riscv/arch-41.c: New test.
>         * gcc.target/riscv/pr116111.c: New test.
>
> Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
> ---
>  gcc/config/riscv/riscv.cc                 | 5 +++++
>  gcc/testsuite/gcc.target/riscv/arch-41.c  | 7 +++++++
>  gcc/testsuite/gcc.target/riscv/pr116111.c | 7 +++++++
>  3 files changed, 19 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/riscv/arch-41.c
>  create mode 100644 gcc/testsuite/gcc.target/riscv/pr116111.c
>
> diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
> index 8ece7859945..b19d56149e7 100644
> --- a/gcc/config/riscv/riscv.cc
> +++ b/gcc/config/riscv/riscv.cc
> @@ -9818,6 +9818,11 @@ riscv_option_override (void)
>         error ("rv64e requires lp64e ABI");
>      }
>
> +  /* ILP32E does not support the 'd' extension.  */
> +  if (riscv_abi == ABI_ILP32E && UNITS_PER_FP_REG > 4)
> +    error ("ILP32E ABI does not support the %qc extension",
> +          UNITS_PER_FP_REG > 8 ? 'Q' : 'D');
> +
>    /* Zfinx require abi ilp32, ilp32e, lp64 or lp64e.  */
>    if (TARGET_ZFINX
>        && riscv_abi != ABI_ILP32 && riscv_abi != ABI_LP64
> diff --git a/gcc/testsuite/gcc.target/riscv/arch-41.c b/gcc/testsuite/gcc.target/riscv/arch-41.c
> new file mode 100644
> index 00000000000..699eeb20a58
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/arch-41.c
> @@ -0,0 +1,7 @@
> +/* { dg-do compile } */
> +/* { dg-options "-march=rv64i -mabi=lp64d" } */
> +int
> +foo ()
> +{}
> +
> +/* { dg-error "requested ABI requires '-march' to subsume the 'D' extension" "" { target *-*-* } 0 } */
> diff --git a/gcc/testsuite/gcc.target/riscv/pr116111.c b/gcc/testsuite/gcc.target/riscv/pr116111.c
> new file mode 100644
> index 00000000000..5c824be2e93
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/pr116111.c
> @@ -0,0 +1,7 @@
> +/* { dg-do compile } */
> +/* { dg-options "-march=rv32ed -mabi=ilp32e" } */
> +int
> +foo ()
> +{}
> +
> +/* { dg-error "ILP32E ABI does not support the 'D' extension" "" { target *-*-* } 0 } */
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 8ece7859945..b19d56149e7 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -9818,6 +9818,11 @@  riscv_option_override (void)
 	error ("rv64e requires lp64e ABI");
     }
 
+  /* ILP32E does not support the 'd' extension.  */
+  if (riscv_abi == ABI_ILP32E && UNITS_PER_FP_REG > 4)
+    error ("ILP32E ABI does not support the %qc extension",
+	   UNITS_PER_FP_REG > 8 ? 'Q' : 'D');
+
   /* Zfinx require abi ilp32, ilp32e, lp64 or lp64e.  */
   if (TARGET_ZFINX
       && riscv_abi != ABI_ILP32 && riscv_abi != ABI_LP64
diff --git a/gcc/testsuite/gcc.target/riscv/arch-41.c b/gcc/testsuite/gcc.target/riscv/arch-41.c
new file mode 100644
index 00000000000..699eeb20a58
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/arch-41.c
@@ -0,0 +1,7 @@ 
+/* { dg-do compile } */
+/* { dg-options "-march=rv64i -mabi=lp64d" } */
+int
+foo ()
+{}
+
+/* { dg-error "requested ABI requires '-march' to subsume the 'D' extension" "" { target *-*-* } 0 } */
diff --git a/gcc/testsuite/gcc.target/riscv/pr116111.c b/gcc/testsuite/gcc.target/riscv/pr116111.c
new file mode 100644
index 00000000000..5c824be2e93
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr116111.c
@@ -0,0 +1,7 @@ 
+/* { dg-do compile } */
+/* { dg-options "-march=rv32ed -mabi=ilp32e" } */
+int
+foo ()
+{}
+
+/* { dg-error "ILP32E ABI does not support the 'D' extension" "" { target *-*-* } 0 } */