]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Adjust the parsing order of extensions to be consistent with riscv-spec and...
authorJin Ma <jinma@linux.alibaba.com>
Tue, 18 Apr 2023 09:26:49 +0000 (17:26 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Tue, 18 Apr 2023 10:13:04 +0000 (18:13 +0800)
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
gcc/testsuite/gcc.target/riscv/arch-5.c

index 2fc0f8bffc15643ebd2ba7aead1e84485ee5f118..309a52def75f1faa497d059fb3e19700bc5bbc13 100644 (file)
@@ -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;
index b945a643cc15c88f788c34d14df64dd71a04ad78..8258552214f8b44dcb1e6ee38f00f9d9bc10eb91 100644 (file)
@@ -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()
 {
 }