[clang] 3f81d25 - [RISCV] Remove 'sx' when parsing arch string to match the latest ISA manual
Jun Sha via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 19 19:32:20 PDT 2023
Author: Jun Sha (Joshua)
Date: 2023-04-20T10:32:24+08:00
New Revision: 3f81d25cee7065a4a7888bbe9ad7138081dcd4cf
URL: https://github.com/llvm/llvm-project/commit/3f81d25cee7065a4a7888bbe9ad7138081dcd4cf
DIFF: https://github.com/llvm/llvm-project/commit/3f81d25cee7065a4a7888bbe9ad7138081dcd4cf.diff
LOG: [RISCV] Remove 'sx' when parsing arch string to match the latest ISA manual
In order to match the latest ISA manual, we need to remove sx prefix.
Reviewed By: asb
Differential Revision: https://reviews.llvm.org/D148617
Added:
Modified:
clang/test/Driver/riscv-arch.c
llvm/lib/Support/RISCVISAInfo.cpp
llvm/unittests/Support/RISCVISAInfoTest.cpp
Removed:
################################################################################
diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index 573f4a6d1f395..4d11db2a5e09a 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -253,11 +253,6 @@
// RV32X: error: invalid arch name 'rv32xabc',
// RV32X: first letter should be 'e', 'i' or 'g'
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32sxabc -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32SX %s
-// RV32SX: error: invalid arch name 'rv32sxabc',
-// RV32SX: first letter should be 'e', 'i' or 'g'
-
// RUN: %clang --target=riscv32-unknown-elf -march=rv32sabc -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32S %s
// RV32S: error: invalid arch name 'rv32sabc',
@@ -268,21 +263,15 @@
// RV32X-NAME: error: invalid arch name 'rv32ix',
// RV32X-NAME: non-standard user-level extension name missing after 'x'
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32isx -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32SX-NAME %s
-// RV32SX-NAME: error: invalid arch name 'rv32isx',
-// RV32SX-NAME: non-standard supervisor-level extension
-// RV32SX-NAME: name missing after 'sx'
-
// RUN: %clang --target=riscv32-unknown-elf -march=rv32is -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32S-NAME %s
// RV32S-NAME: error: invalid arch name 'rv32is',
// RV32S-NAME: standard supervisor-level extension
// RV32S-NAME: name missing after 's'
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32ix_s_sx -### %s \
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32ix_s -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32ALL-NAME %s
-// RV32ALL-NAME: error: invalid arch name 'rv32ix_s_sx',
+// RV32ALL-NAME: error: invalid arch name 'rv32ix_s',
// RV32ALL-NAME: non-standard user-level extension
// RV32ALL-NAME: name missing after 'x'
@@ -296,14 +285,9 @@
// RV32S-UNS: error: invalid arch name 'rv32isa',
// RV32S-UNS: unsupported standard supervisor-level extension 'sa'
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32isxabc -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32SX-UNS %s
-// RV32SX-UNS: error: invalid arch name 'rv32isxabc',
-// RV32SX-UNS: unsupported non-standard supervisor-level extension 'sxabc'
-
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32isp_xabc_sxlw -### %s \
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32isp_xabc -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32ALL %s
-// RV32ALL: error: invalid arch name 'rv32isp_xabc_sxlw',
+// RV32ALL: error: invalid arch name 'rv32isp_xabc',
// RV32ALL: unsupported standard supervisor-level extension 'sp'
// RUN: %clang --target=riscv32-unknown-elf -march=rv32i20 -### %s \
@@ -336,11 +320,6 @@
// RV32-SMINOR0: error: invalid arch name 'rv32ist2p0',
// RV32-SMINOR0: unsupported version number 2.0 for extension 'st'
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32isxt2p1 -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-SXMINOR1 %s
-// RV32-SXMINOR1: error: invalid arch name 'rv32isxt2p1', unsupported
-// RV32-SXMINOR1: version number 2.1 for extension 'sxt'
-
// RUN: %clang --target=riscv32-unknown-elf -march=rv32ixabc_ -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-XSEP %s
// RV32-XSEP: error: invalid arch name 'rv32ixabc_',
@@ -357,12 +336,6 @@
// RV32-X-ORDER: standard supervisor-level extension not given
// RV32-X-ORDER: in canonical order 'sabc'
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32isxabc_sdef -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-S-ORDER %s
-// RV32-S-ORDER: error: invalid arch name 'rv32isxabc_sdef',
-// RV32-S-ORDER: standard supervisor-level extension not given
-// RV32-S-ORDER: in canonical order 'sdef'
-
// RUN: %clang --target=riscv32-unknown-elf -march=rv32ixabc_xabc -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-XDUP %s
// RV32-XDUP: error: invalid arch name 'rv32ixabc_xabc',
@@ -373,10 +346,10 @@
// RV32-X-X-INVAL: error: invalid arch name 'rv32ixabc_xdef', unsupported
// RV32-X-X-INVAL: non-standard user-level extension 'xabc'
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32isdef_xabc_sxghi -### %s \
-// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-X-S-SX-INVAL %s
-// RV32-X-S-SX-INVAL: error: invalid arch name 'rv32isdef_xabc_sxghi',
-// RV32-X-S-SX-INVAL: unsupported standard supervisor-level extension 'sdef'
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32isdef_xabc -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-X-S-INVAL %s
+// RV32-X-S-INVAL: error: invalid arch name 'rv32isdef_xabc',
+// RV32-X-S-INVAL: unsupported standard supervisor-level extension 'sdef'
// RUN: %clang --target=riscv32-unknown-elf -march=rv32i -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-TARGET %s
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp
index d5523ef6893ce..4cb70884ee28c 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -217,8 +217,6 @@ void RISCVISAInfo::addExtension(StringRef ExtName, unsigned MajorVersion,
}
static StringRef getExtensionTypeDesc(StringRef Ext) {
- if (Ext.startswith("sx"))
- return "non-standard supervisor-level extension";
if (Ext.startswith("s"))
return "standard supervisor-level extension";
if (Ext.startswith("x"))
@@ -229,8 +227,6 @@ static StringRef getExtensionTypeDesc(StringRef Ext) {
}
static StringRef getExtensionType(StringRef Ext) {
- if (Ext.startswith("sx"))
- return "sx";
if (Ext.startswith("s"))
return "s";
if (Ext.startswith("x"))
@@ -640,7 +636,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
StringRef Exts = Arch.substr(5);
// Remove multi-letter standard extensions, non-standard extensions and
- // supervisor-level extensions. They have 'z', 'x', 's', 'sx' prefixes.
+ // supervisor-level extensions. They have 'z', 'x', 's' prefixes.
// Parse them at the end.
// Find the very first occurrence of 's', 'x' or 'z'.
StringRef OtherExts;
@@ -759,7 +755,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
// Parse the ISA string containing non-standard user-level
// extensions, standard supervisor-level extensions and
// non-standard supervisor-level extensions.
- // These extensions start with 'z', 's', 'x', 'sx' prefixes, follow a
+ // These extensions start with 'z', 's', 'x' prefixes, follow a
// canonical order, might have a version number (major, minor)
// and are separated by a single underscore '_'.
// Set the hardware features for the extensions that are supported.
@@ -770,7 +766,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
OtherExts.split(Split, '_');
SmallVector<StringRef, 8> AllExts;
- std::array<StringRef, 4> Prefix{"z", "s", "x", "sx"};
+ std::array<StringRef, 4> Prefix{"z", "s", "x"};
auto I = Prefix.begin();
auto E = Prefix.end();
if (Split.size() > 1 || Split[0] != "") {
diff --git a/llvm/unittests/Support/RISCVISAInfoTest.cpp b/llvm/unittests/Support/RISCVISAInfoTest.cpp
index 44f1abd972544..a301b25cf7d6f 100644
--- a/llvm/unittests/Support/RISCVISAInfoTest.cpp
+++ b/llvm/unittests/Support/RISCVISAInfoTest.cpp
@@ -223,10 +223,6 @@ TEST(ParseArchString, RejectsUnrecognizedExtensionNamesByDefault) {
toString(
RISCVISAInfo::parseArchString("rv64g_smadeup", true).takeError()),
"unsupported standard supervisor-level extension 'smadeup'");
- EXPECT_EQ(
- toString(
- RISCVISAInfo::parseArchString("rv64g_sxmadeup", true).takeError()),
- "unsupported non-standard supervisor-level extension 'sxmadeup'");
EXPECT_EQ(
toString(
RISCVISAInfo::parseArchString("rv64g_xmadeup", true).takeError()),
@@ -234,8 +230,8 @@ TEST(ParseArchString, RejectsUnrecognizedExtensionNamesByDefault) {
}
TEST(ParseArchString, IgnoresUnrecognizedExtensionNamesWithIgnoreUnknown) {
- for (StringRef Input : {"rv32ib", "rv32i_zmadeup", "rv64i_smadeup",
- "rv32i_sxmadeup", "rv64i_xmadeup"}) {
+ for (StringRef Input : {"rv32ib", "rv32i_zmadeup",
+ "rv64i_smadeup", "rv64i_xmadeup"}) {
auto MaybeISAInfo = RISCVISAInfo::parseArchString(Input, true, false, true);
ASSERT_THAT_EXPECTED(MaybeISAInfo, Succeeded());
RISCVISAInfo &Info = **MaybeISAInfo;
More information about the cfe-commits
mailing list