Debian Codegraph @

llvm/test/CodeGen/SPIRV/transcoding/SampledImage.ll

raw
1 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3
4 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
5 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
6
7 ;; constant sampler_t constSampl = CLK_FILTER_LINEAR;
8 ;;
9 ;; __kernel
10 ;; void sample_kernel_float(image2d_t input, float2 coords, global float4 *results, sampler_t argSampl) {
11 ;; *results = read_imagef(input, constSampl, coords);
12 ;; *results = read_imagef(input, argSampl, coords);
13 ;; *results = read_imagef(input, CLK_FILTER_NEAREST|CLK_ADDRESS_REPEAT, coords);
14 ;; }
15 ;;
16 ;; __kernel
17 ;; void sample_kernel_int(image2d_t input, float2 coords, global int4 *results, sampler_t argSampl) {
18 ;; *results = read_imagei(input, constSampl, coords);
19 ;; *results = read_imagei(input, argSampl, coords);
20 ;; *results = read_imagei(input, CLK_FILTER_NEAREST|CLK_ADDRESS_REPEAT, coords);
21 ;; }
22
23 ; CHECK-SPIRV: OpCapability LiteralSampler
24 ; CHECK-SPIRV: OpName %[[#sample_kernel_float:]] "sample_kernel_float"
25 ; CHECK-SPIRV: OpName %[[#sample_kernel_int:]] "sample_kernel_int"
26
27 ; CHECK-SPIRV-DAG: %[[#TypeSampler:]] = OpTypeSampler
28 ; CHECK-SPIRV-DAG: %[[#SampledImageTy:]] = OpTypeSampledImage
29 ; CHECK-SPIRV-DAG: %[[#ConstSampler1:]] = OpConstantSampler %[[#TypeSampler]] None 0 Linear
30 ; CHECK-SPIRV-DAG: %[[#ConstSampler2:]] = OpConstantSampler %[[#TypeSampler]] Repeat 0 Nearest
31
32 ; CHECK-SPIRV: %[[#sample_kernel_float]] = OpFunction %{{.*}}
33 ; CHECK-SPIRV: %[[#InputImage:]] = OpFunctionParameter %{{.*}}
34 ; CHECK-SPIRV: %[[#argSampl:]] = OpFunctionParameter %[[#TypeSampler]]
35
36 ; CHECK-SPIRV: %[[#SampledImage1:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#ConstSampler1]]
37 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage1]]
38
39 ; CHECK-SPIRV: %[[#SampledImage2:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#argSampl]]
40 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage2]]
41
42 ; CHECK-SPIRV: %[[#SampledImage3:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#ConstSampler2]]
43 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage3]]
44
45 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, ptr addrspace(1) nocapture noundef writeonly %results, target("spirv.Sampler") %argSampl) local_unnamed_addr {
46 entry:
47 %0 = tail call spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32 32)
48 %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)
49 store <4 x float> %call, ptr addrspace(1) %results, align 16
50 %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)
51 store <4 x float> %call1, ptr addrspace(1) %results, align 16
52 %1 = tail call spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32 22)
53 %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)
54 store <4 x float> %call2, ptr addrspace(1) %results, align 16
55 ret void
56 }
57
58 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
59
60 declare spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32) local_unnamed_addr
61
62 ; CHECK-SPIRV: %[[#sample_kernel_int]] = OpFunction %{{.*}}
63 ; CHECK-SPIRV: %[[#InputImage:]] = OpFunctionParameter %{{.*}}
64 ; CHECK-SPIRV: %[[#argSampl:]] = OpFunctionParameter %[[#TypeSampler]]
65
66 ; CHECK-SPIRV: %[[#SampledImage4:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#ConstSampler1]]
67 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage4]]
68
69 ; CHECK-SPIRV: %[[#SampledImage5:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#argSampl]]
70 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage5]]
71
72 ; CHECK-SPIRV: %[[#SampledImage6:]] = OpSampledImage %[[#SampledImageTy]] %[[#InputImage]] %[[#ConstSampler2]]
73 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SampledImage6]]
74
75 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, ptr addrspace(1) nocapture noundef writeonly %results, target("spirv.Sampler") %argSampl) local_unnamed_addr {
76 entry:
77 %0 = tail call spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32 32)
78 %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)
79 store <4 x i32> %call, ptr addrspace(1) %results, align 16
80 %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)
81 store <4 x i32> %call1, ptr addrspace(1) %results, align 16
82 %1 = tail call spir_func target("spirv.Sampler") @__translate_sampler_initializer(i32 22)
83 %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)
84 store <4 x i32> %call2, ptr addrspace(1) %results, align 16
85 ret void
86 }
87
88 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