aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/Instructions/InstEmitSimdCvt.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ARMeilleure/Instructions/InstEmitSimdCvt.cs')
-rw-r--r--ARMeilleure/Instructions/InstEmitSimdCvt.cs137
1 files changed, 65 insertions, 72 deletions
diff --git a/ARMeilleure/Instructions/InstEmitSimdCvt.cs b/ARMeilleure/Instructions/InstEmitSimdCvt.cs
index 49f0365b..9696fa28 100644
--- a/ARMeilleure/Instructions/InstEmitSimdCvt.cs
+++ b/ARMeilleure/Instructions/InstEmitSimdCvt.cs
@@ -4,6 +4,7 @@ using ARMeilleure.State;
using ARMeilleure.Translation;
using System;
using System.Diagnostics;
+using System.Reflection;
using static ARMeilleure.Instructions.InstEmitHelper;
using static ARMeilleure.Instructions.InstEmitSimdHelper;
@@ -61,9 +62,7 @@ namespace ARMeilleure.Instructions
{
Operand ne = context.VectorExtract(OperandType.FP32, GetVec(op.Rn), 0);
- Delegate dlg = new _U16_F32(SoftFloat32_16.FPConvert);
-
- Operand res = context.Call(dlg, ne);
+ Operand res = context.Call(typeof(SoftFloat32_16).GetMethod(nameof(SoftFloat32_16.FPConvert)), ne);
res = context.ZeroExtend16(OperandType.I64, res);
@@ -73,9 +72,7 @@ namespace ARMeilleure.Instructions
{
Operand ne = EmitVectorExtractZx(context, op.Rn, 0, 1);
- Delegate dlg = new _F32_U16(SoftFloat16_32.FPConvert);
-
- Operand res = context.Call(dlg, ne);
+ Operand res = context.Call(typeof(SoftFloat16_32).GetMethod(nameof(SoftFloat16_32.FPConvert)), ne);
context.Copy(GetVec(op.Rd), context.VectorInsert(context.VectorZero(), res, 0));
}
@@ -161,9 +158,7 @@ namespace ARMeilleure.Instructions
{
Operand ne = EmitVectorExtractZx(context, op.Rn, part + index, 1);
- Delegate dlg = new _F32_U16(SoftFloat16_32.FPConvert);
-
- Operand e = context.Call(dlg, ne);
+ Operand e = context.Call(typeof(SoftFloat16_32).GetMethod(nameof(SoftFloat16_32.FPConvert)), ne);
res = context.VectorInsert(res, e, index);
}
@@ -189,7 +184,7 @@ namespace ARMeilleure.Instructions
}
else
{
- EmitFcvt_s_Gp(context, (op1) => EmitUnaryMathCall(context, MathF.Floor, Math.Floor, op1));
+ EmitFcvt_s_Gp(context, (op1) => EmitUnaryMathCall(context, nameof(Math.Floor), op1));
}
}
@@ -201,7 +196,7 @@ namespace ARMeilleure.Instructions
}
else
{
- EmitFcvt_u_Gp(context, (op1) => EmitUnaryMathCall(context, MathF.Floor, Math.Floor, op1));
+ EmitFcvt_u_Gp(context, (op1) => EmitUnaryMathCall(context, nameof(Math.Floor), op1));
}
}
@@ -247,9 +242,7 @@ namespace ARMeilleure.Instructions
if (sizeF == 0)
{
- Delegate dlg = new _U16_F32(SoftFloat32_16.FPConvert);
-
- Operand e = context.Call(dlg, ne);
+ Operand e = context.Call(typeof(SoftFloat32_16).GetMethod(nameof(SoftFloat32_16.FPConvert)), ne);
e = context.ZeroExtend16(OperandType.I64, e);
@@ -271,7 +264,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse41)
{
- EmitSse41Fcvts(context, FPRoundingMode.ToNearest, scalar: true);
+ EmitSse41FcvtsOpF(context, FPRoundingMode.ToNearest, scalar: true);
}
else
{
@@ -283,7 +276,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse41)
{
- EmitSse41Fcvts(context, FPRoundingMode.ToNearest, scalar: false);
+ EmitSse41FcvtsOpF(context, FPRoundingMode.ToNearest, scalar: false);
}
else
{
@@ -295,7 +288,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse41)
{
- EmitSse41Fcvtu(context, FPRoundingMode.ToNearest, scalar: true);
+ EmitSse41FcvtuOpF(context, FPRoundingMode.ToNearest, scalar: true);
}
else
{
@@ -307,7 +300,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse41)
{
- EmitSse41Fcvtu(context, FPRoundingMode.ToNearest, scalar: false);
+ EmitSse41FcvtuOpF(context, FPRoundingMode.ToNearest, scalar: false);
}
else
{
@@ -323,7 +316,7 @@ namespace ARMeilleure.Instructions
}
else
{
- EmitFcvt_s_Gp(context, (op1) => EmitUnaryMathCall(context, MathF.Ceiling, Math.Ceiling, op1));
+ EmitFcvt_s_Gp(context, (op1) => EmitUnaryMathCall(context, nameof(Math.Ceiling), op1));
}
}
@@ -335,7 +328,7 @@ namespace ARMeilleure.Instructions
}
else
{
- EmitFcvt_u_Gp(context, (op1) => EmitUnaryMathCall(context, MathF.Ceiling, Math.Ceiling, op1));
+ EmitFcvt_u_Gp(context, (op1) => EmitUnaryMathCall(context, nameof(Math.Ceiling), op1));
}
}
@@ -367,7 +360,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse41)
{
- EmitSse41Fcvts(context, FPRoundingMode.TowardsZero, scalar: true);
+ EmitSse41FcvtsOpF(context, FPRoundingMode.TowardsZero, scalar: true);
}
else
{
@@ -379,7 +372,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse41)
{
- EmitSse41Fcvts(context, FPRoundingMode.TowardsZero, scalar: false);
+ EmitSse41FcvtsOpF(context, FPRoundingMode.TowardsZero, scalar: false);
}
else
{
@@ -391,7 +384,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse41)
{
- EmitSse41Fcvts(context, FPRoundingMode.TowardsZero, scalar: false);
+ EmitSse41FcvtsOpF(context, FPRoundingMode.TowardsZero, scalar: false);
}
else
{
@@ -427,7 +420,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse41)
{
- EmitSse41Fcvtu(context, FPRoundingMode.TowardsZero, scalar: true);
+ EmitSse41FcvtuOpF(context, FPRoundingMode.TowardsZero, scalar: true);
}
else
{
@@ -439,7 +432,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse41)
{
- EmitSse41Fcvtu(context, FPRoundingMode.TowardsZero, scalar: false);
+ EmitSse41FcvtuOpF(context, FPRoundingMode.TowardsZero, scalar: false);
}
else
{
@@ -451,7 +444,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse41)
{
- EmitSse41Fcvtu(context, FPRoundingMode.TowardsZero, scalar: false);
+ EmitSse41FcvtuOpF(context, FPRoundingMode.TowardsZero, scalar: false);
}
else
{
@@ -497,7 +490,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse2)
{
- EmitSse2Scvtf(context, scalar: true);
+ EmitSse2ScvtfOp(context, scalar: true);
}
else
{
@@ -517,7 +510,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse2)
{
- EmitSse2Scvtf(context, scalar: false);
+ EmitSse2ScvtfOp(context, scalar: false);
}
else
{
@@ -529,7 +522,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse2)
{
- EmitSse2Scvtf(context, scalar: false);
+ EmitSse2ScvtfOp(context, scalar: false);
}
else
{
@@ -565,7 +558,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse2)
{
- EmitSse2Ucvtf(context, scalar: true);
+ EmitSse2UcvtfOp(context, scalar: true);
}
else
{
@@ -585,7 +578,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse2)
{
- EmitSse2Ucvtf(context, scalar: false);
+ EmitSse2UcvtfOp(context, scalar: false);
}
else
{
@@ -597,7 +590,7 @@ namespace ARMeilleure.Instructions
{
if (Optimizations.UseSse2)
{
- EmitSse2Ucvtf(context, scalar: false);
+ EmitSse2UcvtfOp(context, scalar: false);
}
else
{
@@ -628,21 +621,21 @@ namespace ARMeilleure.Instructions
if (sizeF == 0)
{
- Delegate dlg = signed
- ? (Delegate)new _S32_F32(SoftFallback.SatF32ToS32)
- : (Delegate)new _U32_F32(SoftFallback.SatF32ToU32);
+ MethodInfo info = signed
+ ? typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF32ToS32))
+ : typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF32ToU32));
- e = context.Call(dlg, e);
+ e = context.Call(info, e);
e = context.ZeroExtend32(OperandType.I64, e);
}
else /* if (sizeF == 1) */
{
- Delegate dlg = signed
- ? (Delegate)new _S64_F64(SoftFallback.SatF64ToS64)
- : (Delegate)new _U64_F64(SoftFallback.SatF64ToU64);
+ MethodInfo info = signed
+ ? typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF64ToS64))
+ : typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF64ToU64));
- e = context.Call(dlg, e);
+ e = context.Call(info, e);
}
res = EmitVectorInsert(context, res, e, index, sizeI);
@@ -676,21 +669,21 @@ namespace ARMeilleure.Instructions
if (sizeF == 0)
{
- Delegate dlg = signed
- ? (Delegate)new _S32_F32(SoftFallback.SatF32ToS32)
- : (Delegate)new _U32_F32(SoftFallback.SatF32ToU32);
+ MethodInfo info = signed
+ ? typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF32ToS32))
+ : typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF32ToU32));
- e = context.Call(dlg, e);
+ e = context.Call(info, e);
e = context.ZeroExtend32(OperandType.I64, e);
}
else /* if (sizeF == 1) */
{
- Delegate dlg = signed
- ? (Delegate)new _S64_F64(SoftFallback.SatF64ToS64)
- : (Delegate)new _U64_F64(SoftFallback.SatF64ToU64);
+ MethodInfo info = signed
+ ? typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF64ToS64))
+ : typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF64ToU64));
- e = context.Call(dlg, e);
+ e = context.Call(info, e);
}
res = EmitVectorInsert(context, res, e, index, sizeI);
@@ -809,22 +802,22 @@ namespace ARMeilleure.Instructions
value = EmitF2iFBitsMul(context, value, fBits);
+ MethodInfo info;
+
if (context.CurrOp.RegisterSize == RegisterSize.Int32)
{
- Delegate dlg = value.Type == OperandType.FP32
- ? (Delegate)new _S32_F32(SoftFallback.SatF32ToS32)
- : (Delegate)new _S32_F64(SoftFallback.SatF64ToS32);
-
- return context.Call(dlg, value);
+ info = value.Type == OperandType.FP32
+ ? typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF32ToS32))
+ : typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF64ToS32));
}
else
{
- Delegate dlg = value.Type == OperandType.FP32
- ? (Delegate)new _S64_F32(SoftFallback.SatF32ToS64)
- : (Delegate)new _S64_F64(SoftFallback.SatF64ToS64);
-
- return context.Call(dlg, value);
+ info = value.Type == OperandType.FP32
+ ? typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF32ToS64))
+ : typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF64ToS64));
}
+
+ return context.Call(info, value);
}
private static Operand EmitScalarFcvtu(ArmEmitterContext context, Operand value, int fBits)
@@ -833,22 +826,22 @@ namespace ARMeilleure.Instructions
value = EmitF2iFBitsMul(context, value, fBits);
+ MethodInfo info;
+
if (context.CurrOp.RegisterSize == RegisterSize.Int32)
{
- Delegate dlg = value.Type == OperandType.FP32
- ? (Delegate)new _U32_F32(SoftFallback.SatF32ToU32)
- : (Delegate)new _U32_F64(SoftFallback.SatF64ToU32);
-
- return context.Call(dlg, value);
+ info = value.Type == OperandType.FP32
+ ? typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF32ToU32))
+ : typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF64ToU32));
}
else
{
- Delegate dlg = value.Type == OperandType.FP32
- ? (Delegate)new _U64_F32(SoftFallback.SatF32ToU64)
- : (Delegate)new _U64_F64(SoftFallback.SatF64ToU64);
-
- return context.Call(dlg, value);
+ info = value.Type == OperandType.FP32
+ ? typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF32ToU64))
+ : typeof(SoftFallback).GetMethod(nameof(SoftFallback.SatF64ToU64));
}
+
+ return context.Call(info, value);
}
private static Operand EmitF2iFBitsMul(ArmEmitterContext context, Operand value, int fBits)
@@ -925,7 +918,7 @@ namespace ARMeilleure.Instructions
return res;
}
- private static void EmitSse2Scvtf(ArmEmitterContext context, bool scalar)
+ private static void EmitSse2ScvtfOp(ArmEmitterContext context, bool scalar)
{
OpCodeSimd op = (OpCodeSimd)context.CurrOp;
@@ -990,7 +983,7 @@ namespace ARMeilleure.Instructions
}
}
- private static void EmitSse2Ucvtf(ArmEmitterContext context, bool scalar)
+ private static void EmitSse2UcvtfOp(ArmEmitterContext context, bool scalar)
{
OpCodeSimd op = (OpCodeSimd)context.CurrOp;
@@ -1079,7 +1072,7 @@ namespace ARMeilleure.Instructions
}
}
- private static void EmitSse41Fcvts(ArmEmitterContext context, FPRoundingMode roundMode, bool scalar)
+ private static void EmitSse41FcvtsOpF(ArmEmitterContext context, FPRoundingMode roundMode, bool scalar)
{
OpCodeSimd op = (OpCodeSimd)context.CurrOp;
@@ -1170,7 +1163,7 @@ namespace ARMeilleure.Instructions
}
}
- private static void EmitSse41Fcvtu(ArmEmitterContext context, FPRoundingMode roundMode, bool scalar)
+ private static void EmitSse41FcvtuOpF(ArmEmitterContext context, FPRoundingMode roundMode, bool scalar)
{
OpCodeSimd op = (OpCodeSimd)context.CurrOp;