[clang] 5d051f6 - clang: Remove unnecessary isAMDGCN wrapper (#189640)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 31 05:23:22 PDT 2026
Author: Matt Arsenault
Date: 2026-03-31T12:23:15Z
New Revision: 5d051f628c61fcec3ef6d23ce09be169454d9f27
URL: https://github.com/llvm/llvm-project/commit/5d051f628c61fcec3ef6d23ce09be169454d9f27
DIFF: https://github.com/llvm/llvm-project/commit/5d051f628c61fcec3ef6d23ce09be169454d9f27.diff
LOG: clang: Remove unnecessary isAMDGCN wrapper (#189640)
Added:
Modified:
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
Removed:
################################################################################
diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp
index eba6ee2ed81c8..48ba5d94df581 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -210,7 +210,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
void AMDGPUTargetInfo::fillValidCPUList(
SmallVectorImpl<StringRef> &Values) const {
- if (isAMDGCN(getTriple()))
+ if (getTriple().isAMDGCN())
llvm::AMDGPU::fillValidArchListAMDGCN(Values);
else
llvm::AMDGPU::fillValidArchListR600(Values);
@@ -223,19 +223,17 @@ void AMDGPUTargetInfo::setAddressSpaceMap(bool DefaultIsPrivate) {
AMDGPUTargetInfo::AMDGPUTargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: TargetInfo(Triple),
- GPUKind(isAMDGCN(Triple) ?
- llvm::AMDGPU::parseArchAMDGCN(Opts.CPU) :
- llvm::AMDGPU::parseArchR600(Opts.CPU)),
- GPUFeatures(isAMDGCN(Triple) ?
- llvm::AMDGPU::getArchAttrAMDGCN(GPUKind) :
- llvm::AMDGPU::getArchAttrR600(GPUKind)) {
+ GPUKind(Triple.isAMDGCN() ? llvm::AMDGPU::parseArchAMDGCN(Opts.CPU)
+ : llvm::AMDGPU::parseArchR600(Opts.CPU)),
+ GPUFeatures(Triple.isAMDGCN() ? llvm::AMDGPU::getArchAttrAMDGCN(GPUKind)
+ : llvm::AMDGPU::getArchAttrR600(GPUKind)) {
resetDataLayout();
setAddressSpaceMap(Triple.getOS() == llvm::Triple::Mesa3D ||
- !isAMDGCN(Triple));
+ !Triple.isAMDGCN());
UseAddrSpaceMapMangling = true;
- if (isAMDGCN(Triple)) {
+ if (Triple.isAMDGCN()) {
// __bf16 is always available as a load/store only type on AMDGCN.
BFloat16Width = BFloat16Align = 16;
BFloat16Format = &llvm::APFloat::BFloat();
@@ -273,7 +271,7 @@ void AMDGPUTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts,
// address space in OpenCL, which needs to be cleaned up, then the references
// to OpenCL can be removed from the following line.
setAddressSpaceMap((Opts.OpenCL && !Opts.OpenCLGenericAddressSpace) ||
- !isAMDGCN(getTriple()));
+ !getTriple().isAMDGCN());
AtomicOpts = AtomicOptions(Opts);
}
@@ -288,7 +286,7 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__AMD__");
Builder.defineMacro("__AMDGPU__");
- if (isAMDGCN(getTriple()))
+ if (getTriple().isAMDGCN())
Builder.defineMacro("__AMDGCN__");
else
Builder.defineMacro("__R600__");
@@ -316,8 +314,8 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
return;
llvm::SmallString<16> CanonName =
- (isAMDGCN(getTriple()) ? getArchNameAMDGCN(GPUKind)
- : getArchNameR600(GPUKind));
+ (getTriple().isAMDGCN() ? getArchNameAMDGCN(GPUKind)
+ : getArchNameR600(GPUKind));
// Sanitize the name of generic targets.
// e.g. gfx10-1-generic -> gfx10_1_generic
@@ -328,7 +326,7 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro(Twine("__") + Twine(CanonName) + Twine("__"));
// Emit macros for gfx family e.g. gfx906 -> __GFX9__, gfx1030 -> __GFX10___
- if (isAMDGCN(getTriple()) && !IsHIPHost) {
+ if (getTriple().isAMDGCN() && !IsHIPHost) {
assert(StringRef(CanonName).starts_with("gfx") &&
"Invalid amdgcn canonical name");
StringRef CanonFamilyName = getArchFamilyNameAMDGCN(GPUKind);
diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h
index 38030ba07f9be..38c92e73708f8 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -78,8 +78,6 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
!!(GPUFeatures & llvm::AMDGPU::FEATURE_LDEXP);
}
- static bool isAMDGCN(const llvm::Triple &TT) { return TT.isAMDGCN(); }
-
static bool isR600(const llvm::Triple &TT) {
return TT.getArch() == llvm::Triple::r600;
}
@@ -137,7 +135,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
return getTriple().isAMDGCN() ? 64 : 32;
}
- bool hasBFloat16Type() const override { return isAMDGCN(getTriple()); }
+ bool hasBFloat16Type() const override { return getTriple().isAMDGCN(); }
std::string_view getClobbers() const override { return ""; }
@@ -306,7 +304,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
Opts["__cl_clang_non_portable_kernel_param_types"] = true;
Opts["__cl_clang_bitfields"] = true;
- bool IsAMDGCN = isAMDGCN(getTriple());
+ bool IsAMDGCN = getTriple().isAMDGCN();
Opts["cl_khr_fp64"] = hasFP64();
Opts["__opencl_c_fp64"] = hasFP64();
@@ -491,7 +489,7 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : public TargetInfo {
}
std::optional<std::string> getTargetID() const override {
- if (!isAMDGCN(getTriple()))
+ if (!getTriple().isAMDGCN())
return std::nullopt;
// When -target-cpu is not set, we assume generic code that it is valid
// for all GPU and use an empty string as target ID to represent that.
More information about the cfe-commits
mailing list