Debian Codegraph @

llvm/test/CodeGen/SPIRV/opencl/image.ll

raw
1 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
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
5 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
6
7 ;; FIXME: Write tests to ensure invalid usage of image are rejected, such as:
8 ;; - invalid AS (only global is allowed);
9 ;; - used in struct, union, array, pointer or return types;
10 ;; - used with invalid CV-qualifiers (const or volatile in C99).
11 ;; FIXME: Write further tests to cover _array, _buffer, _depth, ... types.
12
13 define void @foo(
14 target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %a,
15 target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1) %b,
16 target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2) %c,
17 ptr addrspace(1) %d
18 ) {
19 %pixel = call <4 x i32> @_Z11read_imagei14ocl_image1d_roi(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0) %a, i32 0)
20 call void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1) %b, <2 x i32> zeroinitializer, <4 x i32> %pixel)
21 %size = call i32 @_Z15get_image_width14ocl_image3d_rw(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2) %c)
22 store i32 %size, ptr addrspace(1) %d
23 ret void
24 }
25
26 declare <4 x i32> @_Z11read_imagei14ocl_image1d_roi(target("spirv.Image", void, 0, 0, 0, 0, 0, 0, 0), i32)
27
28 declare void @_Z12write_imagei14ocl_image2d_woDv2_iDv4_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 1), <2 x i32>, <4 x i32>)
29
30 declare i32 @_Z15get_image_width14ocl_image3d_rw(target("spirv.Image", void, 2, 0, 0, 0, 0, 0, 2))
31
32
33 ;; Capabilities:
34 ; CHECK-DAG: OpCapability ImageReadWrite
35 ; CHECK-NOT: DAG-FENCE
36
37 ;; Types, Constants and Variables:
38 ;; FIXME: The values should be double checked here.
39 ; CHECK-DAG: %[[#IMG_1D:]] = OpTypeImage %[[#VOID:]] 1D 0 0 0 0 Unknown ReadOnly
40 ; CHECK-DAG: %[[#IMG_2D:]] = OpTypeImage %[[#VOID]] 2D 0 0 0 0 Unknown WriteOnly
41 ; CHECK-DAG: %[[#IMG_3D:]] = OpTypeImage %[[#VOID]] 3D 0 0 0 0 Unknown ReadWrite
42 ; CHECK-DAG: %[[#PTR:]] = OpTypePointer CrossWorkgroup %[[#I32:]]
43 ; CHECK-DAG: %[[#FN:]] = OpTypeFunction %[[#VOID]] %[[#IMG_1D]] %[[#IMG_2D]] %[[#IMG_3D]] %[[#PTR]]
44
45 ;; Functions:
46 ; CHECK: OpFunction %[[#VOID]] None %[[#FN]]
47 ; CHECK: %[[#A:]] = OpFunctionParameter %[[#IMG_1D]]
48 ; CHECK: %[[#B:]] = OpFunctionParameter %[[#IMG_2D]]
49 ; CHECK: %[[#C:]] = OpFunctionParameter %[[#IMG_3D]]
50 ; CHECK: %[[#D:]] = OpFunctionParameter %[[#PTR]]
51 ; CHECK: %[[#PIXEL:]] = OpImageRead %[[#VEC:]] %[[#A]] %[[#]]
52 ; CHECK: OpImageWrite %[[#B]] %[[#]] %[[#PIXEL]]
53 ;; FIXME: It is unclear which of OpImageQuerySize and OpImageQuerySizeLod should be used.
54 ; CHECK: %[[#SIZE:]] = OpImageQuerySize{{(Lod)?}} %[[#]] %[[#C]]