1 ; RUN: llc -mtriple=r600 -mcpu=juniper < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
3 ; === WIDTH ==================================================================
4 ; 9 implicit args = 9 dwords to first image argument.
5 ; First width at dword index 9+1 -> KC0[2].Z
7 ; FUNC-LABEL: {{^}}width_2d:
8 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
9 ; EG: MOV * [[VAL]], KC0[2].Z
10 define amdgpu_kernel void @width_2d (ptr addrspace(1) %in,
11 ptr addrspace(1) %out) {
13 %0 = call [3 x i32] @llvm.OpenCL.image.get.size.2d(
14 ptr addrspace(1) %in) #0
15 %1 = extractvalue [3 x i32] %0, 0
16 store i32 %1, ptr addrspace(1) %out
20 ; FUNC-LABEL: {{^}}width_3d:
21 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
22 ; EG: MOV * [[VAL]], KC0[2].Z
23 define amdgpu_kernel void @width_3d (ptr addrspace(1) %in,
24 ptr addrspace(1) %out) {
26 %0 = call [3 x i32] @llvm.OpenCL.image.get.size.3d(
27 ptr addrspace(1) %in) #0
28 %1 = extractvalue [3 x i32] %0, 0
29 store i32 %1, ptr addrspace(1) %out
34 ; === HEIGHT =================================================================
35 ; First height at dword index 9+2 -> KC0[2].W
37 ; FUNC-LABEL: {{^}}height_2d:
38 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
39 ; EG: MOV * [[VAL]], KC0[2].W
40 define amdgpu_kernel void @height_2d (ptr addrspace(1) %in,
41 ptr addrspace(1) %out) {
43 %0 = call [3 x i32] @llvm.OpenCL.image.get.size.2d(
44 ptr addrspace(1) %in) #0
45 %1 = extractvalue [3 x i32] %0, 1
46 store i32 %1, ptr addrspace(1) %out
50 ; FUNC-LABEL: {{^}}height_3d:
51 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
52 ; EG: MOV * [[VAL]], KC0[2].W
53 define amdgpu_kernel void @height_3d (ptr addrspace(1) %in,
54 ptr addrspace(1) %out) {
56 %0 = call [3 x i32] @llvm.OpenCL.image.get.size.3d(
57 ptr addrspace(1) %in) #0
58 %1 = extractvalue [3 x i32] %0, 1
59 store i32 %1, ptr addrspace(1) %out
64 ; === DEPTH ==================================================================
65 ; First depth at dword index 9+3 -> KC0[3].X
67 ; FUNC-LABEL: {{^}}depth_3d:
68 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
69 ; EG: MOV * [[VAL]], KC0[3].X
70 define amdgpu_kernel void @depth_3d (ptr addrspace(1) %in,
71 ptr addrspace(1) %out) {
73 %0 = call [3 x i32] @llvm.OpenCL.image.get.size.3d(
74 ptr addrspace(1) %in) #0
75 %1 = extractvalue [3 x i32] %0, 2
76 store i32 %1, ptr addrspace(1) %out
81 ; === CHANNEL DATA TYPE ======================================================
82 ; First channel data type at dword index 9+4 -> KC0[3].Y
84 ; FUNC-LABEL: {{^}}data_type_2d:
85 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
86 ; EG: MOV * [[VAL]], KC0[3].Y
87 define amdgpu_kernel void @data_type_2d (ptr addrspace(1) %in,
88 ptr addrspace(1) %out) {
90 %0 = call [2 x i32] @llvm.OpenCL.image.get.format.2d(
91 ptr addrspace(1) %in) #0
92 %1 = extractvalue [2 x i32] %0, 0
93 store i32 %1, ptr addrspace(1) %out
97 ; FUNC-LABEL: {{^}}data_type_3d:
98 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
99 ; EG: MOV * [[VAL]], KC0[3].Y
100 define amdgpu_kernel void @data_type_3d (ptr addrspace(1) %in,
101 ptr addrspace(1) %out) {
103 %0 = call [2 x i32] @llvm.OpenCL.image.get.format.3d(
104 ptr addrspace(1) %in) #0
105 %1 = extractvalue [2 x i32] %0, 0
106 store i32 %1, ptr addrspace(1) %out
111 ; === CHANNEL ORDER ==========================================================
112 ; First channel order at dword index 9+5 -> KC0[3].Z
114 ; FUNC-LABEL: {{^}}channel_order_2d:
115 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
116 ; EG: MOV * [[VAL]], KC0[3].Z
117 define amdgpu_kernel void @channel_order_2d (ptr addrspace(1) %in,
118 ptr addrspace(1) %out) {
120 %0 = call [2 x i32] @llvm.OpenCL.image.get.format.2d(
121 ptr addrspace(1) %in) #0
122 %1 = extractvalue [2 x i32] %0, 1
123 store i32 %1, ptr addrspace(1) %out
127 ; FUNC-LABEL: {{^}}channel_order_3d:
128 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
129 ; EG: MOV * [[VAL]], KC0[3].Z
130 define amdgpu_kernel void @channel_order_3d (ptr addrspace(1) %in,
131 ptr addrspace(1) %out) {
133 %0 = call [2 x i32] @llvm.OpenCL.image.get.format.3d(
134 ptr addrspace(1) %in) #0
135 %1 = extractvalue [2 x i32] %0, 1
136 store i32 %1, ptr addrspace(1) %out
141 ; === 2ND IMAGE ==============================================================
142 ; 9 implicit args + 2 explicit args + 5 implicit args for 1st image argument
143 ; = 16 dwords to 2nd image argument.
144 ; Height of the second image is at 16+2 -> KC0[4].Z
146 ; FUNC-LABEL: {{^}}image_arg_2nd:
147 ; EG: MEM_RAT_CACHELESS STORE_RAW [[VAL:T[0-9]+\.X]]
148 ; EG: MOV * [[VAL]], KC0[4].Z
149 define amdgpu_kernel void @image_arg_2nd (ptr addrspace(1) %in1,
151 ptr addrspace(1) %in2,
152 ptr addrspace(1) %out) {
154 %0 = call [3 x i32] @llvm.OpenCL.image.get.size.2d(
155 ptr addrspace(1) %in2) #0
156 %1 = extractvalue [3 x i32] %0, 1
157 store i32 %1, ptr addrspace(1) %out
161 %opencl.image2d_t = type opaque
162 %opencl.image3d_t = type opaque
164 declare [3 x i32] @llvm.OpenCL.image.get.size.2d(ptr addrspace(1)) #0
165 declare [3 x i32] @llvm.OpenCL.image.get.size.3d(ptr addrspace(1)) #0
166 declare [2 x i32] @llvm.OpenCL.image.get.format.2d(ptr addrspace(1)) #0
167 declare [2 x i32] @llvm.OpenCL.image.get.format.3d(ptr addrspace(1)) #0
169 attributes #0 = { readnone }
171 !opencl.kernels = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9}
172 !0 = !{ptr @width_2d,
173 !10, !20, !30, !40, !50}
174 !1 = !{ptr @width_3d,
175 !10, !21, !31, !41, !50}
176 !2 = !{ptr @height_2d,
177 !10, !20, !30, !40, !50}
178 !3 = !{ptr @height_3d,
179 !10, !21, !31, !41, !50}
180 !4 = !{ptr @depth_3d,
181 !10, !21, !31, !41, !50}
182 !5 = !{ptr @data_type_2d,
183 !10, !20, !30, !40, !50}
184 !6 = !{ptr @data_type_3d,
185 !10, !21, !31, !41, !50}
186 !7 = !{ptr @channel_order_2d,
187 !10, !20, !30, !40, !50}
188 !8 = !{ptr @channel_order_3d,
189 !10, !21, !31, !41, !50}
190 !9 = !{ptr @image_arg_2nd, !12, !22, !32, !42, !52}
192 !10 = !{!"kernel_arg_addr_space", i32 1, i32 1}
193 !20 = !{!"kernel_arg_access_qual", !"read_only", !"none"}
194 !21 = !{!"kernel_arg_access_qual", !"read_only", !"none"}
195 !30 = !{!"kernel_arg_type", !"image2d_t", !"int*"}
196 !31 = !{!"kernel_arg_type", !"image3d_t", !"int*"}
197 !40 = !{!"kernel_arg_base_type", !"image2d_t", !"int*"}
198 !41 = !{!"kernel_arg_base_type", !"image3d_t", !"int*"}
199 !50 = !{!"kernel_arg_type_qual", !"", !""}
201 !12 = !{!"kernel_arg_addr_space", i32 1, i32 0, i32 1, i32 1}
202 !22 = !{!"kernel_arg_access_qual", !"read_only", !"none", !"write_only", !"none"}
203 !32 = !{!"kernel_arg_type", !"image3d_t", !"sampler_t", !"image2d_t", !"int*"}
204 !42 = !{!"kernel_arg_base_type", !"image3d_t", !"sampler_t", !"image2d_t", !"int*"}
205 !52 = !{!"kernel_arg_type_qual", !"", !"", !"", !""}