[PATCH] D42979: [ARM] Add 'fillValidCPUArchList' to ARM targets
Erich Keane via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 7 12:24:11 PST 2018
erichkeane updated this revision to Diff 133275.
erichkeane added a comment.
Added tests as requested. Should cover all current comments.
https://reviews.llvm.org/D42979
Files:
include/llvm/Support/TargetParser.h
lib/Support/TargetParser.cpp
unittests/Support/TargetParserTest.cpp
Index: unittests/Support/TargetParserTest.cpp
===================================================================
--- unittests/Support/TargetParserTest.cpp
+++ unittests/Support/TargetParserTest.cpp
@@ -279,6 +279,20 @@
"7-S"));
}
+static const int NumARMCPUArchs = 82;
+
+TEST(TargetParserTest, testARMCPUArchList) {
+ SmallVector<StringRef, 32> List;
+ ARM::fillValidCPUArchList(List);
+
+ // No list exists for these in this test suite, so ensure all are
+ // valid, and match the expected 'magic' count.
+ EXPECT_EQ(List.size(), NumARMCPUArchs);
+ for(StringRef CPU : List) {
+ EXPECT_NE(ARM::parseCPUArch(CPU), ARM::ArchKind::INVALID);
+ }
+}
+
TEST(TargetParserTest, testInvalidARMArch) {
auto InvalidArchStrings = {"armv", "armv99", "noarm"};
for (const char* InvalidArch : InvalidArchStrings)
@@ -747,6 +761,20 @@
"8-A"));
}
+static const int NumAArch64CPUArchs = 19;
+
+TEST(TargetParserTest, testAArch64CPUArchList) {
+ SmallVector<StringRef, 32> List;
+ AArch64::fillValidCPUArchList(List);
+
+ // No list exists for these in this test suite, so ensure all are
+ // valid, and match the expected 'magic' count.
+ EXPECT_EQ(List.size(), NumAArch64CPUArchs);
+ for(StringRef CPU : List) {
+ EXPECT_NE(AArch64::parseCPUArch(CPU), AArch64::ArchKind::INVALID);
+ }
+}
+
bool testAArch64Arch(StringRef Arch, StringRef DefaultCPU, StringRef SubArch,
unsigned ArchAttr) {
AArch64::ArchKind AK = AArch64::parseArch(Arch);
Index: lib/Support/TargetParser.cpp
===================================================================
--- lib/Support/TargetParser.cpp
+++ lib/Support/TargetParser.cpp
@@ -689,6 +689,20 @@
return ARM::ArchKind::INVALID;
}
+void llvm::ARM::fillValidCPUArchList(SmallVectorImpl<StringRef> &Values) {
+ for (const CpuNames<ARM::ArchKind> &Arch : CPUNames) {
+ if (Arch.ArchID != ARM::ArchKind::INVALID)
+ Values.emplace_back(Arch.NameCStr, Arch.NameLength);
+ }
+}
+
+void llvm::AArch64::fillValidCPUArchList(SmallVectorImpl<StringRef> &Values) {
+ for (const CpuNames<AArch64::ArchKind> &Arch : AArch64CPUNames) {
+ if (Arch.ArchID != AArch64::ArchKind::INVALID)
+ Values.emplace_back(Arch.NameCStr, Arch.NameLength);
+ }
+}
+
// ARM, Thumb, AArch64
ARM::ISAKind ARM::parseArchISA(StringRef Arch) {
return StringSwitch<ARM::ISAKind>(Arch)
Index: include/llvm/Support/TargetParser.h
===================================================================
--- include/llvm/Support/TargetParser.h
+++ include/llvm/Support/TargetParser.h
@@ -137,6 +137,7 @@
ArchKind parseArch(StringRef Arch);
unsigned parseArchExt(StringRef ArchExt);
ArchKind parseCPUArch(StringRef CPU);
+void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values);
ISAKind parseArchISA(StringRef Arch);
EndianKind parseArchEndian(StringRef Arch);
ProfileKind parseArchProfile(StringRef Arch);
@@ -205,6 +206,7 @@
AArch64::ArchKind parseArch(StringRef Arch);
ArchExtKind parseArchExt(StringRef ArchExt);
ArchKind parseCPUArch(StringRef CPU);
+void fillValidCPUArchList(SmallVectorImpl<StringRef> &Values);
ARM::ISAKind parseArchISA(StringRef Arch);
ARM::EndianKind parseArchEndian(StringRef Arch);
ARM::ProfileKind parseArchProfile(StringRef Arch);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42979.133275.patch
Type: text/x-patch
Size: 3273 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180207/67394f81/attachment.bin>
More information about the llvm-commits
mailing list