clang: Remove unnecessary isAMDGCN wrapper (#189640)

This commit is contained in:
Matt Arsenault 2026-03-31 14:23:15 +02:00 committed by GitHub
parent a839e500e8
commit 5d051f628c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 19 deletions

View File

@ -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);

View File

@ -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 @@ public:
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 @@ public:
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 @@ public:
}
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.