CpuTestSimdReg32.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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[] _8B4H2S1D_()
  92. {
  93. return new ulong[] { 0x0000000000000000ul, 0x7F7F7F7F7F7F7F7Ful,
  94. 0x8080808080808080ul, 0x7FFF7FFF7FFF7FFFul,
  95. 0x8000800080008000ul, 0x7FFFFFFF7FFFFFFFul,
  96. 0x8000000080000000ul, 0x7FFFFFFFFFFFFFFFul,
  97. 0x8000000000000000ul, 0xFFFFFFFFFFFFFFFFul };
  98. }
  99. private static IEnumerable<ulong> _1S_F_()
  100. {
  101. yield return 0x00000000FF7FFFFFul; // -Max Normal (float.MinValue)
  102. yield return 0x0000000080800000ul; // -Min Normal
  103. yield return 0x00000000807FFFFFul; // -Max Subnormal
  104. yield return 0x0000000080000001ul; // -Min Subnormal (-float.Epsilon)
  105. yield return 0x000000007F7FFFFFul; // +Max Normal (float.MaxValue)
  106. yield return 0x0000000000800000ul; // +Min Normal
  107. yield return 0x00000000007FFFFFul; // +Max Subnormal
  108. yield return 0x0000000000000001ul; // +Min Subnormal (float.Epsilon)
  109. if (!NoZeros)
  110. {
  111. yield return 0x0000000080000000ul; // -Zero
  112. yield return 0x0000000000000000ul; // +Zero
  113. }
  114. if (!NoInfs)
  115. {
  116. yield return 0x00000000FF800000ul; // -Infinity
  117. yield return 0x000000007F800000ul; // +Infinity
  118. }
  119. if (!NoNaNs)
  120. {
  121. yield return 0x00000000FFC00000ul; // -QNaN (all zeros payload) (float.NaN)
  122. yield return 0x00000000FFBFFFFFul; // -SNaN (all ones payload)
  123. yield return 0x000000007FC00000ul; // +QNaN (all zeros payload) (-float.NaN) (DefaultNaN)
  124. yield return 0x000000007FBFFFFFul; // +SNaN (all ones payload)
  125. }
  126. for (int cnt = 1; cnt <= RndCnt; cnt++)
  127. {
  128. ulong grbg = TestContext.CurrentContext.Random.NextUInt();
  129. ulong rnd1 = GenNormalS();
  130. ulong rnd2 = GenSubnormalS();
  131. yield return (grbg << 32) | rnd1;
  132. yield return (grbg << 32) | rnd2;
  133. }
  134. }
  135. private static IEnumerable<ulong> _2S_F_()
  136. {
  137. yield return 0xFF7FFFFFFF7FFFFFul; // -Max Normal (float.MinValue)
  138. yield return 0x8080000080800000ul; // -Min Normal
  139. yield return 0x807FFFFF807FFFFFul; // -Max Subnormal
  140. yield return 0x8000000180000001ul; // -Min Subnormal (-float.Epsilon)
  141. yield return 0x7F7FFFFF7F7FFFFFul; // +Max Normal (float.MaxValue)
  142. yield return 0x0080000000800000ul; // +Min Normal
  143. yield return 0x007FFFFF007FFFFFul; // +Max Subnormal
  144. yield return 0x0000000100000001ul; // +Min Subnormal (float.Epsilon)
  145. if (!NoZeros)
  146. {
  147. yield return 0x8000000080000000ul; // -Zero
  148. yield return 0x0000000000000000ul; // +Zero
  149. }
  150. if (!NoInfs)
  151. {
  152. yield return 0xFF800000FF800000ul; // -Infinity
  153. yield return 0x7F8000007F800000ul; // +Infinity
  154. }
  155. if (!NoNaNs)
  156. {
  157. yield return 0xFFC00000FFC00000ul; // -QNaN (all zeros payload) (float.NaN)
  158. yield return 0xFFBFFFFFFFBFFFFFul; // -SNaN (all ones payload)
  159. yield return 0x7FC000007FC00000ul; // +QNaN (all zeros payload) (-float.NaN) (DefaultNaN)
  160. yield return 0x7FBFFFFF7FBFFFFFul; // +SNaN (all ones payload)
  161. }
  162. for (int cnt = 1; cnt <= RndCnt; cnt++)
  163. {
  164. ulong rnd1 = GenNormalS();
  165. ulong rnd2 = GenSubnormalS();
  166. yield return (rnd1 << 32) | rnd1;
  167. yield return (rnd2 << 32) | rnd2;
  168. }
  169. }
  170. private static IEnumerable<ulong> _1D_F_()
  171. {
  172. yield return 0xFFEFFFFFFFFFFFFFul; // -Max Normal (double.MinValue)
  173. yield return 0x8010000000000000ul; // -Min Normal
  174. yield return 0x800FFFFFFFFFFFFFul; // -Max Subnormal
  175. yield return 0x8000000000000001ul; // -Min Subnormal (-double.Epsilon)
  176. yield return 0x7FEFFFFFFFFFFFFFul; // +Max Normal (double.MaxValue)
  177. yield return 0x0010000000000000ul; // +Min Normal
  178. yield return 0x000FFFFFFFFFFFFFul; // +Max Subnormal
  179. yield return 0x0000000000000001ul; // +Min Subnormal (double.Epsilon)
  180. if (!NoZeros)
  181. {
  182. yield return 0x8000000000000000ul; // -Zero
  183. yield return 0x0000000000000000ul; // +Zero
  184. }
  185. if (!NoInfs)
  186. {
  187. yield return 0xFFF0000000000000ul; // -Infinity
  188. yield return 0x7FF0000000000000ul; // +Infinity
  189. }
  190. if (!NoNaNs)
  191. {
  192. yield return 0xFFF8000000000000ul; // -QNaN (all zeros payload) (double.NaN)
  193. yield return 0xFFF7FFFFFFFFFFFFul; // -SNaN (all ones payload)
  194. yield return 0x7FF8000000000000ul; // +QNaN (all zeros payload) (-double.NaN) (DefaultNaN)
  195. yield return 0x7FF7FFFFFFFFFFFFul; // +SNaN (all ones payload)
  196. }
  197. for (int cnt = 1; cnt <= RndCnt; cnt++)
  198. {
  199. ulong rnd1 = GenNormalD();
  200. ulong rnd2 = GenSubnormalD();
  201. yield return rnd1;
  202. yield return rnd2;
  203. }
  204. }
  205. #endregion
  206. private const int RndCnt = 2;
  207. private static readonly bool NoZeros = false;
  208. private static readonly bool NoInfs = false;
  209. private static readonly bool NoNaNs = false;
  210. [Explicit]
  211. [Test, Pairwise, Description("VADD.f32 V0, V0, V0")]
  212. public void Vadd_f32([Values(0u)] uint rd,
  213. [Values(0u, 1u)] uint rn,
  214. [Values(0u, 2u)] uint rm,
  215. [ValueSource("_2S_F_")] ulong z0,
  216. [ValueSource("_2S_F_")] ulong z1,
  217. [ValueSource("_2S_F_")] ulong a0,
  218. [ValueSource("_2S_F_")] ulong a1,
  219. [ValueSource("_2S_F_")] ulong b0,
  220. [ValueSource("_2S_F_")] ulong b1,
  221. [Values] bool q)
  222. {
  223. uint opcode = 0xf2000d00u; // VADD.F32 D0, D0, D0
  224. if (q)
  225. {
  226. opcode |= 1 << 6;
  227. rm <<= 1;
  228. rn <<= 1;
  229. rd <<= 1;
  230. }
  231. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  232. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  233. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  234. V128 v0 = MakeVectorE0E1(z0, z1);
  235. V128 v1 = MakeVectorE0E1(a0, a1);
  236. V128 v2 = MakeVectorE0E1(b0, b1);
  237. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  238. CompareAgainstUnicorn();
  239. }
  240. [Test, Pairwise]
  241. public void V_Add_Sub_Wide_I([ValueSource("_V_Add_Sub_Wide_I_")] uint opcode,
  242. [Range(0u, 5u)] uint rd,
  243. [Range(0u, 5u)] uint rn,
  244. [Range(0u, 5u)] uint rm,
  245. [ValueSource("_8B4H2S1D_")] [Random(RndCnt)] ulong z,
  246. [ValueSource("_8B4H2S1D_")] [Random(RndCnt)] ulong a,
  247. [ValueSource("_8B4H2S1D_")] [Random(RndCnt)] ulong b,
  248. [Values(0u, 1u, 2u)] uint size, // <SU8, SU16, SU32>
  249. [Values] bool u) // <S, U>
  250. {
  251. if (u)
  252. {
  253. opcode |= 1 << 24;
  254. }
  255. rd >>= 1; rd <<= 1;
  256. rn >>= 1; rn <<= 1;
  257. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  258. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  259. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  260. opcode |= (size & 0x3) << 20;
  261. V128 v0 = MakeVectorE0E1(z, ~z);
  262. V128 v1 = MakeVectorE0E1(a, ~a);
  263. V128 v2 = MakeVectorE0E1(b, ~b);
  264. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  265. CompareAgainstUnicorn();
  266. }
  267. [Test, Pairwise, Description("VCMP.f<size> Vd, Vm")]
  268. public void Vcmp([Values(2u, 3u)] uint size,
  269. [ValueSource("_1S_F_")] ulong a,
  270. [ValueSource("_1S_F_")] ulong b,
  271. [Values] bool e)
  272. {
  273. uint opcode = 0xeeb40840u;
  274. uint rm = 1;
  275. uint rd = 2;
  276. if (size == 3)
  277. {
  278. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  279. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  280. }
  281. else
  282. {
  283. opcode |= ((rm & 0x1e) >> 1) | ((rm & 0x1) << 5);
  284. opcode |= ((rd & 0x1e) << 11) | ((rd & 0x1) << 22);
  285. }
  286. opcode |= ((size & 3) << 8);
  287. if (e)
  288. {
  289. opcode |= 1 << 7;
  290. }
  291. V128 v1 = MakeVectorE0(a);
  292. V128 v2 = MakeVectorE0(b);
  293. int fpscr = (int)(TestContext.CurrentContext.Random.NextUInt(0xf) << 28);
  294. SingleOpcode(opcode, v1: v1, v2: v2, fpscr: fpscr);
  295. CompareAgainstUnicorn(fpsrMask: Fpsr.Nzcv);
  296. }
  297. [Test, Pairwise] [Explicit] // Fused.
  298. public void Vfma_Vfms_Vfnma_Vfnms_S_F32([ValueSource(nameof(_Vfma_Vfms_Vfnma_Vfnms_S_F32_))] uint opcode,
  299. [Values(0u, 1u, 2u, 3u)] uint rd,
  300. [Values(0u, 1u, 2u, 3u)] uint rn,
  301. [Values(0u, 1u, 2u, 3u)] uint rm,
  302. [ValueSource(nameof(_1S_F_))] ulong s0,
  303. [ValueSource(nameof(_1S_F_))] ulong s1,
  304. [ValueSource(nameof(_1S_F_))] ulong s2,
  305. [ValueSource(nameof(_1S_F_))] ulong s3)
  306. {
  307. opcode |= (((rd & 0x1) << 22) | (rd & 0x1e) << 11);
  308. opcode |= (((rn & 0x1) << 7) | (rn & 0x1e) << 15);
  309. opcode |= (((rm & 0x1) << 5) | (rm & 0x1e) >> 1);
  310. V128 v0 = MakeVectorE0E1E2E3((uint)s0, (uint)s1, (uint)s2, (uint)s3);
  311. SingleOpcode(opcode, v0: v0);
  312. CompareAgainstUnicorn();
  313. }
  314. [Test, Pairwise] [Explicit] // Fused.
  315. public void Vfma_Vfms_Vfnma_Vfnms_S_F64([ValueSource(nameof(_Vfma_Vfms_Vfnma_Vfnms_S_F64_))] uint opcode,
  316. [Values(0u, 1u)] uint rd,
  317. [Values(0u, 1u)] uint rn,
  318. [Values(0u, 1u)] uint rm,
  319. [ValueSource(nameof(_1D_F_))] ulong d0,
  320. [ValueSource(nameof(_1D_F_))] ulong d1)
  321. {
  322. opcode |= (((rd & 0x10) << 18) | (rd & 0xf) << 12);
  323. opcode |= (((rn & 0x10) << 3) | (rn & 0xf) << 16);
  324. opcode |= (((rm & 0x10) << 1) | (rm & 0xf) << 0);
  325. V128 v0 = MakeVectorE0E1(d0, d1);
  326. SingleOpcode(opcode, v0: v0);
  327. CompareAgainstUnicorn();
  328. }
  329. [Test, Pairwise] [Explicit] // Fused.
  330. public void Vfma_Vfms_V_F32([ValueSource(nameof(_Vfma_Vfms_V_F32_))] uint opcode,
  331. [Values(0u, 1u, 2u, 3u)] uint rd,
  332. [Values(0u, 1u, 2u, 3u)] uint rn,
  333. [Values(0u, 1u, 2u, 3u)] uint rm,
  334. [ValueSource(nameof(_2S_F_))] ulong d0,
  335. [ValueSource(nameof(_2S_F_))] ulong d1,
  336. [ValueSource(nameof(_2S_F_))] ulong d2,
  337. [ValueSource(nameof(_2S_F_))] ulong d3,
  338. [Values] bool q)
  339. {
  340. if (q)
  341. {
  342. opcode |= 1 << 6;
  343. rd >>= 1; rd <<= 1;
  344. rn >>= 1; rn <<= 1;
  345. rm >>= 1; rm <<= 1;
  346. }
  347. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  348. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  349. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  350. V128 v0 = MakeVectorE0E1(d0, d1);
  351. V128 v1 = MakeVectorE0E1(d2, d3);
  352. SingleOpcode(opcode, v0: v0, v1: v1);
  353. CompareAgainstUnicorn();
  354. }
  355. [Test, Pairwise] [Explicit]
  356. public void Vmla_Vmls_Vnmla_Vnmls_S_F32([ValueSource(nameof(_Vmla_Vmls_Vnmla_Vnmls_S_F32_))] uint opcode,
  357. [Values(0u, 1u, 2u, 3u)] uint rd,
  358. [Values(0u, 1u, 2u, 3u)] uint rn,
  359. [Values(0u, 1u, 2u, 3u)] uint rm,
  360. [ValueSource(nameof(_1S_F_))] ulong s0,
  361. [ValueSource(nameof(_1S_F_))] ulong s1,
  362. [ValueSource(nameof(_1S_F_))] ulong s2,
  363. [ValueSource(nameof(_1S_F_))] ulong s3)
  364. {
  365. opcode |= (((rd & 0x1) << 22) | (rd & 0x1e) << 11);
  366. opcode |= (((rn & 0x1) << 7) | (rn & 0x1e) << 15);
  367. opcode |= (((rm & 0x1) << 5) | (rm & 0x1e) >> 1);
  368. V128 v0 = MakeVectorE0E1E2E3((uint)s0, (uint)s1, (uint)s2, (uint)s3);
  369. SingleOpcode(opcode, v0: v0);
  370. CompareAgainstUnicorn();
  371. }
  372. [Test, Pairwise] [Explicit]
  373. public void Vmla_Vmls_Vnmla_Vnmls_S_F64([ValueSource(nameof(_Vmla_Vmls_Vnmla_Vnmls_S_F64_))] uint opcode,
  374. [Values(0u, 1u)] uint rd,
  375. [Values(0u, 1u)] uint rn,
  376. [Values(0u, 1u)] uint rm,
  377. [ValueSource(nameof(_1D_F_))] ulong d0,
  378. [ValueSource(nameof(_1D_F_))] ulong d1)
  379. {
  380. opcode |= (((rd & 0x10) << 18) | (rd & 0xf) << 12);
  381. opcode |= (((rn & 0x10) << 3) | (rn & 0xf) << 16);
  382. opcode |= (((rm & 0x10) << 1) | (rm & 0xf) << 0);
  383. V128 v0 = MakeVectorE0E1(d0, d1);
  384. SingleOpcode(opcode, v0: v0);
  385. CompareAgainstUnicorn();
  386. }
  387. [Test, Pairwise, Description("VMLSL.<type><size> <Vd>, <Vn>, <Vm>")]
  388. public void Vmlsl_I([Values(0u)] uint rd,
  389. [Values(1u, 0u)] uint rn,
  390. [Values(2u, 0u)] uint rm,
  391. [Values(0u, 1u, 2u)] uint size,
  392. [Random(RndCnt)] ulong z,
  393. [Random(RndCnt)] ulong a,
  394. [Random(RndCnt)] ulong b,
  395. [Values] bool u)
  396. {
  397. uint opcode = 0xf2800a00u; // VMLSL.S8 Q0, D0, D0
  398. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  399. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  400. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  401. opcode |= size << 20;
  402. if (u)
  403. {
  404. opcode |= 1 << 24;
  405. }
  406. V128 v0 = MakeVectorE0E1(z, z);
  407. V128 v1 = MakeVectorE0E1(a, z);
  408. V128 v2 = MakeVectorE0E1(b, z);
  409. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  410. CompareAgainstUnicorn();
  411. }
  412. [Test, Pairwise, Description("VMULL.<size> <Vd>, <Vn>, <Vm>")]
  413. public void Vmull_I([Values(0u)] uint rd,
  414. [Values(1u, 0u)] uint rn,
  415. [Values(2u, 0u)] uint rm,
  416. [Values(0u, 1u, 2u)] uint size,
  417. [Random(RndCnt)] ulong z,
  418. [Random(RndCnt)] ulong a,
  419. [Random(RndCnt)] ulong b,
  420. [Values] bool op,
  421. [Values] bool u)
  422. {
  423. uint opcode = 0xf2800c00u; // VMULL.S8 Q0, D0, D0
  424. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  425. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  426. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  427. if (op)
  428. {
  429. opcode |= 1 << 9;
  430. size = 0;
  431. u = false;
  432. }
  433. opcode |= size << 20;
  434. if (u)
  435. {
  436. opcode |= 1 << 24;
  437. }
  438. V128 v0 = MakeVectorE0E1(z, z);
  439. V128 v1 = MakeVectorE0E1(a, z);
  440. V128 v2 = MakeVectorE0E1(b, z);
  441. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  442. CompareAgainstUnicorn();
  443. }
  444. [Test, Pairwise, Description("VSHL.<size> {<Vd>}, <Vm>, <Vn>")]
  445. public void Vshl([Values(0u)] uint rd,
  446. [Values(1u, 0u)] uint rn,
  447. [Values(2u, 0u)] uint rm,
  448. [Values(0u, 1u, 2u, 3u)] uint size,
  449. [Random(RndCnt)] ulong z,
  450. [Random(RndCnt)] ulong a,
  451. [Random(RndCnt)] ulong b,
  452. [Values] bool q,
  453. [Values] bool u)
  454. {
  455. uint opcode = 0xf2000400u; // VSHL.S8 D0, D0, D0
  456. if (q)
  457. {
  458. opcode |= 1 << 6;
  459. rm <<= 1;
  460. rn <<= 1;
  461. rd <<= 1;
  462. }
  463. if (u)
  464. {
  465. opcode |= 1 << 24;
  466. }
  467. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  468. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  469. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  470. opcode |= size << 20;
  471. V128 v0 = MakeVectorE0E1(z, z);
  472. V128 v1 = MakeVectorE0E1(a, z);
  473. V128 v2 = MakeVectorE0E1(b, z);
  474. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  475. CompareAgainstUnicorn();
  476. }
  477. [Explicit]
  478. [Test, Pairwise]
  479. public void Vp_Add_Max_Min_F([ValueSource("_Vp_Add_Max_Min_F_")] uint opcode,
  480. [Values(0u)] uint rd,
  481. [Range(0u, 7u)] uint rn,
  482. [Range(0u, 7u)] uint rm,
  483. [ValueSource("_2S_F_")] ulong z0,
  484. [ValueSource("_2S_F_")] ulong z1,
  485. [ValueSource("_2S_F_")] ulong a0,
  486. [ValueSource("_2S_F_")] ulong a1,
  487. [ValueSource("_2S_F_")] ulong b0,
  488. [ValueSource("_2S_F_")] ulong b1)
  489. {
  490. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  491. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  492. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  493. var rnd = TestContext.CurrentContext.Random;
  494. V128 v0 = MakeVectorE0E1(z0, z1);
  495. V128 v1 = MakeVectorE0E1(a0, a1);
  496. V128 v2 = MakeVectorE0E1(b0, b1);
  497. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  498. CompareAgainstUnicorn();
  499. }
  500. [Test, Pairwise]
  501. public void Vp_Add_Max_Min_I([ValueSource("_Vp_Add_Max_Min_I_")] uint opcode,
  502. [Values(0u)] uint rd,
  503. [Range(0u, 5u)] uint rn,
  504. [Range(0u, 5u)] uint rm,
  505. [Values(0u, 1u, 2u)] uint size,
  506. [Random(RndCnt)] ulong z,
  507. [Random(RndCnt)] ulong a,
  508. [Random(RndCnt)] ulong b,
  509. [Values] bool u)
  510. {
  511. if (u && opcode != VpaddI8)
  512. {
  513. opcode |= 1 << 24;
  514. }
  515. opcode |= ((rm & 0xf) << 0) | ((rm & 0x10) << 1);
  516. opcode |= ((rd & 0xf) << 12) | ((rd & 0x10) << 18);
  517. opcode |= ((rn & 0xf) << 16) | ((rn & 0x10) << 3);
  518. opcode |= size << 20;
  519. V128 v0 = MakeVectorE0E1(z, z);
  520. V128 v1 = MakeVectorE0E1(a, z);
  521. V128 v2 = MakeVectorE0E1(b, z);
  522. SingleOpcode(opcode, v0: v0, v1: v1, v2: v2);
  523. CompareAgainstUnicorn();
  524. }
  525. #endif
  526. }
  527. }