InstEmitSimdHash.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using ARMeilleure.Decoders;
  2. using ARMeilleure.IntermediateRepresentation;
  3. using ARMeilleure.Translation;
  4. using static ARMeilleure.Instructions.InstEmitHelper;
  5. namespace ARMeilleure.Instructions
  6. {
  7. static partial class InstEmit
  8. {
  9. #region "Sha1"
  10. public static void Sha1c_V(ArmEmitterContext context)
  11. {
  12. OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
  13. Operand d = GetVec(op.Rd);
  14. Operand ne = context.VectorExtract(OperandType.I32, GetVec(op.Rn), 0);
  15. Operand m = GetVec(op.Rm);
  16. Operand res = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.HashChoose)), d, ne, m);
  17. context.Copy(GetVec(op.Rd), res);
  18. }
  19. public static void Sha1h_V(ArmEmitterContext context)
  20. {
  21. OpCodeSimd op = (OpCodeSimd)context.CurrOp;
  22. Operand ne = context.VectorExtract(OperandType.I32, GetVec(op.Rn), 0);
  23. Operand res = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.FixedRotate)), ne);
  24. context.Copy(GetVec(op.Rd), context.VectorCreateScalar(res));
  25. }
  26. public static void Sha1m_V(ArmEmitterContext context)
  27. {
  28. OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
  29. Operand d = GetVec(op.Rd);
  30. Operand ne = context.VectorExtract(OperandType.I32, GetVec(op.Rn), 0);
  31. Operand m = GetVec(op.Rm);
  32. Operand res = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.HashMajority)), d, ne, m);
  33. context.Copy(GetVec(op.Rd), res);
  34. }
  35. public static void Sha1p_V(ArmEmitterContext context)
  36. {
  37. OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
  38. Operand d = GetVec(op.Rd);
  39. Operand ne = context.VectorExtract(OperandType.I32, GetVec(op.Rn), 0);
  40. Operand m = GetVec(op.Rm);
  41. Operand res = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.HashParity)), d, ne, m);
  42. context.Copy(GetVec(op.Rd), res);
  43. }
  44. public static void Sha1su0_V(ArmEmitterContext context)
  45. {
  46. OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
  47. Operand d = GetVec(op.Rd);
  48. Operand n = GetVec(op.Rn);
  49. Operand m = GetVec(op.Rm);
  50. Operand res = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Sha1SchedulePart1)), d, n, m);
  51. context.Copy(GetVec(op.Rd), res);
  52. }
  53. public static void Sha1su1_V(ArmEmitterContext context)
  54. {
  55. OpCodeSimd op = (OpCodeSimd)context.CurrOp;
  56. Operand d = GetVec(op.Rd);
  57. Operand n = GetVec(op.Rn);
  58. Operand res = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Sha1SchedulePart2)), d, n);
  59. context.Copy(GetVec(op.Rd), res);
  60. }
  61. #endregion
  62. #region "Sha256"
  63. public static void Sha256h_V(ArmEmitterContext context)
  64. {
  65. OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
  66. Operand d = GetVec(op.Rd);
  67. Operand n = GetVec(op.Rn);
  68. Operand m = GetVec(op.Rm);
  69. Operand res = InstEmitSimdHashHelper.EmitSha256h(context, d, n, m, part2: false);
  70. context.Copy(GetVec(op.Rd), res);
  71. }
  72. public static void Sha256h2_V(ArmEmitterContext context)
  73. {
  74. OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
  75. Operand d = GetVec(op.Rd);
  76. Operand n = GetVec(op.Rn);
  77. Operand m = GetVec(op.Rm);
  78. Operand res = InstEmitSimdHashHelper.EmitSha256h(context, n, d, m, part2: true);
  79. context.Copy(GetVec(op.Rd), res);
  80. }
  81. public static void Sha256su0_V(ArmEmitterContext context)
  82. {
  83. OpCodeSimd op = (OpCodeSimd)context.CurrOp;
  84. Operand d = GetVec(op.Rd);
  85. Operand n = GetVec(op.Rn);
  86. Operand res = InstEmitSimdHashHelper.EmitSha256su0(context, d, n);
  87. context.Copy(GetVec(op.Rd), res);
  88. }
  89. public static void Sha256su1_V(ArmEmitterContext context)
  90. {
  91. OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp;
  92. Operand d = GetVec(op.Rd);
  93. Operand n = GetVec(op.Rn);
  94. Operand m = GetVec(op.Rm);
  95. Operand res = InstEmitSimdHashHelper.EmitSha256su1(context, d, n, m);
  96. context.Copy(GetVec(op.Rd), res);
  97. }
  98. #endregion
  99. }
  100. }