-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Clang] Remove AArch64TargetInfo::setArchFeatures #146107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[Clang] Remove AArch64TargetInfo::setArchFeatures #146107
Conversation
@llvm/pr-subscribers-backend-aarch64 Author: Sander de Smalen (sdesmalen-arm) ChangesWhen compiling with After some experimenting, I found out that the list of features passed into From that I conclude that Full diff: https://github.com/llvm/llvm-project/pull/146107.diff 2 Files Affected:
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 124b340b62d9f..e57feafe3ae24 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -125,79 +125,6 @@ static constexpr auto BuiltinAArch64Infos =
#include "clang/Basic/BuiltinsAArch64.def"
});
-void AArch64TargetInfo::setArchFeatures() {
- if (*ArchInfo == llvm::AArch64::ARMV8R) {
- HasDotProd = true;
- HasDIT = true;
- HasFlagM = true;
- HasRCPC = true;
- FPU |= NeonMode;
- HasCCPP = true;
- HasCRC = true;
- HasLSE = true;
- HasRDM = true;
- } else if (ArchInfo->Version.getMajor() == 8) {
- if (ArchInfo->Version.getMinor() >= 7u) {
- HasWFxT = true;
- }
- if (ArchInfo->Version.getMinor() >= 6u) {
- HasBFloat16 = true;
- HasMatMul = true;
- }
- if (ArchInfo->Version.getMinor() >= 5u) {
- HasAlternativeNZCV = true;
- HasFRInt3264 = true;
- HasSSBS = true;
- HasSB = true;
- HasPredRes = true;
- HasBTI = true;
- }
- if (ArchInfo->Version.getMinor() >= 4u) {
- HasDotProd = true;
- HasDIT = true;
- HasFlagM = true;
- }
- if (ArchInfo->Version.getMinor() >= 3u) {
- HasRCPC = true;
- FPU |= NeonMode;
- }
- if (ArchInfo->Version.getMinor() >= 2u) {
- HasCCPP = true;
- }
- if (ArchInfo->Version.getMinor() >= 1u) {
- HasCRC = true;
- HasLSE = true;
- HasRDM = true;
- }
- } else if (ArchInfo->Version.getMajor() == 9) {
- if (ArchInfo->Version.getMinor() >= 2u) {
- HasWFxT = true;
- }
- if (ArchInfo->Version.getMinor() >= 1u) {
- HasBFloat16 = true;
- HasMatMul = true;
- }
- FPU |= SveMode;
- HasSVE2 = true;
- HasFullFP16 = true;
- HasAlternativeNZCV = true;
- HasFRInt3264 = true;
- HasSSBS = true;
- HasSB = true;
- HasPredRes = true;
- HasBTI = true;
- HasDotProd = true;
- HasDIT = true;
- HasFlagM = true;
- HasRCPC = true;
- FPU |= NeonMode;
- HasCCPP = true;
- HasCRC = true;
- HasLSE = true;
- HasRDM = true;
- }
-}
-
AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: TargetInfo(Triple), ABI("aapcs") {
@@ -1266,7 +1193,6 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
}
setDataLayout();
- setArchFeatures();
if (HasNoFP) {
FPU &= ~FPUMode;
diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h
index 1951e0679d2ec..56adfa97efb1a 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -158,8 +158,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
return false;
}
- void setArchFeatures();
-
void getTargetDefinesARMV81A(const LangOptions &Opts,
MacroBuilder &Builder) const;
void getTargetDefinesARMV82A(const LangOptions &Opts,
|
@llvm/pr-subscribers-clang Author: Sander de Smalen (sdesmalen-arm) ChangesWhen compiling with After some experimenting, I found out that the list of features passed into From that I conclude that Full diff: https://github.com/llvm/llvm-project/pull/146107.diff 2 Files Affected:
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index 124b340b62d9f..e57feafe3ae24 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -125,79 +125,6 @@ static constexpr auto BuiltinAArch64Infos =
#include "clang/Basic/BuiltinsAArch64.def"
});
-void AArch64TargetInfo::setArchFeatures() {
- if (*ArchInfo == llvm::AArch64::ARMV8R) {
- HasDotProd = true;
- HasDIT = true;
- HasFlagM = true;
- HasRCPC = true;
- FPU |= NeonMode;
- HasCCPP = true;
- HasCRC = true;
- HasLSE = true;
- HasRDM = true;
- } else if (ArchInfo->Version.getMajor() == 8) {
- if (ArchInfo->Version.getMinor() >= 7u) {
- HasWFxT = true;
- }
- if (ArchInfo->Version.getMinor() >= 6u) {
- HasBFloat16 = true;
- HasMatMul = true;
- }
- if (ArchInfo->Version.getMinor() >= 5u) {
- HasAlternativeNZCV = true;
- HasFRInt3264 = true;
- HasSSBS = true;
- HasSB = true;
- HasPredRes = true;
- HasBTI = true;
- }
- if (ArchInfo->Version.getMinor() >= 4u) {
- HasDotProd = true;
- HasDIT = true;
- HasFlagM = true;
- }
- if (ArchInfo->Version.getMinor() >= 3u) {
- HasRCPC = true;
- FPU |= NeonMode;
- }
- if (ArchInfo->Version.getMinor() >= 2u) {
- HasCCPP = true;
- }
- if (ArchInfo->Version.getMinor() >= 1u) {
- HasCRC = true;
- HasLSE = true;
- HasRDM = true;
- }
- } else if (ArchInfo->Version.getMajor() == 9) {
- if (ArchInfo->Version.getMinor() >= 2u) {
- HasWFxT = true;
- }
- if (ArchInfo->Version.getMinor() >= 1u) {
- HasBFloat16 = true;
- HasMatMul = true;
- }
- FPU |= SveMode;
- HasSVE2 = true;
- HasFullFP16 = true;
- HasAlternativeNZCV = true;
- HasFRInt3264 = true;
- HasSSBS = true;
- HasSB = true;
- HasPredRes = true;
- HasBTI = true;
- HasDotProd = true;
- HasDIT = true;
- HasFlagM = true;
- HasRCPC = true;
- FPU |= NeonMode;
- HasCCPP = true;
- HasCRC = true;
- HasLSE = true;
- HasRDM = true;
- }
-}
-
AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: TargetInfo(Triple), ABI("aapcs") {
@@ -1266,7 +1193,6 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
}
setDataLayout();
- setArchFeatures();
if (HasNoFP) {
FPU &= ~FPUMode;
diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h
index 1951e0679d2ec..56adfa97efb1a 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -158,8 +158,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
return false;
}
- void setArchFeatures();
-
void getTargetDefinesARMV81A(const LangOptions &Opts,
MacroBuilder &Builder) const;
void getTargetDefinesARMV82A(const LangOptions &Opts,
|
Thanks @sdesmalen-arm. We'd like to move all these kinds of dependencies into tablegen, and have nothing encoded in C++, and I've got a (half-started) diff to do this, but haven't found time to prioritise it yet. Your change helps, though! LGTM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised this has no effect, but if so LGTM. Are any of the values set here now dead?
The best kind of patch.
Could we add a test for this, in case it comes up again in the future? Negative features have not worked super well in the past and could do with extra test coverage. |
When compiling with `-march=armv9-a+nosve` we found that Clang still defines the `__ARM_FEATURE_SVE2` macro, which is explicitly set in `setArchFeatures` when compiling for armv9-a. After some experimenting, I found out that the list of features passed into `AArch64TargetInfo::handleTargetFeatures` has already been expanded and takes into account `+no[feature]` and has already expanded features like `armv9-a`. From that I conclude that `setArchFeatures` is no longer required.
525a4c5
to
c44ab03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
When compiling with
-march=armv9-a+nosve
we found that Clang still defines the__ARM_FEATURE_SVE2
macro, which is explicitly set insetArchFeatures
when compiling for armv9-a.After some experimenting, I found out that the list of features passed into
AArch64TargetInfo::handleTargetFeatures
has already been expanded and takes into account+no[feature]
and has already expanded features likearmv9-a
.From that I conclude that
setArchFeatures
is no longer required.