aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/Targets/AMDGPU.cpp
diff options
context:
space:
mode:
authorDominik Adamski <dominik.adamski@amd.com>2023-03-27 07:19:40 -0500
committerDominik Adamski <dominik.adamski@amd.com>2023-03-29 02:23:37 -0500
commite43247dd329cabf7eb4dd4323b3422d3774e57a7 (patch)
tree2890e76debe4cf3f7d4050c36a3a752999a9f394 /clang/lib/Basic/Targets/AMDGPU.cpp
parentb7528f52c7d8c22d06a9a386b58e52cb76cfa54c (diff)
downloadllvm-e43247dd329cabf7eb4dd4323b3422d3774e57a7.zip
llvm-e43247dd329cabf7eb4dd4323b3422d3774e57a7.tar.gz
llvm-e43247dd329cabf7eb4dd4323b3422d3774e57a7.tar.bz2
[Clang][Flang][AMDGPU] Add support for AMDGPU to Flang driver
Scope of changes: 1) Extract common code between Clang and Flang for parsing AMDGPU features 2) Add function which adds implicit target features for AMDGPU as Clang does 3) Add AMDGPU target as one of valid targets for Flang Differential Revision: https://reviews.llvm.org/D145579 Reviewed By: yaxunl, awarzynski
Diffstat (limited to 'clang/lib/Basic/Targets/AMDGPU.cpp')
-rw-r--r--clang/lib/Basic/Targets/AMDGPU.cpp186
1 files changed, 4 insertions, 182 deletions
diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp
index 9b3a0b0..5b99755 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -179,197 +179,19 @@ ArrayRef<const char *> AMDGPUTargetInfo::getGCCRegNames() const {
bool AMDGPUTargetInfo::initFeatureMap(
llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
const std::vector<std::string> &FeatureVec) const {
- const bool IsNullCPU = CPU.empty();
- bool IsWave32Capable = false;
using namespace llvm::AMDGPU;
-
- // XXX - What does the member GPU mean if device name string passed here?
- if (isAMDGCN(getTriple())) {
- switch (llvm::AMDGPU::parseArchAMDGCN(CPU)) {
- case GK_GFX1103:
- case GK_GFX1102:
- case GK_GFX1101:
- case GK_GFX1100:
- IsWave32Capable = true;
- Features["ci-insts"] = true;
- Features["dot5-insts"] = true;
- Features["dot7-insts"] = true;
- Features["dot8-insts"] = true;
- Features["dot9-insts"] = true;
- Features["dot10-insts"] = true;
- Features["dl-insts"] = true;
- Features["16-bit-insts"] = true;
- Features["dpp"] = true;
- Features["gfx8-insts"] = true;
- Features["gfx9-insts"] = true;
- Features["gfx10-insts"] = true;
- Features["gfx10-3-insts"] = true;
- Features["gfx11-insts"] = true;
- Features["atomic-fadd-rtn-insts"] = true;
- break;
- case GK_GFX1036:
- case GK_GFX1035:
- case GK_GFX1034:
- case GK_GFX1033:
- case GK_GFX1032:
- case GK_GFX1031:
- case GK_GFX1030:
- IsWave32Capable = true;
- Features["ci-insts"] = true;
- Features["dot1-insts"] = true;
- Features["dot2-insts"] = true;
- Features["dot5-insts"] = true;
- Features["dot6-insts"] = true;
- Features["dot7-insts"] = true;
- Features["dot10-insts"] = true;
- Features["dl-insts"] = true;
- Features["16-bit-insts"] = true;
- Features["dpp"] = true;
- Features["gfx8-insts"] = true;
- Features["gfx9-insts"] = true;
- Features["gfx10-insts"] = true;
- Features["gfx10-3-insts"] = true;
- Features["s-memrealtime"] = true;
- Features["s-memtime-inst"] = true;
- break;
- case GK_GFX1012:
- case GK_GFX1011:
- Features["dot1-insts"] = true;
- Features["dot2-insts"] = true;
- Features["dot5-insts"] = true;
- Features["dot6-insts"] = true;
- Features["dot7-insts"] = true;
- Features["dot10-insts"] = true;
- [[fallthrough]];
- case GK_GFX1013:
- case GK_GFX1010:
- IsWave32Capable = true;
- Features["dl-insts"] = true;
- Features["ci-insts"] = true;
- Features["16-bit-insts"] = true;
- Features["dpp"] = true;
- Features["gfx8-insts"] = true;
- Features["gfx9-insts"] = true;
- Features["gfx10-insts"] = true;
- Features["s-memrealtime"] = true;
- Features["s-memtime-inst"] = true;
- break;
- case GK_GFX940:
- Features["gfx940-insts"] = true;
- Features["fp8-insts"] = true;
- Features["atomic-ds-pk-add-16-insts"] = true;
- Features["atomic-flat-pk-add-16-insts"] = true;
- Features["atomic-global-pk-add-bf16-inst"] = true;
- [[fallthrough]];
- case GK_GFX90A:
- Features["gfx90a-insts"] = true;
- Features["atomic-buffer-global-pk-add-f16-insts"] = true;
- Features["atomic-fadd-rtn-insts"] = true;
- [[fallthrough]];
- case GK_GFX908:
- Features["dot3-insts"] = true;
- Features["dot4-insts"] = true;
- Features["dot5-insts"] = true;
- Features["dot6-insts"] = true;
- Features["mai-insts"] = true;
- [[fallthrough]];
- case GK_GFX906:
- Features["dl-insts"] = true;
- Features["dot1-insts"] = true;
- Features["dot2-insts"] = true;
- Features["dot7-insts"] = true;
- Features["dot10-insts"] = true;
- [[fallthrough]];
- case GK_GFX90C:
- case GK_GFX909:
- case GK_GFX904:
- case GK_GFX902:
- case GK_GFX900:
- Features["gfx9-insts"] = true;
- [[fallthrough]];
- case GK_GFX810:
- case GK_GFX805:
- case GK_GFX803:
- case GK_GFX802:
- case GK_GFX801:
- Features["gfx8-insts"] = true;
- Features["16-bit-insts"] = true;
- Features["dpp"] = true;
- Features["s-memrealtime"] = true;
- [[fallthrough]];
- case GK_GFX705:
- case GK_GFX704:
- case GK_GFX703:
- case GK_GFX702:
- case GK_GFX701:
- case GK_GFX700:
- Features["ci-insts"] = true;
- [[fallthrough]];
- case GK_GFX602:
- case GK_GFX601:
- case GK_GFX600:
- Features["s-memtime-inst"] = true;
- break;
- case GK_NONE:
- break;
- default:
- llvm_unreachable("Unhandled GPU!");
- }
- } else {
- if (CPU.empty())
- CPU = "r600";
-
- switch (llvm::AMDGPU::parseArchR600(CPU)) {
- case GK_CAYMAN:
- case GK_CYPRESS:
- case GK_RV770:
- case GK_RV670:
- // TODO: Add fp64 when implemented.
- break;
- case GK_TURKS:
- case GK_CAICOS:
- case GK_BARTS:
- case GK_SUMO:
- case GK_REDWOOD:
- case GK_JUNIPER:
- case GK_CEDAR:
- case GK_RV730:
- case GK_RV710:
- case GK_RS880:
- case GK_R630:
- case GK_R600:
- break;
- default:
- llvm_unreachable("Unhandled GPU!");
- }
- }
-
+ fillAMDGPUFeatureMap(CPU, getTriple(), Features);
if (!TargetInfo::initFeatureMap(Features, Diags, CPU, FeatureVec))
return false;
- // FIXME: Not diagnosing wavefrontsize32 on wave64 only targets.
- const bool HaveWave32 =
- (IsWave32Capable || IsNullCPU) && Features.count("wavefrontsize32");
- const bool HaveWave64 = Features.count("wavefrontsize64");
-
// TODO: Should move this logic into TargetParser
- if (HaveWave32 && HaveWave64) {
- Diags.Report(diag::err_invalid_feature_combination)
- << "'wavefrontsize32' and 'wavefrontsize64' are mutually exclusive";
+ std::string ErrorMsg;
+ if (!insertWaveSizeFeature(CPU, getTriple(), Features, ErrorMsg)) {
+ Diags.Report(diag::err_invalid_feature_combination) << ErrorMsg;
return false;
}
- // Don't assume any wavesize with an unknown subtarget.
- if (!IsNullCPU) {
- // Default to wave32 if available, or wave64 if not
- if (!HaveWave32 && !HaveWave64) {
- StringRef DefaultWaveSizeFeature =
- IsWave32Capable ? "wavefrontsize32" : "wavefrontsize64";
- Features.insert(std::make_pair(DefaultWaveSizeFeature, true));
- }
- }
-
return true;
}