1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright (C) 2021 Collabora, Ltd.
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 FROM,
20bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21bf215546Sopenharmony_ci * SOFTWARE.
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ci#include "va_compiler.h"
25bf215546Sopenharmony_ci#include "bi_test.h"
26bf215546Sopenharmony_ci#include "bi_builder.h"
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ci#include <gtest/gtest.h>
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_ci#define CASE(instr, expected) do { \
31bf215546Sopenharmony_ci   uint64_t _value = va_pack_instr(instr); \
32bf215546Sopenharmony_ci   if (_value != expected) { \
33bf215546Sopenharmony_ci      fprintf(stderr, "Got %" PRIx64 ", expected %" PRIx64 "\n", _value, (uint64_t) expected); \
34bf215546Sopenharmony_ci      bi_print_instr(instr, stderr); \
35bf215546Sopenharmony_ci      fprintf(stderr, "\n"); \
36bf215546Sopenharmony_ci      ADD_FAILURE(); \
37bf215546Sopenharmony_ci   } \
38bf215546Sopenharmony_ci} while(0)
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_ciclass ValhallPacking : public testing::Test {
41bf215546Sopenharmony_ciprotected:
42bf215546Sopenharmony_ci   ValhallPacking() {
43bf215546Sopenharmony_ci      mem_ctx = ralloc_context(NULL);
44bf215546Sopenharmony_ci      b = bit_builder(mem_ctx);
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_ci      zero = bi_fau((enum bir_fau) (BIR_FAU_IMMEDIATE | 0), false);
47bf215546Sopenharmony_ci      one = bi_fau((enum bir_fau) (BIR_FAU_IMMEDIATE | 8), false);
48bf215546Sopenharmony_ci      n4567 = bi_fau((enum bir_fau) (BIR_FAU_IMMEDIATE | 4), true);
49bf215546Sopenharmony_ci   }
50bf215546Sopenharmony_ci
51bf215546Sopenharmony_ci   ~ValhallPacking() {
52bf215546Sopenharmony_ci      ralloc_free(mem_ctx);
53bf215546Sopenharmony_ci   }
54bf215546Sopenharmony_ci
55bf215546Sopenharmony_ci   void *mem_ctx;
56bf215546Sopenharmony_ci   bi_builder *b;
57bf215546Sopenharmony_ci   bi_index zero, one, n4567;
58bf215546Sopenharmony_ci};
59bf215546Sopenharmony_ci
60bf215546Sopenharmony_ciTEST_F(ValhallPacking, Moves) {
61bf215546Sopenharmony_ci   CASE(bi_mov_i32_to(b, bi_register(1), bi_register(2)),
62bf215546Sopenharmony_ci         0x0091c10000000002ULL);
63bf215546Sopenharmony_ci   CASE(bi_mov_i32_to(b, bi_register(1), bi_fau((enum bir_fau) (BIR_FAU_UNIFORM | 5), false)),
64bf215546Sopenharmony_ci         0x0091c1000000008aULL);
65bf215546Sopenharmony_ci}
66bf215546Sopenharmony_ci
67bf215546Sopenharmony_ciTEST_F(ValhallPacking, Fadd) {
68bf215546Sopenharmony_ci   CASE(bi_fadd_f32_to(b, bi_register(0), bi_register(1), bi_register(2)),
69bf215546Sopenharmony_ci         0x00a4c00000000201ULL);
70bf215546Sopenharmony_ci   CASE(bi_fadd_f32_to(b, bi_register(0), bi_register(1), bi_abs(bi_register(2))),
71bf215546Sopenharmony_ci         0x00a4c02000000201ULL);
72bf215546Sopenharmony_ci   CASE(bi_fadd_f32_to(b, bi_register(0), bi_register(1), bi_neg(bi_register(2))),
73bf215546Sopenharmony_ci         0x00a4c01000000201ULL);
74bf215546Sopenharmony_ci
75bf215546Sopenharmony_ci   CASE(bi_fadd_v2f16_to(b, bi_register(0), bi_swz_16(bi_register(1), false, false),
76bf215546Sopenharmony_ci                         bi_swz_16(bi_register(0), true, true)),
77bf215546Sopenharmony_ci         0x00a5c0000c000001ULL);
78bf215546Sopenharmony_ci
79bf215546Sopenharmony_ci   CASE(bi_fadd_v2f16_to(b, bi_register(0), bi_register(1), bi_register(0)),
80bf215546Sopenharmony_ci         0x00a5c00028000001ULL);
81bf215546Sopenharmony_ci
82bf215546Sopenharmony_ci   CASE(bi_fadd_v2f16_to(b, bi_register(0), bi_register(1),
83bf215546Sopenharmony_ci                         bi_swz_16(bi_register(0), true, false)),
84bf215546Sopenharmony_ci         0x00a5c00024000001ULL);
85bf215546Sopenharmony_ci
86bf215546Sopenharmony_ci   CASE(bi_fadd_v2f16_to(b, bi_register(0), bi_discard(bi_abs(bi_register(0))),
87bf215546Sopenharmony_ci                         bi_neg(zero)),
88bf215546Sopenharmony_ci         0x00a5c0902800c040ULL);
89bf215546Sopenharmony_ci
90bf215546Sopenharmony_ci   CASE(bi_fadd_f32_to(b, bi_register(0), bi_register(1),
91bf215546Sopenharmony_ci                       zero),
92bf215546Sopenharmony_ci         0x00a4c0000000c001ULL);
93bf215546Sopenharmony_ci
94bf215546Sopenharmony_ci   CASE(bi_fadd_f32_to(b, bi_register(0), bi_register(1),
95bf215546Sopenharmony_ci                       bi_neg(zero)),
96bf215546Sopenharmony_ci         0x00a4c0100000c001ULL);
97bf215546Sopenharmony_ci
98bf215546Sopenharmony_ci   CASE(bi_fadd_f32_to(b, bi_register(0), bi_register(1),
99bf215546Sopenharmony_ci                       bi_half(bi_register(0), true)),
100bf215546Sopenharmony_ci         0x00a4c00008000001ULL);
101bf215546Sopenharmony_ci
102bf215546Sopenharmony_ci   CASE(bi_fadd_f32_to(b, bi_register(0), bi_register(1),
103bf215546Sopenharmony_ci                       bi_half(bi_register(0), false)),
104bf215546Sopenharmony_ci         0x00a4c00004000001ULL);
105bf215546Sopenharmony_ci}
106bf215546Sopenharmony_ci
107bf215546Sopenharmony_ciTEST_F(ValhallPacking, Clper) {
108bf215546Sopenharmony_ci   CASE(bi_clper_i32_to(b, bi_register(0), bi_register(0), bi_byte(n4567, 0),
109bf215546Sopenharmony_ci                        BI_INACTIVE_RESULT_F1, BI_LANE_OP_NONE, BI_SUBGROUP_SUBGROUP16),
110bf215546Sopenharmony_ci         0x00a0c030128fc900);
111bf215546Sopenharmony_ci}
112bf215546Sopenharmony_ci
113bf215546Sopenharmony_ciTEST_F(ValhallPacking, Clamps) {
114bf215546Sopenharmony_ci   bi_instr *I = bi_fadd_f32_to(b, bi_register(0), bi_register(1),
115bf215546Sopenharmony_ci                                bi_neg(bi_abs(bi_register(2))));
116bf215546Sopenharmony_ci   CASE(I, 0x00a4c03000000201ULL);
117bf215546Sopenharmony_ci
118bf215546Sopenharmony_ci   I->clamp = BI_CLAMP_CLAMP_M1_1;
119bf215546Sopenharmony_ci   CASE(I, 0x00a4c03200000201ULL);
120bf215546Sopenharmony_ci}
121bf215546Sopenharmony_ci
122bf215546Sopenharmony_ciTEST_F(ValhallPacking, Misc) {
123bf215546Sopenharmony_ci   CASE(bi_fma_f32_to(b, bi_register(1), bi_discard(bi_register(1)),
124bf215546Sopenharmony_ci                         bi_fau((enum bir_fau) (BIR_FAU_UNIFORM | 4), false),
125bf215546Sopenharmony_ci                         bi_neg(zero)),
126bf215546Sopenharmony_ci         0x00b2c10400c08841ULL);
127bf215546Sopenharmony_ci
128bf215546Sopenharmony_ci   CASE(bi_fround_f32_to(b, bi_register(2), bi_discard(bi_neg(bi_register(2))),
129bf215546Sopenharmony_ci                         BI_ROUND_RTN),
130bf215546Sopenharmony_ci         0x0090c240800d0042ULL);
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_ci   CASE(bi_fround_v2f16_to(b, bi_half(bi_register(0), false), bi_register(0),
133bf215546Sopenharmony_ci                         BI_ROUND_RTN),
134bf215546Sopenharmony_ci         0x00904000a00f0000ULL);
135bf215546Sopenharmony_ci
136bf215546Sopenharmony_ci   CASE(bi_fround_v2f16_to(b, bi_half(bi_register(0), false),
137bf215546Sopenharmony_ci                           bi_swz_16(bi_register(1), true, false), BI_ROUND_RTN),
138bf215546Sopenharmony_ci         0x00904000900f0001ULL);
139bf215546Sopenharmony_ci}
140bf215546Sopenharmony_ci
141bf215546Sopenharmony_ciTEST_F(ValhallPacking, FaddImm) {
142bf215546Sopenharmony_ci   CASE(bi_fadd_imm_f32_to(b, bi_register(2), bi_discard(bi_register(2)), 0x4847C6C0),
143bf215546Sopenharmony_ci         0x0114C24847C6C042ULL);
144bf215546Sopenharmony_ci
145bf215546Sopenharmony_ci   CASE(bi_fadd_imm_v2f16_to(b, bi_register(2), bi_discard(bi_register(2)), 0x70AC6784),
146bf215546Sopenharmony_ci         0x0115C270AC678442ULL);
147bf215546Sopenharmony_ci}
148bf215546Sopenharmony_ci
149bf215546Sopenharmony_ciTEST_F(ValhallPacking, Comparions) {
150bf215546Sopenharmony_ci   bi_instr *I =
151bf215546Sopenharmony_ci      bi_icmp_v2s16_to(b, bi_register(2),
152bf215546Sopenharmony_ci            bi_discard(bi_swz_16(bi_register(3), true, false)),
153bf215546Sopenharmony_ci            bi_discard(bi_swz_16(bi_register(2), true, false)),
154bf215546Sopenharmony_ci            BI_CMPF_GT,
155bf215546Sopenharmony_ci            BI_RESULT_TYPE_M1);
156bf215546Sopenharmony_ci   I->src[2] = zero; // TODO: model in the IR
157bf215546Sopenharmony_ci
158bf215546Sopenharmony_ci   CASE(I, 0x00f9c21184c04243);
159bf215546Sopenharmony_ci
160bf215546Sopenharmony_ci   I->op = BI_OPCODE_FCMP_V2F16;
161bf215546Sopenharmony_ci   I->src[1] = bi_discard(bi_swz_16(bi_register(2), false, false));
162bf215546Sopenharmony_ci   CASE(I, 0x00f5c20190c04243);
163bf215546Sopenharmony_ci}
164bf215546Sopenharmony_ci
165bf215546Sopenharmony_ciTEST_F(ValhallPacking, Conversions) {
166bf215546Sopenharmony_ci   CASE(bi_v2s16_to_v2f16_to(b, bi_register(2), bi_discard(bi_register(2))),
167bf215546Sopenharmony_ci         0x0090c22000070042);
168bf215546Sopenharmony_ci}
169bf215546Sopenharmony_ci
170bf215546Sopenharmony_ciTEST_F(ValhallPacking, BranchzI16) {
171bf215546Sopenharmony_ci   bi_instr *I = bi_branchz_i16(b, bi_half(bi_register(2), false), bi_null(), BI_CMPF_EQ);
172bf215546Sopenharmony_ci   I->branch_offset = 1;
173bf215546Sopenharmony_ci   CASE(I, 0x001fc03000000102);
174bf215546Sopenharmony_ci}
175bf215546Sopenharmony_ci
176bf215546Sopenharmony_ciTEST_F(ValhallPacking, BranchzI16Backwards) {
177bf215546Sopenharmony_ci   bi_instr *I = bi_branchz_i16(b, zero, bi_null(), BI_CMPF_EQ);
178bf215546Sopenharmony_ci   I->branch_offset = -8;
179bf215546Sopenharmony_ci   CASE(I, 0x001fc017fffff8c0);
180bf215546Sopenharmony_ci}
181bf215546Sopenharmony_ci
182bf215546Sopenharmony_ciTEST_F(ValhallPacking, Blend) {
183bf215546Sopenharmony_ci   CASE(bi_blend_to(b, bi_null(), bi_register(0), bi_register(60),
184bf215546Sopenharmony_ci                       bi_fau(BIR_FAU_BLEND_0, false),
185bf215546Sopenharmony_ci                       bi_fau(BIR_FAU_BLEND_0, true),
186bf215546Sopenharmony_ci                       bi_null(), BI_REGISTER_FORMAT_F16, 2, 0),
187bf215546Sopenharmony_ci        0x007f4004333c00f0);
188bf215546Sopenharmony_ci}
189bf215546Sopenharmony_ci
190bf215546Sopenharmony_ciTEST_F(ValhallPacking, Mux) {
191bf215546Sopenharmony_ci   CASE(bi_mux_i32_to(b, bi_register(0), bi_discard(bi_register(0)),
192bf215546Sopenharmony_ci                      bi_discard(bi_register(4)),
193bf215546Sopenharmony_ci                      bi_fau((enum bir_fau) (BIR_FAU_UNIFORM | 0), false), BI_MUX_BIT),
194bf215546Sopenharmony_ci        0x00b8c00300804440ull);
195bf215546Sopenharmony_ci}
196bf215546Sopenharmony_ci
197bf215546Sopenharmony_ciTEST_F(ValhallPacking, AtestFP16) {
198bf215546Sopenharmony_ci   bi_instr *I = bi_atest_to(b, bi_register(60), bi_register(60),
199bf215546Sopenharmony_ci         bi_half(bi_register(1), true));
200bf215546Sopenharmony_ci   I->src[2] = bi_fau(BIR_FAU_ATEST_PARAM, false);
201bf215546Sopenharmony_ci
202bf215546Sopenharmony_ci   CASE(I, 0x007dbc0208ea013c);
203bf215546Sopenharmony_ci}
204bf215546Sopenharmony_ci
205bf215546Sopenharmony_ciTEST_F(ValhallPacking, AtestFP32) {
206bf215546Sopenharmony_ci   bi_instr *I = bi_atest_to(b, bi_register(60), bi_register(60), one);
207bf215546Sopenharmony_ci   I->src[2] = bi_fau(BIR_FAU_ATEST_PARAM, false);
208bf215546Sopenharmony_ci   CASE(I, 0x007dbc0200ead03c);
209bf215546Sopenharmony_ci}
210bf215546Sopenharmony_ci
211bf215546Sopenharmony_ciTEST_F(ValhallPacking, Transcendentals) {
212bf215546Sopenharmony_ci   CASE(bi_frexpm_f32_to(b, bi_register(1), bi_register(0), false, true),
213bf215546Sopenharmony_ci        0x0099c10001000000);
214bf215546Sopenharmony_ci
215bf215546Sopenharmony_ci   CASE(bi_frexpe_f32_to(b, bi_register(0), bi_discard(bi_register(0)), false, true),
216bf215546Sopenharmony_ci        0x0099c00001020040);
217bf215546Sopenharmony_ci
218bf215546Sopenharmony_ci   CASE(bi_frsq_f32_to(b, bi_register(2), bi_register(1)),
219bf215546Sopenharmony_ci        0x009cc20000020001);
220bf215546Sopenharmony_ci
221bf215546Sopenharmony_ci   CASE(bi_fma_rscale_f32_to(b, bi_register(0), bi_discard(bi_register(1)), bi_discard(bi_register(2)), bi_neg(zero), bi_discard(bi_register(0)), BI_SPECIAL_LEFT),
222bf215546Sopenharmony_ci        0x0162c00440c04241);
223bf215546Sopenharmony_ci}
224bf215546Sopenharmony_ci
225bf215546Sopenharmony_ciTEST_F(ValhallPacking, Csel) {
226bf215546Sopenharmony_ci   CASE(bi_csel_u32_to(b, bi_register(1), bi_discard(bi_register(2)),
227bf215546Sopenharmony_ci                       bi_discard(bi_register(3)),
228bf215546Sopenharmony_ci                       bi_fau((enum bir_fau) (BIR_FAU_UNIFORM | 2), false),
229bf215546Sopenharmony_ci                       bi_fau((enum bir_fau) (BIR_FAU_UNIFORM | 2), true),
230bf215546Sopenharmony_ci                       BI_CMPF_EQ),
231bf215546Sopenharmony_ci        0x0150c10085844342);
232bf215546Sopenharmony_ci
233bf215546Sopenharmony_ci   CASE(bi_csel_u32_to(b, bi_register(1), bi_discard(bi_register(2)),
234bf215546Sopenharmony_ci                       bi_discard(bi_register(3)),
235bf215546Sopenharmony_ci                       bi_fau((enum bir_fau) (BIR_FAU_UNIFORM | 2), false),
236bf215546Sopenharmony_ci                       bi_fau((enum bir_fau) (BIR_FAU_UNIFORM | 2), true),
237bf215546Sopenharmony_ci                       BI_CMPF_LT),
238bf215546Sopenharmony_ci        0x0150c10485844342);
239bf215546Sopenharmony_ci
240bf215546Sopenharmony_ci   CASE(bi_csel_s32_to(b, bi_register(1), bi_discard(bi_register(2)),
241bf215546Sopenharmony_ci                       bi_discard(bi_register(3)),
242bf215546Sopenharmony_ci                       bi_fau((enum bir_fau) (BIR_FAU_UNIFORM | 2), false),
243bf215546Sopenharmony_ci                       bi_fau((enum bir_fau) (BIR_FAU_UNIFORM | 2), true),
244bf215546Sopenharmony_ci                       BI_CMPF_LT),
245bf215546Sopenharmony_ci        0x0158c10485844342);
246bf215546Sopenharmony_ci}
247bf215546Sopenharmony_ci
248bf215546Sopenharmony_ciTEST_F(ValhallPacking, LdAttrImm) {
249bf215546Sopenharmony_ci   bi_instr *I = bi_ld_attr_imm_to(b, bi_register(0),
250bf215546Sopenharmony_ci                                   bi_discard(bi_register(60)),
251bf215546Sopenharmony_ci                                   bi_discard(bi_register(61)),
252bf215546Sopenharmony_ci                                   BI_REGISTER_FORMAT_F16, BI_VECSIZE_V4, 1);
253bf215546Sopenharmony_ci   I->table = 1;
254bf215546Sopenharmony_ci
255bf215546Sopenharmony_ci   CASE(I, 0x0066800433117d7c);
256bf215546Sopenharmony_ci}
257bf215546Sopenharmony_ci
258bf215546Sopenharmony_ciTEST_F(ValhallPacking, LdVarBufImmF16) {
259bf215546Sopenharmony_ci   CASE(bi_ld_var_buf_imm_f16_to(b, bi_register(2), bi_register(61),
260bf215546Sopenharmony_ci                                 BI_REGISTER_FORMAT_F16, BI_SAMPLE_CENTER,
261bf215546Sopenharmony_ci                                 BI_SOURCE_FORMAT_F16,
262bf215546Sopenharmony_ci                                 BI_UPDATE_RETRIEVE, BI_VECSIZE_V4, 0),
263bf215546Sopenharmony_ci        0x005d82143300003d);
264bf215546Sopenharmony_ci
265bf215546Sopenharmony_ci   CASE(bi_ld_var_buf_imm_f16_to(b, bi_register(0), bi_register(61),
266bf215546Sopenharmony_ci                                 BI_REGISTER_FORMAT_F16, BI_SAMPLE_SAMPLE,
267bf215546Sopenharmony_ci                                 BI_SOURCE_FORMAT_F16,
268bf215546Sopenharmony_ci                                 BI_UPDATE_STORE, BI_VECSIZE_V4, 0),
269bf215546Sopenharmony_ci         0x005d80843300003d);
270bf215546Sopenharmony_ci
271bf215546Sopenharmony_ci   CASE(bi_ld_var_buf_imm_f16_to(b, bi_register(0), bi_register(61),
272bf215546Sopenharmony_ci                                 BI_REGISTER_FORMAT_F16, BI_SAMPLE_CENTROID,
273bf215546Sopenharmony_ci                                 BI_SOURCE_FORMAT_F16,
274bf215546Sopenharmony_ci                                 BI_UPDATE_STORE, BI_VECSIZE_V4, 8),
275bf215546Sopenharmony_ci         0x005d80443308003d);
276bf215546Sopenharmony_ci}
277bf215546Sopenharmony_ci
278bf215546Sopenharmony_ciTEST_F(ValhallPacking, LeaBufImm) {
279bf215546Sopenharmony_ci   CASE(bi_lea_buf_imm_to(b, bi_register(4), bi_discard(bi_register(59))),
280bf215546Sopenharmony_ci        0x005e840400000d7b);
281bf215546Sopenharmony_ci}
282bf215546Sopenharmony_ci
283bf215546Sopenharmony_ciTEST_F(ValhallPacking, StoreSegment) {
284bf215546Sopenharmony_ci   CASE(bi_store_i96(b, bi_register(0), bi_discard(bi_register(4)),
285bf215546Sopenharmony_ci                        bi_discard(bi_register(5)), BI_SEG_VARY, 0),
286bf215546Sopenharmony_ci        0x0061400632000044);
287bf215546Sopenharmony_ci}
288bf215546Sopenharmony_ci
289bf215546Sopenharmony_ciTEST_F(ValhallPacking, Convert16To32) {
290bf215546Sopenharmony_ci   CASE(bi_u16_to_u32_to(b, bi_register(2), bi_discard(bi_swz_16(bi_register(55), false, false))),
291bf215546Sopenharmony_ci         0x0090c20000140077);
292bf215546Sopenharmony_ci
293bf215546Sopenharmony_ci   CASE(bi_u16_to_u32_to(b, bi_register(2), bi_discard(bi_swz_16(bi_register(55), true, false))),
294bf215546Sopenharmony_ci         0x0090c20010140077);
295bf215546Sopenharmony_ci
296bf215546Sopenharmony_ci   CASE(bi_u16_to_f32_to(b, bi_register(2), bi_discard(bi_swz_16(bi_register(55), false, false))),
297bf215546Sopenharmony_ci         0x0090c20000150077);
298bf215546Sopenharmony_ci
299bf215546Sopenharmony_ci   CASE(bi_u16_to_f32_to(b, bi_register(2), bi_discard(bi_swz_16(bi_register(55), true, false))),
300bf215546Sopenharmony_ci         0x0090c20010150077);
301bf215546Sopenharmony_ci
302bf215546Sopenharmony_ci   CASE(bi_s16_to_s32_to(b, bi_register(2), bi_discard(bi_swz_16(bi_register(55), false, false))),
303bf215546Sopenharmony_ci         0x0090c20000040077);
304bf215546Sopenharmony_ci
305bf215546Sopenharmony_ci   CASE(bi_s16_to_s32_to(b, bi_register(2), bi_discard(bi_swz_16(bi_register(55), true, false))),
306bf215546Sopenharmony_ci         0x0090c20010040077);
307bf215546Sopenharmony_ci}
308bf215546Sopenharmony_ci
309bf215546Sopenharmony_ciTEST_F(ValhallPacking, Swizzle8) {
310bf215546Sopenharmony_ci   bi_instr *I = bi_icmp_v4u8_to(b, bi_register(1), bi_byte(bi_register(0), 0),
311bf215546Sopenharmony_ci                                 zero, BI_CMPF_NE, BI_RESULT_TYPE_I1);
312bf215546Sopenharmony_ci   I->src[2] = zero; // TODO: model in the IR
313bf215546Sopenharmony_ci
314bf215546Sopenharmony_ci   CASE(I, 0x00f2c14300c0c000);
315bf215546Sopenharmony_ci}
316bf215546Sopenharmony_ci
317bf215546Sopenharmony_ciTEST_F(ValhallPacking, FauPage1) {
318bf215546Sopenharmony_ci   CASE(bi_mov_i32_to(b, bi_register(1), bi_fau((enum bir_fau) (BIR_FAU_UNIFORM | 32), false)),
319bf215546Sopenharmony_ci         0x0291c10000000080ULL);
320bf215546Sopenharmony_ci}
321bf215546Sopenharmony_ci
322bf215546Sopenharmony_ciTEST_F(ValhallPacking, LdTileV3F16) {
323bf215546Sopenharmony_ci   CASE(bi_ld_tile_to(b, bi_register(4), bi_discard(bi_register(0)),
324bf215546Sopenharmony_ci                         bi_register(60), bi_register(3),
325bf215546Sopenharmony_ci                         BI_REGISTER_FORMAT_F16, BI_VECSIZE_V3),
326bf215546Sopenharmony_ci        0x0078840423033c40);
327bf215546Sopenharmony_ci}
328