RISC-V: Add Z*inx incompatible check in gcc.

Message ID 20230326083458.1240538-1-jiawei@iscas.ac.cn
State Dropped
Headers
Series RISC-V: Add Z*inx incompatible check in gcc. |

Commit Message

Jiawei March 26, 2023, 8:34 a.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/config/riscv/riscv.cc | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Kito Cheng March 27, 2023, 8:15 a.m. UTC | #1
HI Jiawei:

Thanks for the fix!

Two comments:
- Could you add testcase like
https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.target/riscv/arch-12.c
- And I would prefer those check happened in riscv_subset_list::parse
@gcc/common/config/riscv/riscv-common.cc

On Sun, Mar 26, 2023 at 4:36 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/config/riscv/riscv.cc | 4 ++++
>  1 file changed, 4 insertions(+)
>
> 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);
> --
> 2.25.1
>
  
Jiawei March 28, 2023, 2:36 p.m. UTC | #2
Hi Kito,

Thanks for your sugestions, I had added the new testcases in the new patch.
I feel it's hard to check long string name extension by use riscv_subset_list::parse,
Since it just check one char when the pointer moving, So I still keep the implement
by check the extenstison with target. Maybe we can add new check function in the new
version :)


&gt; -----原始邮件-----
&gt; 发件人: "Kito Cheng" <kito.cheng@gmail.com>
&gt; 发送时间: 2023-03-27 16:15:00 (星期一)
&gt; 收件人: 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] RISC-V: Add Z*inx incompatible check in gcc.
&gt; 
&gt; HI Jiawei:
&gt; 
&gt; Thanks for the fix!
&gt; 
&gt; Two comments:
&gt; - Could you add testcase like
&gt; https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.target/riscv/arch-12.c
&gt; - And I would prefer those check happened in riscv_subset_list::parse
&gt; @gcc/common/config/riscv/riscv-common.cc
&gt; 
&gt; On Sun, Mar 26, 2023 at 4:36 PM Jiawei <jiawei@iscas.ac.cn> wrote:
&gt; &gt;
&gt; &gt; Z*inx is conflict with float extensions, add incompatible check when
&gt; &gt; z*inx and hard_float both enabled.
&gt; &gt;
&gt; &gt; gcc/ChangeLog:
&gt; &gt;
&gt; &gt;         * config/riscv/riscv.cc (riscv_option_override): New check.
&gt; &gt;
&gt; &gt; ---
&gt; &gt;  gcc/config/riscv/riscv.cc | 4 ++++
&gt; &gt;  1 file changed, 4 insertions(+)
&gt; &gt;
&gt; &gt; diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
&gt; &gt; index 76eee4a55e9..162ba14d3c7 100644
&gt; &gt; --- a/gcc/config/riscv/riscv.cc
&gt; &gt; +++ b/gcc/config/riscv/riscv.cc
&gt; &gt; @@ -6285,6 +6285,10 @@ riscv_option_override (void)
&gt; &gt;        &amp;&amp; riscv_abi != ABI_LP64 &amp;&amp; riscv_abi != ABI_ILP32E)
&gt; &gt;      error ("z*inx requires ABI ilp32, ilp32e or lp64");
&gt; &gt;
&gt; &gt; +  // Zfinx is conflict with float extensions.
&gt; &gt; +  if (TARGET_ZFINX &amp;&amp; TARGET_HARD_FLOAT)
&gt; &gt; +    error ("z*inx is conflict with float extensions");
&gt; &gt; +
&gt; &gt;    /* We do not yet support ILP32 on RV64.  */
&gt; &gt;    if (BITS_PER_WORD != POINTER_SIZE)
&gt; &gt;      error ("ABI requires %&lt;-march=rv%d%&gt;", POINTER_SIZE);
&gt; &gt; --
&gt; &gt; 2.25.1
&gt; &gt;
</jiawei@iscas.ac.cn></jiawei@iscas.ac.cn></kito.cheng@gmail.com>
  
