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: spirv-val %t.spv 6; RUN: llvm-spirv -r %t.spv -o %t.rev.bc 7; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM 8; RUN: llvm-spirv -r %t.spv -o %t.rev.bc --spirv-target-env=SPV-IR 9; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-SPIRV 10; RUN: llvm-spirv %t.rev.bc -o %t.rev.spv 11; RUN: spirv-val %t.rev.spv 12; RUN: llvm-spirv %t.rev.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV 13 14target 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" 15target triple = "spir-unknown-unknown" 16 17%opencl.image2d_ro_t = type opaque 18; CHECK-SPIRV-DAG: 4 Constant {{[0-9]+}} [[DataTypeOffsetId:[0-9]+]] 4304 19; CHECK-SPIRV-DAG: 4 Constant {{[0-9]+}} [[OrderOffsetId:[0-9]+]] 4272 20 21; Function Attrs: nounwind 22define spir_kernel void @f(%opencl.image2d_ro_t addrspace(1)* %img, i32 addrspace(1)* nocapture %type, i32 addrspace(1)* nocapture %order) #0 !kernel_arg_addr_space !1 !kernel_arg_access_qual !2 !kernel_arg_type !3 !kernel_arg_base_type !4 !kernel_arg_type_qual !5 { 23; CHECK-LLVM-DAG: [[DTCALL:%.+]] ={{.*}} call spir_func i32 @_Z27get_image_channel_data_type14ocl_image2d_ro 24; CHECK-LLVM: [[DTSUB:%.+]] = sub i32 [[DTCALL]], 4304 25; CHECK-LLVM: [[DTADD:%.+]] = add i32 [[DTSUB]], 4304 26; CHECK-LLVM: store i32 [[DTADD]] 27 28; CHECK-LLVM-SPIRV: [[DTCALL:%.+]] = call spir_func i32 @_Z24__spirv_ImageQueryFormatPU3AS133__spirv_Image__void_1_0_0_0_0_0_0(%spirv.Image._void_1_0_0_0_0_0_0 addrspace(1)* %img) 29; CHECK-LLVM-SPIRV: add i32 [[DTCALL]], 4304 30 31; CHECK-SPIRV: 4 ImageQueryFormat {{[0-9]+}} [[DataTypeID:[0-9]+]] 32; CHECK-SPIRV: 5 IAdd {{[0-9]+}} [[DTAddID:[0-9]+]] [[DataTypeID]] [[DataTypeOffsetId]] 33; CHECK-SPIRV: 5 Store {{[0-9]+}} [[DTAddID]] 34 35 %1 = tail call spir_func i32 @_Z27get_image_channel_data_type14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)* %img) #2 36 store i32 %1, i32 addrspace(1)* %type, align 4 37 38; CHECK-LLVM-DAG: [[OCALL:%.+]] ={{.*}} call spir_func i32 @_Z23get_image_channel_order14ocl_image2d_ro 39; CHECK-LLVM: [[OSUB:%.+]] = sub i32 [[OCALL]], 4272 40; CHECK-LLVM: [[OADD:%.+]] = add i32 [[OSUB]], 4272 41; CHECK-LLVM: store i32 [[OADD]] 42 43; CHECK-LLVM-SPIRV: [[OCALL:%.+]] = call spir_func i32 @_Z23__spirv_ImageQueryOrderPU3AS133__spirv_Image__void_1_0_0_0_0_0_0(%spirv.Image._void_1_0_0_0_0_0_0 addrspace(1)* %img) 44; CHECK-LLVM-SPIRV: add i32 [[OCALL]], 4272 45 46; CHECK-SPIRV: 4 ImageQueryOrder {{[0-9]+}} [[OrderID:[0-9]+]] 47; CHECK-SPIRV: 5 IAdd {{[0-9]+}} [[OrderAddID:[0-9]+]] [[OrderID]] [[OrderOffsetId]] 48; CHECK-SPIRV: 5 Store {{[0-9]+}} [[OrderAddID]] 49 50 %2 = tail call spir_func i32 @_Z23get_image_channel_order14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)* %img) #2 51 store i32 %2, i32 addrspace(1)* %order, align 4 52 ret void 53} 54 55declare spir_func i32 @_Z27get_image_channel_data_type14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)*) #1 56 57declare spir_func i32 @_Z23get_image_channel_order14ocl_image2d_ro(%opencl.image2d_ro_t addrspace(1)*) #1 58 59attributes #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" } 60attributes #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" } 61attributes #2 = { nounwind } 62 63!opencl.spir.version = !{!6} 64!opencl.ocl.version = !{!7} 65!opencl.used.extensions = !{!8} 66!opencl.used.optional.core.features = !{!9} 67!opencl.compiler.options = !{!8} 68 69!1 = !{i32 1, i32 1, i32 1} 70!2 = !{!"read_only", !"none", !"none"} 71!3 = !{!"image2d_t", !"int*", !"int*"} 72!4 = !{!"image2d_t", !"int*", !"int*"} 73!5 = !{!"", !"", !""} 74!6 = !{i32 1, i32 2} 75!7 = !{i32 2, i32 0} 76!8 = !{} 77!9 = !{!"cl_images"} 78