Skip to content

Commit 3c17966

Browse files
committed
Use NVPTXTargetInfo for arch info
1 parent 028d270 commit 3c17966

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

clang/lib/Basic/Targets/NVPTX.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ class LLVM_LIBRARY_VISIBILITY NVPTXTargetInfo : public TargetInfo {
181181

182182
bool hasBitIntType() const override { return true; }
183183
bool hasBFloat16Type() const override { return true; }
184+
185+
CudaArch getGPU() const { return GPU; }
184186
};
185187
} // namespace targets
186188
} // namespace clang

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
#include "../Basic/Targets/NVPTX.h"
1314
#include "clang/AST/ASTConsumer.h"
1415
#include "clang/AST/ASTContext.h"
1516
#include "clang/AST/ASTMutationListener.h"
@@ -5609,17 +5610,9 @@ bool Sema::CheckRegparmAttr(const ParsedAttr &AL, unsigned &numParams) {
56095610

56105611
// Helper to get CudaArch.
56115612
static CudaArch getCudaArch(const TargetInfo &TI) {
5612-
if (!TI.hasFeature("ptx")) {
5613-
return CudaArch::UNKNOWN;
5614-
}
5615-
for (const auto &Feature : TI.getTargetOpts().FeatureMap) {
5616-
if (Feature.getValue()) {
5617-
CudaArch Arch = StringToCudaArch(Feature.getKey());
5618-
if (Arch != CudaArch::UNKNOWN)
5619-
return Arch;
5620-
}
5621-
}
5622-
return CudaArch::UNKNOWN;
5613+
if (!TI.getTriple().isNVPTX())
5614+
llvm_unreachable("getCudaArch is only valid for NVPTX triple");
5615+
return static_cast<const targets::NVPTXTargetInfo *>(&TI)->getGPU();
56235616
}
56245617

56255618
// Checks whether an argument of launch_bounds attribute is

0 commit comments

Comments
 (0)