Kito Cheng March 28, 2023, 2:43 p.m. UTC | #3
Maybe something like this?

diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index acfd7b92563..aa7edc8cfec 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -1155,6 +1155,10 @@ riscv_subset_list::parse (const char *arch,
location_t loc)

  subset_list->handle_combine_ext ();

+  if (subset_list->lookup("zfinx") && subset_list->lookup("f"))
+    error_at (loc, "%<-march=%s%>: z*inx is conflict with float extensions",
+             arch);
+
  return subset_list;

fail:



On Tue, Mar 28, 2023 at 10:36 PM <jiawei@iscas.ac.cn> wrote:
>
> Hi Kito,
>
> Thanks for your sugestions, I had added the new testcases in the new patch.
> I feel it's hard to check long string name extension by use riscv_subset_list::parse,
> Since it just check one char when the pointer moving, So I still keep the implement
> by check the extenstison with target. Maybe we can add new check function in the new
> version :)
>
>
> &gt; -----原始邮件-----
> &gt; 发件人: "Kito Cheng" <kito.cheng@gmail.com>
> &gt; 发送时间: 2023-03-27 16:15:00 (星期一)
> &gt; 收件人: 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] RISC-V: Add Z*inx incompatible check in gcc.
> &gt;
> &gt; HI Jiawei:
> &gt;
> &gt; Thanks for the fix!
> &gt;
> &gt; Two comments:
> &gt; - Could you add testcase like
> &gt; https://github.com/gcc-mirror/gcc/blob/master/gcc/testsuite/gcc.target/riscv/arch-12.c
> &gt; - And I would prefer those check happened in riscv_subset_list::parse
> &gt; @gcc/common/config/riscv/riscv-common.cc
> &gt;
> &gt; On Sun, Mar 26, 2023 at 4:36 PM Jiawei <jiawei@iscas.ac.cn> wrote:
> &gt; &gt;
> &gt; &gt; Z*inx is conflict with float extensions, add incompatible check when
> &gt; &gt; z*inx and hard_float both enabled.
> &gt; &gt;
> &gt; &gt; gcc/ChangeLog:
> &gt; &gt;
> &gt; &gt;         * config/riscv/riscv.cc (riscv_option_override): New check.
> &gt; &gt;
> &gt; &gt; ---
> &gt; &gt;  gcc/config/riscv/riscv.cc | 4 ++++
> &gt; &gt;  1 file changed, 4 insertions(+)
> &gt; &gt;
> &gt; &gt; diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
> &gt; &gt; index 76eee4a55e9..162ba14d3c7 100644
> &gt; &gt; --- a/gcc/config/riscv/riscv.cc
> &gt; &gt; +++ b/gcc/config/riscv/riscv.cc
> &gt; &gt; @@ -6285,6 +6285,10 @@ riscv_option_override (void)
> &gt; &gt;        &amp;&amp; riscv_abi != ABI_LP64 &amp;&amp; riscv_abi != ABI_ILP32E)
> &gt; &gt;      error ("z*inx requires ABI ilp32, ilp32e or lp64");
> &gt; &gt;
> &gt; &gt; +  // Zfinx is conflict with float extensions.
> &gt; &gt; +  if (TARGET_ZFINX &amp;&amp; TARGET_HARD_FLOAT)
> &gt; &gt; +    error ("z*inx is conflict with float extensions");
> &gt; &gt; +
> &gt; &gt;    /* We do not yet support ILP32 on RV64.  */
> &gt; &gt;    if (BITS_PER_WORD != POINTER_SIZE)
> &gt; &gt;      error ("ABI requires %&lt;-march=rv%d%&gt;", POINTER_SIZE);
> &gt; &gt; --
> &gt; &gt; 2.25.1
> &gt; &gt;
> </jiawei@iscas.ac.cn></jiawei@iscas.ac.cn></kito.cheng@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);