1 ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
3 ;; constant sampler_t constSampl = CLK_FILTER_LINEAR;
6 ;; void sample_kernel_float(image2d_t input, float2 coords, global float4 *results, sampler_t argSampl) {
7 ;; *results = read_imagef(input, constSampl, coords);
8 ;; *results = read_imagef(input, argSampl, coords);
9 ;; *results = read_imagef(input, CLK_FILTER_NEAREST|CLK_ADDRESS_REPEAT, coords);
13 ;; void sample_kernel_int(image2d_t input, float2 coords, global int4 *results, sampler_t argSampl) {
14 ;; *results = read_imagei(input, constSampl, coords);
15 ;; *results = read_imagei(input, argSampl, coords);
16 ;; *results = read_imagei(input, CLK_FILTER_NEAREST|CLK_ADDRESS_REPEAT, coords);
19 ; CHECK-SPIRV: OpCapability LiteralSampler
20 ; CHECK-SPIRV: OpName %[[#sample_kernel_float:]] "sample_kernel_float"
21 ; CHECK-SPIRV: OpName %[[#sample_kernel_int:]] "sample_kernel_int"
23 ; CHECK-SPIRV: %[[#TypeSampler:]] = OpTypeSampler
24 ; CHECK-SPIRV-DAG: %[[#SampledImageTy:]] = OpTypeSampledImage
25 ; CHECK-SPIRV-DAG: %[[#ConstSampler1:]] = OpConstantSampler %[[#TypeSampler]] None 0 Linear
26 ; CHECK-SPIRV-DAG: %[[#ConstSampler2:]] = OpConstantSampler %[[#TypeSampler]] Repeat 0 Nearest
27 ; CHECK-SPIRV-DAG: %[[#ConstSampler3:]] = OpConstantSampler %[[#TypeSampler]] None 0 Linear
28 ; CHECK-SPIRV-DAG: %[[#ConstSampler4:]] = OpConstantSampler %[[#TypeSampler]] Repeat 0 Nearest
30 ; CHECK-SPIRV: %[[#sample_kernel_float]] = OpFunction %{{.*}}
31 ; CHECK-SPIRV: %[[#InputImage:]] = OpFunctionParameter %{{.*}}
32 ; CHECK-SPIRV: %[[#argSampl:]] = OpFunctionParameter %[[#TypeSampler]]
34 ; CHECK-SPIRV: %[[#SampledImage1:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#ConstSampler1]]
35 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage1]]
37 ; CHECK-SPIRV: %[[#SampledImage2:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#argSampl]]
38 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage2]]
40 ; CHECK-SPIRV: %[[#SampledImage3:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#ConstSampler2]]
41 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage3]]
43 define dso_local spir_kernel void @sample_kernel_float(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, <2 x float> noundef %coords, <4 x float> addrspace(1)* nocapture noundef writeonly %results, target("spirv.Sampler") %argSampl) local_unnamed_addr {
45 %0 = tail call spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32 32)
46 %call = tail call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, target("spirv.Sampler") %0, <2 x float> noundef %coords)
47 store <4 x float> %call, <4 x float> addrspace(1)* %results, align 16
48 %call1 = tail call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, target("spirv.Sampler") %argSampl, <2 x float> noundef %coords)
49 store <4 x float> %call1, <4 x float> addrspace(1)* %results, align 16
50 %1 = tail call spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32 22)
51 %call2 = tail call spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, target("spirv.Sampler") %1, <2 x float> noundef %coords)
52 store <4 x float> %call2, <4 x float> addrspace(1)* %results, align 16
56 declare spir_func <4 x float> @_Z11read_imagef14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), target("spirv.Sampler"), <2 x float> noundef) local_unnamed_addr
58 declare spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32) local_unnamed_addr
60 ; CHECK-SPIRV: %[[#sample_kernel_int]] = OpFunction %{{.*}}
61 ; CHECK-SPIRV: %[[#InputImage:]] = OpFunctionParameter %{{.*}}
62 ; CHECK-SPIRV: %[[#argSampl:]] = OpFunctionParameter %[[#TypeSampler]]
64 ; CHECK-SPIRV: %[[#SampledImage4:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#ConstSampler3]]
65 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage4]]
67 ; CHECK-SPIRV: %[[#SampledImage5:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#argSampl]]
68 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage5]]
70 ; CHECK-SPIRV: %[[#SampledImage6:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#ConstSampler4]]
71 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage6]]
73 define dso_local spir_kernel void @sample_kernel_int(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, <2 x float> noundef %coords, <4 x i32> addrspace(1)* nocapture noundef writeonly %results, target("spirv.Sampler") %argSampl) local_unnamed_addr {
75 %0 = tail call spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32 32)
76 %call = tail call spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, target("spirv.Sampler") %0, <2 x float> noundef %coords)
77 store <4 x i32> %call, <4 x i32> addrspace(1)* %results, align 16
78 %call1 = tail call spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, target("spirv.Sampler") %argSampl, <2 x float> noundef %coords)
79 store <4 x i32> %call1, <4 x i32> addrspace(1)* %results, align 16
80 %1 = tail call spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32 22)
81 %call2 = tail call spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %input, target("spirv.Sampler") %1, <2 x float> noundef %coords)
82 store <4 x i32> %call2, <4 x i32> addrspace(1)* %results, align 16
86 declare spir_func <4 x i32> @_Z11read_imagei14ocl_image2d_ro11ocl_samplerDv2_f(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), target("spirv.Sampler"), <2 x float> noundef) local_unnamed_addr