From: Jin Ma Date: Tue, 18 Apr 2023 09:26:49 +0000 (+0800) Subject: RISC-V: Adjust the parsing order of extensions to be consistent with riscv-spec and... X-Git-Tag: basepoints/gcc-15~10116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4204ed2dc74390ab3689d1d6a53001761338baf6;p=thirdparty%2Fgcc.git RISC-V: Adjust the parsing order of extensions to be consistent with riscv-spec and binutils. 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. --- diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 2fc0f8bffc15..309a52def75f 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 b945a643cc15..8258552214f8 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() { }