diff mbox series

RISC-V: Fix parsing of Zic* extensions

Message ID 20240428230445.855337-1-christoph.muellner@vrull.eu
State New
Headers show
Series RISC-V: Fix parsing of Zic* extensions | expand

Commit Message

Christoph Müllner April 28, 2024, 11:04 p.m. UTC
The extension parsing table entries for a range of Zic* extensions
does not match the mask definition in riscv.opt.
This results in broken TARGET_ZIC* macros, because the values of
riscv_zi_subext and riscv_zicmo_subext are set wrong.

This patch fixes this by moving Zic64b into riscv_zicmo_subext
and all other affected Zic* extensions to riscv_zi_subext.

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc: Move ziccamoa, ziccif,
	zicclsm, and ziccrse into riscv_zi_subext.
	* config/riscv/riscv.opt: Define MASK_ZIC64B for
	riscv_ziccmo_subext.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
---
 gcc/common/config/riscv/riscv-common.cc | 8 ++++----
 gcc/config/riscv/riscv.opt              | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

Comments

Kito Cheng April 29, 2024, 3:57 a.m. UTC | #1
OK for trunk, and my understanding is that flag isn't really used in
code gen yet, so it's not necessary to port to GCC 14 branch?

On Mon, Apr 29, 2024 at 7:05 AM Christoph Müllner
<christoph.muellner@vrull.eu> wrote:
>
> The extension parsing table entries for a range of Zic* extensions
> does not match the mask definition in riscv.opt.
> This results in broken TARGET_ZIC* macros, because the values of
> riscv_zi_subext and riscv_zicmo_subext are set wrong.
>
> This patch fixes this by moving Zic64b into riscv_zicmo_subext
> and all other affected Zic* extensions to riscv_zi_subext.
>
> gcc/ChangeLog:
>
>         * common/config/riscv/riscv-common.cc: Move ziccamoa, ziccif,
>         zicclsm, and ziccrse into riscv_zi_subext.
>         * config/riscv/riscv.opt: Define MASK_ZIC64B for
>         riscv_ziccmo_subext.
>
> Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
> ---
>  gcc/common/config/riscv/riscv-common.cc | 8 ++++----
>  gcc/config/riscv/riscv.opt              | 4 ++--
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
> index 43b7549e3ec..8cc0e727737 100644
> --- a/gcc/common/config/riscv/riscv-common.cc
> +++ b/gcc/common/config/riscv/riscv-common.cc
> @@ -1638,15 +1638,15 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] =
>
>    {"zihintntl", &gcc_options::x_riscv_zi_subext, MASK_ZIHINTNTL},
>    {"zihintpause", &gcc_options::x_riscv_zi_subext, MASK_ZIHINTPAUSE},
> +  {"ziccamoa", &gcc_options::x_riscv_zi_subext, MASK_ZICCAMOA},
> +  {"ziccif", &gcc_options::x_riscv_zi_subext, MASK_ZICCIF},
> +  {"zicclsm", &gcc_options::x_riscv_zi_subext, MASK_ZICCLSM},
> +  {"ziccrse", &gcc_options::x_riscv_zi_subext, MASK_ZICCRSE},
>
>    {"zicboz", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOZ},
>    {"zicbom", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOM},
>    {"zicbop", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOP},
>    {"zic64b", &gcc_options::x_riscv_zicmo_subext, MASK_ZIC64B},
> -  {"ziccamoa", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCAMOA},
> -  {"ziccif", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCIF},
> -  {"zicclsm", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCLSM},
> -  {"ziccrse", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCRSE},
>
>    {"zve32x",   &gcc_options::x_target_flags, MASK_VECTOR},
>    {"zve32f",   &gcc_options::x_target_flags, MASK_VECTOR},
> diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
> index b14888e9816..ee824756381 100644
> --- a/gcc/config/riscv/riscv.opt
> +++ b/gcc/config/riscv/riscv.opt
> @@ -237,8 +237,6 @@ Mask(ZIHINTPAUSE) Var(riscv_zi_subext)
>
>  Mask(ZICOND)      Var(riscv_zi_subext)
>
> -Mask(ZIC64B)      Var(riscv_zi_subext)
> -
>  Mask(ZICCAMOA)    Var(riscv_zi_subext)
>
>  Mask(ZICCIF)      Var(riscv_zi_subext)
> @@ -390,6 +388,8 @@ Mask(ZICBOM) Var(riscv_zicmo_subext)
>
>  Mask(ZICBOP) Var(riscv_zicmo_subext)
>
> +Mask(ZIC64B) Var(riscv_zicmo_subext)
> +
>  TargetVariable
>  int riscv_zf_subext
>
> --
> 2.44.0
>
Christoph Müllner April 29, 2024, 7:09 a.m. UTC | #2
On Mon, Apr 29, 2024 at 5:58 AM Kito Cheng <kito.cheng@gmail.com> wrote:
>
> OK for trunk, and my understanding is that flag isn't really used in
> code gen yet, so it's not necessary to port to GCC 14 branch?

Pushed to master.

Since the riscv_zi_subext masks of the affected extensions are applied
to higher bits of riscv_zicmo_subext (beyond Zicbom, Zicbop, Zicboz),
this triggers indeed no issue in GCC 14 (because the TARGET_ZI* macros
are not used). Therefore, no backport to GCC 14.

Thanks!

