Debian Codegraph @

llvm/test/CodeGen/SPIRV/transcoding/spirv-types.ll

raw
1 ;; Test SPIR-V opaque types
2
3 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
4 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
5
6 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
7 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
8
9 ; CHECK-SPIRV-DAG: OpCapability Float16
10 ; CHECK-SPIRV-DAG: OpCapability ImageReadWrite
11 ; CHECK-SPIRV-DAG: OpCapability Pipes
12 ; CHECK-SPIRV-DAG: OpCapability DeviceEnqueue
13
14 ; CHECK-SPIRV-DAG: %[[#VOID:]] = OpTypeVoid
15 ; CHECK-SPIRV-DAG: %[[#INT:]] = OpTypeInt 32 0
16 ; CHECK-SPIRV-DAG: %[[#HALF:]] = OpTypeFloat 16
17 ; CHECK-SPIRV-DAG: %[[#FLOAT:]] = OpTypeFloat 32
18 ; CHECK-SPIRV-DAG: %[[#PIPE_RD:]] = OpTypePipe ReadOnly
19 ; CHECK-SPIRV-DAG: %[[#PIPE_WR:]] = OpTypePipe WriteOnly
20 ; CHECK-SPIRV-DAG: %[[#IMG1D_RD:]] = OpTypeImage %[[#VOID]] 1D 0 0 0 0 Unknown ReadOnly
21 ; CHECK-SPIRV-DAG: %[[#IMG2D_RD:]] = OpTypeImage %[[#INT]] 2D 0 0 0 0 Unknown ReadOnly
22 ; CHECK-SPIRV-DAG: %[[#IMG3D_RD:]] = OpTypeImage %[[#INT]] 3D 0 0 0 0 Unknown ReadOnly
23 ; CHECK-SPIRV-DAG: %[[#IMG2DD_RD:]] = OpTypeImage %[[#FLOAT]] 2D 1 0 0 0 Unknown ReadOnly
24 ; CHECK-SPIRV-DAG: %[[#IMG2DA_RD:]] = OpTypeImage %[[#HALF]] 2D 0 1 0 0 Unknown ReadOnly
25 ; CHECK-SPIRV-DAG: %[[#IMG1DB_RD:]] = OpTypeImage %[[#FLOAT]] Buffer 0 0 0 0 Unknown ReadOnly
26 ; CHECK-SPIRV-DAG: %[[#IMG1D_WR:]] = OpTypeImage %[[#VOID]] 1D 0 0 0 0 Unknown WriteOnly
27 ; CHECK-SPIRV-DAG: %[[#IMG2D_RW:]] = OpTypeImage %[[#VOID]] 2D 0 0 0 0 Unknown ReadWrite
28 ; CHECK-SPIRV-DAG: %[[#DEVEVENT:]] = OpTypeDeviceEvent
29 ; CHECK-SPIRV-DAG: %[[#EVENT:]] = OpTypeEvent
30 ; CHECK-SPIRV-DAG: %[[#QUEUE:]] = OpTypeQueue
31 ; CHECK-SPIRV-DAG: %[[#RESID:]] = OpTypeReserveId
32 ; CHECK-SPIRV-DAG: %[[#SAMP:]] = OpTypeSampler
33 ; CHECK-SPIRV-DAG: %[[#SAMPIMG:]] = OpTypeSampledImage %[[#IMG2DD_RD]]
34
35 ; CHECK-SPIRV: OpFunction
36 ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#PIPE_RD]]
37 ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#PIPE_WR]]
38 ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#IMG1D_RD]]
39 ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#IMG2D_RD]]
40 ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#IMG3D_RD]]
41 ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#IMG2DA_RD]]
42 ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#IMG1DB_RD]]
43 ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#IMG1D_WR]]
44 ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#IMG2D_RW]]
45
46 define spir_kernel void @foo(
47 target("spirv.Pipe", 0) %a,
48 target("spirv.Pipe", 1) %b,
49 target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %c1,
50 target("spirv.Image", i32, 1, 0, 0, 0, 0, 0, 0) %d1,
51 target("spirv.Image", i32, 2, 0, 0, 0, 0, 0, 0) %e1,
52 target("spirv.Image", half, 1, 0, 1, 0, 0, 0, 0) %f1,
53 target("spirv.Image", float, 5, 0, 0, 0, 0, 0, 0) %g1,
54 target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1) %c2,
55 target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 2) %d3) {
56 entry:
57 ret void
58 }
59
60 ; CHECK-SPIRV: OpFunction
61 ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#DEVEVENT]]
62 ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#EVENT]]
63 ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#QUEUE]]
64 ; CHECK-SPIRV: %[[#]] = OpFunctionParameter %[[#RESID]]
65
66 define spir_func void @bar(
67 target("spirv.DeviceEvent") %a,
68 target("spirv.Event") %b,
69 target("spirv.Queue") %c,
70 target("spirv.ReserveId") %d) {
71 ret void
72 }
73
74 ; CHECK-SPIRV: OpFunction
75 ; CHECK-SPIRV: %[[#IMG_ARG:]] = OpFunctionParameter %[[#IMG2DD_RD]]
76 ; CHECK-SPIRV: %[[#SAMP_ARG:]] = OpFunctionParameter %[[#SAMP]]
77 ; CHECK-SPIRV: %[[#SAMPIMG_VAR:]] = OpSampledImage %[[#SAMPIMG]] %[[#IMG_ARG]] %[[#SAMP_ARG]]
78 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod %[[#]] %[[#SAMPIMG_VAR]]
79
80 define spir_func void @test_sampler(target("spirv.Image", float, 1, 1, 0, 0, 0, 0, 0) %srcimg.coerce,
81 target("spirv.Sampler") %s.coerce) {
82 %1 = tail call spir_func target("spirv.Image", float, 1, 1, 0, 0, 0, 0, 0) @_Z20__spirv_SampledImagePU3AS1K34__spirv_Image__float_1_1_0_0_0_0_0PU3AS1K15__spirv_Sampler(target("spirv.Image", float, 1, 1, 0, 0, 0, 0, 0) %srcimg.coerce, target("spirv.Sampler") %s.coerce)
83 %2 = tail call spir_func <4 x float> @_Z38__spirv_ImageSampleExplicitLod_Rfloat4PU3AS120__spirv_SampledImageDv4_iif(target("spirv.Image", float, 1, 1, 0, 0, 0, 0, 0) %1, <4 x i32> zeroinitializer, i32 2, float 1.000000e+00)
84 ret void
85 }
86
87 declare spir_func target("spirv.Image", float, 1, 1, 0, 0, 0, 0, 0) @_Z20__spirv_SampledImagePU3AS1K34__spirv_Image__float_1_1_0_0_0_0_0PU3AS1K15__spirv_Sampler(target("spirv.Image", float, 1, 1, 0, 0, 0, 0, 0), target("spirv.Sampler"))
88 declare spir_func <4 x float> @_Z38__spirv_ImageSampleExplicitLod_Rfloat4PU3AS120__spirv_SampledImageDv4_iif(target("spirv.Image", float, 1, 1, 0, 0, 0, 0, 0), <4 x i32>, i32, float)
89
90 ; CHECK-SPIRV: %[[#]] = OpImageRead
91 ; CHECK-SPIRV: %[[#]] = OpImageRead
92 ; CHECK-SPIRV: %[[#]] = OpImageRead
93 ; CHECK-SPIRV: %[[#]] = OpImageRead
94 ; CHECK-SPIRV: %[[#]] = OpImageRead
95 ; CHECK-SPIRV: %[[#]] = OpImageRead
96 ; CHECK-SPIRV: %[[#]] = OpImageRead
97 ; CHECK-SPIRV: %[[#]] = OpImageSampleExplicitLod
98
99 define dso_local spir_kernel void @reads() {
100 %1 = tail call spir_func i32 @_Z17__spirv_ImageReadIi14ocl_image3d_roDv4_iET_T0_T1_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) poison, <4 x i32> zeroinitializer)
101 %2 = tail call spir_func <2 x i32> @_Z17__spirv_ImageReadIDv2_i14ocl_image2d_roS0_ET_T0_T1_(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) poison, <2 x i32> zeroinitializer)
102 %3 = tail call spir_func <4 x i32> @_Z17__spirv_ImageReadIDv4_j14ocl_image3d_roDv4_iET_T0_T1_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) poison, <4 x i32> zeroinitializer)
103 %4 = tail call spir_func signext i16 @_Z17__spirv_ImageReadIs14ocl_image1d_roiET_T0_T1_(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) poison, i32 0)
104 %5 = tail call spir_func zeroext i16 @_Z17__spirv_ImageReadIt14ocl_image3d_roDv4_iET_T0_T1_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0) poison, <4 x i32> zeroinitializer)
105 %6 = tail call spir_func <2 x float> @_Z17__spirv_ImageReadIDv2_f14ocl_image1d_roiET_T0_T1_(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) poison, i32 0)
106 %7 = tail call spir_func half @_Z17__spirv_ImageReadIDF16_14ocl_image2d_roDv2_iET_T0_T1_(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) poison, <2 x i32> zeroinitializer)
107 %8 = tail call spir_func <4 x i32> @_Z30__spirv_ImageSampleExplicitLodI32__spirv_SampledImage__image1d_roDv4_jfET0_T_T1_if(target("spirv.SampledImage", void, 0, 0, 0, 0, 0, 0, 0) poison, float 0.000000e+00, i32 2, float 0.000000e+00)
108 ret void
109 }
110
111 declare dso_local spir_func i32 @_Z17__spirv_ImageReadIi14ocl_image3d_roDv4_iET_T0_T1_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0), <4 x i32>)
112 declare dso_local spir_func <2 x i32> @_Z17__spirv_ImageReadIDv2_i14ocl_image2d_roS0_ET_T0_T1_(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), <2 x i32>)
113 declare dso_local spir_func <4 x i32> @_Z17__spirv_ImageReadIDv4_j14ocl_image3d_roDv4_iET_T0_T1_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0), <4 x i32>)
114 declare dso_local spir_func signext i16 @_Z17__spirv_ImageReadIs14ocl_image1d_roiET_T0_T1_(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0), i32)
115 declare dso_local spir_func zeroext i16 @_Z17__spirv_ImageReadIt14ocl_image3d_roDv4_iET_T0_T1_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 0), <4 x i32>)
116 declare dso_local spir_func <2 x float> @_Z17__spirv_ImageReadIDv2_f14ocl_image1d_roiET_T0_T1_(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0), i32)
117 declare dso_local spir_func half @_Z17__spirv_ImageReadIDF16_14ocl_image2d_roDv2_iET_T0_T1_(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), <2 x i32>)
118 declare dso_local spir_func <4 x i32> @_Z30__spirv_ImageSampleExplicitLodI32__spirv_SampledImage__image1d_roDv4_jfET0_T_T1_if(target("spirv.SampledImage", void, 0, 0, 0, 0, 0, 0, 0), float noundef, i32 noundef, float noundef)
119
120 ; CHECK-SPIRV: OpImageWrite
121 ; CHECK-SPIRV: OpImageWrite
122 ; CHECK-SPIRV: OpImageWrite
123 ; CHECK-SPIRV: OpImageWrite
124 ; CHECK-SPIRV: OpImageWrite
125 ; CHECK-SPIRV: OpImageWrite
126 ; CHECK-SPIRV: OpImageWrite
127
128 define dso_local spir_kernel void @writes() {
129 call spir_func void @_Z18__spirv_ImageWriteI14ocl_image3d_woDv4_iiEvT_T0_T1_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1) poison, <4 x i32> zeroinitializer, i32 zeroinitializer)
130 call spir_func void @_Z18__spirv_ImageWriteI14ocl_image2d_woDv2_iS1_EvT_T0_T1_(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1) poison, <2 x i32> zeroinitializer, <2 x i32> zeroinitializer)
131 call spir_func void @_Z18__spirv_ImageWriteI14ocl_image3d_woDv4_iDv4_jEvT_T0_T1_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1) poison, <4 x i32> zeroinitializer, <4 x i32> zeroinitializer)
132 call spir_func void @_Z18__spirv_ImageWriteI14ocl_image1d_woisEvT_T0_T1_(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1) poison, i32 0, i16 signext 0)
133 call spir_func void @_Z18__spirv_ImageWriteI14ocl_image3d_woDv4_itEvT_T0_T1_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1) poison, <4 x i32> zeroinitializer, i16 zeroext 0)
134 call spir_func void @_Z18__spirv_ImageWriteI14ocl_image1d_woiDv2_fEvT_T0_T1_(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1) poison, i32 0, <2 x float> zeroinitializer)
135 call spir_func void @_Z18__spirv_ImageWriteI14ocl_image2d_woDv2_iDF16_EvT_T0_T1_(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1) poison, <2 x i32> zeroinitializer, half zeroinitializer)
136 ret void
137 }
138
139 declare dso_local spir_func void @_Z18__spirv_ImageWriteI14ocl_image3d_woDv4_iiEvT_T0_T1_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1), <4 x i32>, i32)
140 declare dso_local spir_func void @_Z18__spirv_ImageWriteI14ocl_image2d_woDv2_iS1_EvT_T0_T1_(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1), <2 x i32>, <2 x i32>)
141 declare dso_local spir_func void @_Z18__spirv_ImageWriteI14ocl_image3d_woDv4_iDv4_jEvT_T0_T1_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1), <4 x i32>, <4 x i32>)
142 declare dso_local spir_func void @_Z18__spirv_ImageWriteI14ocl_image1d_woisEvT_T0_T1_(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1), i32, i16 signext)
143 declare dso_local spir_func void @_Z18__spirv_ImageWriteI14ocl_image3d_woDv4_itEvT_T0_T1_(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 1), <4 x i32>, i16 zeroext)
144 declare dso_local spir_func void @_Z18__spirv_ImageWriteI14ocl_image1d_woiDv2_fEvT_T0_T1_(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 1), i32, <2 x float>)
145 declare dso_local spir_func void @_Z18__spirv_ImageWriteI14ocl_image2d_woDv2_iDF16_EvT_T0_T1_(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1), <2 x i32>, half)