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
|
#define Bfm
using NUnit.Framework;
namespace Ryujinx.Tests.Cpu
{
[Category("Bfm")]
public sealed class CpuTestBfm : CpuTest
{
#if Bfm
private const int RndCnt = 2;
[Test, Pairwise, Description("BFM <Xd>, <Xn>, #<immr>, #<imms>")]
public void Bfm_64bit([Values(0u, 31u)] uint rd,
[Values(1u, 31u)] uint rn,
[Random(RndCnt)] ulong xd,
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn,
[Values(0u, 31u, 32u, 63u)] uint immr,
[Values(0u, 31u, 32u, 63u)] uint imms)
{
uint opcode = 0xB3400000; // BFM X0, X0, #0, #0
opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
opcode |= ((immr & 63) << 16) | ((imms & 63) << 10);
ulong x31 = TestContext.CurrentContext.Random.NextULong();
SingleOpcode(opcode, x0: xd, x1: xn, x31: x31);
CompareAgainstUnicorn();
}
[Test, Pairwise, Description("BFM <Wd>, <Wn>, #<immr>, #<imms>")]
public void Bfm_32bit([Values(0u, 31u)] uint rd,
[Values(1u, 31u)] uint rn,
[Random(RndCnt)] uint wd,
[Values(0x00000000u, 0x7FFFFFFFu,
0x80000000u, 0xFFFFFFFFu)] uint wn,
[Values(0u, 15u, 16u, 31u)] uint immr,
[Values(0u, 15u, 16u, 31u)] uint imms)
{
uint opcode = 0x33000000; // BFM W0, W0, #0, #0
opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
opcode |= ((immr & 63) << 16) | ((imms & 63) << 10);
uint w31 = TestContext.CurrentContext.Random.NextUInt();
SingleOpcode(opcode, x0: wd, x1: wn, x31: w31);
CompareAgainstUnicorn();
}
[Test, Pairwise, Description("SBFM <Xd>, <Xn>, #<immr>, #<imms>")]
public void Sbfm_64bit([Values(0u, 31u)] uint rd,
[Values(1u, 31u)] uint rn,
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn,
[Values(0u, 31u, 32u, 63u)] uint immr,
[Values(0u, 31u, 32u, 63u)] uint imms)
{
uint opcode = 0x93400000; // SBFM X0, X0, #0, #0
opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
opcode |= ((immr & 63) << 16) | ((imms & 63) << 10);
ulong x31 = TestContext.CurrentContext.Random.NextULong();
SingleOpcode(opcode, x1: xn, x31: x31);
CompareAgainstUnicorn();
}
[Test, Pairwise, Description("SBFM <Wd>, <Wn>, #<immr>, #<imms>")]
public void Sbfm_32bit([Values(0u, 31u)] uint rd,
[Values(1u, 31u)] uint rn,
[Values(0x00000000u, 0x7FFFFFFFu,
0x80000000u, 0xFFFFFFFFu)] uint wn,
[Values(0u, 15u, 16u, 31u)] uint immr,
[Values(0u, 15u, 16u, 31u)] uint imms)
{
uint opcode = 0x13000000; // SBFM W0, W0, #0, #0
opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
opcode |= ((immr & 63) << 16) | ((imms & 63) << 10);
uint w31 = TestContext.CurrentContext.Random.NextUInt();
SingleOpcode(opcode, x1: wn, x31: w31);
CompareAgainstUnicorn();
}
[Test, Pairwise, Description("UBFM <Xd>, <Xn>, #<immr>, #<imms>")]
public void Ubfm_64bit([Values(0u, 31u)] uint rd,
[Values(1u, 31u)] uint rn,
[Values(0x0000000000000000ul, 0x7FFFFFFFFFFFFFFFul,
0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul)] ulong xn,
[Values(0u, 31u, 32u, 63u)] uint immr,
[Values(0u, 31u, 32u, 63u)] uint imms)
{
uint opcode = 0xD3400000; // UBFM X0, X0, #0, #0
opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
opcode |= ((immr & 63) << 16) | ((imms & 63) << 10);
ulong x31 = TestContext.CurrentContext.Random.NextULong();
SingleOpcode(opcode, x1: xn, x31: x31);
CompareAgainstUnicorn();
}
[Test, Pairwise, Description("UBFM <Wd>, <Wn>, #<immr>, #<imms>")]
public void Ubfm_32bit([Values(0u, 31u)] uint rd,
[Values(1u, 31u)] uint rn,
[Values(0x00000000u, 0x7FFFFFFFu,
0x80000000u, 0xFFFFFFFFu)] uint wn,
[Values(0u, 15u, 16u, 31u)] uint immr,
[Values(0u, 15u, 16u, 31u)] uint imms)
{
uint opcode = 0x53000000; // UBFM W0, W0, #0, #0
opcode |= ((rn & 31) << 5) | ((rd & 31) << 0);
opcode |= ((immr & 63) << 16) | ((imms & 63) << 10);
uint w31 = TestContext.CurrentContext.Random.NextUInt();
SingleOpcode(opcode, x1: wn, x31: w31);
CompareAgainstUnicorn();
}
#endif
}
}
|