Ei kuvausta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

v64.cs 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. using System.Diagnostics;
  2. using System.Runtime.InteropServices;
  3. namespace Unity.Burst.Intrinsics
  4. {
  5. /// <summary>
  6. /// Represents a 64-bit SIMD value (Arm only)
  7. /// </summary>
  8. [StructLayout(LayoutKind.Explicit)]
  9. [DebuggerTypeProxy(typeof(V64DebugView))]
  10. public struct v64
  11. {
  12. /// <summary>
  13. /// Get the 0th Byte of the vector
  14. /// </summary>
  15. [FieldOffset(0)] public byte Byte0;
  16. /// <summary>
  17. /// Get the 1st Byte of the vector
  18. /// </summary>
  19. [FieldOffset(1)] public byte Byte1;
  20. /// <summary>
  21. /// Get the 2nd Byte of the vector
  22. /// </summary>
  23. [FieldOffset(2)] public byte Byte2;
  24. /// <summary>
  25. /// Get the 3rd Byte of the vector
  26. /// </summary>
  27. [FieldOffset(3)] public byte Byte3;
  28. /// <summary>
  29. /// Get the 4th Byte of the vector
  30. /// </summary>
  31. [FieldOffset(4)] public byte Byte4;
  32. /// <summary>
  33. /// Get the 5th Byte of the vector
  34. /// </summary>
  35. [FieldOffset(5)] public byte Byte5;
  36. /// <summary>
  37. /// Get the 6th Byte of the vector
  38. /// </summary>
  39. [FieldOffset(6)] public byte Byte6;
  40. /// <summary>
  41. /// Get the 7th Byte of the vector
  42. /// </summary>
  43. [FieldOffset(7)] public byte Byte7;
  44. /// <summary>
  45. /// Get the 0th SByte of the vector
  46. /// </summary>
  47. [FieldOffset(0)] public sbyte SByte0;
  48. /// <summary>
  49. /// Get the 1st SByte of the vector
  50. /// </summary>
  51. [FieldOffset(1)] public sbyte SByte1;
  52. /// <summary>
  53. /// Get the 2nd SByte of the vector
  54. /// </summary>
  55. [FieldOffset(2)] public sbyte SByte2;
  56. /// <summary>
  57. /// Get the 3rd SByte of the vector
  58. /// </summary>
  59. [FieldOffset(3)] public sbyte SByte3;
  60. /// <summary>
  61. /// Get the 4th SByte of the vector
  62. /// </summary>
  63. [FieldOffset(4)] public sbyte SByte4;
  64. /// <summary>
  65. /// Get the 5th SByte of the vector
  66. /// </summary>
  67. [FieldOffset(5)] public sbyte SByte5;
  68. /// <summary>
  69. /// Get the 6th SByte of the vector
  70. /// </summary>
  71. [FieldOffset(6)] public sbyte SByte6;
  72. /// <summary>
  73. /// Get the 7th SByte of the vector
  74. /// </summary>
  75. [FieldOffset(7)] public sbyte SByte7;
  76. /// <summary>
  77. /// Get the 0th UShort of the vector
  78. /// </summary>
  79. [FieldOffset(0)] public ushort UShort0;
  80. /// <summary>
  81. /// Get the 1st UShort of the vector
  82. /// </summary>
  83. [FieldOffset(2)] public ushort UShort1;
  84. /// <summary>
  85. /// Get the 2nd UShort of the vector
  86. /// </summary>
  87. [FieldOffset(4)] public ushort UShort2;
  88. /// <summary>
  89. /// Get the 3rd UShort of the vector
  90. /// </summary>
  91. [FieldOffset(6)] public ushort UShort3;
  92. /// <summary>
  93. /// Get the 0th SShort of the vector
  94. /// </summary>
  95. [FieldOffset(0)] public short SShort0;
  96. /// <summary>
  97. /// Get the 1st SShort of the vector
  98. /// </summary>
  99. [FieldOffset(2)] public short SShort1;
  100. /// <summary>
  101. /// Get the 2nd SShort of the vector
  102. /// </summary>
  103. [FieldOffset(4)] public short SShort2;
  104. /// <summary>
  105. /// Get the 3rd SShort of the vector
  106. /// </summary>
  107. [FieldOffset(6)] public short SShort3;
  108. #if BURST_INTERNAL || UNITY_BURST_EXPERIMENTAL_NEON_INTRINSICS
  109. /// <summary>
  110. /// Get the 0th f16 of the vector
  111. /// </summary>
  112. [FieldOffset(0)] public f16 Half0;
  113. /// <summary>
  114. /// Get the 1st f16 of the vector
  115. /// </summary>
  116. [FieldOffset(2)] public f16 Half1;
  117. /// <summary>
  118. /// Get the 2nd f16 of the vector
  119. /// </summary>
  120. [FieldOffset(4)] public f16 Half2;
  121. /// <summary>
  122. /// Get the 3rd f16 of the vector
  123. /// </summary>
  124. [FieldOffset(6)] public f16 Half3;
  125. #endif // BURST_INTERNAL || UNITY_BURST_EXPERIMENTAL_NEON_INTRINSICS
  126. /// <summary>
  127. /// Get the 0th UInt of the vector
  128. /// </summary>
  129. [FieldOffset(0)] public uint UInt0;
  130. /// <summary>
  131. /// Get the 1st UInt of the vector
  132. /// </summary>
  133. [FieldOffset(4)] public uint UInt1;
  134. /// <summary>
  135. /// Get the 0th SInt of the vector
  136. /// </summary>
  137. [FieldOffset(0)] public int SInt0;
  138. /// <summary>
  139. /// Get the 1st SInt of the vector
  140. /// </summary>
  141. [FieldOffset(4)] public int SInt1;
  142. /// <summary>
  143. /// Get the 0th ULong of the vector
  144. /// </summary>
  145. [FieldOffset(0)] public ulong ULong0;
  146. /// <summary>
  147. /// Get the 0th SLong of the vector
  148. /// </summary>
  149. [FieldOffset(0)] public long SLong0;
  150. /// <summary>
  151. /// Get the 0th Float of the vector
  152. /// </summary>
  153. [FieldOffset(0)] public float Float0;
  154. /// <summary>
  155. /// Get the 1st Float of the vector
  156. /// </summary>
  157. [FieldOffset(4)] public float Float1;
  158. /// <summary>
  159. /// Get the 0th Double of the vector
  160. /// </summary>
  161. [FieldOffset(0)] public double Double0;
  162. /// <summary>
  163. /// Splat a single byte across the v64
  164. /// </summary>
  165. /// <param name="b">Splatted byte</param>
  166. public v64(byte b)
  167. {
  168. this = default(v64);
  169. Byte0 = Byte1 = Byte2 = Byte3 = Byte4 = Byte5 = Byte6 = Byte7 = b;
  170. }
  171. /// <summary>
  172. /// Initialize the v64 with 8 bytes
  173. /// </summary>
  174. /// <param name="a">byte a</param>
  175. /// <param name="b">byte b</param>
  176. /// <param name="c">byte c</param>
  177. /// <param name="d">byte d</param>
  178. /// <param name="e">byte e</param>
  179. /// <param name="f">byte f</param>
  180. /// <param name="g">byte g</param>
  181. /// <param name="h">byte h</param>
  182. public v64(
  183. byte a, byte b, byte c, byte d,
  184. byte e, byte f, byte g, byte h)
  185. {
  186. this = default(v64);
  187. Byte0 = a;
  188. Byte1 = b;
  189. Byte2 = c;
  190. Byte3 = d;
  191. Byte4 = e;
  192. Byte5 = f;
  193. Byte6 = g;
  194. Byte7 = h;
  195. }
  196. /// <summary>
  197. /// Splat a single sbyte across the v64
  198. /// </summary>
  199. /// <param name="b">Splatted sbyte</param>
  200. public v64(sbyte b)
  201. {
  202. this = default(v64);
  203. SByte0 = SByte1 = SByte2 = SByte3 = SByte4 = SByte5 = SByte6 = SByte7 = b;
  204. }
  205. /// <summary>
  206. /// Initialize the v64 with 8 sbytes
  207. /// </summary>
  208. /// <param name="a">sbyte a</param>
  209. /// <param name="b">sbyte b</param>
  210. /// <param name="c">sbyte c</param>
  211. /// <param name="d">sbyte d</param>
  212. /// <param name="e">sbyte e</param>
  213. /// <param name="f">sbyte f</param>
  214. /// <param name="g">sbyte g</param>
  215. /// <param name="h">sbyte h</param>
  216. public v64(
  217. sbyte a, sbyte b, sbyte c, sbyte d,
  218. sbyte e, sbyte f, sbyte g, sbyte h)
  219. {
  220. this = default(v64);
  221. SByte0 = a;
  222. SByte1 = b;
  223. SByte2 = c;
  224. SByte3 = d;
  225. SByte4 = e;
  226. SByte5 = f;
  227. SByte6 = g;
  228. SByte7 = h;
  229. }
  230. /// <summary>
  231. /// Splat a single short across the v64
  232. /// </summary>
  233. /// <param name="v">Splatted short</param>
  234. public v64(short v)
  235. {
  236. this = default(v64);
  237. SShort0 = SShort1 = SShort2 = SShort3 = v;
  238. }
  239. /// <summary>
  240. /// Initialize the v64 with 4 shorts
  241. /// </summary>
  242. /// <param name="a">short a</param>
  243. /// <param name="b">short b</param>
  244. /// <param name="c">short c</param>
  245. /// <param name="d">short d</param>
  246. public v64(short a, short b, short c, short d)
  247. {
  248. this = default(v64);
  249. SShort0 = a;
  250. SShort1 = b;
  251. SShort2 = c;
  252. SShort3 = d;
  253. }
  254. /// <summary>
  255. /// Splat a single ushort across the v64
  256. /// </summary>
  257. /// <param name="v">Splatted ushort</param>
  258. public v64(ushort v)
  259. {
  260. this = default(v64);
  261. UShort0 = UShort1 = UShort2 = UShort3 = v;
  262. }
  263. /// <summary>
  264. /// Initialize the v64 with 4 ushorts
  265. /// </summary>
  266. /// <param name="a">ushort a</param>
  267. /// <param name="b">ushort b</param>
  268. /// <param name="c">ushort c</param>
  269. /// <param name="d">ushort d</param>
  270. public v64(ushort a, ushort b, ushort c, ushort d)
  271. {
  272. this = default(v64);
  273. UShort0 = a;
  274. UShort1 = b;
  275. UShort2 = c;
  276. UShort3 = d;
  277. }
  278. #if BURST_INTERNAL || UNITY_BURST_EXPERIMENTAL_NEON_INTRINSICS
  279. /// <summary>
  280. /// Splat a single f16 across the v64
  281. /// </summary>
  282. /// <param name="v">Splatted f16</param>
  283. public v64(f16 v)
  284. {
  285. this = default(v64);
  286. Half0 = Half1 = Half2 = Half3 = v;
  287. }
  288. /// <summary>
  289. /// Initialize the v64 with 4 half's
  290. /// </summary>
  291. /// <param name="a">f16 a</param>
  292. /// <param name="b">f16 b</param>
  293. /// <param name="c">f16 c</param>
  294. /// <param name="d">f16 d</param>
  295. public v64(f16 a, f16 b, f16 c, f16 d)
  296. {
  297. this = default(v64);
  298. Half0 = a;
  299. Half1 = b;
  300. Half2 = c;
  301. Half3 = d;
  302. }
  303. #endif // BURST_INTERNAL || UNITY_BURST_EXPERIMENTAL_NEON_INTRINSICS
  304. /// <summary>
  305. /// Splat a single int across the v64
  306. /// </summary>
  307. /// <param name="v">Splatted int</param>
  308. public v64(int v)
  309. {
  310. this = default(v64);
  311. SInt0 = SInt1 = v;
  312. }
  313. /// <summary>
  314. /// Initialize the v64 with 2 ints
  315. /// </summary>
  316. /// <param name="a">int a</param>
  317. /// <param name="b">int b</param>
  318. public v64(int a, int b)
  319. {
  320. this = default(v64);
  321. SInt0 = a;
  322. SInt1 = b;
  323. }
  324. /// <summary>
  325. /// Splat a single uint across the v64
  326. /// </summary>
  327. /// <param name="v">Splatted uint</param>
  328. public v64(uint v)
  329. {
  330. this = default(v64);
  331. UInt0 = UInt1 = v;
  332. }
  333. /// <summary>
  334. /// Initialize the v64 with 2 uints
  335. /// </summary>
  336. /// <param name="a">uint a</param>
  337. /// <param name="b">uint b</param>
  338. public v64(uint a, uint b)
  339. {
  340. this = default(v64);
  341. UInt0 = a;
  342. UInt1 = b;
  343. }
  344. /// <summary>
  345. /// Splat a single float across the v64
  346. /// </summary>
  347. /// <param name="f">Splatted float</param>
  348. public v64(float f)
  349. {
  350. this = default(v64);
  351. Float0 = Float1 = f;
  352. }
  353. /// <summary>
  354. /// Initialize the v64 with 2 floats
  355. /// </summary>
  356. /// <param name="a">float a</param>
  357. /// <param name="b">float b</param>
  358. public v64(float a, float b)
  359. {
  360. this = default(v64);
  361. Float0 = a;
  362. Float1 = b;
  363. }
  364. /// <summary>
  365. /// Initialize the v64 with a double
  366. /// </summary>
  367. /// <param name="a">Splatted double</param>
  368. public v64(double a)
  369. {
  370. this = default(v64);
  371. Double0 = a;
  372. }
  373. /// <summary>
  374. /// Initialize the v64 with a long
  375. /// </summary>
  376. /// <param name="a">long a</param>
  377. public v64(long a)
  378. {
  379. this = default(v64);
  380. SLong0 = a;
  381. }
  382. /// <summary>
  383. /// Initialize the v64 with a ulong
  384. /// </summary>
  385. /// <param name="a">ulong a</param>
  386. public v64(ulong a)
  387. {
  388. this = default(v64);
  389. ULong0 = a;
  390. }
  391. }
  392. #if BURST_INTERNAL || UNITY_BURST_EXPERIMENTAL_NEON_INTRINSICS
  393. /// <summary>
  394. /// Represents a 128-bit SIMD value (Arm only)
  395. /// (a combination of 2 64-bit values, equivalent to Arm Neon *x2 types)
  396. /// </summary>
  397. [StructLayout(LayoutKind.Explicit)]
  398. public struct v64x2
  399. {
  400. /// <summary>
  401. /// Get the first 64 bits of the vector
  402. /// </summary>
  403. [FieldOffset(0)] public v64 v64_0;
  404. /// <summary>
  405. /// Get the second 64 bits of the vector
  406. /// </summary>
  407. [FieldOffset(8)] public v64 v64_1;
  408. /// <summary>
  409. /// Initialize the v64x2 with 2 v64's
  410. /// </summary>
  411. /// <param name="v0">First v64.</param>
  412. /// <param name="v1">Second v64.</param>
  413. public v64x2(v64 v0, v64 v1)
  414. {
  415. this = default(v64x2);
  416. v64_0 = v0;
  417. v64_1 = v1;
  418. }
  419. }
  420. /// <summary>
  421. /// Represents a 192-bit SIMD value (Arm only)
  422. /// (a combination of 3 64-bit values, equivalent to Arm Neon *x3 types)
  423. /// </summary>
  424. [StructLayout(LayoutKind.Explicit)]
  425. public struct v64x3
  426. {
  427. /// <summary>
  428. /// Get the first 64 bits of the vector
  429. /// </summary>
  430. [FieldOffset(0)] public v64 v64_0;
  431. /// <summary>
  432. /// Get the second 64 bits of the vector
  433. /// </summary>
  434. [FieldOffset(8)] public v64 v64_1;
  435. /// <summary>
  436. /// Get the third 64 bits of the vector
  437. /// </summary>
  438. [FieldOffset(16)] public v64 v64_2;
  439. /// <summary>
  440. /// Initialize the v64x3 with 3 v64's
  441. /// </summary>
  442. /// <param name="v0">First v64.</param>
  443. /// <param name="v1">Second v64.</param>
  444. /// <param name="v2">Third v64.</param>
  445. public v64x3(v64 v0, v64 v1, v64 v2)
  446. {
  447. this = default(v64x3);
  448. v64_0 = v0;
  449. v64_1 = v1;
  450. v64_2 = v2;
  451. }
  452. }
  453. /// <summary>
  454. /// Represents a 256-bit SIMD value (Arm only)
  455. /// (a combination of 4 64-bit values, equivalent to Arm Neon *x4 types)
  456. /// </summary>
  457. [StructLayout(LayoutKind.Explicit)]
  458. public struct v64x4
  459. {
  460. /// <summary>
  461. /// Get the first 64 bits of the vector
  462. /// </summary>
  463. [FieldOffset(0)] public v64 v64_0;
  464. /// <summary>
  465. /// Get the second 64 bits of the vector
  466. /// </summary>
  467. [FieldOffset(8)] public v64 v64_1;
  468. /// <summary>
  469. /// Get the third 64 bits of the vector
  470. /// </summary>
  471. [FieldOffset(16)] public v64 v64_2;
  472. /// <summary>
  473. /// Get the fourth 64 bits of the vector
  474. /// </summary>
  475. [FieldOffset(24)] public v64 v64_3;
  476. /// <summary>
  477. /// Initialize the v64x4 with 4 v64's
  478. /// </summary>
  479. /// <param name="v0">First v64.</param>
  480. /// <param name="v1">Second v64.</param>
  481. /// <param name="v2">Third v64.</param>
  482. /// <param name="v3">Fourth v64.</param>
  483. public v64x4(v64 v0, v64 v1, v64 v2, v64 v3)
  484. {
  485. this = default(v64x4);
  486. v64_0 = v0;
  487. v64_1 = v1;
  488. v64_2 = v2;
  489. v64_3 = v3;
  490. }
  491. }
  492. #endif // BURST_INTERNAL || UNITY_BURST_EXPERIMENTAL_NEON_INTRINSICS
  493. }