| 1 |
; ModuleID = '<stdin>' |
| 2 |
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" |
| 3 |
target triple = "spir64-unknown-unknown" |
| 4 |
|
| 5 |
; RUN: llvm-as -opaque-pointers=0 %s -o %t.bc |
| 6 |
; RUN: llvm-spirv %t.bc -opaque-pointers=0 -spirv-text -o %t.txt |
| 7 |
; RUN: FileCheck < %t.txt %s --check-prefix=CHECK-SPIRV |
| 8 |
; RUN: llvm-spirv %t.bc -opaque-pointers=0 -o %t.spv |
| 9 |
; RUN: spirv-val %t.spv |
| 10 |
; RUN: llvm-spirv -r %t.spv -o %t.bc |
| 11 |
; RUN: llvm-dis -opaque-pointers=0 < %t.bc | FileCheck %s |
| 12 |
|
| 13 |
; Check conversion of get_image_width, get_image_height, get_image_depth, |
| 14 |
; get_image_array_size, and get_image_dim OCL built-ins. |
| 15 |
; In general the SPIR-V reader converts OpImageQuerySize into get_image_dim |
| 16 |
; and subsequent extract or shufflevector instructions. Unfortunately there is |
| 17 |
; no get_image_dim for 1D images and get_image_dim cannot replace get_image_array_size |
| 18 |
|
| 19 |
; CHECK-DAG: %opencl.image1d_ro_t = type opaque |
| 20 |
; CHECK-DAG: %opencl.image1d_buffer_ro_t = type opaque |
| 21 |
; CHECK-DAG: %opencl.image1d_array_ro_t = type opaque |
| 22 |
; CHECK-DAG: %opencl.image2d_ro_t = type opaque |
| 23 |
; CHECK-DAG: %opencl.image2d_depth_ro_t = type opaque |
| 24 |
; CHECK-DAG: %opencl.image2d_array_ro_t = type opaque |
| 25 |
; CHECK-SPIRV: 10 TypeImage [[ArrayTypeID:[0-9]+]] {{[0-9]+}} 0 0 1 0 0 0 0 |
| 26 |
; CHECK-DAG: %opencl.image2d_array_depth_ro_t = type opaque |
| 27 |
; CHECK-DAG: %opencl.image3d_ro_t = type opaque |
| 28 |
|
| 29 |
%opencl.image1d_ro_t = type opaque |
| 30 |
%opencl.image1d_buffer_ro_t = type opaque |
| 31 |
%opencl.image1d_array_ro_t = type opaque |
| 32 |
%opencl.image2d_ro_t = type opaque |
| 33 |
%opencl.image2d_depth_ro_t = type opaque |
| 34 |
%opencl.image2d_array_ro_t = type opaque |
| 35 |
%opencl.image2d_array_depth_ro_t = type opaque |
| 36 |
%opencl.image3d_ro_t = type opaque |
| 37 |
|
| 38 |
; CHECK-LABEL: define {{.*}} @test_image1d |
| 39 |
|
| 40 |
; CHECK: call {{.*}} @_Z15get_image_width14ocl_image1d_ro |
| 41 |
|
| 42 |
; CHECK: call {{.*}} @_Z15get_image_width21ocl_image1d_buffer_ro |
| 43 |
|
| 44 |
; CHECK: call {{.*}} @_Z15get_image_width20ocl_image1d_array_ro |
| 45 |
; CHECK: insertelement <2 x i32> {{.*}} 0 |
| 46 |
; CHECK: call {{.*}} i64 @_Z20get_image_array_size20ocl_image1d_array_ro |
| 47 |
; CHECK: trunc i64 {{.*}} to i32 |
| 48 |
; CHECK: insertelement <2 x i32> {{.*}} 1 |
| 49 |
|
| 50 |
; CHECK: call {{.*}} i64 @_Z20get_image_array_size20ocl_image1d_array_ro |
| 51 |
; CHECK-SPIRV: 3 FunctionParameter [[ArrayTypeID]] [[ArrayVarID:[0-9]+]] |
| 52 |
; CHECK-SPIRV: ImageQuerySizeLod {{[0-9]+}} {{[0-9]+}} [[ArrayVarID]] |
| 53 |
; CHECK-SPIRV-NOT: {{[0-9]*}} ExtInst {{[0-9]*}} {{[0-9]*}} {{[0-9]*}} get_image_array_size |
| 54 |
|
| 55 |
; Function Attrs: nounwind |
| 56 |
define spir_kernel void @test_image1d(i32 addrspace(1)* nocapture %sizes, %opencl.image1d_ro_t addrspace(1)* %img, %opencl.image1d_buffer_ro_t addrspace(1)* %buffer, %opencl.image1d_array_ro_t addrspace(1)* %array) #0 !kernel_arg_addr_space !1 !kernel_arg_access_qual !2 !kernel_arg_type !3 !kernel_arg_base_type !5 !kernel_arg_type_qual !4 { |
| 57 |
%1 = tail call spir_func i32 @_Z15get_image_width14ocl_image1d_ro(%opencl.image1d_ro_t addrspace(1)* %img) #1 |
| 58 |
%2 = tail call spir_func i32 @_Z15get_image_width21ocl_image1d_buffer_ro(%opencl.image1d_buffer_ro_t addrspace(1)* %buffer) #1 |
| 59 |
%3 = tail call spir_func i32 @_Z15get_image_width20ocl_image1d_array_ro(%opencl.image1d_array_ro_t addrspace(1)* %array) #1 |
| 60 |
%4 = tail call spir_func i64 @_Z20get_image_array_size20ocl_image1d_array_ro(%opencl.image1d_array_ro_t addrspace(1)* %array) #1 |
| 61 |
%5 = trunc i64 %4 to i32 |
| 62 |
%6 = add nsw i32 %2, %1 |
| 63 |
%7 = add nsw i32 %6, %3 |
| 64 |
%8 = add nsw i32 %7, %5 |
| 65 |
store i32 %8, i32 addrspace(1)* %sizes, align 4, !tbaa !22 |
| 66 |
ret void |
| 67 |
} |
| 68 |
|
| 69 |
; Function Attrs: nounwind readnone |
| 70 |
declare spir_func i32 @_Z15get_image_width14ocl_image1d_ro(%opencl.image1d_ro_t addrspace(1)*) #1 |
| 71 |
|
| 72 |
; Function Attrs: nounwind readnone |
| 73 |
declare spir_func i32 @_Z15get_image_width21ocl_image1d_buffer_ro(%opencl.image1d_buffer_ro_t addrspace(1)*) #1 |
| 74 |
|
| 75 |
; Function Attrs: nounwind readnone |
| 76 |
declare spir_func i32 @_Z15get_image_width20ocl_image1d_array_ro(%opencl.image1d_array_ro_t addrspace(1)*) #1 |
| 77 |
|
| 78 |
; Function Attrs: nounwind readnone |
| 79 |
declare spir_func i64 @_Z20get_image_array_size20ocl_image1d_array_ro(%opencl.image1d_array_ro_t addrspace(1)*) #1 |
| 80 |
|
| 81 |
; CHECK-LABEL: define {{.*}} @test_image2d |
| 82 |
|
| 83 |
; CHECK: call {{.*}} @_Z13get_image_dim14ocl_image2d_ro |
| 84 |
; CHECK: extractelement <2 x i32> {{.*}} 0 |
| 85 |
|
| 86 |
; CHECK: call {{.*}} @_Z13get_image_dim14ocl_image2d_ro |
| 87 |
; CHECK: extractelement <2 x i32> {{.*}} 1 |
| 88 |
|
| 89 |
; CHECK: call {{.*}} @_Z13get_image_dim14ocl_image2d_ro |
| 90 |
; CHECK: call {{.*}} @_Z13get_image_dim20ocl_image2d_array_ro |
| 91 |
; CHECK: shufflevector <2 x i32> {{.*}} <3 x i32> |
| 92 |
; CHECK: call {{.*}} i64 @_Z20get_image_array_size20ocl_image2d_array_ro |
| 93 |
; CHECK: trunc i64 {{.*}} to i32 |
| 94 |
; CHECK: insertelement <3 x i32> {{.*}} i32 2 |
| 95 |
; CHECK: extractelement <3 x i32> {{.*}} 0 |
| 96 |
|
| 97 |
; CHECK: call {{.*}} @_Z13get_image_dim20ocl_image2d_array_ro |
| 98 |
; CHECK: shufflevector <2 x i32> {{.*}} <3 x i32> |
| 99 |
; CHECK: call {{.*}} i64 @_Z20get_image_array_size20ocl_image2d_array_ro |
| 100 |
; CHECK: trunc i64 {{.*}} to i32 |
| 101 |
; CHECK: insertelement <3 x i32> {{.*}} i32 2 |
| 102 |
; CHECK: extractelement <3 x i32> {{.*}} 1 |
| 103 |
|
| 104 |
; CHECK: call {{.*}} @_Z20get_image_array_size20ocl_image2d_array_ro |
| 105 |
|
| 106 |
; CHECK: call {{.*}} @_Z13get_image_dim20ocl_image2d_array_ro |
| 107 |
; CHECK: shufflevector <2 x i32> {{.*}} <3 x i32> |
| 108 |
; CHECK: call {{.*}} i64 @_Z20get_image_array_size20ocl_image2d_array_ro |
| 109 |
; CHECK: trunc i64 {{.*}} to i32 |
| 110 |
; CHECK: insertelement <3 x i32> {{.*}} i32 2 |
| 111 |
; CHECK: shufflevector <3 x i32> {{.*}} <2 x i32> |
| 112 |
|
| 113 |
; Function Attrs: nounwind |
| 114 |
define spir_kernel void @test_image2d(i32 addrspace(1)* nocapture %sizes, %opencl.image2d_ro_t addrspace(1)* %img, %opencl.image2d_depth_ro_t addrspace(1)* nocapture %img_depth, %opencl.image2d_array_ro_t addrspace(1)* %array, %opencl.image2d_array_depth_ro_t addrspace(1)* nocapture %array_depth) #0 !kernel_arg_addr_space !7 !kernel_arg_access_qual !8 !kernel_arg_type !9 !kernel_arg_base_type !11 !kernel_arg_type_qual !10 { |
| 115 |
%1 = tail call spir_func i32 @_Z15get_image_width14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)* %img) #1 |
| 116 |
%2 = tail call spir_func i32 @_Z16get_image_height14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)* %img) #1 |
| 117 |
%3 = tail call spir_func <2 x i32> @_Z13get_image_dim14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)* %img) #1 |
| 118 |
%4 = tail call spir_func i32 @_Z15get_image_width20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)* %array) #1 |
| 119 |
%5 = tail call spir_func i32 @_Z16get_image_height20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)* %array) #1 |
| 120 |
%6 = tail call spir_func i64 @_Z20get_image_array_size20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)* %array) #1 |
| 121 |
%7 = trunc i64 %6 to i32 |
| 122 |
%8 = tail call spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)* %array) #1 |
| 123 |
%9 = add nsw i32 %2, %1 |
| 124 |
%10 = extractelement <2 x i32> %3, i32 0 |
| 125 |
%11 = add nsw i32 %9, %10 |
| 126 |
%12 = extractelement <2 x i32> %3, i32 1 |
| 127 |
%13 = add nsw i32 %11, %12 |
| 128 |
%14 = add nsw i32 %13, %4 |
| 129 |
%15 = add nsw i32 %14, %5 |
| 130 |
%16 = add nsw i32 %15, %7 |
| 131 |
%17 = extractelement <2 x i32> %8, i32 0 |
| 132 |
%18 = add nsw i32 %16, %17 |
| 133 |
%19 = extractelement <2 x i32> %8, i32 1 |
| 134 |
%20 = add nsw i32 %18, %19 |
| 135 |
store i32 %20, i32 addrspace(1)* %sizes, align 4, !tbaa !22 |
| 136 |
ret void |
| 137 |
} |
| 138 |
|
| 139 |
; Function Attrs: nounwind readnone |
| 140 |
declare spir_func i32 @_Z15get_image_width14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)*) #1 |
| 141 |
|
| 142 |
; Function Attrs: nounwind readnone |
| 143 |
declare spir_func i32 @_Z16get_image_height14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)*) #1 |
| 144 |
|
| 145 |
; Function Attrs: nounwind readnone |
| 146 |
declare spir_func <2 x i32> @_Z13get_image_dim14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)*) #1 |
| 147 |
|
| 148 |
; Function Attrs: nounwind readnone |
| 149 |
declare spir_func i32 @_Z15get_image_width20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)*) #1 |
| 150 |
|
| 151 |
; Function Attrs: nounwind readnone |
| 152 |
declare spir_func i32 @_Z16get_image_height20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)*) #1 |
| 153 |
|
| 154 |
; Function Attrs: nounwind readnone |
| 155 |
declare spir_func i64 @_Z20get_image_array_size20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)*) #1 |
| 156 |
|
| 157 |
; Function Attrs: nounwind readnone |
| 158 |
declare spir_func <2 x i32> @_Z13get_image_dim20ocl_image2d_array_ro(%opencl.image2d_array_ro_t addrspace(1)*) #1 |
| 159 |
|
| 160 |
; CHECK-LABEL: define {{.*}} @test_image3d |
| 161 |
|
| 162 |
; CHECK: call {{.*}} @_Z13get_image_dim14ocl_image3d_ro |
| 163 |
; CHECK: shufflevector <4 x i32> {{.*}} <3 x i32> |
| 164 |
; CHECK: extractelement <3 x i32> {{.*}} 0 |
| 165 |
|
| 166 |
; CHECK: call {{.*}} @_Z13get_image_dim14ocl_image3d_ro |
| 167 |
; CHECK: shufflevector <4 x i32> {{.*}} <3 x i32> |
| 168 |
; CHECK: extractelement <3 x i32> {{.*}} 1 |
| 169 |
|
| 170 |
; CHECK: call {{.*}} @_Z13get_image_dim14ocl_image3d_ro |
| 171 |
; CHECK: shufflevector <4 x i32> {{.*}} <3 x i32> |
| 172 |
; CHECK: extractelement <3 x i32> {{.*}} 2 |
| 173 |
|
| 174 |
; CHECK: call {{.*}} @_Z13get_image_dim14ocl_image3d_ro |
| 175 |
; CHECK: shufflevector <4 x i32> {{.*}} <3 x i32> |
| 176 |
; CHECK: shufflevector <3 x i32> {{.*}} <4 x i32> |
| 177 |
|
| 178 |
; Function Attrs: nounwind |
| 179 |
define spir_kernel void @test_image3d(i32 addrspace(1)* nocapture %sizes, %opencl.image3d_ro_t addrspace(1)* %img) #0 !kernel_arg_addr_space !13 !kernel_arg_access_qual !14 !kernel_arg_type !15 !kernel_arg_base_type !17 !kernel_arg_type_qual !16 { |
| 180 |
%1 = tail call spir_func i32 @_Z15get_image_width14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)* %img) #1 |
| 181 |
%2 = tail call spir_func i32 @_Z16get_image_height14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)* %img) #1 |
| 182 |
%3 = tail call spir_func i32 @_Z15get_image_depth14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)* %img) #1 |
| 183 |
%4 = tail call spir_func <4 x i32> @_Z13get_image_dim14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)* %img) #1 |
| 184 |
%5 = add nsw i32 %2, %1 |
| 185 |
%6 = add nsw i32 %5, %3 |
| 186 |
%7 = extractelement <4 x i32> %4, i32 0 |
| 187 |
%8 = add nsw i32 %6, %7 |
| 188 |
%9 = extractelement <4 x i32> %4, i32 1 |
| 189 |
%10 = add nsw i32 %8, %9 |
| 190 |
%11 = extractelement <4 x i32> %4, i32 2 |
| 191 |
%12 = add nsw i32 %10, %11 |
| 192 |
%13 = extractelement <4 x i32> %4, i32 3 |
| 193 |
%14 = add nsw i32 %12, %13 |
| 194 |
store i32 %14, i32 addrspace(1)* %sizes, align 4, !tbaa !22 |
| 195 |
ret void |
| 196 |
} |
| 197 |
|
| 198 |
; Function Attrs: nounwind readnone |
| 199 |
declare spir_func i32 @_Z15get_image_width14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)*) #1 |
| 200 |
|
| 201 |
; Function Attrs: nounwind readnone |
| 202 |
declare spir_func i32 @_Z16get_image_height14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)*) #1 |
| 203 |
|
| 204 |
; Function Attrs: nounwind readnone |
| 205 |
declare spir_func i32 @_Z15get_image_depth14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)*) #1 |
| 206 |
|
| 207 |
; Function Attrs: nounwind readnone |
| 208 |
declare spir_func <4 x i32> @_Z13get_image_dim14ocl_image3d_ro(%opencl.image3d_ro_t addrspace(1)*) #1 |
| 209 |
|
| 210 |
; CHECK-LABEL: define {{.*}} @test_image2d_array_depth_t |
| 211 |
|
| 212 |
; CHECK: call {{.*}} <2 x i32> @_Z13get_image_dim26ocl_image2d_array_depth_ro |
| 213 |
; CHECK: shufflevector <2 x i32> |
| 214 |
; CHECK: call {{.*}} i64 @_Z20get_image_array_size26ocl_image2d_array_depth_ro |
| 215 |
; CHECK: trunc i64 {{.*}} to i32 |
| 216 |
; CHECK: insertelement <3 x i32> {{.*}} 2 |
| 217 |
; CHECK: extractelement <3 x i32> {{.*}} 0 |
| 218 |
|
| 219 |
; CHECK: call {{.*}} <2 x i32> @_Z13get_image_dim26ocl_image2d_array_depth_ro |
| 220 |
; CHECK: shufflevector <2 x i32> |
| 221 |
; CHECK: call {{.*}} i64 @_Z20get_image_array_size26ocl_image2d_array_depth_ro |
| 222 |
; CHECK: trunc i64 {{.*}} to i32 |
| 223 |
; CHECK: insertelement <3 x i32> {{.*}} 2 |
| 224 |
; CHECK: extractelement <3 x i32> {{.*}} 1 |
| 225 |
|
| 226 |
; Function Attrs: nounwind |
| 227 |
define spir_kernel void @test_image2d_array_depth_t(i32 addrspace(1)* nocapture %sizes, %opencl.image2d_array_depth_ro_t addrspace(1)* %array) #0 !kernel_arg_addr_space !27 !kernel_arg_access_qual !28 !kernel_arg_type !29 !kernel_arg_base_type !31 !kernel_arg_type_qual !30 { |
| 228 |
%1 = tail call spir_func i32 @_Z15get_image_width26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)* %array) #1 |
| 229 |
%2 = tail call spir_func i32 @_Z16get_image_height26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)* %array) #1 |
| 230 |
%3 = tail call spir_func i64 @_Z20get_image_array_size26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)* %array) #1 |
| 231 |
%4 = trunc i64 %3 to i32 |
| 232 |
%5 = add nsw i32 %2, %1 |
| 233 |
%6 = add nsw i32 %5, %4 |
| 234 |
store i32 %5, i32 addrspace(1)* %sizes, align 4, !tbaa !22 |
| 235 |
ret void |
| 236 |
} |
| 237 |
|
| 238 |
; Function Attrs: nounwind readnone |
| 239 |
declare spir_func i32 @_Z15get_image_width26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)*) #1 |
| 240 |
|
| 241 |
; Function Attrs: nounwind readnone |
| 242 |
declare spir_func i32 @_Z16get_image_height26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)*) #1 |
| 243 |
|
| 244 |
; Function Attrs: nounwind readnone |
| 245 |
declare spir_func i64 @_Z20get_image_array_size26ocl_image2d_array_depth_ro(%opencl.image2d_array_depth_ro_t addrspace(1)*) #1 |
| 246 |
|
| 247 |
attributes #0 = { nounwind } |
| 248 |
attributes #1 = { nounwind readnone } |
| 249 |
|
| 250 |
!opencl.enable.FP_CONTRACT = !{} |
| 251 |
!opencl.spir.version = !{!18} |
| 252 |
!opencl.ocl.version = !{!18} |
| 253 |
!opencl.used.extensions = !{!19} |
| 254 |
!opencl.used.optional.core.features = !{!20} |
| 255 |
!opencl.compiler.options = !{!21} |
| 256 |
|
| 257 |
!1 = !{i32 1, i32 1, i32 1, i32 1} |
| 258 |
!2 = !{!"none", !"read_only", !"read_only", !"read_only"} |
| 259 |
!3 = !{!"int*", !"image1d_t", !"image1d_buffer_t", !"image1d_array_t"} |
| 260 |
!4 = !{!"", !"", !"", !""} |
| 261 |
!5 = !{!"int*", !"image1d_t", !"image1d_buffer_t", !"image1d_array_t"} |
| 262 |
!7 = !{i32 1, i32 1, i32 1, i32 1, i32 1} |
| 263 |
!8 = !{!"none", !"read_only", !"read_only", !"read_only", !"read_only"} |
| 264 |
!9 = !{!"int*", !"image2d_t", !"image2d_depth_t", !"image2d_array_t", !"image2d_array_depth_t"} |
| 265 |
!10 = !{!"", !"", !"", !"", !""} |
| 266 |
!11 = !{!"int*", !"image2d_t", !"image2d_depth_t", !"image2d_array_t", !"image2d_array_depth_t"} |
| 267 |
!13 = !{i32 1, i32 1} |
| 268 |
!14 = !{!"none", !"read_only"} |
| 269 |
!15 = !{!"int*", !"image3d_t"} |
| 270 |
!16 = !{!"", !""} |
| 271 |
!17 = !{!"int*", !"image3d_t"} |
| 272 |
!18 = !{i32 1, i32 2} |
| 273 |
!19 = !{!"cl_khr_depth_images"} |
| 274 |
!20 = !{!"cl_images"} |
| 275 |
!21 = !{} |
| 276 |
!22 = !{!23, !23, i64 0} |
| 277 |
!23 = !{!"int", !24} |
| 278 |
!24 = !{!"omnipotent char", !25} |
| 279 |
!25 = !{!"Simple C/C++ TBAA"} |
| 280 |
!27 = !{i32 1, i32 1} |
| 281 |
!28 = !{!"none", !"read_only"} |
| 282 |
!29 = !{!"int*", !"image2d_array_depth_t"} |
| 283 |
!30 = !{!"", !""} |
| 284 |
!31 = !{!"int*", !"image2d_array_depth_t"} |