[llvm] [clang] [RISCV] Deduplicate version struct in RISCVISAInfo. NFC (PR #77645)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 10 09:53:24 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 14e291000f96c20e35ef494bd407f459b4617fca 916d4f271982501b7236d60b90c9fa822f7aa2a6 -- clang/lib/Basic/Targets/RISCV.cpp llvm/include/llvm/Support/RISCVISAInfo.h llvm/lib/Support/RISCVISAInfo.cpp llvm/unittests/Support/RISCVISAInfoTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp
index abd947700a..fb312b6cf2 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -163,9 +163,8 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
auto ExtName = Extension.first;
auto ExtInfo = Extension.second;
- Builder.defineMacro(
- Twine("__riscv_", ExtName),
- Twine(getVersionValue(ExtInfo.Major, ExtInfo.Minor)));
+ Builder.defineMacro(Twine("__riscv_", ExtName),
+ Twine(getVersionValue(ExtInfo.Major, ExtInfo.Minor)));
}
if (ISAInfo->hasExtension("m") || ISAInfo->hasExtension("zmmul"))
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp
index 86be440add..2d21d371dc 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -189,8 +189,7 @@ static const RISCVSupportedExtension SupportedExperimentalExtensions[] = {
{"zfbfmin", {0, 8}},
- {"zicfilp", {0, 4}},
- {"zicfiss", {0, 4}},
+ {"zicfilp", {0, 4}}, {"zicfiss", {0, 4}},
{"zicond", {1, 0}},
@@ -198,8 +197,7 @@ static const RISCVSupportedExtension SupportedExperimentalExtensions[] = {
{"ztso", {0, 1}},
- {"zvfbfmin", {0, 8}},
- {"zvfbfwma", {0, 8}},
+ {"zvfbfmin", {0, 8}}, {"zvfbfwma", {0, 8}},
};
static void verifyTables() {
@@ -232,8 +230,8 @@ void llvm::riscvExtensionsHelp(StringMap<StringRef> DescMap) {
for (const auto &E : SupportedExtensions)
ExtMap[E.Name] = {E.Version.Major, E.Version.Minor};
for (const auto &E : ExtMap) {
- std::string Version = std::to_string(E.second.Major) + "." +
- std::to_string(E.second.Minor);
+ std::string Version =
+ std::to_string(E.second.Major) + "." + std::to_string(E.second.Minor);
PrintExtension(E.first, Version, DescMap[E.first]);
}
@@ -242,8 +240,8 @@ void llvm::riscvExtensionsHelp(StringMap<StringRef> DescMap) {
for (const auto &E : SupportedExperimentalExtensions)
ExtMap[E.Name] = {E.Version.Major, E.Version.Minor};
for (const auto &E : ExtMap) {
- std::string Version = std::to_string(E.second.Major) + "." +
- std::to_string(E.second.Minor);
+ std::string Version =
+ std::to_string(E.second.Major) + "." + std::to_string(E.second.Minor);
PrintExtension(E.first, Version, DescMap["experimental-" + E.first]);
}
@@ -304,7 +302,8 @@ findDefaultVersion(StringRef ExtName) {
return std::nullopt;
}
-void RISCVISAInfo::addExtension(StringRef ExtName, RISCVISAInfo::ExtensionVersion Version) {
+void RISCVISAInfo::addExtension(StringRef ExtName,
+ RISCVISAInfo::ExtensionVersion Version) {
Exts[ExtName.str()] = Version;
}
diff --git a/llvm/unittests/Support/RISCVISAInfoTest.cpp b/llvm/unittests/Support/RISCVISAInfoTest.cpp
index 236b513b69..997551e5c4 100644
--- a/llvm/unittests/Support/RISCVISAInfoTest.cpp
+++ b/llvm/unittests/Support/RISCVISAInfoTest.cpp
@@ -50,28 +50,32 @@ TEST(ParseNormalizedArchString, AcceptsValidBaseISAsAndSetsXLen) {
ASSERT_THAT_EXPECTED(MaybeRV32I, Succeeded());
RISCVISAInfo &InfoRV32I = **MaybeRV32I;
EXPECT_EQ(InfoRV32I.getExtensions().size(), 1UL);
- EXPECT_TRUE(InfoRV32I.getExtensions().at("i") == (RISCVISAInfo::ExtensionVersion{2, 0}));
+ EXPECT_TRUE(InfoRV32I.getExtensions().at("i") ==
+ (RISCVISAInfo::ExtensionVersion{2, 0}));
EXPECT_EQ(InfoRV32I.getXLen(), 32U);
auto MaybeRV32E = RISCVISAInfo::parseNormalizedArchString("rv32e2p0");
ASSERT_THAT_EXPECTED(MaybeRV32E, Succeeded());
RISCVISAInfo &InfoRV32E = **MaybeRV32E;
EXPECT_EQ(InfoRV32E.getExtensions().size(), 1UL);
- EXPECT_TRUE(InfoRV32E.getExtensions().at("e") == (RISCVISAInfo::ExtensionVersion{2, 0}));
+ EXPECT_TRUE(InfoRV32E.getExtensions().at("e") ==
+ (RISCVISAInfo::ExtensionVersion{2, 0}));
EXPECT_EQ(InfoRV32E.getXLen(), 32U);
auto MaybeRV64I = RISCVISAInfo::parseNormalizedArchString("rv64i2p0");
ASSERT_THAT_EXPECTED(MaybeRV64I, Succeeded());
RISCVISAInfo &InfoRV64I = **MaybeRV64I;
EXPECT_EQ(InfoRV64I.getExtensions().size(), 1UL);
- EXPECT_TRUE(InfoRV64I.getExtensions().at("i") == (RISCVISAInfo::ExtensionVersion{2, 0}));
+ EXPECT_TRUE(InfoRV64I.getExtensions().at("i") ==
+ (RISCVISAInfo::ExtensionVersion{2, 0}));
EXPECT_EQ(InfoRV64I.getXLen(), 64U);
auto MaybeRV64E = RISCVISAInfo::parseNormalizedArchString("rv64e2p0");
ASSERT_THAT_EXPECTED(MaybeRV64E, Succeeded());
RISCVISAInfo &InfoRV64E = **MaybeRV64E;
EXPECT_EQ(InfoRV64E.getExtensions().size(), 1UL);
- EXPECT_TRUE(InfoRV64E.getExtensions().at("e") == (RISCVISAInfo::ExtensionVersion{2, 0}));
+ EXPECT_TRUE(InfoRV64E.getExtensions().at("e") ==
+ (RISCVISAInfo::ExtensionVersion{2, 0}));
EXPECT_EQ(InfoRV64E.getXLen(), 64U);
}
@@ -81,12 +85,16 @@ TEST(ParseNormalizedArchString, AcceptsArbitraryExtensionsAndVersions) {
ASSERT_THAT_EXPECTED(MaybeISAInfo, Succeeded());
RISCVISAInfo &Info = **MaybeISAInfo;
EXPECT_EQ(Info.getExtensions().size(), 5UL);
- EXPECT_TRUE(Info.getExtensions().at("i") == (RISCVISAInfo::ExtensionVersion{5, 1}));
- EXPECT_TRUE(Info.getExtensions().at("m") == (RISCVISAInfo::ExtensionVersion{3, 2}));
+ EXPECT_TRUE(Info.getExtensions().at("i") ==
+ (RISCVISAInfo::ExtensionVersion{5, 1}));
+ EXPECT_TRUE(Info.getExtensions().at("m") ==
+ (RISCVISAInfo::ExtensionVersion{3, 2}));
EXPECT_TRUE(Info.getExtensions().at("zmadeup") ==
(RISCVISAInfo::ExtensionVersion{11, 12}));
- EXPECT_TRUE(Info.getExtensions().at("sfoo") == (RISCVISAInfo::ExtensionVersion{2, 0}));
- EXPECT_TRUE(Info.getExtensions().at("xbar") == (RISCVISAInfo::ExtensionVersion{3, 0}));
+ EXPECT_TRUE(Info.getExtensions().at("sfoo") ==
+ (RISCVISAInfo::ExtensionVersion{2, 0}));
+ EXPECT_TRUE(Info.getExtensions().at("xbar") ==
+ (RISCVISAInfo::ExtensionVersion{3, 0}));
}
TEST(ParseNormalizedArchString, UpdatesFLenMinVLenMaxELen) {
@@ -155,7 +163,8 @@ TEST(ParseArchString, AcceptsSupportedBaseISAsAndSetsXLenAndFLen) {
EXPECT_TRUE(ExtsRV32G.at("f") == (RISCVISAInfo::ExtensionVersion{2, 2}));
EXPECT_TRUE(ExtsRV32G.at("d") == (RISCVISAInfo::ExtensionVersion{2, 2}));
EXPECT_TRUE(ExtsRV32G.at("zicsr") == (RISCVISAInfo::ExtensionVersion{2, 0}));
- EXPECT_TRUE(ExtsRV32G.at("zifencei") == (RISCVISAInfo::ExtensionVersion{2, 0}));
+ EXPECT_TRUE(ExtsRV32G.at("zifencei") ==
+ (RISCVISAInfo::ExtensionVersion{2, 0}));
EXPECT_EQ(InfoRV32G.getXLen(), 32U);
EXPECT_EQ(InfoRV32G.getFLen(), 64U);
@@ -188,7 +197,8 @@ TEST(ParseArchString, AcceptsSupportedBaseISAsAndSetsXLenAndFLen) {
EXPECT_TRUE(ExtsRV64G.at("f") == (RISCVISAInfo::ExtensionVersion{2, 2}));
EXPECT_TRUE(ExtsRV64G.at("d") == (RISCVISAInfo::ExtensionVersion{2, 2}));
EXPECT_TRUE(ExtsRV64G.at("zicsr") == (RISCVISAInfo::ExtensionVersion{2, 0}));
- EXPECT_TRUE(ExtsRV64G.at("zifencei") == (RISCVISAInfo::ExtensionVersion{2, 0}));
+ EXPECT_TRUE(ExtsRV64G.at("zifencei") ==
+ (RISCVISAInfo::ExtensionVersion{2, 0}));
EXPECT_EQ(InfoRV64G.getXLen(), 64U);
EXPECT_EQ(InfoRV64G.getFLen(), 64U);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/77645
More information about the llvm-commits
mailing list