[v2] RISC-V: Add Z*inx imcompatible check in gcc.

Message ID 20230328142302.3824535-1-jiawei@iscas.ac.cn
State Committed
Headers
Series [v2] RISC-V: Add Z*inx imcompatible check in gcc. |

Commit Message

Jiawei March 28, 2023, 2:23 p.m. UTC
  Z*inx is conflict with float extensions, add incompatible check when
z*inx and hard_float both enabled.

gcc/ChangeLog:

        * config/riscv/riscv.cc (riscv_option_override): New check.

gcc/testsuite/ChangeLog:

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

---
 gcc/config/riscv/riscv.cc                | 4 ++++
 gcc/testsuite/gcc.target/riscv/arch-19.c | 4 ++++
 2 files changed, 8 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/riscv/arch-19.c
  

Comments

Kito Cheng March 28, 2023, 2:30 p.m. UTC | #1
I would prefer those checking happened in
riscv_subset_list::parse@gcc/common/config/riscv/riscv-common.cc that
could be reused when we adding target attribute.

And I plan integrate the arch-canonicalize script to just reusing
whole arch string parser in GCC 14, so it would be great to have all
check within riscv_subset_list::parse

On Tue, Mar 28, 2023 at 10:23 PM Jiawei <jiawei@iscas.ac.cn> wrote:
>
> Z*inx is conflict with float extensions, add incompatible check when
> z*inx and hard_float both enabled.
>
> gcc/ChangeLog:
>
>         * config/riscv/riscv.cc (riscv_option_override): New check.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/riscv/arch-19.c: New test.
>
> ---
>  gcc/config/riscv/riscv.cc                | 4 ++++
>  gcc/testsuite/gcc.target/riscv/arch-19.c | 4 ++++
>  2 files changed, 8 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/riscv/arch-19.c
>
> diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
> index 76eee4a55e9..162ba14d3c7 100644
> --- a/gcc/config/riscv/riscv.cc
> +++ b/gcc/config/riscv/riscv.cc
> @@ -6285,6 +6285,10 @@ riscv_option_override (void)
>        && riscv_abi != ABI_LP64 && riscv_abi != ABI_ILP32E)
>      error ("z*inx requires ABI ilp32, ilp32e or lp64");
>
> +  // Zfinx is conflict with float extensions.
> +  if (TARGET_ZFINX && TARGET_HARD_FLOAT)
> +    error ("z*inx is conflict with float extensions");
> +
>    /* We do not yet support ILP32 on RV64.  */
>    if (BITS_PER_WORD != POINTER_SIZE)
>      error ("ABI requires %<-march=rv%d%>", POINTER_SIZE);
> diff --git a/gcc/testsuite/gcc.target/riscv/arch-19.c b/gcc/testsuite/gcc.target/riscv/arch-19.c
> new file mode 100644
> index 00000000000..a6f72af3677
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/riscv/arch-19.c
> @@ -0,0 +1,4 @@
> +/* { dg-do compile } */
> +/* { dg-options "-march=rv64if_zfinx -mabi=lp64" } */
> +int foo() {}
> +/* { dg-error "z*inx is conflict with float extensions" "" { target *-*-* } 0 } */
> --
> 2.25.1
>
  
Hans-Peter Nilsson April 4, 2023, 1:46 a.m. UTC | #2
On Tue, 28 Mar 2023, Jiawei wrote:

> +  // Zfinx is conflict with float extensions.
> +  if (TARGET_ZFINX && TARGET_HARD_FLOAT)
> +    error ("z*inx is conflict with float extensions");
> +

While I'm not a native English speaker, "is conflict with" 
doesn't sound grammatically correct.  Perhaps "conflicts with" 
or "is in conflict with"?

brgds, H-P
  
Jeff Law April 5, 2023, 1:30 a.m. UTC | #3
On 4/3/23 19:46, Hans-Peter Nilsson wrote:
> On Tue, 28 Mar 2023, Jiawei wrote:
> 
>> +  // Zfinx is conflict with float extensions.
>> +  if (TARGET_ZFINX && TARGET_HARD_FLOAT)
>> +    error ("z*inx is conflict with float extensions");
>> +
> 
> While I'm not a native English speaker, "is conflict with"
> doesn't sound grammatically correct.  Perhaps "conflicts with"
> or "is in conflict with"?
"conflicts with" is better.

Jeff
  
Jiawei April 6, 2023, 2:56 a.m. UTC | #4
&gt; -----原始邮件-----
&gt; 发件人: "Jeff Law" <jeffreyalaw@gmail.com>
&gt; 发送时间: 2023-04-05 09:30:43 (星期三)
&gt; 收件人: "Hans-Peter Nilsson" <hp@bitrange.com>, Jiawei <jiawei@iscas.ac.cn>
&gt; 抄送: gcc-patches@gcc.gnu.org, kito.cheng@sifive.com, palmer@dabbelt.com, christoph.muellner@vrull.eu, wuwei2016@iscas.ac.cn
&gt; 主题: Re: [PATCH v2] RISC-V: Add Z*inx imcompatible check in gcc.
&gt; 
&gt; 
&gt; 
&gt; On 4/3/23 19:46, Hans-Peter Nilsson wrote:
&gt; &gt; On Tue, 28 Mar 2023, Jiawei wrote:
&gt; &gt; 
&gt; &gt;&gt; +  // Zfinx is conflict with float extensions.
&gt; &gt;&gt; +  if (TARGET_ZFINX &amp;&amp; TARGET_HARD_FLOAT)
&gt; &gt;&gt; +    error ("z*inx is conflict with float extensions");
&gt; &gt;&gt; +
&gt; &gt; 
&gt; &gt; While I'm not a native English speaker, "is conflict with"
&gt; &gt; doesn't sound grammatically correct.  Perhaps "conflicts with"
&gt; &gt; or "is in conflict with"?
&gt; "conflicts with" is better.
&gt; 
&gt; Jeff

Thanks for your reply, fixed in the trunk.

BR,
Jiawei</jiawei@iscas.ac.cn></hp@bitrange.com></jeffreyalaw@gmail.com>
  

Patch

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 76eee4a55e9..162ba14d3c7 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -6285,6 +6285,10 @@  riscv_option_override (void)
       && riscv_abi != ABI_LP64 && riscv_abi != ABI_ILP32E)
     error ("z*inx requires ABI ilp32, ilp32e or lp64");
 
+  // Zfinx is conflict with float extensions.
+  if (TARGET_ZFINX && TARGET_HARD_FLOAT)
+    error ("z*inx is conflict with float extensions");
+
   /* We do not yet support ILP32 on RV64.  */
   if (BITS_PER_WORD != POINTER_SIZE)
     error ("ABI requires %<-march=rv%d%>", POINTER_SIZE);
diff --git a/gcc/testsuite/gcc.target/riscv/arch-19.c b/gcc/testsuite/gcc.target/riscv/arch-19.c
new file mode 100644
index 00000000000..a6f72af3677
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/arch-19.c
@@ -0,0 +1,4 @@ 
+/* { dg-do compile } */
+/* { dg-options "-march=rv64if_zfinx -mabi=lp64" } */
+int foo() {}
+/* { dg-error "z*inx is conflict with float extensions" "" { target *-*-* } 0 } */