Skip to content

Commit 7aaceaf

Browse files
committed
[Backport to 19] [LLVM->SPV-IR] Add const to pointer arg of prefetch, change num_elements arg type to unsigned (KhronosGroup#3188)
Per SPIR-V OpenCL.ExtendedInstructionSet spec, the num_elements arg must be size_t. So this PR changes its type to unsigned in SPV-IR. Adding const to pointer arg aligns with OpenCL spec and allows const pointer input.
1 parent 172d89d commit 7aaceaf

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/SPIRV/SPIRVUtil.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,6 +2644,10 @@ class OpenCLStdToSPIRVFriendlyIRMangleInfo : public BuiltinFuncMangleInfo {
26442644
case OpenCLLIB::Nan:
26452645
addUnsignedArg(0);
26462646
break;
2647+
case OpenCLLIB::Prefetch:
2648+
setArgAttr(0, SPIR::ATTR_CONST);
2649+
addUnsignedArg(1);
2650+
break;
26472651
case OpenCLLIB::Shuffle:
26482652
addUnsignedArg(1);
26492653
break;

test/extensions/INTEL/SPV_INTEL_cache_controls/decorate-prefetch-w-cache-controls.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ $_ZTSZ4mainEUlvE_ = comdat any
3232
; translation
3333

3434
; CHECK-LLVM: %[[CALL1:.*]] = call spir_func ptr addrspace(1) @_Z41__spirv_GenericCastToPtrExplicit_ToGlobal{{.*}} !spirv.Decorations ![[MD1:.*]]
35-
; CHECK-LLVM: call spir_func void @_Z20__spirv_ocl_prefetch{{.*}}(ptr addrspace(1) %[[CALL1]], i64 1)
35+
; CHECK-LLVM: call spir_func void @_Z20__spirv_ocl_prefetchPU3AS1Kcm(ptr addrspace(1) %[[CALL1]], i64 1)
3636
; CHECK-LLVM: %[[CALL2:.*]] = call spir_func ptr addrspace(1) @_Z41__spirv_GenericCastToPtrExplicit_ToGlobal{{.*}} !spirv.Decorations ![[MD2:.*]]
37-
; CHECK-LLVM: call spir_func void @_Z20__spirv_ocl_prefetch{{.*}}(ptr addrspace(1) %[[CALL2]], i64 1)
37+
; CHECK-LLVM: call spir_func void @_Z20__spirv_ocl_prefetchPU3AS1Kcm(ptr addrspace(1) %[[CALL2]], i64 1)
3838
; CHECK-LLVM: %[[CALL3:.*]] = call spir_func ptr addrspace(1) @_Z41__spirv_GenericCastToPtrExplicit_ToGlobal{{.*}} !spirv.Decorations ![[MD3:.*]]
39-
; CHECK-LLVM: call spir_func void @_Z20__spirv_ocl_prefetch{{.*}}(ptr addrspace(1) %[[CALL3]], i64 2)
39+
; CHECK-LLVM: call spir_func void @_Z20__spirv_ocl_prefetchPU3AS1Kcm(ptr addrspace(1) %[[CALL3]], i64 2)
4040

4141

4242
; Function Attrs: convergent norecurse nounwind

0 commit comments

Comments
 (0)