-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Frontend: sink vendor definitions from Basic to Frontend #80364
base: main
Are you sure you want to change the base?
Conversation
CC: @kubamracek |
@llvm/pr-subscribers-backend-amdgpu @llvm/pr-subscribers-clang Author: Saleem Abdulrasool (compnerd) ChangesThe vendor specific macro definitions are based on the vendor rather than the target specific information. This ensures that Full diff: https://github.com/llvm/llvm-project/pull/80364.diff 3 Files Affected:
diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp
index 141501e8a4d9a..c6d68f591a5a8 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -266,7 +266,6 @@ ArrayRef<Builtin::Info> AMDGPUTargetInfo::getTargetBuiltins() const {
void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
- Builder.defineMacro("__AMD__");
Builder.defineMacro("__AMDGPU__");
if (isAMDGCN(getTriple()))
diff --git a/clang/lib/Basic/Targets/OSTargets.cpp b/clang/lib/Basic/Targets/OSTargets.cpp
index 899aefa6173ac..64b4514ba55bb 100644
--- a/clang/lib/Basic/Targets/OSTargets.cpp
+++ b/clang/lib/Basic/Targets/OSTargets.cpp
@@ -23,7 +23,6 @@ void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
const llvm::Triple &Triple, StringRef &PlatformName,
VersionTuple &PlatformMinVersion) {
Builder.defineMacro("__APPLE_CC__", "6000");
- Builder.defineMacro("__APPLE__");
Builder.defineMacro("__STDC_NO_THREADS__");
// AddressSanitizer doesn't play well with source fortification, which is on
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index 877e205e2e9bf..27621ee332419 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -804,6 +804,11 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
}
}
+ if (TI.getTriple().getVendor() == Triple::AMD)
+ Builder.defineMacro("__AMD__");
+ if (TI.getTriple().getVendor() == Triple::Apple)
+ Builder.defineMacro("__APPLE__");
+
// Define macros for the C11 / C++11 memory orderings
Builder.defineMacro("__ATOMIC_RELAXED", "0");
Builder.defineMacro("__ATOMIC_CONSUME", "1");
|
if (TI.getTriple().getVendor() == Triple::AMD) | ||
Builder.defineMacro("__AMD__"); | ||
if (TI.getTriple().getVendor() == Triple::Apple) | ||
Builder.defineMacro("__APPLE__"); |
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 think this is a behavior change for non-darwin triples, but only in a "tree falls in the forest" kind of way.
@fpetrogalli you were talking about this a while back. I don't remember the verdict.
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.
Yes, and something that I think that is desirable in the context of Swift as well (where we are looking at some of the embedded system usage where the target triple may be something like arm64-apple-none-macho
).
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.
👍
The vendor specific macro definitions are based on the vendor rather than the target specific information. This ensures that `__APPLE__` is always defined for `*-apple-*` targets. Take the opportunity to do likewise with the `__AMD__` vendor macro.
The vendor specific macro definitions are based on the vendor rather than the target specific information. This ensures that
__APPLE__
is always defined for*-apple-*
targets. Take the opportunity to do likewise with the__AMD__
vendor macro.