Skip to content

Commit 301599b

Browse files
committed
[Backport to 18] [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 5c4329e commit 301599b

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
@@ -2625,6 +2625,10 @@ class OpenCLStdToSPIRVFriendlyIRMangleInfo : public BuiltinFuncMangleInfo {
26252625
case OpenCLLIB::Nan:
26262626
addUnsignedArg(0);
26272627
break;
2628+
case OpenCLLIB::Prefetch:
2629+
setArgAttr(0, SPIR::ATTR_CONST);
2630+
addUnsignedArg(1);
2631+
break;
26282632
case OpenCLLIB::Shuffle:
26292633
addUnsignedArg(1);
26302634
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)