[PATCH] D64048: [TargetParser][ARM] Account dependencies when processing target features
Alexandros Lamprineas via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 1 17:08:01 PDT 2019
labrinea created this revision.
labrinea added reviewers: llvm-commits, ostannard.
Herald added subscribers: cfe-commits, dmgreen, hiraditya, kristof.beyls, javed.absar.
Herald added projects: clang, LLVM.
Teaches `ARM::appendArchExtFeatures` to account dependencies when processing target features: i.e. when you say `-march=armv8.1-m.main+mve.fp+nofp` it means `mve.fp` should get discarded too. (Split from D63936 <https://reviews.llvm.org/D63936>)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D64048
Files:
clang/test/Preprocessor/arm-target-features.c
llvm/lib/Support/ARMTargetParser.cpp
Index: llvm/lib/Support/ARMTargetParser.cpp
===================================================================
--- llvm/lib/Support/ARMTargetParser.cpp
+++ llvm/lib/Support/ARMTargetParser.cpp
@@ -508,16 +508,30 @@
return ARM::FK_INVALID;
}
+static unsigned getAEKID(StringRef ArchExtName) {
+ for (const auto AE : ARM::ARCHExtNames)
+ if (AE.getName() == ArchExtName)
+ return AE.ID;
+ return ARM::AEK_INVALID;
+}
+
bool ARM::appendArchExtFeatures(
StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
std::vector<StringRef> &Features) {
- StringRef StandardFeature = getArchExtFeature(ArchExt);
- if (!StandardFeature.empty()) {
- Features.push_back(StandardFeature);
- return true;
- }
+ size_t StartingNumFeatures = Features.size();
const bool Negated = stripNegationPrefix(ArchExt);
+ unsigned ID = getAEKID(ArchExt);
+
+ if (ID == AEK_INVALID)
+ return false;
+
+ for (const auto AE : ARCHExtNames) {
+ if (Negated && (AE.ID & ID) == ID && AE.NegFeature)
+ Features.push_back(AE.NegFeature);
+ else if (AE.ID == ID && AE.Feature)
+ Features.push_back(AE.Feature);
+ }
if (CPU == "")
CPU = "generic";
@@ -537,7 +551,7 @@
}
return ARM::getFPUFeatures(FPUKind, Features);
}
- return false;
+ return StartingNumFeatures != Features.size();
}
StringRef ARM::getHWDivName(unsigned HWDivKind) {
Index: clang/test/Preprocessor/arm-target-features.c
===================================================================
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -769,6 +769,14 @@
// CHECK-V81M-MVE-FP: #define __ARM_FEATURE_SIMD32 1
// CHECK-V81M-MVE-FP: #define __ARM_FPV5__ 1
+// nofp discards mve.fp
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp+nofp -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V81M-MVEFP-NOFP %s
+// CHECK-V81M-MVEFP-NOFP-NOT: #define __ARM_FEATURE_MVE
+
+// nomve discards mve.fp
+// RUN: %clang -target arm-arm-none-eabi -march=armv8.1-m.main+mve.fp+nomve -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V81M-MVEFP-NOMVE %s
+// CHECK-V81M-MVEFP-NOMVE-NOT: #define __ARM_FEATURE_MVE
+
// RUN: %clang -target armv8.1a-none-none-eabi -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V81A %s
// CHECK-V81A: #define __ARM_ARCH 8
// CHECK-V81A: #define __ARM_ARCH_8_1A__ 1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64048.207443.patch
Type: text/x-patch
Size: 2440 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190702/bafbaf97/attachment-0001.bin>
More information about the cfe-commits
mailing list