1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2020 Valve Corporation
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21bf215546Sopenharmony_ci * IN THE SOFTWARE.
22bf215546Sopenharmony_ci *
23bf215546Sopenharmony_ci */
24bf215546Sopenharmony_ci#include "helpers.h"
25bf215546Sopenharmony_ci#include "sid.h"
26bf215546Sopenharmony_ci
27bf215546Sopenharmony_ciusing namespace aco;
28bf215546Sopenharmony_ci
29bf215546Sopenharmony_cistatic void create_mubuf(Temp desc=Temp(0, s8), unsigned vtx_binding=0)
30bf215546Sopenharmony_ci{
31bf215546Sopenharmony_ci   Operand desc_op(desc);
32bf215546Sopenharmony_ci   desc_op.setFixed(PhysReg(0));
33bf215546Sopenharmony_ci   bld.mubuf(aco_opcode::buffer_load_dword, Definition(PhysReg(256), v1), desc_op,
34bf215546Sopenharmony_ci             Operand(PhysReg(256), v1), Operand::zero(), 0, false)
35bf215546Sopenharmony_ci      .instr->mubuf()
36bf215546Sopenharmony_ci      .vtx_binding = vtx_binding;
37bf215546Sopenharmony_ci}
38bf215546Sopenharmony_ci
39bf215546Sopenharmony_cistatic void create_mubuf_store()
40bf215546Sopenharmony_ci{
41bf215546Sopenharmony_ci   bld.mubuf(aco_opcode::buffer_store_dword, Operand(PhysReg(0), s4), Operand(PhysReg(256), v1),
42bf215546Sopenharmony_ci             Operand(PhysReg(256), v1), Operand::zero(), 0, false);
43bf215546Sopenharmony_ci}
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_cistatic void create_mtbuf(Temp desc=Temp(0, s8), unsigned vtx_binding=0)
46bf215546Sopenharmony_ci{
47bf215546Sopenharmony_ci   Operand desc_op(desc);
48bf215546Sopenharmony_ci   desc_op.setFixed(PhysReg(0));
49bf215546Sopenharmony_ci   bld.mtbuf(aco_opcode::tbuffer_load_format_x, Definition(PhysReg(256), v1), desc_op,
50bf215546Sopenharmony_ci             Operand(PhysReg(256), v1), Operand::zero(), V_008F0C_BUF_DATA_FORMAT_32,
51bf215546Sopenharmony_ci             V_008F0C_BUF_NUM_FORMAT_FLOAT, 0, false)
52bf215546Sopenharmony_ci      .instr->mtbuf()
53bf215546Sopenharmony_ci      .vtx_binding = vtx_binding;
54bf215546Sopenharmony_ci}
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_cistatic void create_flat()
57bf215546Sopenharmony_ci{
58bf215546Sopenharmony_ci   bld.flat(aco_opcode::flat_load_dword, Definition(PhysReg(256), v1),
59bf215546Sopenharmony_ci             Operand(PhysReg(256), v2), Operand(s2));
60bf215546Sopenharmony_ci}
61bf215546Sopenharmony_ci
62bf215546Sopenharmony_cistatic void create_global()
63bf215546Sopenharmony_ci{
64bf215546Sopenharmony_ci   bld.global(aco_opcode::global_load_dword, Definition(PhysReg(256), v1),
65bf215546Sopenharmony_ci              Operand(PhysReg(256), v2), Operand(s2));
66bf215546Sopenharmony_ci}
67bf215546Sopenharmony_ci
68bf215546Sopenharmony_cistatic void create_mimg(bool nsa, Temp desc=Temp(0, s8))
69bf215546Sopenharmony_ci{
70bf215546Sopenharmony_ci   aco_ptr<MIMG_instruction> mimg{create_instruction<MIMG_instruction>(
71bf215546Sopenharmony_ci      aco_opcode::image_sample, Format::MIMG, 5, 1)};
72bf215546Sopenharmony_ci   mimg->definitions[0] = Definition(PhysReg(256), v1);
73bf215546Sopenharmony_ci   mimg->operands[0] = Operand(desc);
74bf215546Sopenharmony_ci   mimg->operands[0].setFixed(PhysReg(0));
75bf215546Sopenharmony_ci   mimg->operands[1] = Operand(PhysReg(0), s4);
76bf215546Sopenharmony_ci   mimg->operands[2] = Operand(v1);
77bf215546Sopenharmony_ci   for (unsigned i = 0; i < 2; i++)
78bf215546Sopenharmony_ci      mimg->operands[3 + i] = Operand(PhysReg(256 + (nsa ? i * 2 : i)), v1);
79bf215546Sopenharmony_ci   mimg->dmask = 0x1;
80bf215546Sopenharmony_ci   mimg->dim = ac_image_2d;
81bf215546Sopenharmony_ci
82bf215546Sopenharmony_ci   bld.insert(std::move(mimg));
83bf215546Sopenharmony_ci}
84bf215546Sopenharmony_ci
85bf215546Sopenharmony_cistatic void create_smem()
86bf215546Sopenharmony_ci{
87bf215546Sopenharmony_ci   bld.smem(aco_opcode::s_load_dword, Definition(PhysReg(0), s1), Operand(PhysReg(0), s2),
88bf215546Sopenharmony_ci            Operand::zero());
89bf215546Sopenharmony_ci}
90bf215546Sopenharmony_ci
91bf215546Sopenharmony_cistatic void create_smem_buffer(Temp desc=Temp(0, s4))
92bf215546Sopenharmony_ci{
93bf215546Sopenharmony_ci   Operand desc_op(desc);
94bf215546Sopenharmony_ci   desc_op.setFixed(PhysReg(0));
95bf215546Sopenharmony_ci   bld.smem(aco_opcode::s_buffer_load_dword, Definition(PhysReg(0), s1), desc_op, Operand::zero());
96bf215546Sopenharmony_ci}
97bf215546Sopenharmony_ci
98bf215546Sopenharmony_ciBEGIN_TEST(form_hard_clauses.type_restrictions)
99bf215546Sopenharmony_ci   if (!setup_cs(NULL, GFX10))
100bf215546Sopenharmony_ci      return;
101bf215546Sopenharmony_ci
102bf215546Sopenharmony_ci   //>> p_unit_test 0
103bf215546Sopenharmony_ci   //! s_clause imm:1
104bf215546Sopenharmony_ci   //; search_re('image_sample')
105bf215546Sopenharmony_ci   //; search_re('image_sample')
106bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::zero());
107bf215546Sopenharmony_ci   create_mimg(false);
108bf215546Sopenharmony_ci   create_mimg(false);
109bf215546Sopenharmony_ci
110bf215546Sopenharmony_ci   //>> p_unit_test 1
111bf215546Sopenharmony_ci   //! s_clause imm:1
112bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
113bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
114bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(1u));
115bf215546Sopenharmony_ci   create_mubuf();
116bf215546Sopenharmony_ci   create_mubuf();
117bf215546Sopenharmony_ci
118bf215546Sopenharmony_ci   //>> p_unit_test 2
119bf215546Sopenharmony_ci   //! s_clause imm:1
120bf215546Sopenharmony_ci   //; search_re('global_load_dword')
121bf215546Sopenharmony_ci   //; search_re('global_load_dword')
122bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(2u));
123bf215546Sopenharmony_ci   create_global();
124bf215546Sopenharmony_ci   create_global();
125bf215546Sopenharmony_ci
126bf215546Sopenharmony_ci   //>> p_unit_test 3
127bf215546Sopenharmony_ci   //! s_clause imm:1
128bf215546Sopenharmony_ci   //; search_re('flat_load_dword')
129bf215546Sopenharmony_ci   //; search_re('flat_load_dword')
130bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(3u));
131bf215546Sopenharmony_ci   create_flat();
132bf215546Sopenharmony_ci   create_flat();
133bf215546Sopenharmony_ci
134bf215546Sopenharmony_ci   //>> p_unit_test 4
135bf215546Sopenharmony_ci   //! s_clause imm:1
136bf215546Sopenharmony_ci   //; search_re('s_load_dword')
137bf215546Sopenharmony_ci   //; search_re('s_load_dword')
138bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(4u));
139bf215546Sopenharmony_ci   create_smem();
140bf215546Sopenharmony_ci   create_smem();
141bf215546Sopenharmony_ci
142bf215546Sopenharmony_ci   //>> p_unit_test 5
143bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
144bf215546Sopenharmony_ci   //; search_re('flat_load_dword')
145bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(5u));
146bf215546Sopenharmony_ci   create_mubuf();
147bf215546Sopenharmony_ci   create_flat();
148bf215546Sopenharmony_ci
149bf215546Sopenharmony_ci   //>> p_unit_test 6
150bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
151bf215546Sopenharmony_ci   //; search_re('s_load_dword')
152bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(6u));
153bf215546Sopenharmony_ci   create_mubuf();
154bf215546Sopenharmony_ci   create_smem();
155bf215546Sopenharmony_ci
156bf215546Sopenharmony_ci   //>> p_unit_test 7
157bf215546Sopenharmony_ci   //; search_re('flat_load_dword')
158bf215546Sopenharmony_ci   //; search_re('s_load_dword')
159bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(7u));
160bf215546Sopenharmony_ci   create_flat();
161bf215546Sopenharmony_ci   create_smem();
162bf215546Sopenharmony_ci
163bf215546Sopenharmony_ci   finish_form_hard_clause_test();
164bf215546Sopenharmony_ciEND_TEST
165bf215546Sopenharmony_ci
166bf215546Sopenharmony_ciBEGIN_TEST(form_hard_clauses.size)
167bf215546Sopenharmony_ci   if (!setup_cs(NULL, GFX10))
168bf215546Sopenharmony_ci      return;
169bf215546Sopenharmony_ci
170bf215546Sopenharmony_ci   //>> p_unit_test 0
171bf215546Sopenharmony_ci   //; search_re('s_load_dword')
172bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::zero());
173bf215546Sopenharmony_ci   create_smem();
174bf215546Sopenharmony_ci
175bf215546Sopenharmony_ci   //>> p_unit_test 1
176bf215546Sopenharmony_ci   //! s_clause imm:63
177bf215546Sopenharmony_ci   //; for i in range(64):
178bf215546Sopenharmony_ci   //;    search_re('s_load_dword')
179bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(1u));
180bf215546Sopenharmony_ci   for (unsigned i = 0; i < 64; i++)
181bf215546Sopenharmony_ci      create_smem();
182bf215546Sopenharmony_ci
183bf215546Sopenharmony_ci   //>> p_unit_test 2
184bf215546Sopenharmony_ci   //! s_clause imm:63
185bf215546Sopenharmony_ci   //; for i in range(65):
186bf215546Sopenharmony_ci   //;    search_re('s_load_dword')
187bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(2u));
188bf215546Sopenharmony_ci   for (unsigned i = 0; i < 65; i++)
189bf215546Sopenharmony_ci      create_smem();
190bf215546Sopenharmony_ci
191bf215546Sopenharmony_ci   //>> p_unit_test 3
192bf215546Sopenharmony_ci   //! s_clause imm:63
193bf215546Sopenharmony_ci   //; for i in range(64):
194bf215546Sopenharmony_ci   //;    search_re('s_load_dword')
195bf215546Sopenharmony_ci   //! s_clause imm:1
196bf215546Sopenharmony_ci   //; search_re('s_load_dword')
197bf215546Sopenharmony_ci   //; search_re('s_load_dword')
198bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(3u));
199bf215546Sopenharmony_ci   for (unsigned i = 0; i < 66; i++)
200bf215546Sopenharmony_ci      create_smem();
201bf215546Sopenharmony_ci
202bf215546Sopenharmony_ci   finish_form_hard_clause_test();
203bf215546Sopenharmony_ciEND_TEST
204bf215546Sopenharmony_ci
205bf215546Sopenharmony_ciBEGIN_TEST(form_hard_clauses.nsa)
206bf215546Sopenharmony_ci   for (unsigned i = GFX10; i <= GFX10_3; i++) {
207bf215546Sopenharmony_ci      if (!setup_cs(NULL, (amd_gfx_level)i))
208bf215546Sopenharmony_ci         continue;
209bf215546Sopenharmony_ci
210bf215546Sopenharmony_ci      //>> p_unit_test 0
211bf215546Sopenharmony_ci      //! s_clause imm:1
212bf215546Sopenharmony_ci      //; search_re('image_sample .* %0:v\[0\], %0:v\[1\]')
213bf215546Sopenharmony_ci      //; search_re('image_sample .* %0:v\[0\], %0:v\[1\]')
214bf215546Sopenharmony_ci      bld.pseudo(aco_opcode::p_unit_test, Operand::zero());
215bf215546Sopenharmony_ci      create_mimg(false);
216bf215546Sopenharmony_ci      create_mimg(false);
217bf215546Sopenharmony_ci
218bf215546Sopenharmony_ci      //>> p_unit_test 1
219bf215546Sopenharmony_ci      //~gfx10_3! s_clause imm:1
220bf215546Sopenharmony_ci      //; search_re('image_sample .* %0:v\[0\], %0:v\[1\]')
221bf215546Sopenharmony_ci      //; search_re('image_sample .* %0:v\[0\], %0:v\[2\]')
222bf215546Sopenharmony_ci      bld.pseudo(aco_opcode::p_unit_test, Operand::c32(1u));
223bf215546Sopenharmony_ci      create_mimg(false);
224bf215546Sopenharmony_ci      create_mimg(true);
225bf215546Sopenharmony_ci
226bf215546Sopenharmony_ci      //>> p_unit_test 2
227bf215546Sopenharmony_ci      //~gfx10_3! s_clause imm:1
228bf215546Sopenharmony_ci      //; search_re('image_sample .* %0:v\[0\], %0:v\[2\]')
229bf215546Sopenharmony_ci      //; search_re('image_sample .* %0:v\[0\], %0:v\[2\]')
230bf215546Sopenharmony_ci      bld.pseudo(aco_opcode::p_unit_test, Operand::c32(2u));
231bf215546Sopenharmony_ci      create_mimg(true);
232bf215546Sopenharmony_ci      create_mimg(true);
233bf215546Sopenharmony_ci
234bf215546Sopenharmony_ci      finish_form_hard_clause_test();
235bf215546Sopenharmony_ci   }
236bf215546Sopenharmony_ciEND_TEST
237bf215546Sopenharmony_ci
238bf215546Sopenharmony_ciBEGIN_TEST(form_hard_clauses.heuristic)
239bf215546Sopenharmony_ci   if (!setup_cs(NULL, GFX10))
240bf215546Sopenharmony_ci      return;
241bf215546Sopenharmony_ci
242bf215546Sopenharmony_ci   Temp img_desc0 = bld.tmp(s8);
243bf215546Sopenharmony_ci   Temp img_desc1 = bld.tmp(s8);
244bf215546Sopenharmony_ci   Temp buf_desc0 = bld.tmp(s4);
245bf215546Sopenharmony_ci   Temp buf_desc1 = bld.tmp(s4);
246bf215546Sopenharmony_ci
247bf215546Sopenharmony_ci   /* Don't form clause with different descriptors */
248bf215546Sopenharmony_ci   //>> p_unit_test 0
249bf215546Sopenharmony_ci   //! s_clause imm:1
250bf215546Sopenharmony_ci   //; search_re('image_sample')
251bf215546Sopenharmony_ci   //; search_re('image_sample')
252bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::zero());
253bf215546Sopenharmony_ci   create_mimg(false, img_desc0);
254bf215546Sopenharmony_ci   create_mimg(false, img_desc0);
255bf215546Sopenharmony_ci
256bf215546Sopenharmony_ci   //>> p_unit_test 1
257bf215546Sopenharmony_ci   //; search_re('image_sample')
258bf215546Sopenharmony_ci   //; search_re('image_sample')
259bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(1u));
260bf215546Sopenharmony_ci   create_mimg(false, img_desc0);
261bf215546Sopenharmony_ci   create_mimg(false, img_desc1);
262bf215546Sopenharmony_ci
263bf215546Sopenharmony_ci   //>> p_unit_test 2
264bf215546Sopenharmony_ci   //! s_clause imm:1
265bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
266bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
267bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(2u));
268bf215546Sopenharmony_ci   create_mubuf(buf_desc0);
269bf215546Sopenharmony_ci   create_mubuf(buf_desc0);
270bf215546Sopenharmony_ci
271bf215546Sopenharmony_ci   //>> p_unit_test 3
272bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
273bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
274bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(3u));
275bf215546Sopenharmony_ci   create_mubuf(buf_desc0);
276bf215546Sopenharmony_ci   create_mubuf(buf_desc1);
277bf215546Sopenharmony_ci
278bf215546Sopenharmony_ci   //>> p_unit_test 4
279bf215546Sopenharmony_ci   //! s_clause imm:1
280bf215546Sopenharmony_ci   //; search_re('s_buffer_load_dword')
281bf215546Sopenharmony_ci   //; search_re('s_buffer_load_dword')
282bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(4u));
283bf215546Sopenharmony_ci   create_smem_buffer(buf_desc0);
284bf215546Sopenharmony_ci   create_smem_buffer(buf_desc0);
285bf215546Sopenharmony_ci
286bf215546Sopenharmony_ci   //>> p_unit_test 5
287bf215546Sopenharmony_ci   //; search_re('s_buffer_load_dword')
288bf215546Sopenharmony_ci   //; search_re('s_buffer_load_dword')
289bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(5u));
290bf215546Sopenharmony_ci   create_smem_buffer(buf_desc0);
291bf215546Sopenharmony_ci   create_smem_buffer(buf_desc1);
292bf215546Sopenharmony_ci
293bf215546Sopenharmony_ci   //>> p_unit_test 6
294bf215546Sopenharmony_ci   //; search_re('s_buffer_load_dword')
295bf215546Sopenharmony_ci   //; search_re('s_load_dword')
296bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(6u));
297bf215546Sopenharmony_ci   create_smem_buffer(buf_desc0);
298bf215546Sopenharmony_ci   create_smem();
299bf215546Sopenharmony_ci
300bf215546Sopenharmony_ci   /* Only form clause between MUBUF and MTBUF if they load from the same binding. Ignore descriptor
301bf215546Sopenharmony_ci    * if they're te same binding.
302bf215546Sopenharmony_ci    */
303bf215546Sopenharmony_ci   //>> p_unit_test 7
304bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
305bf215546Sopenharmony_ci   //; search_re('tbuffer_load_format_x')
306bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(7u));
307bf215546Sopenharmony_ci   create_mubuf(buf_desc0);
308bf215546Sopenharmony_ci   create_mtbuf(buf_desc0);
309bf215546Sopenharmony_ci
310bf215546Sopenharmony_ci   //>> p_unit_test 8
311bf215546Sopenharmony_ci   //! s_clause imm:1
312bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
313bf215546Sopenharmony_ci   //; search_re('tbuffer_load_format_x')
314bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(8u));
315bf215546Sopenharmony_ci   create_mubuf(buf_desc0, 1);
316bf215546Sopenharmony_ci   create_mtbuf(buf_desc0, 1);
317bf215546Sopenharmony_ci
318bf215546Sopenharmony_ci   //>> p_unit_test 9
319bf215546Sopenharmony_ci   //! s_clause imm:1
320bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
321bf215546Sopenharmony_ci   //; search_re('tbuffer_load_format_x')
322bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(9u));
323bf215546Sopenharmony_ci   create_mubuf(buf_desc0, 1);
324bf215546Sopenharmony_ci   create_mtbuf(buf_desc1, 1);
325bf215546Sopenharmony_ci
326bf215546Sopenharmony_ci   finish_form_hard_clause_test();
327bf215546Sopenharmony_ciEND_TEST
328bf215546Sopenharmony_ci
329bf215546Sopenharmony_ciBEGIN_TEST(form_hard_clauses.stores)
330bf215546Sopenharmony_ci   if (!setup_cs(NULL, GFX10))
331bf215546Sopenharmony_ci      return;
332bf215546Sopenharmony_ci
333bf215546Sopenharmony_ci   //>> p_unit_test 0
334bf215546Sopenharmony_ci   //; search_re('buffer_store_dword')
335bf215546Sopenharmony_ci   //; search_re('buffer_store_dword')
336bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::zero());
337bf215546Sopenharmony_ci   create_mubuf_store();
338bf215546Sopenharmony_ci   create_mubuf_store();
339bf215546Sopenharmony_ci
340bf215546Sopenharmony_ci   //>> p_unit_test 1
341bf215546Sopenharmony_ci   //! s_clause imm:1
342bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
343bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
344bf215546Sopenharmony_ci   //; search_re('buffer_store_dword')
345bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(1u));
346bf215546Sopenharmony_ci   create_mubuf();
347bf215546Sopenharmony_ci   create_mubuf();
348bf215546Sopenharmony_ci   create_mubuf_store();
349bf215546Sopenharmony_ci
350bf215546Sopenharmony_ci   //>> p_unit_test 2
351bf215546Sopenharmony_ci   //; search_re('buffer_store_dword')
352bf215546Sopenharmony_ci   //! s_clause imm:1
353bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
354bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
355bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(2u));
356bf215546Sopenharmony_ci   create_mubuf_store();
357bf215546Sopenharmony_ci   create_mubuf();
358bf215546Sopenharmony_ci   create_mubuf();
359bf215546Sopenharmony_ci
360bf215546Sopenharmony_ci   /* Unclear whether this is the best behaviour */
361bf215546Sopenharmony_ci   //>> p_unit_test 3
362bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
363bf215546Sopenharmony_ci   //; search_re('buffer_store_dword')
364bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
365bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(3u));
366bf215546Sopenharmony_ci   create_mubuf();
367bf215546Sopenharmony_ci   create_mubuf_store();
368bf215546Sopenharmony_ci   create_mubuf();
369bf215546Sopenharmony_ci
370bf215546Sopenharmony_ci   /* Unimportant pass limitations */
371bf215546Sopenharmony_ci   //>> p_unit_test 4
372bf215546Sopenharmony_ci   //; search_re('buffer_store_dword')
373bf215546Sopenharmony_ci   //! s_clause imm:62
374bf215546Sopenharmony_ci   //; for i in range(63):
375bf215546Sopenharmony_ci   //;    search_re('buffer_load_dword')
376bf215546Sopenharmony_ci   //; search_re('buffer_load_dword')
377bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(4u));
378bf215546Sopenharmony_ci   create_mubuf_store();
379bf215546Sopenharmony_ci   for (unsigned i = 0; i < 64; i++)
380bf215546Sopenharmony_ci      create_mubuf();
381bf215546Sopenharmony_ci
382bf215546Sopenharmony_ci   //>> p_unit_test 5
383bf215546Sopenharmony_ci   //! s_clause imm:63
384bf215546Sopenharmony_ci   //; for i in range(64):
385bf215546Sopenharmony_ci   //;    search_re('buffer_load_dword')
386bf215546Sopenharmony_ci   //; search_re('buffer_store_dword')
387bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Operand::c32(5u));
388bf215546Sopenharmony_ci   for (unsigned i = 0; i < 64; i++)
389bf215546Sopenharmony_ci      create_mubuf();
390bf215546Sopenharmony_ci   create_mubuf_store();
391bf215546Sopenharmony_ci
392bf215546Sopenharmony_ci   finish_form_hard_clause_test();
393bf215546Sopenharmony_ciEND_TEST
394