Home | History | Annotate | Download | only in SPIRV
      1 ; RUN: llvm-as < %s | llvm-spirv -spirv-text -o %t
      2 ; RUN: FileCheck < %t %s
      3 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"
      4 target triple = "spir-unknown-unknown"
      5 
      6 %opencl.image2d_t = type opaque
      7 
      8 ; Function Attrs: nounwind
      9 ; CHECK: {{[0-9]*}} Store
     10 ; CHECK-NEXT: 1 Return
     11 define spir_kernel void @test_fn(%opencl.image2d_t addrspace(1)* %srcimg, i32 %sampler, <4 x float> addrspace(1)* %results) #0 {
     12 entry:
     13   %srcimg.addr = alloca %opencl.image2d_t addrspace(1)*, align 4
     14   %sampler.addr = alloca i32, align 4
     15   %results.addr = alloca <4 x float> addrspace(1)*, align 4
     16   %tid_x = alloca i32, align 4
     17   %tid_y = alloca i32, align 4
     18   %.compoundliteral = alloca <2 x i32>, align 8
     19   store %opencl.image2d_t addrspace(1)* %srcimg, %opencl.image2d_t addrspace(1)** %srcimg.addr, align 4
     20   store i32 %sampler, i32* %sampler.addr, align 4
     21   store <4 x float> addrspace(1)* %results, <4 x float> addrspace(1)** %results.addr, align 4
     22   %call = call spir_func i32 @_Z13get_global_idj(i32 0) #2
     23   store i32 %call, i32* %tid_x, align 4
     24   %call1 = call spir_func i32 @_Z13get_global_idj(i32 1) #2
     25   store i32 %call1, i32* %tid_y, align 4
     26   %0 = load %opencl.image2d_t addrspace(1)*, %opencl.image2d_t addrspace(1)** %srcimg.addr, align 4
     27   %1 = load i32, i32* %sampler.addr, align 4
     28   %2 = load i32, i32* %tid_x, align 4
     29   %vecinit = insertelement <2 x i32> undef, i32 %2, i32 0
     30   %3 = load i32, i32* %tid_y, align 4
     31   %vecinit2 = insertelement <2 x i32> %vecinit, i32 %3, i32 1
     32   store <2 x i32> %vecinit2, <2 x i32>* %.compoundliteral
     33   %4 = load <2 x i32>, <2 x i32>* %.compoundliteral
     34   %call3 = call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(%opencl.image2d_t addrspace(1)* %0, i32 %1, <2 x i32> %4) #2
     35   %5 = load i32, i32* %tid_y, align 4
     36   %6 = load %opencl.image2d_t addrspace(1)*, %opencl.image2d_t addrspace(1)** %srcimg.addr, align 4
     37   %call4 = call spir_func i32 @_Z15get_image_width11ocl_image2d(%opencl.image2d_t addrspace(1)* %6) #2
     38   %mul = mul nsw i32 %5, %call4
     39   %7 = load i32, i32* %tid_x, align 4
     40   %add = add nsw i32 %mul, %7
     41   %8 = load <4 x float> addrspace(1)*, <4 x float> addrspace(1)** %results.addr, align 4
     42   %arrayidx = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %8, i32 %add
     43   store <4 x float> %call3, <4 x float> addrspace(1)* %arrayidx, align 16
     44   ret void
     45 }
     46 
     47 ; Function Attrs: nounwind readnone
     48 declare spir_func i32 @_Z13get_global_idj(i32) #1
     49 
     50 ; Function Attrs: nounwind readnone
     51 declare spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(%opencl.image2d_t addrspace(1)*, i32, <2 x i32>) #1
     52 
     53 ; Function Attrs: nounwind readnone
     54 declare spir_func i32 @_Z15get_image_width11ocl_image2d(%opencl.image2d_t addrspace(1)*) #1
     55 
     56 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" }
     57 attributes #1 = { nounwind readnone "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" }
     58 attributes #2 = { nounwind readnone }
     59 
     60 !opencl.kernels = !{!0}
     61 !opencl.enable.FP_CONTRACT = !{}
     62 !opencl.spir.version = !{!6}
     63 !opencl.ocl.version = !{!6}
     64 !opencl.used.extensions = !{!7}
     65 !opencl.used.optional.core.features = !{!8}
     66 !opencl.compiler.options = !{!7}
     67 
     68 !0 = !{void (%opencl.image2d_t addrspace(1)*, i32, <4 x float> addrspace(1)*)* @test_fn, !1, !2, !3, !4, !5}
     69 !1 = !{!"kernel_arg_addr_space", i32 1, i32 0, i32 1}
     70 !2 = !{!"kernel_arg_access_qual", !"read_only", !"none", !"none"}
     71 !3 = !{!"kernel_arg_type", !"image2d_t", !"sampler_t", !"float4*"}
     72 !4 = !{!"kernel_arg_base_type", !"image2d_t", !"sampler_t", !"float4*"}
     73 !5 = !{!"kernel_arg_type_qual", !"", !"", !""}
     74 !6 = !{i32 1, i32 2}
     75 !7 = !{}
     76 !8 = !{!"cl_images"}
     77