[llvm] r283527 - Use StringReg in TargetParser APIs (NFC)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 7 01:37:31 PDT 2016
Author: mehdi_amini
Date: Fri Oct 7 03:37:29 2016
New Revision: 283527
URL: http://llvm.org/viewvc/llvm-project?rev=283527&view=rev
Log:
Use StringReg in TargetParser APIs (NFC)
Modified:
llvm/trunk/include/llvm/Support/TargetParser.h
llvm/trunk/lib/Support/TargetParser.cpp
llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/trunk/unittests/Support/TargetParserTest.cpp
Modified: llvm/trunk/include/llvm/Support/TargetParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetParser.h?rev=283527&r1=283526&r2=283527&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/TargetParser.h (original)
+++ llvm/trunk/include/llvm/Support/TargetParser.h Fri Oct 7 03:37:29 2016
@@ -111,17 +111,17 @@ unsigned getFPUNeonSupportLevel(unsigned
unsigned getFPURestriction(unsigned FPUKind);
// FIXME: These should be moved to TargetTuple once it exists
-bool getFPUFeatures(unsigned FPUKind, std::vector<const char *> &Features);
-bool getHWDivFeatures(unsigned HWDivKind, std::vector<const char *> &Features);
+bool getFPUFeatures(unsigned FPUKind, std::vector<StringRef> &Features);
+bool getHWDivFeatures(unsigned HWDivKind, std::vector<StringRef> &Features);
bool getExtensionFeatures(unsigned Extensions,
- std::vector<const char*> &Features);
+ std::vector<StringRef> &Features);
StringRef getArchName(unsigned ArchKind);
unsigned getArchAttr(unsigned ArchKind);
StringRef getCPUAttr(unsigned ArchKind);
StringRef getSubArch(unsigned ArchKind);
StringRef getArchExtName(unsigned ArchExtKind);
-const char *getArchExtFeature(StringRef ArchExt);
+StringRef getArchExtFeature(StringRef ArchExt);
StringRef getHWDivName(unsigned HWDivKind);
// Information by Name
@@ -174,17 +174,17 @@ unsigned getFPUNeonSupportLevel(unsigned
unsigned getFPURestriction(unsigned FPUKind);
// FIXME: These should be moved to TargetTuple once it exists
-bool getFPUFeatures(unsigned FPUKind, std::vector<const char *> &Features);
+bool getFPUFeatures(unsigned FPUKind, std::vector<StringRef> &Features);
bool getExtensionFeatures(unsigned Extensions,
- std::vector<const char*> &Features);
-bool getArchFeatures(unsigned ArchKind, std::vector<const char *> &Features);
+ std::vector<StringRef> &Features);
+bool getArchFeatures(unsigned ArchKind, std::vector<StringRef> &Features);
StringRef getArchName(unsigned ArchKind);
unsigned getArchAttr(unsigned ArchKind);
StringRef getCPUAttr(unsigned ArchKind);
StringRef getSubArch(unsigned ArchKind);
StringRef getArchExtName(unsigned ArchExtKind);
-const char *getArchExtFeature(StringRef ArchExt);
+StringRef getArchExtFeature(StringRef ArchExt);
unsigned checkArchVersion(StringRef Arch);
// Information by Name
Modified: llvm/trunk/lib/Support/TargetParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/TargetParser.cpp?rev=283527&r1=283526&r2=283527&view=diff
==============================================================================
--- llvm/trunk/lib/Support/TargetParser.cpp (original)
+++ llvm/trunk/lib/Support/TargetParser.cpp Fri Oct 7 03:37:29 2016
@@ -200,7 +200,7 @@ unsigned llvm::ARM::getDefaultExtensions
}
bool llvm::ARM::getHWDivFeatures(unsigned HWDivKind,
- std::vector<const char *> &Features) {
+ std::vector<StringRef> &Features) {
if (HWDivKind == ARM::AEK_INVALID)
return false;
@@ -219,7 +219,7 @@ bool llvm::ARM::getHWDivFeatures(unsigne
}
bool llvm::ARM::getExtensionFeatures(unsigned Extensions,
- std::vector<const char *> &Features) {
+ std::vector<StringRef> &Features) {
if (Extensions == ARM::AEK_INVALID)
return false;
@@ -238,7 +238,7 @@ bool llvm::ARM::getExtensionFeatures(uns
}
bool llvm::ARM::getFPUFeatures(unsigned FPUKind,
- std::vector<const char *> &Features) {
+ std::vector<StringRef> &Features) {
if (FPUKind >= ARM::FK_LAST || FPUKind == ARM::FK_INVALID)
return false;
@@ -351,20 +351,20 @@ StringRef llvm::ARM::getArchExtName(unsi
return StringRef();
}
-const char *llvm::ARM::getArchExtFeature(StringRef ArchExt) {
+StringRef llvm::ARM::getArchExtFeature(StringRef ArchExt) {
if (ArchExt.startswith("no")) {
StringRef ArchExtBase(ArchExt.substr(2));
for (const auto AE : ARCHExtNames) {
if (AE.NegFeature && ArchExtBase == AE.getName())
- return AE.NegFeature;
+ return StringRef(AE.NegFeature);
}
}
for (const auto AE : ARCHExtNames) {
if (AE.Feature && ArchExt == AE.getName())
- return AE.Feature;
+ return StringRef(AE.Feature);
}
- return nullptr;
+ return StringRef();
}
StringRef llvm::ARM::getHWDivName(unsigned HWDivKind) {
@@ -429,7 +429,7 @@ unsigned llvm::AArch64::getDefaultExtens
}
bool llvm::AArch64::getExtensionFeatures(unsigned Extensions,
- std::vector<const char *> &Features) {
+ std::vector<StringRef> &Features) {
if (Extensions == AArch64::AEK_INVALID)
return false;
@@ -453,12 +453,12 @@ bool llvm::AArch64::getExtensionFeatures
}
bool llvm::AArch64::getFPUFeatures(unsigned FPUKind,
- std::vector<const char *> &Features) {
+ std::vector<StringRef> &Features) {
return ARM::getFPUFeatures(FPUKind, Features);
}
bool llvm::AArch64::getArchFeatures(unsigned ArchKind,
- std::vector<const char *> &Features) {
+ std::vector<StringRef> &Features) {
if (ArchKind == static_cast<unsigned>(AArch64::ArchKind::AK_ARMV8_1A))
Features.push_back("+v8.1a");
if (ArchKind == static_cast<unsigned>(AArch64::ArchKind::AK_ARMV8_2A))
@@ -501,19 +501,19 @@ StringRef llvm::AArch64::getArchExtName(
return StringRef();
}
-const char *llvm::AArch64::getArchExtFeature(StringRef ArchExt) {
+StringRef llvm::AArch64::getArchExtFeature(StringRef ArchExt) {
if (ArchExt.startswith("no")) {
StringRef ArchExtBase(ArchExt.substr(2));
for (const auto &AE : AArch64ARCHExtNames) {
if (AE.NegFeature && ArchExtBase == AE.getName())
- return AE.NegFeature;
+ return StringRef(AE.NegFeature);
}
}
for (const auto &AE : AArch64ARCHExtNames)
if (AE.Feature && ArchExt == AE.getName())
- return AE.Feature;
- return nullptr;
+ return StringRef(AE.Feature);
+ return StringRef();
}
StringRef llvm::AArch64::getDefaultCPU(StringRef Arch) {
Modified: llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp?rev=283527&r1=283526&r2=283527&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp Fri Oct 7 03:37:29 2016
@@ -4217,7 +4217,7 @@ bool AArch64AsmParser::parseDirectiveArc
}
// Get the architecture and extension features.
- std::vector<const char *> AArch64Features;
+ std::vector<StringRef> AArch64Features;
AArch64::getArchFeatures(ID, AArch64Features);
AArch64::getExtensionFeatures(AArch64::getDefaultExtensions("generic", ID),
AArch64Features);
Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=283527&r1=283526&r2=283527&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Fri Oct 7 03:37:29 2016
@@ -9729,7 +9729,7 @@ bool ARMAsmParser::parseDirectiveFPU(SML
StringRef FPU = getParser().parseStringToEndOfStatement().trim();
unsigned ID = ARM::parseFPU(FPU);
- std::vector<const char *> Features;
+ std::vector<StringRef> Features;
if (!ARM::getFPUFeatures(ID, Features)) {
Error(FPUNameLoc, "Unknown FPU name");
return false;
Modified: llvm/trunk/unittests/Support/TargetParserTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TargetParserTest.cpp?rev=283527&r1=283526&r2=283527&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/TargetParserTest.cpp (original)
+++ llvm/trunk/unittests/Support/TargetParserTest.cpp Fri Oct 7 03:37:29 2016
@@ -179,7 +179,7 @@ TEST(TargetParserTest, ARMDefaultExtensi
}
TEST(TargetParserTest, ARMExtensionFeatures) {
- std::vector<const char *> Features;
+ std::vector<StringRef> Features;
unsigned Extensions = ARM::AEK_CRC | ARM::AEK_CRYPTO | ARM::AEK_DSP |
ARM::AEK_HWDIVARM | ARM::AEK_HWDIV | ARM::AEK_MP |
ARM::AEK_SEC | ARM::AEK_VIRT | ARM::AEK_RAS;
@@ -190,7 +190,7 @@ TEST(TargetParserTest, ARMExtensionFeatu
}
TEST(TargetParserTest, ARMFPUFeatures) {
- std::vector<const char *> Features;
+ std::vector<StringRef> Features;
for (ARM::FPUKind FK = static_cast<ARM::FPUKind>(0);
FK <= ARM::FPUKind::FK_LAST;
FK = static_cast<ARM::FPUKind>(static_cast<unsigned>(FK) + 1))
@@ -227,8 +227,8 @@ TEST(TargetParserTest, ARMArchExtFeature
{"xscale", "noxscale", nullptr, nullptr}};
for (unsigned i = 0; i < array_lengthof(ArchExt); i++) {
- EXPECT_STREQ(ArchExt[i][2], ARM::getArchExtFeature(ArchExt[i][0]));
- EXPECT_STREQ(ArchExt[i][3], ARM::getArchExtFeature(ArchExt[i][1]));
+ EXPECT_EQ(StringRef(ArchExt[i][2]), ARM::getArchExtFeature(ArchExt[i][0]));
+ EXPECT_EQ(StringRef(ArchExt[i][3]), ARM::getArchExtFeature(ArchExt[i][1]));
}
}
@@ -431,7 +431,7 @@ TEST(TargetParserTest, AArch64DefaultExt
}
TEST(TargetParserTest, AArch64ExtensionFeatures) {
- std::vector<const char *> Features;
+ std::vector<StringRef> Features;
unsigned Extensions = AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
AArch64::AEK_FP | AArch64::AEK_SIMD |
AArch64::AEK_FP16 | AArch64::AEK_PROFILE |
@@ -443,7 +443,7 @@ TEST(TargetParserTest, AArch64ExtensionF
}
TEST(TargetParserTest, AArch64ArchFeatures) {
- std::vector<const char *> Features;
+ std::vector<StringRef> Features;
for (unsigned AK = 0; AK < static_cast<unsigned>(AArch64::ArchKind::AK_LAST);
AK++)
@@ -507,8 +507,8 @@ TEST(TargetParserTest, AArch64ArchExtFea
{"ras", "noras", "+ras", "-ras"}};
for (unsigned i = 0; i < array_lengthof(ArchExt); i++) {
- EXPECT_STREQ(ArchExt[i][2], AArch64::getArchExtFeature(ArchExt[i][0]));
- EXPECT_STREQ(ArchExt[i][3], AArch64::getArchExtFeature(ArchExt[i][1]));
+ EXPECT_EQ(StringRef(ArchExt[i][2]), AArch64::getArchExtFeature(ArchExt[i][0]));
+ EXPECT_EQ(StringRef(ArchExt[i][3]), AArch64::getArchExtFeature(ArchExt[i][1]));
}
}
More information about the llvm-commits
mailing list