diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2019-02-25 20:46:34 -0300 |
|---|---|---|
| committer | jduncanator <1518948+jduncanator@users.noreply.github.com> | 2019-02-26 10:46:34 +1100 |
| commit | 504f4f4abfd34696699fbf484264404f3011ec17 (patch) | |
| tree | b264d5fcc9226d91d3e6a180d7f1e84a11bdd19e /ChocolArm64/Instructions/InstEmitSimdHelper.cs | |
| parent | 5001f78b1d07b988709dd5f5d1009ebe9b44c669 (diff) | |
Remove all the calls to StaticCast methods (#605)
Diffstat (limited to 'ChocolArm64/Instructions/InstEmitSimdHelper.cs')
| -rw-r--r-- | ChocolArm64/Instructions/InstEmitSimdHelper.cs | 113 |
1 files changed, 10 insertions, 103 deletions
diff --git a/ChocolArm64/Instructions/InstEmitSimdHelper.cs b/ChocolArm64/Instructions/InstEmitSimdHelper.cs index 5a44e1a1..b7dd09b4 100644 --- a/ChocolArm64/Instructions/InstEmitSimdHelper.cs +++ b/ChocolArm64/Instructions/InstEmitSimdHelper.cs @@ -86,13 +86,13 @@ namespace ChocolArm64.Instructions { OpCodeSimd64 op = (OpCodeSimd64)context.CurrOp; - EmitLdvecWithSignedCast(context, op.Rn, op.Size); + context.EmitLdvec(op.Rn); Type baseType = VectorIntTypesPerSizeLog2[op.Size]; if (op is OpCodeSimdReg64 binOp) { - EmitLdvecWithSignedCast(context, binOp.Rm, op.Size); + context.EmitLdvec(binOp.Rm); context.EmitCall(type.GetMethod(name, new Type[] { baseType, baseType })); } @@ -101,7 +101,7 @@ namespace ChocolArm64.Instructions context.EmitCall(type.GetMethod(name, new Type[] { baseType })); } - EmitStvecWithSignedCast(context, op.Rd, op.Size); + context.EmitStvec(op.Rd); if (op.RegisterSize == RegisterSize.Simd64) { @@ -109,80 +109,6 @@ namespace ChocolArm64.Instructions } } - public static void EmitLdvecWithSignedCast(ILEmitterCtx context, int reg, int size) - { - context.EmitLdvec(reg); - - switch (size) - { - case 0: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleToSByte)); break; - case 1: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleToInt16)); break; - case 2: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleToInt32)); break; - case 3: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleToInt64)); break; - - default: throw new ArgumentOutOfRangeException(nameof(size)); - } - } - - public static void EmitLdvecWithCastToDouble(ILEmitterCtx context, int reg) - { - context.EmitLdvec(reg); - - VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleToDouble)); - } - - public static void EmitStvecWithCastFromDouble(ILEmitterCtx context, int reg) - { - VectorHelper.EmitCall(context, nameof(VectorHelper.VectorDoubleToSingle)); - - context.EmitStvec(reg); - } - - public static void EmitLdvecWithUnsignedCast(ILEmitterCtx context, int reg, int size) - { - context.EmitLdvec(reg); - - switch (size) - { - case 0: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleToByte)); break; - case 1: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleToUInt16)); break; - case 2: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleToUInt32)); break; - case 3: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleToUInt64)); break; - - default: throw new ArgumentOutOfRangeException(nameof(size)); - } - } - - public static void EmitStvecWithSignedCast(ILEmitterCtx context, int reg, int size) - { - switch (size) - { - case 0: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSByteToSingle)); break; - case 1: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorInt16ToSingle)); break; - case 2: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorInt32ToSingle)); break; - case 3: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorInt64ToSingle)); break; - - default: throw new ArgumentOutOfRangeException(nameof(size)); - } - - context.EmitStvec(reg); - } - - public static void EmitStvecWithUnsignedCast(ILEmitterCtx context, int reg, int size) - { - switch (size) - { - case 0: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorByteToSingle)); break; - case 1: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorUInt16ToSingle)); break; - case 2: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorUInt32ToSingle)); break; - case 3: VectorHelper.EmitCall(context, nameof(VectorHelper.VectorUInt64ToSingle)); break; - - default: throw new ArgumentOutOfRangeException(nameof(size)); - } - - context.EmitStvec(reg); - } - public static void EmitScalarSseOrSse2OpF(ILEmitterCtx context, string name) { EmitSseOrSse2OpF(context, name, true); @@ -199,17 +125,7 @@ namespace ChocolArm64.Instructions int sizeF = op.Size & 1; - void Ldvec(int reg) - { - context.EmitLdvec(reg); - - if (sizeF == 1) - { - VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleToDouble)); - } - } - - Ldvec(op.Rn); + context.EmitLdvec(op.Rn); Type type; Type baseType; @@ -227,7 +143,7 @@ namespace ChocolArm64.Instructions if (op is OpCodeSimdReg64 binOp) { - Ldvec(binOp.Rm); + context.EmitLdvec(binOp.Rm); context.EmitCall(type.GetMethod(name, new Type[] { baseType, baseType })); } @@ -236,11 +152,6 @@ namespace ChocolArm64.Instructions context.EmitCall(type.GetMethod(name, new Type[] { baseType })); } - if (sizeF == 1) - { - VectorHelper.EmitCall(context, nameof(VectorHelper.VectorDoubleToSingle)); - } - context.EmitStvec(op.Rd); if (scalar) @@ -1014,12 +925,12 @@ namespace ChocolArm64.Instructions { Type[] types = new Type[] { typeof(Vector128<double>), typeof(Vector128<double>) }; - EmitLdvecWithCastToDouble(context, op.Rn); + context.EmitLdvec(op.Rn); context.Emit(OpCodes.Dup); context.EmitStvectmp(); - EmitLdvecWithCastToDouble(context, op.Rm); + context.EmitLdvec(op.Rm); context.Emit(OpCodes.Dup); context.EmitStvectmp2(); @@ -1033,7 +944,7 @@ namespace ChocolArm64.Instructions context.EmitCall(typeof(Sse2).GetMethod(name, types)); - EmitStvecWithCastFromDouble(context, op.Rd); + context.EmitStvec(op.Rd); } } @@ -1277,13 +1188,9 @@ namespace ChocolArm64.Instructions } // TSrc (16bit, 32bit, 64bit; signed, unsigned) > TDst (8bit, 16bit, 32bit; signed, unsigned). - public static void EmitSatQ( - ILEmitterCtx context, - int sizeDst, - bool signedSrc, - bool signedDst) + public static void EmitSatQ(ILEmitterCtx context, int sizeDst, bool signedSrc, bool signedDst) { - if (sizeDst > 2) + if ((uint)sizeDst > 2) { throw new ArgumentOutOfRangeException(nameof(sizeDst)); } |