>
> On Mon, Apr 29, 2024 at 7:05 AM Christoph Müllner
> <christoph.muellner@vrull.eu> wrote:
> >
> > The extension parsing table entries for a range of Zic* extensions
> > does not match the mask definition in riscv.opt.
> > This results in broken TARGET_ZIC* macros, because the values of
> > riscv_zi_subext and riscv_zicmo_subext are set wrong.
> >
> > This patch fixes this by moving Zic64b into riscv_zicmo_subext
> > and all other affected Zic* extensions to riscv_zi_subext.
> >
> > gcc/ChangeLog:
> >
> >         * common/config/riscv/riscv-common.cc: Move ziccamoa, ziccif,
> >         zicclsm, and ziccrse into riscv_zi_subext.
> >         * config/riscv/riscv.opt: Define MASK_ZIC64B for
> >         riscv_ziccmo_subext.
> >
> > Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
> > ---
> >  gcc/common/config/riscv/riscv-common.cc | 8 ++++----
> >  gcc/config/riscv/riscv.opt              | 4 ++--
> >  2 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
> > index 43b7549e3ec..8cc0e727737 100644
> > --- a/gcc/common/config/riscv/riscv-common.cc
> > +++ b/gcc/common/config/riscv/riscv-common.cc
> > @@ -1638,15 +1638,15 @@ static const riscv_ext_flag_table_t riscv_ext_flag_table[] =
> >
> >    {"zihintntl", &gcc_options::x_riscv_zi_subext, MASK_ZIHINTNTL},
> >    {"zihintpause", &gcc_options::x_riscv_zi_subext, MASK_ZIHINTPAUSE},
> > +  {"ziccamoa", &gcc_options::x_riscv_zi_subext, MASK_ZICCAMOA},
> > +  {"ziccif", &gcc_options::x_riscv_zi_subext, MASK_ZICCIF},
> > +  {"zicclsm", &gcc_options::x_riscv_zi_subext, MASK_ZICCLSM},
> > +  {"ziccrse", &gcc_options::x_riscv_zi_subext, MASK_ZICCRSE},
> >
> >    {"zicboz", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOZ},
> >    {"zicbom", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOM},
> >    {"zicbop", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOP},
> >    {"zic64b", &gcc_options::x_riscv_zicmo_subext, MASK_ZIC64B},
> > -  {"ziccamoa", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCAMOA},
> > -  {"ziccif", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCIF},
> > -  {"zicclsm", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCLSM},
> > -  {"ziccrse", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCRSE},
> >
> >    {"zve32x",   &gcc_options::x_target_flags, MASK_VECTOR},
> >    {"zve32f",   &gcc_options::x_target_flags, MASK_VECTOR},
> > diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
> > index b14888e9816..ee824756381 100644
> > --- a/gcc/config/riscv/riscv.opt
> > +++ b/gcc/config/riscv/riscv.opt
> > @@ -237,8 +237,6 @@ Mask(ZIHINTPAUSE) Var(riscv_zi_subext)
> >
> >  Mask(ZICOND)      Var(riscv_zi_subext)
> >
> > -Mask(ZIC64B)      Var(riscv_zi_subext)
> > -
> >  Mask(ZICCAMOA)    Var(riscv_zi_subext)
> >
> >  Mask(ZICCIF)      Var(riscv_zi_subext)
> > @@ -390,6 +388,8 @@ Mask(ZICBOM) Var(riscv_zicmo_subext)
> >
> >  Mask(ZICBOP) Var(riscv_zicmo_subext)
> >
> > +Mask(ZIC64B) Var(riscv_zicmo_subext)
> > +
> >  TargetVariable
> >  int riscv_zf_subext
> >
> > --
> > 2.44.0
> >
diff mbox series

Patch

diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
index 43b7549e3ec..8cc0e727737 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -1638,15 +1638,15 @@  static const riscv_ext_flag_table_t riscv_ext_flag_table[] =
 
   {"zihintntl", &gcc_options::x_riscv_zi_subext, MASK_ZIHINTNTL},
   {"zihintpause", &gcc_options::x_riscv_zi_subext, MASK_ZIHINTPAUSE},
+  {"ziccamoa", &gcc_options::x_riscv_zi_subext, MASK_ZICCAMOA},
+  {"ziccif", &gcc_options::x_riscv_zi_subext, MASK_ZICCIF},
+  {"zicclsm", &gcc_options::x_riscv_zi_subext, MASK_ZICCLSM},
+  {"ziccrse", &gcc_options::x_riscv_zi_subext, MASK_ZICCRSE},
 
   {"zicboz", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOZ},
   {"zicbom", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOM},
   {"zicbop", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOP},
   {"zic64b", &gcc_options::x_riscv_zicmo_subext, MASK_ZIC64B},
-  {"ziccamoa", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCAMOA},
-  {"ziccif", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCIF},
-  {"zicclsm", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCLSM},
-  {"ziccrse", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCRSE},
 
   {"zve32x",   &gcc_options::x_target_flags, MASK_VECTOR},
   {"zve32f",   &gcc_options::x_target_flags, MASK_VECTOR},
diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
index b14888e9816..ee824756381 100644
--- a/gcc/config/riscv/riscv.opt
+++ b/gcc/config/riscv/riscv.opt
@@ -237,8 +237,6 @@  Mask(ZIHINTPAUSE) Var(riscv_zi_subext)
 
 Mask(ZICOND)      Var(riscv_zi_subext)
 
-Mask(ZIC64B)      Var(riscv_zi_subext)
-
 Mask(ZICCAMOA)    Var(riscv_zi_subext)
 
 Mask(ZICCIF)      Var(riscv_zi_subext)
@@ -390,6 +388,8 @@  Mask(ZICBOM) Var(riscv_zicmo_subext)
 
 Mask(ZICBOP) Var(riscv_zicmo_subext)
 
+Mask(ZIC64B) Var(riscv_zicmo_subext)
+
 TargetVariable
 int riscv_zf_subext