aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/Cuda.cpp
diff options
context:
space:
mode:
authorYaxun (Sam) Liu <yaxun.liu@amd.com>2021-12-17 11:01:51 -0500
committerYaxun (Sam) Liu <yaxun.liu@amd.com>2021-12-20 10:45:09 -0500
commita6786cdd575701ec1a1bc42adc086cfb70201ad3 (patch)
tree136ca6d252b2a72e4d4fa7ad804da57c265e6768 /clang/lib/Basic/Cuda.cpp
parent9cd55c7c3463fea334fd3169023bb63cca7276e5 (diff)
downloadllvm-a6786cdd575701ec1a1bc42adc086cfb70201ad3.zip
llvm-a6786cdd575701ec1a1bc42adc086cfb70201ad3.tar.gz
llvm-a6786cdd575701ec1a1bc42adc086cfb70201ad3.tar.bz2
[HIPSPV][3/4] Enable SPIR-V emission for HIP
This patch enables SPIR-V binary emission for HIP device code via the HIPSPV tool chain. ‘--offload’ option, which is envisioned in [1], is added for specifying offload targets. This option is used to override default device target (amdgcn-amd-amdhsa) for HIP compilation for emitting device code as SPIR-V binary. The option is handled in getHIPOffloadTargetTriple(). getOffloadingDeviceToolChain() function (based on the design in the SYCL repository) is added to select HIPSPVToolChain when HIP offload target is ‘spirv64’. The HIPActionBuilder is modified to produce LLVM IR at the backend phase. HIPSPV tool chain expects to receive HIP device code as LLVM IR so it can run external LLVM passes over them. HIPSPV TC is also responsible for emitting the SPIR-V binary. A Cuda GPU architecture ‘generic’ is added. The name is picked from the LLVM SPIR-V Backend. In the HIPSPV code path the architecture name is inserted to the bundle entry ID as target ID. Target ID is expected to be always present so a component in the target triple is not mistaken as target ID. Tests are added for checking the HIPSPV tool chain. [1]: https://lists.llvm.org/pipermail/cfe-dev/2020-December/067362.html Patch by: Henry Linjamäki Reviewed by: Yaxun Liu, Artem Belevich, Alexey Bader Differential Revision: https://reviews.llvm.org/D110622
Diffstat (limited to 'clang/lib/Basic/Cuda.cpp')
-rw-r--r--clang/lib/Basic/Cuda.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index e82a3a7..2d75578 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -123,6 +123,7 @@ static const CudaArchToStringMap arch_names[] = {
GFX(1033), // gfx1033
GFX(1034), // gfx1034
GFX(1035), // gfx1035
+ {CudaArch::Generic, "generic", ""},
// clang-format on
};
#undef SM