llvm.org GIT mirror llvm / a47cbd9
Use StringReg in TargetParser APIs (NFC) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283527 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 3 years ago
5 changed file(s) with 34 addition(s) and 34 deletion(s). Raw diff Collapse all Expand all
110110 unsigned getFPURestriction(unsigned FPUKind);
111111
112112 // FIXME: These should be moved to TargetTuple once it exists
113 bool getFPUFeatures(unsigned FPUKind, std::vector &Features);
114 bool getHWDivFeatures(unsigned HWDivKind, std::vector> &Features);
113 bool getFPUFeatures(unsigned FPUKind, std::vector> &Features);
114 bool getHWDivFeatures(unsigned HWDivKind, std::vector &Features);
115115 bool getExtensionFeatures(unsigned Extensions,
116 std::vector> &Features);
116 std::vector> &Features);
117117
118118 StringRef getArchName(unsigned ArchKind);
119119 unsigned getArchAttr(unsigned ArchKind);
120120 StringRef getCPUAttr(unsigned ArchKind);
121121 StringRef getSubArch(unsigned ArchKind);
122122 StringRef getArchExtName(unsigned ArchExtKind);
123 const char *getArchExtFeature(StringRef ArchExt);
123 StringRef getArchExtFeature(StringRef ArchExt);
124124 StringRef getHWDivName(unsigned HWDivKind);
125125
126126 // Information by Name
173173 unsigned getFPURestriction(unsigned FPUKind);
174174
175175 // FIXME: These should be moved to TargetTuple once it exists
176 bool getFPUFeatures(unsigned FPUKind, std::vector<const char *> &Features);
176 bool getFPUFeatures(unsigned FPUKind, std::vector<StringRef> &Features);
177177 bool getExtensionFeatures(unsigned Extensions,
178 std::vector &Features);
179 bool getArchFeatures(unsigned ArchKind, std::vector> &Features);
178 std::vector> &Features);
179 bool getArchFeatures(unsigned ArchKind, std::vector &Features);
180180
181181 StringRef getArchName(unsigned ArchKind);
182182 unsigned getArchAttr(unsigned ArchKind);
183183 StringRef getCPUAttr(unsigned ArchKind);
184184 StringRef getSubArch(unsigned ArchKind);
185185 StringRef getArchExtName(unsigned ArchExtKind);
186 const char *getArchExtFeature(StringRef ArchExt);
186 StringRef getArchExtFeature(StringRef ArchExt);
187187 unsigned checkArchVersion(StringRef Arch);
188188
189189 // Information by Name
199199 }
200200
201201 bool llvm::ARM::getHWDivFeatures(unsigned HWDivKind,
202 std::vector<const char *> &Features) {
202 std::vector<StringRef> &Features) {
203203
204204 if (HWDivKind == ARM::AEK_INVALID)
205205 return false;
218218 }
219219
220220 bool llvm::ARM::getExtensionFeatures(unsigned Extensions,
221 std::vector<const char *> &Features) {
221 std::vector<StringRef> &Features) {
222222
223223 if (Extensions == ARM::AEK_INVALID)
224224 return false;
237237 }
238238
239239 bool llvm::ARM::getFPUFeatures(unsigned FPUKind,
240 std::vector<const char *> &Features) {
240 std::vector<StringRef> &Features) {
241241
242242 if (FPUKind >= ARM::FK_LAST || FPUKind == ARM::FK_INVALID)
243243 return false;
350350 return StringRef();
351351 }
352352
353 const char *llvm::ARM::getArchExtFeature(StringRef ArchExt) {
353 StringRef llvm::ARM::getArchExtFeature(StringRef ArchExt) {
354354 if (ArchExt.startswith("no")) {
355355 StringRef ArchExtBase(ArchExt.substr(2));
356356 for (const auto AE : ARCHExtNames) {
357357 if (AE.NegFeature && ArchExtBase == AE.getName())
358 return AE.NegFeature;
358 return StringRef(AE.NegFeature);
359359 }
360360 }
361361 for (const auto AE : ARCHExtNames) {
362362 if (AE.Feature && ArchExt == AE.getName())
363 return AE.Feature;
364 }
365
366 return nullptr;
363 return StringRef(AE.Feature);
364 }
365
366 return StringRef();
367367 }
368368
369369 StringRef llvm::ARM::getHWDivName(unsigned HWDivKind) {
428428 }
429429
430430 bool llvm::AArch64::getExtensionFeatures(unsigned Extensions,
431 std::vector<const char *> &Features) {
431 std::vector<StringRef> &Features) {
432432
433433 if (Extensions == AArch64::AEK_INVALID)
434434 return false;
452452 }
453453
454454 bool llvm::AArch64::getFPUFeatures(unsigned FPUKind,
455 std::vector<const char *> &Features) {
455 std::vector<StringRef> &Features) {
456456 return ARM::getFPUFeatures(FPUKind, Features);
457457 }
458458
459459 bool llvm::AArch64::getArchFeatures(unsigned ArchKind,
460 std::vector<const char *> &Features) {
460 std::vector<StringRef> &Features) {
461461 if (ArchKind == static_cast(AArch64::ArchKind::AK_ARMV8_1A))
462462 Features.push_back("+v8.1a");
463463 if (ArchKind == static_cast(AArch64::ArchKind::AK_ARMV8_2A))
500500 return StringRef();
501501 }
502502
503 const char *llvm::AArch64::getArchExtFeature(StringRef ArchExt) {
503 StringRef llvm::AArch64::getArchExtFeature(StringRef ArchExt) {
504504 if (ArchExt.startswith("no")) {
505505 StringRef ArchExtBase(ArchExt.substr(2));
506506 for (const auto &AE : AArch64ARCHExtNames) {
507507 if (AE.NegFeature && ArchExtBase == AE.getName())
508 return AE.NegFeature;
508 return StringRef(AE.NegFeature);
509509 }
510510 }
511511
512512 for (const auto &AE : AArch64ARCHExtNames)
513513 if (AE.Feature && ArchExt == AE.getName())
514 return AE.Feature;
515 return nullptr;
514 return StringRef(AE.Feature);
515 return StringRef();
516516 }
517517
518518 StringRef llvm::AArch64::getDefaultCPU(StringRef Arch) {
42164216 }
42174217
42184218 // Get the architecture and extension features.
4219 std::vector<const char *> AArch64Features;
4219 std::vector<StringRef> AArch64Features;
42204220 AArch64::getArchFeatures(ID, AArch64Features);
42214221 AArch64::getExtensionFeatures(AArch64::getDefaultExtensions("generic", ID),
42224222 AArch64Features);
97289728 StringRef FPU = getParser().parseStringToEndOfStatement().trim();
97299729
97309730 unsigned ID = ARM::parseFPU(FPU);
9731 std::vector<const char *> Features;
9731 std::vector<StringRef> Features;
97329732 if (!ARM::getFPUFeatures(ID, Features)) {
97339733 Error(FPUNameLoc, "Unknown FPU name");
97349734 return false;
178178 }
179179
180180 TEST(TargetParserTest, ARMExtensionFeatures) {
181 std::vector<const char *> Features;
181 std::vector<StringRef> Features;
182182 unsigned Extensions = ARM::AEK_CRC | ARM::AEK_CRYPTO | ARM::AEK_DSP |
183183 ARM::AEK_HWDIVARM | ARM::AEK_HWDIV | ARM::AEK_MP |
184184 ARM::AEK_SEC | ARM::AEK_VIRT | ARM::AEK_RAS;
189189 }
190190
191191 TEST(TargetParserTest, ARMFPUFeatures) {
192 std::vector<const char *> Features;
192 std::vector<StringRef> Features;
193193 for (ARM::FPUKind FK = static_cast(0);
194194 FK <= ARM::FPUKind::FK_LAST;
195195 FK = static_cast(static_cast(FK) + 1))
226226 {"xscale", "noxscale", nullptr, nullptr}};
227227
228228 for (unsigned i = 0; i < array_lengthof(ArchExt); i++) {
229 EXPECT_STREQ(ArchExt[i][2], ARM::getArchExtFeature(ArchExt[i][0]));
230 EXPECT_STREQ(ArchExt[i][3], ARM::getArchExtFeature(ArchExt[i][1]));
229 EXPECT_EQ(StringRef(ArchExt[i][2]), ARM::getArchExtFeature(ArchExt[i][0]));
230 EXPECT_EQ(StringRef(ArchExt[i][3]), ARM::getArchExtFeature(ArchExt[i][1]));
231231 }
232232 }
233233
430430 }
431431
432432 TEST(TargetParserTest, AArch64ExtensionFeatures) {
433 std::vector<const char *> Features;
433 std::vector<StringRef> Features;
434434 unsigned Extensions = AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
435435 AArch64::AEK_FP | AArch64::AEK_SIMD |
436436 AArch64::AEK_FP16 | AArch64::AEK_PROFILE |
442442 }
443443
444444 TEST(TargetParserTest, AArch64ArchFeatures) {
445 std::vector<const char *> Features;
445 std::vector<StringRef> Features;
446446
447447 for (unsigned AK = 0; AK < static_cast(AArch64::ArchKind::AK_LAST);
448448 AK++)
506506 {"ras", "noras", "+ras", "-ras"}};
507507
508508 for (unsigned i = 0; i < array_lengthof(ArchExt); i++) {
509 EXPECT_STREQ(ArchExt[i][2], AArch64::getArchExtFeature(ArchExt[i][0]));
510 EXPECT_STREQ(ArchExt[i][3], AArch64::getArchExtFeature(ArchExt[i][1]));
509 EXPECT_EQ(StringRef(ArchExt[i][2]), AArch64::getArchExtFeature(ArchExt[i][0]));
510 EXPECT_EQ(StringRef(ArchExt[i][3]), AArch64::getArchExtFeature(ArchExt[i][1]));
511511 }
512512 }
513513