xref: /llvm-project/llvm/test/CodeGen/SPIRV/linkage/link-attribute.ll (revision f9c98068c852c1bb1ec029c2c8df8ace9605f16f)
1*f9c98068SVyacheslav Levytskyy; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
2*f9c98068SVyacheslav Levytskyy; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
33ae63430SVyacheslav Levytskyy
43ae63430SVyacheslav Levytskyy; CHECK: OpDecorate %[[#ID:]] LinkageAttributes "imageSampler" Export
53ae63430SVyacheslav Levytskyy; CHECK: %[[#ID]] = OpVariable %[[#]] UniformConstant %[[#]]
63ae63430SVyacheslav Levytskyy
73ae63430SVyacheslav Levytskyy@imageSampler = addrspace(2) constant i32 36, align 4
83ae63430SVyacheslav Levytskyy
93ae63430SVyacheslav Levytskyydefine spir_kernel void @sample_kernel(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, ptr addrspace(1) nocapture %xOffsets, ptr addrspace(1) nocapture %yOffsets, ptr addrspace(1) nocapture %results) {
103ae63430SVyacheslav Levytskyy  %1 = tail call spir_func i64 @_Z13get_global_idj(i32 0)
113ae63430SVyacheslav Levytskyy  %2 = trunc i64 %1 to i32
123ae63430SVyacheslav Levytskyy  %3 = tail call spir_func i64 @_Z13get_global_idj(i32 1)
133ae63430SVyacheslav Levytskyy  %4 = trunc i64 %3 to i32
143ae63430SVyacheslav Levytskyy  %5 = tail call spir_func i32 @_Z15get_image_width11ocl_image2d(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input)
153ae63430SVyacheslav Levytskyy  %6 = mul nsw i32 %4, %5
163ae63430SVyacheslav Levytskyy  %7 = add nsw i32 %6, %2
173ae63430SVyacheslav Levytskyy  %8 = sitofp i32 %2 to float
183ae63430SVyacheslav Levytskyy  %9 = insertelement <2 x float> undef, float %8, i32 0
193ae63430SVyacheslav Levytskyy  %10 = sitofp i32 %4 to float
203ae63430SVyacheslav Levytskyy  %11 = insertelement <2 x float> %9, float %10, i32 1
213ae63430SVyacheslav Levytskyy  %12 = tail call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, i32 36, <2 x float> %11)
223ae63430SVyacheslav Levytskyy  %13 = sext i32 %7 to i64
233ae63430SVyacheslav Levytskyy  %14 = getelementptr inbounds <4 x float>, ptr addrspace(1) %results, i64 %13
243ae63430SVyacheslav Levytskyy  store <4 x float> %12, ptr addrspace(1) %14, align 16
253ae63430SVyacheslav Levytskyy  ret void
263ae63430SVyacheslav Levytskyy}
273ae63430SVyacheslav Levytskyy
283ae63430SVyacheslav Levytskyydeclare spir_func i64 @_Z13get_global_idj(i32)
293ae63430SVyacheslav Levytskyy
303ae63430SVyacheslav Levytskyydeclare spir_func i32 @_Z15get_image_width11ocl_image2d(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0))
313ae63430SVyacheslav Levytskyy
323ae63430SVyacheslav Levytskyydeclare spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), i32, <2 x float>)
33