public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] RISC-V: Adjust the parsing order of extensions to be consistent with riscv-spec and binutils.
@ 2023-04-18  9:26 Jin Ma
  2023-04-18 10:19 ` Kito Cheng
  0 siblings, 1 reply; 2+ messages in thread
From: Jin Ma @ 2023-04-18  9:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: jeffreyalaw, kito.cheng, kito.cheng, palmer, ijinma, Jin Ma

The current order of gcc and binutils parsing extensions is inconsistent.

According to latest risc-v spec, the canonical order in which extension names must
appear in the name string specified in Table 29.1 is different from before.

In the latest table, non-standard extensions must be listed after all standard
extensions. To keep consistent, we now change the parsing order.

Related llvm patch links:
 https://reviews.llvm.org/D148315

gcc/ChangeLog:

	* common/config/riscv/riscv-common.cc (multi_letter_subset_rank): Swap the order
	of z-extensions and s-extensions.
	(riscv_subset_list::parse): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/arch-5.c: Likewise.
---
 gcc/common/config/riscv/riscv-common.cc | 12 ++++++------
 gcc/testsuite/gcc.target/riscv/arch-5.c |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
index 2fc0f8bffc1..309a52def75 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -398,10 +398,10 @@ multi_letter_subset_rank (const std::string &subset)
   char multiletter_class = subset[0];
   switch (multiletter_class)
     {
-    case 's':
+    case 'z':
       high_order = 0;
       break;
-    case 'z':
+    case 's':
       high_order = 1;
       break;
     case 'x':
@@ -1121,14 +1121,14 @@ riscv_subset_list::parse (const char *arch, location_t loc)
   if (p == NULL)
     goto fail;
 
-  /* Parsing supervisor extension.  */
-  p = subset_list->parse_multiletter_ext (p, "s", "supervisor extension");
+  /* Parsing sub-extensions.  */
+  p = subset_list->parse_multiletter_ext (p, "z", "sub-extension");
 
   if (p == NULL)
     goto fail;
 
-  /* Parsing sub-extensions.  */
-  p = subset_list->parse_multiletter_ext (p, "z", "sub-extension");
+  /* Parsing supervisor extension.  */
+  p = subset_list->parse_multiletter_ext (p, "s", "supervisor extension");
 
   if (p == NULL)
     goto fail;
diff --git a/gcc/testsuite/gcc.target/riscv/arch-5.c b/gcc/testsuite/gcc.target/riscv/arch-5.c
index b945a643cc1..8258552214f 100644
--- a/gcc/testsuite/gcc.target/riscv/arch-5.c
+++ b/gcc/testsuite/gcc.target/riscv/arch-5.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv32isabc_zfoo_xbar -mabi=ilp32" } */
+/* { dg-options "-march=rv32i_zfoo_sabc_xbar -mabi=ilp32" } */
 int foo()
 {
 }
-- 
2.17.1


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

* Re: [PATCH] RISC-V: Adjust the parsing order of extensions to be consistent with riscv-spec and binutils.
  2023-04-18  9:26 [PATCH] RISC-V: Adjust the parsing order of extensions to be consistent with riscv-spec and binutils Jin Ma
@ 2023-04-18 10:19 ` Kito Cheng
  0 siblings, 0 replies; 2+ messages in thread
From: Kito Cheng @ 2023-04-18 10:19 UTC (permalink / raw)
  To: Jin Ma; +Cc: gcc-patches, jeffreyalaw, kito.cheng, palmer, ijinma

Thanks, applied to trunk :)

On Tue, Apr 18, 2023 at 5:27 PM Jin Ma <jinma@linux.alibaba.com> wrote:
>
> The current order of gcc and binutils parsing extensions is inconsistent.
>
> According to latest risc-v spec, the canonical order in which extension names must
> appear in the name string specified in Table 29.1 is different from before.
>
> In the latest table, non-standard extensions must be listed after all standard
> extensions. To keep consistent, we now change the parsing order.
>
> Related llvm patch links:
>  https://reviews.llvm.org/D148315
>
> gcc/ChangeLog:
>
>         * common/config/riscv/riscv-common.cc (multi_letter_subset_rank): Swap the order
>         of z-extensions and s-extensions.
>         (riscv_subset_list::parse): Likewise.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/riscv/arch-5.c: Likewise.
> ---
>  gcc/common/config/riscv/riscv-common.cc | 12 ++++++------
>  gcc/testsuite/gcc.target/riscv/arch-5.c |  2 +-
>  2 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc
> index 2fc0f8bffc1..309a52def75 100644
> --- a/gcc/common/config/riscv/riscv-common.cc
> +++ b/gcc/common/config/riscv/riscv-common.cc
> @@ -398,10 +398,10 @@ multi_letter_subset_rank (const std::string &subset)
>    char multiletter_class = subset[0];
>    switch (multiletter_class)
>      {
> -    case 's':
> +    case 'z':
>        high_order = 0;
>        break;
> -    case 'z':
> +    case 's':
>        high_order = 1;
>        break;
>      case 'x':
> @@ -1121,14 +1121,14 @@ riscv_subset_list::parse (const char *arch, location_t loc)
>    if (p == NULL)
>      goto fail;
>
> -  /* Parsing supervisor extension.  */
> -  p = subset_list->parse_multiletter_ext (p, "s", "supervisor extension");
> +  /* Parsing sub-extensions.  */
> +  p = subset_list->parse_multiletter_ext (p, "z", "sub-extension");
>
>    if (p == NULL)
>      goto fail;
>
> -  /* Parsing sub-extensions.  */
> -  p = subset_list->parse_multiletter_ext (p, "z", "sub-extension");
> +  /* Parsing supervisor extension.  */
> +  p = subset_list->parse_multiletter_ext (p, "s", "supervisor extension");
>
>    if (p == NULL)
>      goto fail;
> diff --git a/gcc/testsuite/gcc.target/riscv/arch-5.c b/gcc/testsuite/gcc.target/riscv/arch-5.c
> index b945a643cc1..8258552214f 100644
> --- a/gcc/testsuite/gcc.target/riscv/arch-5.c
> +++ b/gcc/testsuite/gcc.target/riscv/arch-5.c
> @@ -1,5 +1,5 @@
>  /* { dg-do compile } */
> -/* { dg-options "-march=rv32isabc_zfoo_xbar -mabi=ilp32" } */
> +/* { dg-options "-march=rv32i_zfoo_sabc_xbar -mabi=ilp32" } */
>  int foo()
>  {
>  }
> --
> 2.17.1
>

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

end of thread, other threads:[~2023-04-18 10:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18  9:26 [PATCH] RISC-V: Adjust the parsing order of extensions to be consistent with riscv-spec and binutils Jin Ma
2023-04-18 10:19 ` 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).