CpuTestSimdReg32.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. #define SimdReg32
  2. using ARMeilleure.State;
  3. using NUnit.Framework;
  4. using System;
  5. using System.Collections.Generic;
  6. namespace Ryujinx.Tests.Cpu
  7. {
  8. [Category("SimdReg32")]
  9. public sealed class CpuTestSimdReg32 : CpuTest32
  10. {
  11. #if SimdReg32
  12. #region "ValueSource (Opcodes)"
  13. private static uint[] _V_Add_Sub_Wide_I_()
  14. {
  15. return new uint[]
  16. {
  17. 0xf2800100u, // VADDW.S8 Q0, Q0, D0
  18. 0xf2800300u // VSUBW.S8 Q0, Q0, D0
  19. };
  20. }
  21. private static uint[] _Vfma_Vfms_Vfnma_Vfnms_S_F32_()
  22. {
  23. return new uint[]
  24. {
  25. 0xEEA00A00u, // VFMA. F32 S0, S0, S0
  26. 0xEEA00A40u, // VFMS. F32 S0, S0, S0
  27. 0xEE900A40u, // VFNMA.F32 S0, S0, S0
  28. 0xEE900A00u // VFNMS.F32 S0, S0, S0
  29. };
  30. }
  31. private static uint[] _Vfma_Vfms_Vfnma_Vfnms_S_F64_()
  32. {
  33. return new uint[]
  34. {
  35. 0xEEA00B00u, // VFMA. F64 D0, D0, D0
  36. 0xEEA00B40u, // VFMS. F64 D0, D0, D0
  37. 0xEE900B40u, // VFNMA.F64 D0, D0, D0
  38. 0xEE900B00u // VFNMS.F64 D0, D0, D0
  39. };
  40. }
  41. private static uint[] _Vfma_Vfms_V_F32_()
  42. {
  43. return new uint[]
  44. {
  45. 0xF2000C10u, // VFMA.F32 D0, D0, D0
  46. 0xF2200C10u // VFMS.F32 D0, D0, D0
  47. };
  48. }
  49. private static uint[] _Vmla_Vmls_Vnmla_Vnmls_S_F32_()
  50. {
  51. return new uint[]
  52. {
  53. 0xEE000A00u, // VMLA. F32 S0, S0, S0
  54. 0xEE000A40u, // VMLS. F32 S0, S0, S0
  55. 0xEE100A40u, // VNMLA.F32 S0, S0, S0
  56. 0xEE100A00u // VNMLS.F32 S0, S0, S0
  57. };
  58. }
  59. private static uint[] _Vmla_Vmls_Vnmla_Vnmls_S_F64_()
  60. {
  61. return new uint[]
  62. {
  63. 0xEE000B00u, // VMLA. F64 D0, D0, D0
  64. 0xEE000B40u, // VMLS. F64 D0, D0, D0
  65. 0xEE100B40u, // VNMLA.F64 D0, D0, D0
  66. 0xEE100B00u // VNMLS.F64 D0, D0, D0
  67. };
  68. }
  69. private static uint[] _Vp_Add_Max_Min_F_()
  70. {
  71. return new uint[]
  72. {
  73. 0xf3000d00u, // VPADD.F32 D0, D0, D0
  74. 0xf3000f00u, // VPMAX.F32 D0, D0, D0
  75. 0xf3200f00u // VPMIN.F32 D0, D0, D0
  76. };
  77. }
  78. // VPADD does not have an unsigned flag, so we check the opcode before setting it.
  79. private static uint VpaddI8 = 0xf2000b10u; // VPADD.I8 D0, D0, D0
  80. private static uint[] _Vp_Add_Max_Min_I_()
  81. {
  82. return new uint[]
  83. {
  84. VpaddI8,
  85. 0xf2000a00u, // VPMAX.S8 D0, D0, D0
  86. 0xf2000a10u // VPMIN.S8 D0, D0, D0
  87. };
  88. }
  89. #endregion
  90. #region "ValueSource (Types)"
  91. private static ulong[] _8B1D_()
  92. {
  93. return new ulong[] { 0x0000000000000000ul, 0x7F7F7F7F7F7F7F7Ful,
  94. 0x8080808080808080ul, 0x7FFFFFFFFFFFFFFFul,
  95. 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul };
  96. }
  97. private static ulong[] _8B4H2S1D_()
  98. {
  99. return new ulong[] { 0x0000000000000000ul, 0x7F7F7F7F7F7F7F7Ful,
  100. 0x8080808080808080ul, 0x7FFF7FFF7FFF7FFFul,
  101. 0x8000800080008000ul, 0x7FFFFFFF7FFFFFFFul,
  102. 0x8000000080000000ul, 0x7FFFFFFFFFFFFFFFul,
  103. 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul };
  104. }
  105. private static IEnumerable<ulong> _1S_F_()
  106. {
  107. yield return 0x00000000FF7FFFFFul; // -Max Normal (float.MinValue)
  108. yield return 0x0000000080800000ul; // -Min Normal
  109. yield return 0x00000000807FFFFFul; // -Max Subnormal
  110. yield return 0x0000000080000001ul; // -Min Subnormal (-float.Epsilon)
  111. yield return 0x000000007F7FFFFFul; // +Max Normal (float.MaxValue)
  112. yield return 0x0000000000800000ul; // +Min Normal
  113. yield return 0x00000000007FFFFFul; // +Max Subnormal
  114. yield return 0x0000000000000001ul; // +Min Subnormal (float.Epsilon)
  115. if (!NoZeros)
  116. {
  117. yield return 0x0000000080000000ul; // -Zero
  118. yield return 0x0000000000000000ul; // +Zero
  119. }
  120. if (!NoInfs)
  121. {
  122. yield return 0x00000000FF800000ul; // -Infinity
  123. yield return 0x000000007F800000ul; // +Infinity
  124. }
  125. if (!NoNaNs)
  126. {
  127. yield return 0x00000000FFC00000ul; // -QNaN (all zeros payload) (float.NaN)
  128. yield return 0x00000000FFBFFFFFul; // -SNaN (all ones payload)
  129. yield return 0x000000007FC00000ul; // +QNaN (all zeros payload) (-float.NaN) (DefaultNaN)
  130. yield return 0x000000007FBFFFFFul; // +SNaN (all ones payload)
  131. }
  132. for (int cnt = 1; cnt <= RndCnt; cnt++)
  133. {
  134. ulong grbg = TestContext.CurrentContext.Random.NextUInt();
  135. ulong rnd1 = GenNormalS();
  136. ulong rnd2 = GenSubnormalS();
  137. yield return (grbg << 32) | rnd1;
  138. yield return (grbg << 32) | rnd2;
  139. }
  140. }
  141. private static IEnumerable<ulong> _2S_F_()
  142. {
  143. yield return 0xFF7FFFFFFF7FFFFFul; // -Max Normal (float.MinValue)
  144. yield return 0x8080000080800000ul; // -Min Normal
  145. yield return 0x807FFFFF807FFFFFul; // -Max Subnormal
  146. yield return 0x8000000180000001ul; // -Min Subnormal (-float.Epsilon)
  147. yield return 0x7F7FFFFF7F7FFFFFul; // +Max Normal (float.MaxValue)
  148. yield return 0x0080000000800000ul; // +Min Normal
  149. yield return 0x007FFFFF007FFFFFul; // +Max Subnormal
  150. yield return 0x0000000100000001ul; // +Min Subnormal (float.Epsilon)
  151. if (!NoZeros)
  152. {
  153. yield return 0x8000000080000000ul; // -Zero
  154. yield return 0x0000000000000000ul; // +Zero
  155. }
  156. if (!NoInfs)
  157. {
  158. yield return 0xFF800000FF800000ul; // -Infinity
  159. yield return 0x7F8000007F800000ul; // +Infinity
  160. }
  161. if (!NoNaNs)
  162. {
  163. yield return 0xFFC00000FFC00000ul; // -QNaN (all zeros payload) (float.NaN)
  164. yield return 0xFFBFFFFFFFBFFFFFul; // -SNaN (all ones payload)
  165. yield return 0x7FC000007FC00000ul; // +QNaN (all zeros payload) (-float.NaN) (DefaultNaN)
  166. yield return 0x7FBFFFFF7FBFFFFFul; // +SNaN (all ones payload)
  167. }
  168. for (int cnt = 1; cnt <= RndCnt; cnt++)
  169. {
  170. ulong rnd1 = GenNormalS();
  171. ulong rnd2 = GenSubnormalS();
  172. yield return (rnd1 << 32) | rnd1;
  173. yield return (rnd2 << 32) | rnd2;
  174. }
  175. }
  176. private static IEnumerable<ulong> _1D_F_()
  177. {
  178. yield return 0xFFEFFFFFFFFFFFFFul; // -Max Normal (double.MinValue)
  179. yield return 0x8010000000000000ul; // -Min Normal
  180. yield return 0x800FFFFFFFFFFFFFul; // -Max Subnormal
  181. yield return 0x8000000000000001ul; // -Min Subnormal (-double.Epsilon)
  182. yield return 0x7FEFFFFFFFFFFFFFul; // +Max Normal (double.MaxValue)
  183. yield return 0x0010000000000000ul; // +Min Normal
  184. yield return 0x000FFFFFFFFFFFFFul; // +Max Subnormal
  185. yield return 0x0000000000000001ul; // +Min Subnormal (double.Epsilon)
  186. if (!NoZeros)
  187. {
  188. yield return 0x8000000000000000ul; // -Zero
  189. yield return 0x0000000000000000ul; // +Zero
  190. }
  191. if (!NoInfs)
  192. {
  193. yield return 0xFFF0000000000000ul; // -Infinity
  194. yield return 0x7FF0000000000000ul; // +Infinity
  195. }
  196. if (!NoNaNs)
  197. {
  198. yield return 0xFFF8000000000000ul; // -QNaN (all zeros payload) (double.NaN)
  199. yield return 0xFFF7FFFFFFFFFFFFul; // -SNaN (all ones payload)
  200. yield return 0x7FF8000000000000ul; // +QNaN (all zeros payload) (-double.NaN) (DefaultNaN)
  201. yield return 0x7FF7FFFFFFFFFFFFul; // +SNaN (all ones payload)
  202. }
  203. for (int cnt = 1; cnt <= RndCnt; cnt++)
  204. {
  205. ulong rnd1 = GenNormalD();
  206. ulong rnd2 = GenSubnormalD();
  207. yield return rnd1;
  208. yield return rnd2;
  209. }
  210. }
  211. #endregion
  212. private const int RndCnt = 2;
  213. private static readonly bool NoZeros = false;
  214. private static readonly bool NoInfs = false;
  215. private static readonly bool NoNaNs = false;
  216. [Explicit]
  217. [Test, Pairwise, Description("VADD.f32 V0, V0, V0")]
  218. public void Vadd_f32([Values(0u)] uint rd,
  219. [Values(0u, 1u)] uint rn,
  220. [Values(0u, 2u)] uint rm,
  221. [ValueSource("_2S_F_")] ulong z0,
  222. [ValueSource("_2S_F_")] ulong z1,
  223. [ValueSource("_2S_F_")] ulong a0,
  224. [ValueSource("_2S_F_")] ulong a1,
  225. [ValueSource("_2S_F_")] ulong b0,
  226. [ValueSource("_2S_F_")] ulong b1,
  227. [Values] bool q)
  228. {
  229. uint opcode = 0xf2000d00u; // VADD.F32 D0, D0, D0
  230. if (q)
  231. {
  232. opcode |= 1 << 6;
  233. rm <<= 1;
  234. rn <<= 1;
  235. rd <<= 1;
  236. }
  237. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  238. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  239. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  240. V128 v0 = MakeVectorE0E1(z0, z1);
  241. V128 v1 = MakeVectorE0E1(a0, a1);
  242. V128 v2 = MakeVectorE0E1(b0, b1);
  243. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  244. CompareAgainstUnicorn();
  245. }
  246. [Test, Pairwise]
  247. public void V_Add_Sub_Wide_I([ValueSource("_V_Add_Sub_Wide_I_")] uint opcode,
  248. [Range(0u, 5u)] uint rd,
  249. [Range(0u, 5u)] uint rn,
  250. [Range(0u, 5u)] uint rm,
  251. [ValueSource("_8B4H2S1D_")] [Random(RndCnt)] ulong z,
  252. [ValueSource("_8B4H2S1D_")] [Random(RndCnt)] ulong a,
  253. [ValueSource("_8B4H2S1D_")] [Random(RndCnt)] ulong b,
  254. [Values(0u, 1u, 2u)] uint size, // <SU8, SU16, SU32>
  255. [Values] bool u) // <S, U>
  256. {
  257. if (u)
  258. {
  259. opcode |= 1 << 24;
  260. }
  261. rd >>= 1; rd <<= 1;
  262. rn >>= 1; rn <<= 1;
  263. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  264. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  265. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  266. opcode |= (size & 0x3) << 20;
  267. V128 v0 = MakeVectorE0E1(z, ~z);
  268. V128 v1 = MakeVectorE0E1(a, ~a);
  269. V128 v2 = MakeVectorE0E1(b, ~b);
  270. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  271. CompareAgainstUnicorn();
  272. }
  273. [Test, Pairwise, Description("VCMP.f<size> Vd, Vm")]
  274. public void Vcmp([Values(2u, 3u)] uint size,
  275. [ValueSource("_1S_F_")] ulong a,
  276. [ValueSource("_1S_F_")] ulong b,
  277. [Values] bool e)
  278. {
  279. uint opcode = 0xeeb40840u;
  280. uint rm = 1;
  281. uint rd = 2;
  282. if (size == 3)
  283. {
  284. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  285. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  286. }
  287. else
  288. {
  289. opcode |= ((rm & 0x1e) >> 1) | ((rm & 0x1) << 5);
  290. opcode |= ((rd & 0x1e) << 11) | ((rd & 0x1) << 22);
  291. }
  292. opcode |= ((size & 3) << 8);
  293. if (e)
  294. {
  295. opcode |= 1 << 7;
  296. }
  297. V128 v1 = MakeVectorE0(a);
  298. V128 v2 = MakeVectorE0(b);
  299. int fpscr = (int)(TestContext.CurrentContext.Random.NextUInt(0xf) << 28);
  300. SingleOpcode(opcode, v1: v1, v2: v2, fpscr: fpscr);
  301. CompareAgainstUnicorn(fpsrMask: Fpsr.Nzcv);
  302. }
  303. [Test, Pairwise] [Explicit] // Fused.
  304. public void Vfma_Vfms_Vfnma_Vfnms_S_F32([ValueSource(nameof(_Vfma_Vfms_Vfnma_Vfnms_S_F32_))] uint opcode,
  305. [Values(0u, 1u, 2u, 3u)] uint rd,
  306. [Values(0u, 1u, 2u, 3u)] uint rn,
  307. [Values(0u, 1u, 2u, 3u)] uint rm,
  308. [ValueSource(nameof(_1S_F_))] ulong s0,
  309. [ValueSource(nameof(_1S_F_))] ulong s1,
  310. [ValueSource(nameof(_1S_F_))] ulong s2,
  311. [ValueSource(nameof(_1S_F_))] ulong s3)
  312. {
  313. opcode |= (((rd & 0x1) << 22) | (rd & 0x1e) << 11);
  314. opcode |= (((rn & 0x1) << 7) | (rn & 0x1e) << 15);
  315. opcode |= (((rm & 0x1) << 5) | (rm & 0x1e) >> 1);
  316. V128 v0 = MakeVectorE0E1E2E3((uint)s0, (uint)s1, (uint)s2, (uint)s3);
  317. SingleOpcode(opcode, v0: v0);
  318. CompareAgainstUnicorn();
  319. }
  320. [Test, Pairwise] [Explicit] // Fused.
  321. public void Vfma_Vfms_Vfnma_Vfnms_S_F64([ValueSource(nameof(_Vfma_Vfms_Vfnma_Vfnms_S_F64_))] uint opcode,
  322. [Values(0u, 1u)] uint rd,
  323. [Values(0u, 1u)] uint rn,
  324. [Values(0u, 1u)] uint rm,
  325. [ValueSource(nameof(_1D_F_))] ulong d0,
  326. [ValueSource(nameof(_1D_F_))] ulong d1)
  327. {
  328. opcode |= (((rd & 0x10) << 18) | (rd & 0xf) << 12);
  329. opcode |= (((rn & 0x10) << 3) | (rn & 0xf) << 16);
  330. opcode |= (((rm & 0x10) << 1) | (rm & 0xf) << 0);
  331. V128 v0 = MakeVectorE0E1(d0, d1);
  332. SingleOpcode(opcode, v0: v0);
  333. CompareAgainstUnicorn();
  334. }
  335. [Test, Pairwise] [Explicit] // Fused.
  336. public void Vfma_Vfms_V_F32([ValueSource(nameof(_Vfma_Vfms_V_F32_))] uint opcode,
  337. [Values(0u, 1u, 2u, 3u)] uint rd,
  338. [Values(0u, 1u, 2u, 3u)] uint rn,
  339. [Values(0u, 1u, 2u, 3u)] uint rm,
  340. [ValueSource(nameof(_2S_F_))] ulong d0,
  341. [ValueSource(nameof(_2S_F_))] ulong d1,
  342. [ValueSource(nameof(_2S_F_))] ulong d2,
  343. [ValueSource(nameof(_2S_F_))] ulong d3,
  344. [Values] bool q)
  345. {
  346. if (q)
  347. {
  348. opcode |= 1 << 6;
  349. rd >>= 1; rd <<= 1;
  350. rn >>= 1; rn <<= 1;
  351. rm >>= 1; rm <<= 1;
  352. }
  353. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  354. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  355. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  356. V128 v0 = MakeVectorE0E1(d0, d1);
  357. V128 v1 = MakeVectorE0E1(d2, d3);
  358. SingleOpcode(opcode, v0: v0, v1: v1);
  359. CompareAgainstUnicorn();
  360. }
  361. [Test, Pairwise] [Explicit]
  362. public void Vmla_Vmls_Vnmla_Vnmls_S_F32([ValueSource(nameof(_Vmla_Vmls_Vnmla_Vnmls_S_F32_))] uint opcode,
  363. [Values(0u, 1u, 2u, 3u)] uint rd,
  364. [Values(0u, 1u, 2u, 3u)] uint rn,
  365. [Values(0u, 1u, 2u, 3u)] uint rm,
  366. [ValueSource(nameof(_1S_F_))] ulong s0,
  367. [ValueSource(nameof(_1S_F_))] ulong s1,
  368. [ValueSource(nameof(_1S_F_))] ulong s2,
  369. [ValueSource(nameof(_1S_F_))] ulong s3)
  370. {
  371. opcode |= (((rd & 0x1) << 22) | (rd & 0x1e) << 11);
  372. opcode |= (((rn & 0x1) << 7) | (rn & 0x1e) << 15);
  373. opcode |= (((rm & 0x1) << 5) | (rm & 0x1e) >> 1);
  374. V128 v0 = MakeVectorE0E1E2E3((uint)s0, (uint)s1, (uint)s2, (uint)s3);
  375. SingleOpcode(opcode, v0: v0);
  376. CompareAgainstUnicorn();
  377. }
  378. [Test, Pairwise] [Explicit]
  379. public void Vmla_Vmls_Vnmla_Vnmls_S_F64([ValueSource(nameof(_Vmla_Vmls_Vnmla_Vnmls_S_F64_))] uint opcode,
  380. [Values(0u, 1u)] uint rd,
  381. [Values(0u, 1u)] uint rn,
  382. [Values(0u, 1u)] uint rm,
  383. [ValueSource(nameof(_1D_F_))] ulong d0,
  384. [ValueSource(nameof(_1D_F_))] ulong d1)
  385. {
  386. opcode |= (((rd & 0x10) << 18) | (rd & 0xf) << 12);
  387. opcode |= (((rn & 0x10) << 3) | (rn & 0xf) << 16);
  388. opcode |= (((rm & 0x10) << 1) | (rm & 0xf) << 0);
  389. V128 v0 = MakeVectorE0E1(d0, d1);
  390. SingleOpcode(opcode, v0: v0);
  391. CompareAgainstUnicorn();
  392. }
  393. [Test, Pairwise, Description("VMLSL.<type><size> <Vd>, <Vn>, <Vm>")]
  394. public void Vmlsl_I([Values(0u)] uint rd,
  395. [Values(1u, 0u)] uint rn,
  396. [Values(2u, 0u)] uint rm,
  397. [Values(0u, 1u, 2u)] uint size,
  398. [Random(RndCnt)] ulong z,
  399. [Random(RndCnt)] ulong a,
  400. [Random(RndCnt)] ulong b,
  401. [Values] bool u)
  402. {
  403. uint opcode = 0xf2800a00u; // VMLSL.S8 Q0, D0, D0
  404. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  405. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  406. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  407. opcode |= size << 20;
  408. if (u)
  409. {
  410. opcode |= 1 << 24;
  411. }
  412. V128 v0 = MakeVectorE0E1(z, z);
  413. V128 v1 = MakeVectorE0E1(a, z);
  414. V128 v2 = MakeVectorE0E1(b, z);
  415. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  416. CompareAgainstUnicorn();
  417. }
  418. [Test, Pairwise, Description("VMULL.<size> <Vd>, <Vn>, <Vm>")]
  419. public void Vmull_I([Values(0u)] uint rd,
  420. [Values(1u, 0u)] uint rn,
  421. [Values(2u, 0u)] uint rm,
  422. [Values(0u, 1u, 2u)] uint size,
  423. [Random(RndCnt)] ulong z,
  424. [Random(RndCnt)] ulong a,
  425. [Random(RndCnt)] ulong b,
  426. [Values] bool op,
  427. [Values] bool u)
  428. {
  429. uint opcode = 0xf2800c00u; // VMULL.S8 Q0, D0, D0
  430. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  431. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  432. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  433. if (op)
  434. {
  435. opcode |= 1 << 9;
  436. size = 0;
  437. u = false;
  438. }
  439. opcode |= size << 20;
  440. if (u)
  441. {
  442. opcode |= 1 << 24;
  443. }
  444. V128 v0 = MakeVectorE0E1(z, z);
  445. V128 v1 = MakeVectorE0E1(a, z);
  446. V128 v2 = MakeVectorE0E1(b, z);
  447. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  448. CompareAgainstUnicorn();
  449. }
  450. [Test, Pairwise, Description("VMULL.<P8, P64> <Qd>, <Dn>, <Dm>")]
  451. public void Vmull_I_P8_P64([Values(0u, 1u)] uint rd,
  452. [Values(0u, 1u)] uint rn,
  453. [Values(0u, 1u)] uint rm,
  454. [ValueSource(nameof(_8B1D_))] [Random(RndCnt)] ulong d0,
  455. [ValueSource(nameof(_8B1D_))] [Random(RndCnt)] ulong d1,
  456. [Values(0u/*, 2u*/)] uint size) // <P8, P64>
  457. {
  458. /*if (size == 2u)
  459. {
  460. Assert.Ignore("Ryujinx.Tests.Unicorn.UnicornException : Invalid instruction (UC_ERR_INSN_INVALID)");
  461. }*/
  462. uint opcode = 0xf2800e00u; // VMULL.P8 Q0, D0, D0
  463. rd >>= 1; rd <<= 1;
  464. opcode |= (((rd & 0x10) << 18) | (rd & 0xf) << 12);
  465. opcode |= (((rn & 0x10) << 3) | (rn & 0xf) << 16);
  466. opcode |= (((rm & 0x10) << 1) | (rm & 0xf) << 0);
  467. opcode |= (size & 0x3) << 20;
  468. V128 v0 = MakeVectorE0E1(d0, d1);
  469. SingleOpcode(opcode, v0: v0);
  470. CompareAgainstUnicorn();
  471. }
  472. [Test, Pairwise, Description("VSHL.<size> {<Vd>}, <Vm>, <Vn>")]
  473. public void Vshl([Values(0u)] uint rd,
  474. [Values(1u, 0u)] uint rn,
  475. [Values(2u, 0u)] uint rm,
  476. [Values(0u, 1u, 2u, 3u)] uint size,
  477. [Random(RndCnt)] ulong z,
  478. [Random(RndCnt)] ulong a,
  479. [Random(RndCnt)] ulong b,
  480. [Values] bool q,
  481. [Values] bool u)
  482. {
  483. uint opcode = 0xf2000400u; // VSHL.S8 D0, D0, D0
  484. if (q)
  485. {
  486. opcode |= 1 << 6;
  487. rm <<= 1;
  488. rn <<= 1;
  489. rd <<= 1;
  490. }
  491. if (u)
  492. {
  493. opcode |= 1 << 24;
  494. }
  495. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  496. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  497. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  498. opcode |= size << 20;
  499. V128 v0 = MakeVectorE0E1(z, z);
  500. V128 v1 = MakeVectorE0E1(a, z);
  501. V128 v2 = MakeVectorE0E1(b, z);
  502. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  503. CompareAgainstUnicorn();
  504. }
  505. [Explicit]
  506. [Test, Pairwise]
  507. public void Vp_Add_Max_Min_F([ValueSource("_Vp_Add_Max_Min_F_")] uint opcode,
  508. [Values(0u)] uint rd,
  509. [Range(0u, 7u)] uint rn,
  510. [Range(0u, 7u)] uint rm,
  511. [ValueSource("_2S_F_")] ulong z0,
  512. [ValueSource("_2S_F_")] ulong z1,
  513. [ValueSource("_2S_F_")] ulong a0,
  514. [ValueSource("_2S_F_")] ulong a1,
  515. [ValueSource("_2S_F_")] ulong b0,
  516. [ValueSource("_2S_F_")] ulong b1)
  517. {
  518. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  519. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  520. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  521. var rnd = TestContext.CurrentContext.Random;
  522. V128 v0 = MakeVectorE0E1(z0, z1);
  523. V128 v1 = MakeVectorE0E1(a0, a1);
  524. V128 v2 = MakeVectorE0E1(b0, b1);
  525. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  526. CompareAgainstUnicorn();
  527. }
  528. [Test, Pairwise]
  529. public void Vp_Add_Max_Min_I([ValueSource("_Vp_Add_Max_Min_I_")] uint opcode,
  530. [Values(0u)] uint rd,
  531. [Range(0u, 5u)] uint rn,
  532. [Range(0u, 5u)] uint rm,
  533. [Values(0u, 1u, 2u)] uint size,
  534. [Random(RndCnt)] ulong z,
  535. [Random(RndCnt)] ulong a,
  536. [Random(RndCnt)] ulong b,
  537. [Values] bool u)
  538. {
  539. if (u && opcode != VpaddI8)
  540. {
  541. opcode |= 1 << 24;
  542. }
  543. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  544. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  545. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  546. opcode |= size << 20;
  547. V128 v0 = MakeVectorE0E1(z, z);
  548. V128 v1 = MakeVectorE0E1(a, z);
  549. V128 v2 = MakeVectorE0E1(b, z);
  550. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  551. CompareAgainstUnicorn();
  552. }
  553. #endif
  554. }
  555. }