aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Tests/Cpu/CpuTestSimdMov32.cs
blob: 85f77fff1bbc94111202ccb3bed029e08ebba143 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
#define SimdMov32

using ARMeilleure.State;
using NUnit.Framework;

namespace Ryujinx.Tests.Cpu
{
    [Category("SimdMov32")]
    public sealed class CpuTestSimdMov32 : CpuTest32
    {
#if SimdMov32
        private const int RndCntImm = 2;

        [Test, Pairwise, Description("VMOV.I<size> <Dd/Qd>, #<imm>")]
        public void Movi_V([Range(0u, 10u)] uint variant,
                           [Values(0u, 1u, 2u, 3u)] uint vd,
                           [Values(0x0u)] uint imm,
                           [Values] bool q)
        {
            uint[] variants =
            {
                // I32
                0b0000_0,
                0b0010_0,
                0b0100_0,
                0b0110_0,

                // I16
                0b1000_0,
                0b1010_0,

                // DT
                0b1100_0,
                0b1101_0,
                0b1110_0,
                0b1111_0,

                0b1110_1,
            };

            uint opcode = 0xf2800010u; // VMOV.I32 D0, #0

            uint cmodeOp = variants[variant];

            if (q)
            {
                vd <<= 1;
            }

            opcode |= ((cmodeOp & 1) << 5) | ((cmodeOp & 0x1e) << 7);
            opcode |= (q ? 1u : 0u) << 6;
            opcode |= (imm & 0xf) | ((imm & 0x70) << 12) | ((imm & 0x80) << 16);

            opcode |= (vd & 0x10) << 18;
            opcode |= (vd & 0xf) << 12;

            SingleOpcode(opcode);

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VMOV.F<size> <Sd>, #<imm>")]
        public void Movi_S([Range(2u, 3u)] uint size,
                           [Values(0u, 1u, 2u, 3u)] uint vd,
                           [Values(0x0u)] uint imm)
        {
            uint opcode = 0xeeb00800u;
            opcode |= (size & 3) << 8;
            opcode |= (imm & 0xf) | ((imm & 0xf0) << 12);

            if (size == 2)
            {
                opcode |= ((vd & 0x1) << 22);
                opcode |= ((vd & 0x1e) << 11);
            }
            else
            {
                opcode |= ((vd & 0x10) << 18);
                opcode |= ((vd & 0xf) << 12);
            }

            SingleOpcode(opcode);

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VMOV <Rd>, <Sd>")]
        public void Mov_GP([Values(0u, 1u, 2u, 3u)] uint vn,
                           [Values(0u, 1u, 2u, 3u)] uint rt,
                           [Random(RndCntImm)] uint valueRn,
                           [Random(RndCntImm)] ulong valueVn1,
                           [Random(RndCntImm)] ulong valueVn2,
                           [Values] bool op)
        {
            uint opcode = 0xee000a10u; // VMOV S0, R0
            opcode |= (vn & 1) << 7;
            opcode |= (vn & 0x1e) << 15;
            opcode |= (rt & 0xf) << 12;

            if (op)
            {
                opcode |= 1 << 20;
            }

            SingleOpcode(opcode, r0: valueRn, r1: valueRn, r2: valueRn, r3: valueRn, v0: new V128(valueVn1, valueVn2));

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VMOV.<size> <Rt>, <Dn[x]>")]
        public void Mov_GP_Elem([Range(0u, 7u)] uint vn,
                                [Values(0u, 1u, 2u, 3u)] uint rt,
                                [Range(0u, 2u)] uint size,
                                [Range(0u, 7u)] uint index,
                                [Random(1)] uint valueRn,
                                [Random(1)] ulong valueVn1,
                                [Random(1)] ulong valueVn2,
                                [Values] bool op,
                                [Values] bool u)
        {
            uint opcode = 0xee000b10u; // VMOV.32 D0[0], R0

            uint opEncode = 0b01000;
            switch (size)
            {
                case 0:
                    opEncode = (0b1000) | index & 7;
                    break;
                case 1:
                    opEncode = (0b0001) | ((index & 3) << 1);
                    break;
                case 2:
                    opEncode = (index & 1) << 2;
                    break;
            }

            opcode |= ((opEncode >> 2) << 21) | ((opEncode & 3) << 5);

            opcode |= (vn & 0x10) << 3;
            opcode |= (vn & 0xf) << 16;
            opcode |= (rt & 0xf) << 12;

            if (op)
            {
                opcode |= 1 << 20;
                if (u && size != 2)
                {
                    opcode |= 1 << 23;
                }
            }

            SingleOpcode(opcode, r0: valueRn, r1: valueRn, r2: valueRn, r3: valueRn, v0: new V128(valueVn1, valueVn2), v1: new V128(valueVn2, valueVn1));

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("(VMOV <Rt>, <Rt2>, <Dm>), (VMOV <Dm>, <Rt>, <Rt2>)")]
        public void Mov_GP_D([Values(0u, 1u, 2u, 3u)] uint vm,
                             [Values(0u, 1u, 2u, 3u)] uint rt,
                             [Values(0u, 1u, 2u, 3u)] uint rt2,
                             [Random(RndCntImm)] uint valueRt1,
                             [Random(RndCntImm)] uint valueRt2,
                             [Random(RndCntImm)] ulong valueVn1,
                             [Random(RndCntImm)] ulong valueVn2,
                             [Values] bool op)
        {
            uint opcode = 0xec400b10u; // VMOV D0, R0, R0
            opcode |= (vm & 0x10) << 1;
            opcode |= (vm & 0xf);
            opcode |= (rt & 0xf) << 12;
            opcode |= (rt2 & 0xf) << 16;

            if (op)
            {
                opcode |= 1 << 20;
            }

            SingleOpcode(opcode, r0: valueRt1, r1: valueRt2, r2: valueRt1, r3: valueRt2, v0: new V128(valueVn1, valueVn2));

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("(VMOV <Rt>, <Rt2>, <Sm>, <Sm1>), (VMOV <Sm>, <Sm1>, <Rt>, <Rt2>)")]
        public void Mov_GP_2([Range(0u, 7u)] uint vm,
                             [Values(0u, 1u, 2u, 3u)] uint rt,
                             [Values(0u, 1u, 2u, 3u)] uint rt2,
                             [Random(RndCntImm)] uint valueRt1,
                             [Random(RndCntImm)] uint valueRt2,
                             [Random(RndCntImm)] ulong valueVn1,
                             [Random(RndCntImm)] ulong valueVn2,
                             [Values] bool op)
        {
            uint opcode = 0xec400a10u; // VMOV S0, S1, R0, R0
            opcode |= (vm & 1) << 5;
            opcode |= (vm & 0x1e) >> 1;
            opcode |= (rt & 0xf) << 12;
            opcode |= (rt2 & 0xf) << 16;

            if (op)
            {
                opcode |= 1 << 20;
            }

            SingleOpcode(opcode, r0: valueRt1, r1: valueRt2, r2: valueRt1, r3: valueRt2, v0: new V128(valueVn1, valueVn2), v1: new V128(valueVn2, valueVn1));

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VMOVN.<size> <Dt>, <Qm>")]
        public void Movn_V([Range(0u, 1u, 2u)] uint size,
                           [Values(0u, 1u, 2u, 3u)] uint vd,
                           [Values(0u, 2u, 4u, 8u)] uint vm)
        {
            uint opcode = 0xf3b20200u; // VMOVN.I16 D0, Q0

            opcode |= (size & 0x3) << 18;
            opcode |= ((vm & 0x10) << 1);
            opcode |= ((vm & 0xf) << 0);

            opcode |= ((vd & 0x10) << 18);
            opcode |= ((vd & 0xf) << 12);

            V128 v0 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v1 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v2 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v3 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());

            SingleOpcode(opcode, v0: v0, v1: v1, v2: v2, v3: v3);

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VMOVL.<size> <Qd>, <Dm>")]
        public void Vmovl([Values(0u, 1u, 2u, 3u)] uint vm,
                          [Values(0u, 2u, 4u, 6u)] uint vd,
                          [Values(1u, 2u, 4u)] uint imm3H,
                          [Values] bool u)
        {
            // This is not VMOVL because imm3H = 0, but once
            // we shift in the imm3H value it turns into VMOVL.
            uint opcode = 0xf2800a10u; // VMOV.I16 D0, #0

            opcode |= (vm & 0x10) << 1;
            opcode |= (vm & 0xf);
            opcode |= (vd & 0x10) << 18;
            opcode |= (vd & 0xf) << 12;
            opcode |= (imm3H & 0x7) << 19;
            if (u)
            {
                opcode |= 1 << 24;
            }

            V128 v0 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v1 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v2 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v3 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());

            SingleOpcode(opcode, v0: v0, v1: v1, v2: v2, v3: v3);

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VMVN.<size> <Vt>, <Vm>")]
        public void Vmvn([Range(0u, 1u, 2u)] uint size,
                         [Values(0u, 1u, 2u, 3u)] uint vd,
                         [Values(0u, 2u, 4u, 8u)] uint vm,
                         [Values] bool q)
        {
            uint opcode = 0xf3b00580u; // VMVN D0, D0

            if (q)
            {
                opcode |= 1 << 6;
                vm <<= 1;
                vd <<= 1;
            }

            opcode |= (size & 0x3) << 18;
            opcode |= (vm & 0x10) << 1;
            opcode |= (vm & 0xf) << 0;

            opcode |= (vd & 0x10) << 18;
            opcode |= (vd & 0xf) << 12;

            V128 v0 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v1 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v2 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v3 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());

            SingleOpcode(opcode, v0: v0, v1: v1, v2: v2, v3: v3);

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VMVN.I<size> <Dd/Qd>, #<imm>")]
        public void Mvni_V([Range(0u, 7u)] uint variant,
                           [Values(0u, 1u, 2u, 3u)] uint vd,
                           [Values(0x0u)] uint imm,
                           [Values] bool q)
        {
            uint[] variants =
            {
                // I32
                0b0000,
                0b0010,
                0b0100,
                0b0110,

                // I16
                0b1000,
                0b1010,

                // I32
                0b1100,
                0b1101,
            };

            uint opcode = 0xf2800030u; // VMVN.I32 D0, #0

            uint cmodeOp = variants[variant];

            if (q)
            {
                vd <<= 1;
            }

            opcode |= (cmodeOp & 0xf) << 8;
            opcode |= (q ? 1u : 0u) << 6;
            opcode |= (imm & 0xf) | ((imm & 0x70) << 12) | ((imm & 0x80) << 16);

            opcode |= (vd & 0x10) << 18;
            opcode |= (vd & 0xf) << 12;

            SingleOpcode(opcode);

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VTRN.<size> <Vd>, <Vm>")]
        public void Vtrn([Values(0u, 1u, 2u, 3u)] uint vm,
                         [Values(0u, 1u, 2u, 3u)] uint vd,
                         [Values(0u, 1u, 2u)] uint size,
                         [Values] bool q)
        {
            uint opcode = 0xf3b20080u; // VTRN.8 D0, D0
            if (vm == vd)
            {
                return; // Undefined.
            }

            if (q)
            {
                opcode |= 1 << 6;
                vd <<= 1;
                vm <<= 1;
            }

            opcode |= (vm & 0x10) << 1;
            opcode |= (vm & 0xf);
            opcode |= (vd & 0x10) << 18;
            opcode |= (vd & 0xf) << 12;
            opcode |= (size & 0x3) << 18;

            V128 v0 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v1 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v2 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v3 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());

            SingleOpcode(opcode, v0: v0, v1: v1, v2: v2, v3: v3);

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VZIP.<size> <Vd>, <Vm>")]
        public void Vzip([Values(0u, 1u, 2u, 3u)] uint vm,
                         [Values(0u, 1u, 2u, 3u)] uint vd,
                         [Values(0u, 1u, 2u)] uint size,
                         [Values] bool q)
        {
            uint opcode = 0xf3b20180u; // VZIP.8 D0, D0
            if (vm == vd || (size == 2 && !q))
            {
                return; // Undefined.
            }

            if (q)
            {
                opcode |= 1 << 6;
                vd <<= 1;
                vm <<= 1;
            }

            opcode |= (vm & 0x10) << 1;
            opcode |= (vm & 0xf);
            opcode |= (vd & 0x10) << 18;
            opcode |= (vd & 0xf) << 12;
            opcode |= (size & 0x3) << 18;

            V128 v0 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v1 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v2 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v3 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());

            SingleOpcode(opcode, v0: v0, v1: v1, v2: v2, v3: v3);

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VUZP.<size> <Vd>, <Vm>")]
        public void Vuzp([Values(0u, 1u, 2u, 3u)] uint vm,
                         [Values(0u, 1u, 2u, 3u)] uint vd,
                         [Values(0u, 1u, 2u)] uint size,
                         [Values] bool q)
        {
            uint opcode = 0xf3b20100u; // VUZP.8 d0, d0
            if (vm == vd || (size == 2 && !q))
            {
                return; // Undefined.
            }

            if (q)
            {
                opcode |= 1 << 6;
                vd <<= 1;
                vm <<= 1;
            }

            opcode |= (vm & 0x10) << 1;
            opcode |= (vm & 0xf);
            opcode |= (vd & 0x10) << 18;
            opcode |= (vd & 0xf) << 12;
            opcode |= (size & 0x3) << 18;

            V128 v0 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v1 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v2 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v3 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());

            SingleOpcode(opcode, v0: v0, v1: v1, v2: v2, v3: v3);

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VTBL.8 <Dd>, {list}, <Dm>")]
        public void Vtbl([Range(0u, 6u)] uint vm, // Indices, include potentially invalid.
                         [Range(4u, 12u)] uint vn, // Selection.
                         [Values(0u, 1u)] uint vd, // Destinations.
                         [Range(0u, 3u)] uint length,
                         [Values] bool x)
        {
            uint opcode = 0xf3b00800u; // VTBL.8 D0, {D0}, D0
            if (vn + length > 31)
            {
                return; // Undefined.
            }

            if (x)
            {
                opcode |= 1 << 6;
            }
            opcode |= (vm & 0x10) << 1;
            opcode |= (vm & 0xf);
            opcode |= (vd & 0x10) << 18;
            opcode |= (vd & 0xf) << 12;

            opcode |= (vn & 0x10) << 3;
            opcode |= (vn & 0xf) << 16;
            opcode |= (length & 0x3) << 8;

            var rnd = TestContext.CurrentContext.Random;
            V128 v2 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v3 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v4 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v5 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());

            byte maxIndex = (byte)(length * 8 - 1);
            byte[] b0 = new byte[16];
            byte[] b1 = new byte[16];
            for (int i = 0; i < 16; i++)
            {
                b0[i] = rnd.NextByte(maxIndex);
                b1[i] = rnd.NextByte(maxIndex);
            }

            V128 v0 = new(b0);
            V128 v1 = new(b1);

            SingleOpcode(opcode, v0: v0, v1: v1, v2: v2, v3: v3, v4: v4, v5: v5);

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VEXT.8 {<Vd>,} <Vn>, <Vm>, #<imm>")]
        public void Vext([Values(0u, 1u, 2u, 3u)] uint vm,
                         [Values(0u, 1u, 2u, 3u)] uint vn,
                         [Values(0u, 1u, 2u, 3u)] uint vd,
                         [Values(0u, 15u)] uint imm4,
                         [Values] bool q)
        {
            uint opcode = 0xf2b00000; // VEXT.32 D0, D0, D0, #0

            if (q)
            {
                opcode |= 1 << 6;
                vd <<= 1;
                vm <<= 1;
                vn <<= 1;
            }
            else if (imm4 > 7)
            {
                return; // Undefined.
            }
            opcode |= (vm & 0x10) << 1;
            opcode |= (vm & 0xf);
            opcode |= (vd & 0x10) << 18;
            opcode |= (vd & 0xf) << 12;
            opcode |= (vn & 0x10) << 3;
            opcode |= (vn & 0xf) << 16;
            opcode |= (imm4 & 0xf) << 8;

            V128 v0 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v1 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v2 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v3 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());

            SingleOpcode(opcode, v0: v0, v1: v1, v2: v2, v3: v3);

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VDUP.<size> <Vd>, <Rt>")]
        public void Vdup_GP([Values(0u, 1u, 2u, 3u)] uint vd,
                            [Values(0u, 1u, 2u, 3u)] uint rt,
                            [Values(0u, 1u, 2u)] uint size,
                            [Random(RndCntImm)] uint valueRn,
                            [Random(RndCntImm)] ulong valueVn1,
                            [Random(RndCntImm)] ulong valueVn2,
                            [Values] bool q)
        {
            uint opcode = 0xee800b10; // VDUP.32 d0, r0

            if (q)
            {
                opcode |= 1 << 21;
                vd <<= 1;
            }

            opcode |= (vd & 0x10) << 3;
            opcode |= (vd & 0xf) << 16;
            opcode |= (rt & 0xf) << 12;

            opcode |= (size & 1) << 5; // E
            opcode |= (size & 2) << 21; // B

            V128 v1 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());

            SingleOpcode(opcode, r0: valueRn, r1: valueRn, r2: valueRn, r3: valueRn, v0: new V128(valueVn1, valueVn2), v1: v1);

            CompareAgainstUnicorn();
        }

        [Test, Pairwise, Description("VDUP.<size> <Vd>, <Dm[x]>")]
        public void Vdup_S([Values(0u, 1u, 2u, 3u)] uint vd,
                           [Values(0u, 1u, 2u, 3u)] uint vm,
                           [Values(0u, 1u, 2u)] uint size,
                           [Range(0u, 7u)] uint index,
                           [Random(RndCntImm)] ulong valueVn1,
                           [Random(RndCntImm)] ulong valueVn2,
                           [Values] bool q)
        {
            uint opcode = 0xf3b00c00;

            if (q)
            {
                opcode |= 1 << 6;
                vd <<= 1;
            }

            opcode |= (vd & 0x10) << 18;
            opcode |= (vd & 0xf) << 12;
            opcode |= (vm & 0x10) << 1;
            opcode |= (vm & 0xf);

            uint imm4 = 0;
            switch (size)
            {
                case 0:
                    imm4 |= 0b0100 | ((index & 1) << 3);
                    break;
                case 1:
                    imm4 |= 0b0010 | ((index & 3) << 2);
                    break;
                case 2:
                    imm4 |= 0b0001 | ((index & 7) << 1);
                    break;
            }

            opcode |= imm4 << 16;

            V128 v1 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v2 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());
            V128 v3 = new(TestContext.CurrentContext.Random.NextULong(), TestContext.CurrentContext.Random.NextULong());

            SingleOpcode(opcode, v0: new V128(valueVn1, valueVn2), v1: v1, v2: v2, v3: v3);

            CompareAgainstUnicorn();
        }
#endif
    }
}