1 ; RUN: llvm-as %s -o %t.bc 2 ; RUN: llvm-spirv %t.bc -spirv-text -o %t.txt 3 ; RUN: FileCheck < %t.txt %s 4 target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" 5 target triple = "spir" 6 7 ;CHECK: EntryPoint {{[0-9]+}} [[KernelId:[0-9]+]] 8 9 %opencl.image2d_t = type opaque 10 ;CHECK: TypeImage [[image2d_t:[0-9]+]] 11 ;CHECK: TypeSampler [[sampler_t:[0-9]+]] 12 ;CHECK: TypeSampledImage [[sampled_image_t:[0-9]+]] 13 14 ; Function Attrs: nounwind 15 define spir_func float @test(%opencl.image2d_t addrspace(1)* %Img, i32 %Smp) #0 { 16 ;CHECK-NOT: Function {{[0-9]+}} [[KernelId]] 17 ;CHECK: Function 18 ;CHECK: FunctionParameter [[image2d_t]] [[image:[0-9]+]] 19 ;CHECK: FunctionParameter [[sampler_t]] [[sampler:[0-9]+]] 20 entry: 21 %call = call spir_func <4 x i32> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(%opencl.image2d_t addrspace(1)* %Img, i32 %Smp, <2 x i32> zeroinitializer) 22 ;CHECK: SampledImage [[sampled_image_t]] [[sampled_image:[0-9]+]] [[image]] [[sampler]] 23 ;CHECK: ImageSampleExplicitLod {{[0-9]+}} {{[0-9]+}} [[sampled_image]] {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} 24 25 %0 = extractelement <4 x i32> %call, i32 0 26 %conv = sitofp i32 %0 to float 27 ret float %conv 28 } 29 30 declare spir_func <4 x i32> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(%opencl.image2d_t addrspace(1)*, i32, <2 x i32>) #1 31 32 ; Function Attrs: nounwind 33 define spir_kernel void @test2(%opencl.image2d_t addrspace(1)* %Img, float addrspace(1)* %result) #0 { 34 ;CHECK: Function {{[0-9]+}} [[KernelId]] 35 entry: 36 %call = call spir_func float @test(%opencl.image2d_t addrspace(1)* %Img, i32 0) 37 %arrayidx = getelementptr inbounds float, float addrspace(1)* %result, i32 0 38 %0 = load float, float addrspace(1)* %arrayidx, align 4 39 %add = fadd float %0, %call 40 store float %add, float addrspace(1)* %arrayidx, align 4 41 ret void 42 } 43 44 attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 45 attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 46 47 !opencl.kernels = !{!0} 48 !opencl.enable.FP_CONTRACT = !{} 49 !opencl.spir.version = !{!6} 50 !opencl.ocl.version = !{!7} 51 !opencl.used.extensions = !{!8} 52 !opencl.used.optional.core.features = !{!9} 53 !opencl.compiler.options = !{!8} 54 55 !0 = !{void (%opencl.image2d_t addrspace(1)*, float addrspace(1)*)* @test2, !1, !2, !3, !4, !5} 56 !1 = !{!"kernel_arg_addr_space", i32 1, i32 1} 57 !2 = !{!"kernel_arg_access_qual", !"read_only", !"none"} 58 !3 = !{!"kernel_arg_type", !"image2d_t", !"float*"} 59 !4 = !{!"kernel_arg_base_type", !"image2d_t", !"float*"} 60 !5 = !{!"kernel_arg_type_qual", !"", !""} 61 !6 = !{i32 1, i32 2} 62 !7 = !{i32 2, i32 0} 63 !8 = !{} 64 !9 = !{!"cl_images"} 65 66