EmitterContextInsts.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. using Ryujinx.Graphics.Shader.IntermediateRepresentation;
  2. using static Ryujinx.Graphics.Shader.IntermediateRepresentation.OperandHelper;
  3. namespace Ryujinx.Graphics.Shader.Translation
  4. {
  5. static class EmitterContextInsts
  6. {
  7. public static Operand AtomicAdd(this EmitterContext context, Instruction mr, Operand a, Operand b, Operand c)
  8. {
  9. return context.Add(Instruction.AtomicAdd | mr, Local(), a, b, c);
  10. }
  11. public static Operand AtomicAnd(this EmitterContext context, Instruction mr, Operand a, Operand b, Operand c)
  12. {
  13. return context.Add(Instruction.AtomicAnd | mr, Local(), a, b, c);
  14. }
  15. public static Operand AtomicCompareAndSwap(this EmitterContext context, Instruction mr, Operand a, Operand b, Operand c, Operand d)
  16. {
  17. return context.Add(Instruction.AtomicCompareAndSwap | mr, Local(), a, b, c, d);
  18. }
  19. public static Operand AtomicMaxS32(this EmitterContext context, Instruction mr, Operand a, Operand b, Operand c)
  20. {
  21. return context.Add(Instruction.AtomicMaxS32 | mr, Local(), a, b, c);
  22. }
  23. public static Operand AtomicMaxU32(this EmitterContext context, Instruction mr, Operand a, Operand b, Operand c)
  24. {
  25. return context.Add(Instruction.AtomicMaxU32 | mr, Local(), a, b, c);
  26. }
  27. public static Operand AtomicMinS32(this EmitterContext context, Instruction mr, Operand a, Operand b, Operand c)
  28. {
  29. return context.Add(Instruction.AtomicMinS32 | mr, Local(), a, b, c);
  30. }
  31. public static Operand AtomicMinU32(this EmitterContext context, Instruction mr, Operand a, Operand b, Operand c)
  32. {
  33. return context.Add(Instruction.AtomicMinU32 | mr, Local(), a, b, c);
  34. }
  35. public static Operand AtomicOr(this EmitterContext context, Instruction mr, Operand a, Operand b, Operand c)
  36. {
  37. return context.Add(Instruction.AtomicOr | mr, Local(), a, b, c);
  38. }
  39. public static Operand AtomicSwap(this EmitterContext context, Instruction mr, Operand a, Operand b, Operand c)
  40. {
  41. return context.Add(Instruction.AtomicSwap | mr, Local(), a, b, c);
  42. }
  43. public static Operand AtomicXor(this EmitterContext context, Instruction mr, Operand a, Operand b, Operand c)
  44. {
  45. return context.Add(Instruction.AtomicXor | mr, Local(), a, b, c);
  46. }
  47. public static Operand Ballot(this EmitterContext context, Operand a)
  48. {
  49. return context.Add(Instruction.Ballot, Local(), a);
  50. }
  51. public static Operand Barrier(this EmitterContext context)
  52. {
  53. return context.Add(Instruction.Barrier);
  54. }
  55. public static Operand BitCount(this EmitterContext context, Operand a)
  56. {
  57. return context.Add(Instruction.BitCount, Local(), a);
  58. }
  59. public static Operand BitfieldExtractS32(this EmitterContext context, Operand a, Operand b, Operand c)
  60. {
  61. return context.Add(Instruction.BitfieldExtractS32, Local(), a, b, c);
  62. }
  63. public static Operand BitfieldExtractU32(this EmitterContext context, Operand a, Operand b, Operand c)
  64. {
  65. return context.Add(Instruction.BitfieldExtractU32, Local(), a, b, c);
  66. }
  67. public static Operand BitfieldInsert(this EmitterContext context, Operand a, Operand b, Operand c, Operand d)
  68. {
  69. return context.Add(Instruction.BitfieldInsert, Local(), a, b, c, d);
  70. }
  71. public static Operand BitfieldReverse(this EmitterContext context, Operand a)
  72. {
  73. return context.Add(Instruction.BitfieldReverse, Local(), a);
  74. }
  75. public static Operand BitwiseAnd(this EmitterContext context, Operand a, Operand b)
  76. {
  77. return context.Add(Instruction.BitwiseAnd, Local(), a, b);
  78. }
  79. public static Operand BitwiseExclusiveOr(this EmitterContext context, Operand a, Operand b)
  80. {
  81. return context.Add(Instruction.BitwiseExclusiveOr, Local(), a, b);
  82. }
  83. public static Operand BitwiseNot(this EmitterContext context, Operand a, bool invert)
  84. {
  85. if (invert)
  86. {
  87. a = context.BitwiseNot(a);
  88. }
  89. return a;
  90. }
  91. public static Operand BitwiseNot(this EmitterContext context, Operand a)
  92. {
  93. return context.Add(Instruction.BitwiseNot, Local(), a);
  94. }
  95. public static Operand BitwiseOr(this EmitterContext context, Operand a, Operand b)
  96. {
  97. return context.Add(Instruction.BitwiseOr, Local(), a, b);
  98. }
  99. public static Operand Branch(this EmitterContext context, Operand d)
  100. {
  101. return context.Add(Instruction.Branch, d);
  102. }
  103. public static Operand BranchIfFalse(this EmitterContext context, Operand d, Operand a)
  104. {
  105. return context.Add(Instruction.BranchIfFalse, d, a);
  106. }
  107. public static Operand BranchIfTrue(this EmitterContext context, Operand d, Operand a)
  108. {
  109. return context.Add(Instruction.BranchIfTrue, d, a);
  110. }
  111. public static Operand Call(this EmitterContext context, int funcId, bool returns, params Operand[] args)
  112. {
  113. Operand[] args2 = new Operand[args.Length + 1];
  114. args2[0] = Const(funcId);
  115. args.CopyTo(args2, 1);
  116. return context.Add(Instruction.Call, returns ? Local() : null, args2);
  117. }
  118. public static Operand ConditionalSelect(this EmitterContext context, Operand a, Operand b, Operand c)
  119. {
  120. return context.Add(Instruction.ConditionalSelect, Local(), a, b, c);
  121. }
  122. public static Operand Copy(this EmitterContext context, Operand a)
  123. {
  124. return context.Add(Instruction.Copy, Local(), a);
  125. }
  126. public static void Copy(this EmitterContext context, Operand d, Operand a)
  127. {
  128. if (d.Type == OperandType.Constant)
  129. {
  130. return;
  131. }
  132. context.Add(Instruction.Copy, d, a);
  133. }
  134. public static Operand Discard(this EmitterContext context)
  135. {
  136. return context.Add(Instruction.Discard);
  137. }
  138. public static Operand EmitVertex(this EmitterContext context)
  139. {
  140. return context.Add(Instruction.EmitVertex);
  141. }
  142. public static Operand EndPrimitive(this EmitterContext context)
  143. {
  144. return context.Add(Instruction.EndPrimitive);
  145. }
  146. public static Operand FindFirstSetS32(this EmitterContext context, Operand a)
  147. {
  148. return context.Add(Instruction.FindFirstSetS32, Local(), a);
  149. }
  150. public static Operand FindFirstSetU32(this EmitterContext context, Operand a)
  151. {
  152. return context.Add(Instruction.FindFirstSetU32, Local(), a);
  153. }
  154. public static Operand FP32ConvertToFP64(this EmitterContext context, Operand a)
  155. {
  156. return context.Add(Instruction.ConvertFP32ToFP64, Local(), a);
  157. }
  158. public static Operand FP64ConvertToFP32(this EmitterContext context, Operand a)
  159. {
  160. return context.Add(Instruction.ConvertFP64ToFP32, Local(), a);
  161. }
  162. public static Operand FPAbsNeg(this EmitterContext context, Operand a, bool abs, bool neg, Instruction fpType = Instruction.FP32)
  163. {
  164. return context.FPNegate(context.FPAbsolute(a, abs, fpType), neg, fpType);
  165. }
  166. public static Operand FPAbsolute(this EmitterContext context, Operand a, bool abs, Instruction fpType = Instruction.FP32)
  167. {
  168. if (abs)
  169. {
  170. a = context.FPAbsolute(a, fpType);
  171. }
  172. return a;
  173. }
  174. public static Operand FPAbsolute(this EmitterContext context, Operand a, Instruction fpType = Instruction.FP32)
  175. {
  176. return context.Add(fpType | Instruction.Absolute, Local(), a);
  177. }
  178. public static Operand FPAdd(this EmitterContext context, Operand a, Operand b, Instruction fpType = Instruction.FP32)
  179. {
  180. return context.Add(fpType | Instruction.Add, Local(), a, b);
  181. }
  182. public static Operand FPCeiling(this EmitterContext context, Operand a, Instruction fpType = Instruction.FP32)
  183. {
  184. return context.Add(fpType | Instruction.Ceiling, Local(), a);
  185. }
  186. public static Operand FPCompareEqual(this EmitterContext context, Operand a, Operand b, Instruction fpType = Instruction.FP32)
  187. {
  188. return context.Add(fpType | Instruction.CompareEqual, Local(), a, b);
  189. }
  190. public static Operand FPCompareLess(this EmitterContext context, Operand a, Operand b, Instruction fpType = Instruction.FP32)
  191. {
  192. return context.Add(fpType | Instruction.CompareLess, Local(), a, b);
  193. }
  194. public static Operand FPConvertToS32(this EmitterContext context, Operand a)
  195. {
  196. return context.Add(Instruction.ConvertFPToS32, Local(), a);
  197. }
  198. public static Operand FPConvertToU32(this EmitterContext context, Operand a)
  199. {
  200. return context.Add(Instruction.ConvertFPToU32, Local(), a);
  201. }
  202. public static Operand FPCosine(this EmitterContext context, Operand a)
  203. {
  204. return context.Add(Instruction.FP32 | Instruction.Cosine, Local(), a);
  205. }
  206. public static Operand FPDivide(this EmitterContext context, Operand a, Operand b)
  207. {
  208. return context.Add(Instruction.FP32 | Instruction.Divide, Local(), a, b);
  209. }
  210. public static Operand FPExponentB2(this EmitterContext context, Operand a)
  211. {
  212. return context.Add(Instruction.FP32 | Instruction.ExponentB2, Local(), a);
  213. }
  214. public static Operand FPFloor(this EmitterContext context, Operand a, Instruction fpType = Instruction.FP32)
  215. {
  216. return context.Add(fpType | Instruction.Floor, Local(), a);
  217. }
  218. public static Operand FPFusedMultiplyAdd(this EmitterContext context, Operand a, Operand b, Operand c, Instruction fpType = Instruction.FP32)
  219. {
  220. return context.Add(fpType | Instruction.FusedMultiplyAdd, Local(), a, b, c);
  221. }
  222. public static Operand FPLogarithmB2(this EmitterContext context, Operand a)
  223. {
  224. return context.Add(Instruction.FP32 | Instruction.LogarithmB2, Local(), a);
  225. }
  226. public static Operand FPMaximum(this EmitterContext context, Operand a, Operand b)
  227. {
  228. return context.Add(Instruction.FP32 | Instruction.Maximum, Local(), a, b);
  229. }
  230. public static Operand FPMinimum(this EmitterContext context, Operand a, Operand b)
  231. {
  232. return context.Add(Instruction.FP32 | Instruction.Minimum, Local(), a, b);
  233. }
  234. public static Operand FPMultiply(this EmitterContext context, Operand a, Operand b, Instruction fpType = Instruction.FP32)
  235. {
  236. return context.Add(fpType | Instruction.Multiply, Local(), a, b);
  237. }
  238. public static Operand FPNegate(this EmitterContext context, Operand a, bool neg, Instruction fpType = Instruction.FP32)
  239. {
  240. if (neg)
  241. {
  242. a = context.FPNegate(a, fpType);
  243. }
  244. return a;
  245. }
  246. public static Operand FPNegate(this EmitterContext context, Operand a, Instruction fpType = Instruction.FP32)
  247. {
  248. return context.Add(fpType | Instruction.Negate, Local(), a);
  249. }
  250. public static Operand FPReciprocal(this EmitterContext context, Operand a)
  251. {
  252. return context.FPDivide(ConstF(1), a);
  253. }
  254. public static Operand FPReciprocalSquareRoot(this EmitterContext context, Operand a)
  255. {
  256. return context.Add(Instruction.FP32 | Instruction.ReciprocalSquareRoot, Local(), a);
  257. }
  258. public static Operand FPRound(this EmitterContext context, Operand a, Instruction fpType = Instruction.FP32)
  259. {
  260. return context.Add(fpType | Instruction.Round, Local(), a);
  261. }
  262. public static Operand FPSaturate(this EmitterContext context, Operand a, bool sat, Instruction fpType = Instruction.FP32)
  263. {
  264. if (sat)
  265. {
  266. a = context.FPSaturate(a, fpType);
  267. }
  268. return a;
  269. }
  270. public static Operand FPSaturate(this EmitterContext context, Operand a, Instruction fpType = Instruction.FP32)
  271. {
  272. return context.Add(fpType | Instruction.Clamp, Local(), a, ConstF(0), ConstF(1));
  273. }
  274. public static Operand FPSine(this EmitterContext context, Operand a)
  275. {
  276. return context.Add(Instruction.FP32 | Instruction.Sine, Local(), a);
  277. }
  278. public static Operand FPSquareRoot(this EmitterContext context, Operand a)
  279. {
  280. return context.Add(Instruction.FP32 | Instruction.SquareRoot, Local(), a);
  281. }
  282. public static Operand FPTruncate(this EmitterContext context, Operand a, Instruction fpType = Instruction.FP32)
  283. {
  284. return context.Add(fpType | Instruction.Truncate, Local(), a);
  285. }
  286. public static Operand FPSwizzleAdd(this EmitterContext context, Operand a, Operand b, int mask)
  287. {
  288. return context.Add(Instruction.SwizzleAdd, Local(), a, b, Const(mask));
  289. }
  290. public static Operand GroupMemoryBarrier(this EmitterContext context)
  291. {
  292. return context.Add(Instruction.GroupMemoryBarrier);
  293. }
  294. public static Operand IAbsNeg(this EmitterContext context, Operand a, bool abs, bool neg)
  295. {
  296. return context.INegate(context.IAbsolute(a, abs), neg);
  297. }
  298. public static Operand IAbsolute(this EmitterContext context, Operand a, bool abs)
  299. {
  300. if (abs)
  301. {
  302. a = context.IAbsolute(a);
  303. }
  304. return a;
  305. }
  306. public static Operand IAbsolute(this EmitterContext context, Operand a)
  307. {
  308. return context.Add(Instruction.Absolute, Local(), a);
  309. }
  310. public static Operand IAdd(this EmitterContext context, Operand a, Operand b)
  311. {
  312. return context.Add(Instruction.Add, Local(), a, b);
  313. }
  314. public static Operand IClampS32(this EmitterContext context, Operand a, Operand b, Operand c)
  315. {
  316. return context.Add(Instruction.Clamp, Local(), a, b, c);
  317. }
  318. public static Operand IClampU32(this EmitterContext context, Operand a, Operand b, Operand c)
  319. {
  320. return context.Add(Instruction.ClampU32, Local(), a, b, c);
  321. }
  322. public static Operand ICompareEqual(this EmitterContext context, Operand a, Operand b)
  323. {
  324. return context.Add(Instruction.CompareEqual, Local(), a, b);
  325. }
  326. public static Operand ICompareGreater(this EmitterContext context, Operand a, Operand b)
  327. {
  328. return context.Add(Instruction.CompareGreater, Local(), a, b);
  329. }
  330. public static Operand ICompareGreaterOrEqual(this EmitterContext context, Operand a, Operand b)
  331. {
  332. return context.Add(Instruction.CompareGreaterOrEqual, Local(), a, b);
  333. }
  334. public static Operand ICompareGreaterOrEqualUnsigned(this EmitterContext context, Operand a, Operand b)
  335. {
  336. return context.Add(Instruction.CompareGreaterOrEqualU32, Local(), a, b);
  337. }
  338. public static Operand ICompareGreaterUnsigned(this EmitterContext context, Operand a, Operand b)
  339. {
  340. return context.Add(Instruction.CompareGreaterU32, Local(), a, b);
  341. }
  342. public static Operand ICompareLess(this EmitterContext context, Operand a, Operand b)
  343. {
  344. return context.Add(Instruction.CompareLess, Local(), a, b);
  345. }
  346. public static Operand ICompareLessOrEqual(this EmitterContext context, Operand a, Operand b)
  347. {
  348. return context.Add(Instruction.CompareLessOrEqual, Local(), a, b);
  349. }
  350. public static Operand ICompareLessOrEqualUnsigned(this EmitterContext context, Operand a, Operand b)
  351. {
  352. return context.Add(Instruction.CompareLessOrEqualU32, Local(), a, b);
  353. }
  354. public static Operand ICompareLessUnsigned(this EmitterContext context, Operand a, Operand b)
  355. {
  356. return context.Add(Instruction.CompareLessU32, Local(), a, b);
  357. }
  358. public static Operand ICompareNotEqual(this EmitterContext context, Operand a, Operand b)
  359. {
  360. return context.Add(Instruction.CompareNotEqual, Local(), a, b);
  361. }
  362. public static Operand IConvertS32ToFP(this EmitterContext context, Operand a)
  363. {
  364. return context.Add(Instruction.ConvertS32ToFP, Local(), a);
  365. }
  366. public static Operand IConvertU32ToFP(this EmitterContext context, Operand a)
  367. {
  368. return context.Add(Instruction.ConvertU32ToFP, Local(), a);
  369. }
  370. public static Operand IMaximumS32(this EmitterContext context, Operand a, Operand b)
  371. {
  372. return context.Add(Instruction.Maximum, Local(), a, b);
  373. }
  374. public static Operand IMaximumU32(this EmitterContext context, Operand a, Operand b)
  375. {
  376. return context.Add(Instruction.MaximumU32, Local(), a, b);
  377. }
  378. public static Operand IMinimumS32(this EmitterContext context, Operand a, Operand b)
  379. {
  380. return context.Add(Instruction.Minimum, Local(), a, b);
  381. }
  382. public static Operand IMinimumU32(this EmitterContext context, Operand a, Operand b)
  383. {
  384. return context.Add(Instruction.MinimumU32, Local(), a, b);
  385. }
  386. public static Operand IMultiply(this EmitterContext context, Operand a, Operand b)
  387. {
  388. return context.Add(Instruction.Multiply, Local(), a, b);
  389. }
  390. public static Operand INegate(this EmitterContext context, Operand a, bool neg)
  391. {
  392. if (neg)
  393. {
  394. a = context.INegate(a);
  395. }
  396. return a;
  397. }
  398. public static Operand INegate(this EmitterContext context, Operand a)
  399. {
  400. return context.Add(Instruction.Negate, Local(), a);
  401. }
  402. public static Operand ISubtract(this EmitterContext context, Operand a, Operand b)
  403. {
  404. return context.Add(Instruction.Subtract, Local(), a, b);
  405. }
  406. public static Operand IsNan(this EmitterContext context, Operand a)
  407. {
  408. return context.Add(Instruction.IsNan, Local(), a);
  409. }
  410. public static Operand LoadAttribute(this EmitterContext context, Operand a, Operand b)
  411. {
  412. return context.Add(Instruction.LoadAttribute, Local(), a, b);
  413. }
  414. public static Operand LoadConstant(this EmitterContext context, Operand a, Operand b)
  415. {
  416. return context.Add(Instruction.LoadConstant, Local(), a, b);
  417. }
  418. public static Operand LoadGlobal(this EmitterContext context, Operand a, Operand b)
  419. {
  420. return context.Add(Instruction.LoadGlobal, Local(), a, b);
  421. }
  422. public static Operand LoadLocal(this EmitterContext context, Operand a)
  423. {
  424. return context.Add(Instruction.LoadLocal, Local(), a);
  425. }
  426. public static Operand LoadShared(this EmitterContext context, Operand a)
  427. {
  428. return context.Add(Instruction.LoadShared, Local(), a);
  429. }
  430. public static Operand MemoryBarrier(this EmitterContext context)
  431. {
  432. return context.Add(Instruction.MemoryBarrier);
  433. }
  434. public static Operand MultiplyHighS32(this EmitterContext context, Operand a, Operand b)
  435. {
  436. return context.Add(Instruction.MultiplyHighS32, Local(), a, b);
  437. }
  438. public static Operand MultiplyHighU32(this EmitterContext context, Operand a, Operand b)
  439. {
  440. return context.Add(Instruction.MultiplyHighU32, Local(), a, b);
  441. }
  442. public static Operand PackDouble2x32(this EmitterContext context, Operand a, Operand b)
  443. {
  444. return context.Add(Instruction.PackDouble2x32, Local(), a, b);
  445. }
  446. public static Operand PackHalf2x16(this EmitterContext context, Operand a, Operand b)
  447. {
  448. return context.Add(Instruction.PackHalf2x16, Local(), a, b);
  449. }
  450. public static void Return(this EmitterContext context)
  451. {
  452. context.PrepareForReturn();
  453. context.Add(Instruction.Return);
  454. }
  455. public static void Return(this EmitterContext context, Operand returnValue)
  456. {
  457. context.PrepareForReturn();
  458. context.Add(Instruction.Return, null, returnValue);
  459. }
  460. public static Operand ShiftLeft(this EmitterContext context, Operand a, Operand b)
  461. {
  462. return context.Add(Instruction.ShiftLeft, Local(), a, b);
  463. }
  464. public static Operand ShiftRightS32(this EmitterContext context, Operand a, Operand b)
  465. {
  466. return context.Add(Instruction.ShiftRightS32, Local(), a, b);
  467. }
  468. public static Operand ShiftRightU32(this EmitterContext context, Operand a, Operand b)
  469. {
  470. return context.Add(Instruction.ShiftRightU32, Local(), a, b);
  471. }
  472. public static Operand Shuffle(this EmitterContext context, Operand a, Operand b, Operand c)
  473. {
  474. return context.Add(Instruction.Shuffle, Local(), a, b, c);
  475. }
  476. public static Operand ShuffleDown(this EmitterContext context, Operand a, Operand b, Operand c)
  477. {
  478. return context.Add(Instruction.ShuffleDown, Local(), a, b, c);
  479. }
  480. public static Operand ShuffleUp(this EmitterContext context, Operand a, Operand b, Operand c)
  481. {
  482. return context.Add(Instruction.ShuffleUp, Local(), a, b, c);
  483. }
  484. public static Operand ShuffleXor(this EmitterContext context, Operand a, Operand b, Operand c)
  485. {
  486. return context.Add(Instruction.ShuffleXor, Local(), a, b, c);
  487. }
  488. public static Operand StoreGlobal(this EmitterContext context, Operand a, Operand b, Operand c)
  489. {
  490. return context.Add(Instruction.StoreGlobal, null, a, b, c);
  491. }
  492. public static Operand StoreLocal(this EmitterContext context, Operand a, Operand b)
  493. {
  494. return context.Add(Instruction.StoreLocal, null, a, b);
  495. }
  496. public static Operand StoreShared(this EmitterContext context, Operand a, Operand b)
  497. {
  498. return context.Add(Instruction.StoreShared, null, a, b);
  499. }
  500. public static Operand UnpackDouble2x32High(this EmitterContext context, Operand a)
  501. {
  502. return UnpackDouble2x32(context, a, 1);
  503. }
  504. public static Operand UnpackDouble2x32Low(this EmitterContext context, Operand a)
  505. {
  506. return UnpackDouble2x32(context, a, 0);
  507. }
  508. private static Operand UnpackDouble2x32(this EmitterContext context, Operand a, int index)
  509. {
  510. Operand dest = Local();
  511. context.Add(new Operation(Instruction.UnpackDouble2x32, index, dest, a));
  512. return dest;
  513. }
  514. public static Operand UnpackHalf2x16High(this EmitterContext context, Operand a)
  515. {
  516. return UnpackHalf2x16(context, a, 1);
  517. }
  518. public static Operand UnpackHalf2x16Low(this EmitterContext context, Operand a)
  519. {
  520. return UnpackHalf2x16(context, a, 0);
  521. }
  522. private static Operand UnpackHalf2x16(this EmitterContext context, Operand a, int index)
  523. {
  524. Operand dest = Local();
  525. context.Add(new Operation(Instruction.UnpackHalf2x16, index, dest, a));
  526. return dest;
  527. }
  528. public static Operand VoteAll(this EmitterContext context, Operand a)
  529. {
  530. return context.Add(Instruction.VoteAll, Local(), a);
  531. }
  532. public static Operand VoteAllEqual(this EmitterContext context, Operand a)
  533. {
  534. return context.Add(Instruction.VoteAllEqual, Local(), a);
  535. }
  536. public static Operand VoteAny(this EmitterContext context, Operand a)
  537. {
  538. return context.Add(Instruction.VoteAny, Local(), a);
  539. }
  540. }
  541. }