• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 --check-prefix=CHECK-SPIRV
4; RUN: llvm-spirv %t.bc -o %t.spv
5; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
6; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
7
8; CHECK-SPIRV: Capability LiteralSampler
9; CHECK-SPIRV: EntryPoint 6 [[sample_kernel:[0-9]+]] "sample_kernel"
10
11; ModuleID = '<stdin>'
12target 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"
13target triple = "spir-unknown-unknown"
14
15%opencl.image2d_t = type opaque
16
17@imageSampler = constant i32 32, align 4
18; CHECK-SPIRV: TypeSampler [[TypeSampler:[0-9]+]]
19; CHECK-SPIRV: TypeSampledImage [[SampledImageTy:[0-9]+]]
20; CHECK-SPIRV: ConstantSampler [[TypeSampler]] [[ConstSampler1:[0-9]+]] 0 0 1
21; CHECK-SPIRV: ConstantSampler [[TypeSampler]] [[ConstSampler2:[0-9]+]] 3 0 0
22
23; CHECK-LLVM: @imageSampler = constant i32 32
24
25; Function Attrs: nounwind
26define spir_kernel void @sample_kernel(%opencl.image2d_t addrspace(1)* %input, <2 x float> %coords, <4 x float> addrspace(1)* %results, i32 %argSampl) #0 {
27; CHECK-SPIRV: Function {{.*}} [[sample_kernel]]
28; CHECK-SPIRV: FunctionParameter {{.*}} [[InputImage:[0-9]+]]
29; CHECK-SPIRV: FunctionParameter [[TypeSampler]] [[argSampl:[0-9]+]]
30; CHECK-LLVM: define spir_kernel void @sample_kernel(%opencl.image2d_t addrspace(1)* %input, <2 x float> %coords, <4 x float> addrspace(1)* %results, i32 %argSampl)
31entry:
32  %0 = load i32, i32* @imageSampler, align 4
33
34  %call = call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(%opencl.image2d_t addrspace(1)* %input, i32 %0, <2 x float> %coords)
35; CHECK-SPIRV: SampledImage [[SampledImageTy]] [[SampledImage1:[0-9]+]] [[InputImage]] [[ConstSampler1]]
36; CHECK-SPIRV: ImageSampleExplicitLod {{.*}} [[SampledImage1]]
37; CHECK-LLVM: call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(%opencl.image2d_t addrspace(1)* %input, i32 32, <2 x float> %coords)
38
39  %arrayidx = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %results, i32 0
40  store <4 x float> %call, <4 x float> addrspace(1)* %arrayidx, align 16
41
42  %call1 = call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(%opencl.image2d_t addrspace(1)* %input, i32 %argSampl, <2 x float> %coords)
43; CHECK-SPIRV: SampledImage [[SampledImageTy]] [[SampledImage2:[0-9]+]] [[InputImage]] [[argSampl]]
44; CHECK-SPIRV: ImageSampleExplicitLod {{.*}} [[SampledImage2]]
45; CHECK-LLVM: call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(%opencl.image2d_t addrspace(1)* %input, i32 %argSampl, <2 x float> %coords)
46
47  %arrayidx2 = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %results, i32 0
48  store <4 x float> %call1, <4 x float> addrspace(1)* %arrayidx2, align 16
49
50  %call3 = call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(%opencl.image2d_t addrspace(1)* %input, i32 22, <2 x float> %coords)
51; CHECK-SPIRV: SampledImage [[SampledImageTy]] [[SampledImage3:[0-9]+]] [[InputImage]] [[ConstSampler2]]
52; CHECK-SPIRV: ImageSampleExplicitLod {{.*}} [[SampledImage3]]
53; CHECK-LLVM: call spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(%opencl.image2d_t addrspace(1)* %input, i32 22, <2 x float> %coords)
54
55  %arrayidx4 = getelementptr inbounds <4 x float>, <4 x float> addrspace(1)* %results, i32 0
56  store <4 x float> %call3, <4 x float> addrspace(1)* %arrayidx4, align 16
57  ret void
58}
59
60declare spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(%opencl.image2d_t addrspace(1)*, i32, <2 x float>) #1
61; CHECK-LLVM: declare spir_func <4 x float> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_f(%opencl.image2d_t addrspace(1)*, i32, <2 x float>)
62
63attributes #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" }
64attributes #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" }
65
66!opencl.kernels = !{!0}
67!opencl.enable.FP_CONTRACT = !{}
68!opencl.spir.version = !{!6}
69!opencl.ocl.version = !{!7}
70!opencl.used.extensions = !{!8}
71!opencl.used.optional.core.features = !{!9}
72!opencl.compiler.options = !{!8}
73
74!0 = !{void (%opencl.image2d_t addrspace(1)*, <2 x float>, <4 x float> addrspace(1)*, i32)* @sample_kernel, !1, !2, !3, !4, !5}
75!1 = !{!"kernel_arg_addr_space", i32 1, i32 0, i32 1, i32 0}
76!2 = !{!"kernel_arg_access_qual", !"read_only", !"none", !"none", !"none"}
77!3 = !{!"kernel_arg_type", !"image2d_t", !"float2", !"float4*", !"sampler_t"}
78!4 = !{!"kernel_arg_base_type", !"image2d_t", !"float2", !"float4*", !"sampler_t"}
79!5 = !{!"kernel_arg_type_qual", !"", !"", !"", !""}
80!6 = !{i32 1, i32 2}
81!7 = !{i32 2, i32 0}
82!8 = !{}
83!9 = !{!"cl_images"}
84