Skip to content

Commit 4eec28c

Browse files
authored
[clang][SPIRV] Default AS generic for Intel-flavored SPIR-V (#153647)
Use the generic AS as the default AS for Intel-flavored SPIR-V. Nobody is using the `spirv64-intel` triple right now as far as I know, I'm planning to use it for OpenMP offload and we will definitely need generic AS as default there. Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 69b9459 commit 4eec28c

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

clang/lib/Basic/Targets/SPIR.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,11 @@ class LLVM_LIBRARY_VISIBILITY BaseSPIRTargetInfo : public TargetInfo {
219219
setAddressSpaceMap(
220220
/*DefaultIsGeneric=*/Opts.SYCLIsDevice ||
221221
// The address mapping from HIP/CUDA language for device code is only
222-
// defined for SPIR-V.
223-
(getTriple().isSPIRV() && Opts.CUDAIsDevice));
222+
// defined for SPIR-V, and all Intel SPIR-V code should have the default
223+
// AS as generic.
224+
(getTriple().isSPIRV() &&
225+
(Opts.CUDAIsDevice ||
226+
getTriple().getVendor() == llvm::Triple::Intel)));
224227
}
225228

226229
void setSupportedOpenCLOpts() override {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clang_cc1 -triple spirv64-intel %s -emit-llvm -o - | FileCheck -check-prefix=CHECK-WITH %s
2+
// RUN: %clang_cc1 -triple spirv32-intel %s -emit-llvm -o - | FileCheck -check-prefix=CHECK-WITH %s
3+
// RUN: %clang_cc1 -triple spir-intel %s -emit-llvm -o - | FileCheck -check-prefix=CHECK-WITHOUT %s
4+
// RUN: %clang_cc1 -triple spir64-intel %s -emit-llvm -o - | FileCheck -check-prefix=CHECK-WITHOUT %s
5+
6+
// CHECK-WITH: spir_func void @foo(ptr addrspace(4) noundef %param) #0 {
7+
// CHECK-WITHOUT: spir_func void @foo(ptr noundef %param) #0 {
8+
void foo(int *param) {
9+
}

0 commit comments

Comments
 (0)