From: Jin Ma <jinma@linux.alibaba.com>
To: gcc-patches@gcc.gnu.org
Cc: jeffreyalaw@gmail.com, kito.cheng@sifive.com,
kito.cheng@gmail.com, palmer@dabbelt.com, ijinma@yeah.net,
Jin Ma <jinma@linux.alibaba.com>
Subject: [PATCH] RISC-V: Adjust the parsing order of extensions to be consistent with riscv-spec and binutils.
Date: Tue, 18 Apr 2023 17:26:49 +0800 [thread overview]
Message-ID: <20230418092649.156-1-jinma@linux.alibaba.com> (raw)
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
next reply other threads:[~2023-04-18 9:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-18 9:26 Jin Ma [this message]
2023-04-18 10:19 ` Kito Cheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230418092649.156-1-jinma@linux.alibaba.com \
--to=jinma@linux.alibaba.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=ijinma@yeah.net \
--cc=jeffreyalaw@gmail.com \
--cc=kito.cheng@gmail.com \
--cc=kito.cheng@sifive.com \
--cc=palmer@dabbelt.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).