InstEmitSimdHash.cs
1 using ARMeilleure.Decoders; 2 using ARMeilleure.IntermediateRepresentation; 3 using ARMeilleure.Translation; 4 5 using static ARMeilleure.Instructions.InstEmitHelper; 6 7 namespace ARMeilleure.Instructions 8 { 9 static partial class InstEmit 10 { 11 #region "Sha1" 12 public static void Sha1c_V(ArmEmitterContext context) 13 { 14 OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp; 15 16 Operand d = GetVec(op.Rd); 17 18 Operand ne = context.VectorExtract(OperandType.I32, GetVec(op.Rn), 0); 19 20 Operand m = GetVec(op.Rm); 21 22 Operand res = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.HashChoose)), d, ne, m); 23 24 context.Copy(GetVec(op.Rd), res); 25 } 26 27 public static void Sha1h_V(ArmEmitterContext context) 28 { 29 OpCodeSimd op = (OpCodeSimd)context.CurrOp; 30 31 Operand ne = context.VectorExtract(OperandType.I32, GetVec(op.Rn), 0); 32 33 Operand res = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.FixedRotate)), ne); 34 35 context.Copy(GetVec(op.Rd), context.VectorCreateScalar(res)); 36 } 37 38 public static void Sha1m_V(ArmEmitterContext context) 39 { 40 OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp; 41 42 Operand d = GetVec(op.Rd); 43 44 Operand ne = context.VectorExtract(OperandType.I32, GetVec(op.Rn), 0); 45 46 Operand m = GetVec(op.Rm); 47 48 Operand res = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.HashMajority)), d, ne, m); 49 50 context.Copy(GetVec(op.Rd), res); 51 } 52 53 public static void Sha1p_V(ArmEmitterContext context) 54 { 55 OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp; 56 57 Operand d = GetVec(op.Rd); 58 59 Operand ne = context.VectorExtract(OperandType.I32, GetVec(op.Rn), 0); 60 61 Operand m = GetVec(op.Rm); 62 63 Operand res = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.HashParity)), d, ne, m); 64 65 context.Copy(GetVec(op.Rd), res); 66 } 67 68 public static void Sha1su0_V(ArmEmitterContext context) 69 { 70 OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp; 71 72 Operand d = GetVec(op.Rd); 73 Operand n = GetVec(op.Rn); 74 Operand m = GetVec(op.Rm); 75 76 Operand res = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Sha1SchedulePart1)), d, n, m); 77 78 context.Copy(GetVec(op.Rd), res); 79 } 80 81 public static void Sha1su1_V(ArmEmitterContext context) 82 { 83 OpCodeSimd op = (OpCodeSimd)context.CurrOp; 84 85 Operand d = GetVec(op.Rd); 86 Operand n = GetVec(op.Rn); 87 88 Operand res = context.Call(typeof(SoftFallback).GetMethod(nameof(SoftFallback.Sha1SchedulePart2)), d, n); 89 90 context.Copy(GetVec(op.Rd), res); 91 } 92 #endregion 93 94 #region "Sha256" 95 public static void Sha256h_V(ArmEmitterContext context) 96 { 97 OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp; 98 99 Operand d = GetVec(op.Rd); 100 Operand n = GetVec(op.Rn); 101 Operand m = GetVec(op.Rm); 102 103 Operand res = InstEmitSimdHashHelper.EmitSha256h(context, d, n, m, part2: false); 104 105 context.Copy(GetVec(op.Rd), res); 106 } 107 108 public static void Sha256h2_V(ArmEmitterContext context) 109 { 110 OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp; 111 112 Operand d = GetVec(op.Rd); 113 Operand n = GetVec(op.Rn); 114 Operand m = GetVec(op.Rm); 115 116 Operand res = InstEmitSimdHashHelper.EmitSha256h(context, n, d, m, part2: true); 117 118 context.Copy(GetVec(op.Rd), res); 119 } 120 121 public static void Sha256su0_V(ArmEmitterContext context) 122 { 123 OpCodeSimd op = (OpCodeSimd)context.CurrOp; 124 125 Operand d = GetVec(op.Rd); 126 Operand n = GetVec(op.Rn); 127 128 Operand res = InstEmitSimdHashHelper.EmitSha256su0(context, d, n); 129 130 context.Copy(GetVec(op.Rd), res); 131 } 132 133 public static void Sha256su1_V(ArmEmitterContext context) 134 { 135 OpCodeSimdReg op = (OpCodeSimdReg)context.CurrOp; 136 137 Operand d = GetVec(op.Rd); 138 Operand n = GetVec(op.Rn); 139 Operand m = GetVec(op.Rm); 140 141 Operand res = InstEmitSimdHashHelper.EmitSha256su1(context, d, n, m); 142 143 context.Copy(GetVec(op.Rd), res); 144 } 145 #endregion 146 } 147 }