|
|
@@ -125,14 +125,7 @@ namespace ChocolArm64.Instructions
|
|
|
|
|
|
public static void Fcvtms_Gp(ILEmitterCtx context)
|
|
|
{
|
|
|
- if (Optimizations.UseSse41)
|
|
|
- {
|
|
|
- EmitSse41Fcvt_Signed_Gp(context, RoundMode.TowardsMinusInfinity, isFixed: false);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- EmitFcvt_s_Gp(context, () => EmitUnaryMathCall(context, nameof(Math.Floor)));
|
|
|
- }
|
|
|
+ EmitFcvt_s_Gp(context, () => EmitUnaryMathCall(context, nameof(Math.Floor)));
|
|
|
}
|
|
|
|
|
|
public static void Fcvtmu_Gp(ILEmitterCtx context)
|
|
|
@@ -216,7 +209,7 @@ namespace ChocolArm64.Instructions
|
|
|
{
|
|
|
if (Optimizations.UseSse41)
|
|
|
{
|
|
|
- EmitSse41Fcvt_Signed(context, RoundMode.ToNearest, isFixed: false, scalar: true);
|
|
|
+ EmitSse41Fcvt_Signed(context, RoundMode.ToNearest, scalar: true);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -228,7 +221,7 @@ namespace ChocolArm64.Instructions
|
|
|
{
|
|
|
if (Optimizations.UseSse41)
|
|
|
{
|
|
|
- EmitSse41Fcvt_Signed(context, RoundMode.ToNearest, isFixed: false, scalar: false);
|
|
|
+ EmitSse41Fcvt_Signed(context, RoundMode.ToNearest, scalar: false);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -238,26 +231,33 @@ namespace ChocolArm64.Instructions
|
|
|
|
|
|
public static void Fcvtnu_S(ILEmitterCtx context)
|
|
|
{
|
|
|
- EmitFcvtn(context, signed: false, scalar: true);
|
|
|
+ if (Optimizations.UseSse41)
|
|
|
+ {
|
|
|
+ EmitSse41Fcvt_Unsigned(context, RoundMode.ToNearest, scalar: true);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ EmitFcvtn(context, signed: false, scalar: true);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static void Fcvtnu_V(ILEmitterCtx context)
|
|
|
- {
|
|
|
- EmitFcvtn(context, signed: false, scalar: false);
|
|
|
- }
|
|
|
-
|
|
|
- public static void Fcvtps_Gp(ILEmitterCtx context)
|
|
|
{
|
|
|
if (Optimizations.UseSse41)
|
|
|
{
|
|
|
- EmitSse41Fcvt_Signed_Gp(context, RoundMode.TowardsPlusInfinity, isFixed: false);
|
|
|
+ EmitSse41Fcvt_Unsigned(context, RoundMode.ToNearest, scalar: false);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- EmitFcvt_s_Gp(context, () => EmitUnaryMathCall(context, nameof(Math.Ceiling)));
|
|
|
+ EmitFcvtn(context, signed: false, scalar: false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static void Fcvtps_Gp(ILEmitterCtx context)
|
|
|
+ {
|
|
|
+ EmitFcvt_s_Gp(context, () => EmitUnaryMathCall(context, nameof(Math.Ceiling)));
|
|
|
+ }
|
|
|
+
|
|
|
public static void Fcvtpu_Gp(ILEmitterCtx context)
|
|
|
{
|
|
|
EmitFcvt_u_Gp(context, () => EmitUnaryMathCall(context, nameof(Math.Ceiling)));
|
|
|
@@ -265,33 +265,19 @@ namespace ChocolArm64.Instructions
|
|
|
|
|
|
public static void Fcvtzs_Gp(ILEmitterCtx context)
|
|
|
{
|
|
|
- if (Optimizations.UseSse41)
|
|
|
- {
|
|
|
- EmitSse41Fcvt_Signed_Gp(context, RoundMode.TowardsZero, isFixed: false);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- EmitFcvt_s_Gp(context, () => { });
|
|
|
- }
|
|
|
+ EmitFcvt_s_Gp(context, () => { });
|
|
|
}
|
|
|
|
|
|
public static void Fcvtzs_Gp_Fixed(ILEmitterCtx context)
|
|
|
{
|
|
|
- if (Optimizations.UseSse41)
|
|
|
- {
|
|
|
- EmitSse41Fcvt_Signed_Gp(context, RoundMode.TowardsZero, isFixed: true);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- EmitFcvtzs_Gp_Fixed(context);
|
|
|
- }
|
|
|
+ EmitFcvtzs_Gp_Fixed(context);
|
|
|
}
|
|
|
|
|
|
public static void Fcvtzs_S(ILEmitterCtx context)
|
|
|
{
|
|
|
if (Optimizations.UseSse41)
|
|
|
{
|
|
|
- EmitSse41Fcvt_Signed(context, RoundMode.TowardsZero, isFixed: false, scalar: true);
|
|
|
+ EmitSse41Fcvt_Signed(context, RoundMode.TowardsZero, scalar: true);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -303,7 +289,7 @@ namespace ChocolArm64.Instructions
|
|
|
{
|
|
|
if (Optimizations.UseSse41)
|
|
|
{
|
|
|
- EmitSse41Fcvt_Signed(context, RoundMode.TowardsZero, isFixed: false, scalar: false);
|
|
|
+ EmitSse41Fcvt_Signed(context, RoundMode.TowardsZero, scalar: false);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -315,7 +301,7 @@ namespace ChocolArm64.Instructions
|
|
|
{
|
|
|
if (Optimizations.UseSse41)
|
|
|
{
|
|
|
- EmitSse41Fcvt_Signed(context, RoundMode.TowardsZero, isFixed: true, scalar: false);
|
|
|
+ EmitSse41Fcvt_Signed(context, RoundMode.TowardsZero, scalar: false);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -335,17 +321,38 @@ namespace ChocolArm64.Instructions
|
|
|
|
|
|
public static void Fcvtzu_S(ILEmitterCtx context)
|
|
|
{
|
|
|
- EmitFcvtz(context, signed: false, scalar: true);
|
|
|
+ if (Optimizations.UseSse41)
|
|
|
+ {
|
|
|
+ EmitSse41Fcvt_Unsigned(context, RoundMode.TowardsZero, scalar: true);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ EmitFcvtz(context, signed: false, scalar: true);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static void Fcvtzu_V(ILEmitterCtx context)
|
|
|
{
|
|
|
- EmitFcvtz(context, signed: false, scalar: false);
|
|
|
+ if (Optimizations.UseSse41)
|
|
|
+ {
|
|
|
+ EmitSse41Fcvt_Unsigned(context, RoundMode.TowardsZero, scalar: false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ EmitFcvtz(context, signed: false, scalar: false);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static void Fcvtzu_V_Fixed(ILEmitterCtx context)
|
|
|
{
|
|
|
- EmitFcvtz(context, signed: false, scalar: false);
|
|
|
+ if (Optimizations.UseSse41)
|
|
|
+ {
|
|
|
+ EmitSse41Fcvt_Unsigned(context, RoundMode.TowardsZero, scalar: false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ EmitFcvtz(context, signed: false, scalar: false);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public static void Scvtf_Gp(ILEmitterCtx context)
|
|
|
@@ -804,50 +811,39 @@ namespace ChocolArm64.Instructions
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void EmitSse41Fcvt_Signed_Gp(ILEmitterCtx context, RoundMode roundMode, bool isFixed)
|
|
|
+ private static void EmitSse41Fcvt_Signed(ILEmitterCtx context, RoundMode roundMode, bool scalar)
|
|
|
{
|
|
|
- OpCodeSimdCvt64 op = (OpCodeSimdCvt64)context.CurrOp;
|
|
|
+ OpCodeSimd64 op = (OpCodeSimd64)context.CurrOp;
|
|
|
|
|
|
- if (op.Size == 0)
|
|
|
+ // sizeF == ((OpCodeSimdShImm64)op).Size - 2
|
|
|
+ int sizeF = op.Size & 1;
|
|
|
+
|
|
|
+ if (sizeF == 0)
|
|
|
{
|
|
|
- Type[] typesCmpMul = new Type[] { typeof(Vector128<float>), typeof(Vector128<float>) };
|
|
|
- Type[] typesAnd = new Type[] { typeof(Vector128<long>), typeof(Vector128<long>) };
|
|
|
+ Type[] types = new Type[] { typeof(Vector128<float>), typeof(Vector128<float>) };
|
|
|
Type[] typesRndCvt = new Type[] { typeof(Vector128<float>) };
|
|
|
- Type[] typesCvt = new Type[] { typeof(Vector128<int>) };
|
|
|
Type[] typesSav = new Type[] { typeof(int) };
|
|
|
|
|
|
- //string nameCvt;
|
|
|
- int fpMaxVal;
|
|
|
-
|
|
|
- if (op.RegisterSize == RegisterSize.Int32)
|
|
|
- {
|
|
|
- //nameCvt = nameof(Sse.ConvertToInt32);
|
|
|
- fpMaxVal = 0x4F000000; // 2.14748365E9f (2147483648)
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //nameCvt = nameof(Sse.ConvertToInt64);
|
|
|
- fpMaxVal = 0x5F000000; // 9.223372E18f (9223372036854775808)
|
|
|
- }
|
|
|
-
|
|
|
context.EmitLdvec(op.Rn);
|
|
|
context.EmitLdvec(op.Rn);
|
|
|
|
|
|
- context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.CompareOrdered), typesCmpMul));
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.CompareOrdered), types));
|
|
|
|
|
|
context.EmitLdvec(op.Rn);
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.And), typesAnd));
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.And), types));
|
|
|
|
|
|
- if (isFixed)
|
|
|
+ if (op is OpCodeSimdShImm64 fixedOp)
|
|
|
{
|
|
|
- // BitConverter.Int32BitsToSingle(fpScaled) == MathF.Pow(2f, op.FBits)
|
|
|
- int fpScaled = 0x40000000 + (op.FBits - 1) * 0x800000;
|
|
|
+ int fBits = GetImmShr(fixedOp);
|
|
|
+
|
|
|
+ // BitConverter.Int32BitsToSingle(fpScaled) == MathF.Pow(2f, fBits)
|
|
|
+ int fpScaled = 0x40000000 + (fBits - 1) * 0x800000;
|
|
|
|
|
|
context.EmitLdc_I4(fpScaled);
|
|
|
context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav));
|
|
|
|
|
|
- context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.Multiply), typesCmpMul));
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.Multiply), types));
|
|
|
}
|
|
|
|
|
|
context.EmitCall(typeof(Sse41).GetMethod(GetSse41NameRnd(roundMode), typesRndCvt));
|
|
|
@@ -855,117 +851,100 @@ namespace ChocolArm64.Instructions
|
|
|
context.EmitStvectmp();
|
|
|
context.EmitLdvectmp();
|
|
|
|
|
|
- // TODO: Use Sse.ConvertToInt64 once it is fixed (in .NET Core 3.0),
|
|
|
- // remove the following if/else and uncomment the code.
|
|
|
-
|
|
|
- //context.EmitCall(typeof(Sse).GetMethod(nameCvt, typesRndCvt));
|
|
|
-
|
|
|
- if (op.RegisterSize == RegisterSize.Int32)
|
|
|
- {
|
|
|
- context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.ConvertToInt32), typesRndCvt));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.ConvertToVector128Double), typesRndCvt));
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.ConvertToInt64), new Type[] { typeof(Vector128<double>) }));
|
|
|
- }
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.ConvertToVector128Int32), typesRndCvt));
|
|
|
|
|
|
context.EmitLdvectmp();
|
|
|
|
|
|
- context.EmitLdc_I4(fpMaxVal);
|
|
|
+ context.EmitLdc_I4(0x4F000000); // 2.14748365E9f (2147483648)
|
|
|
context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav));
|
|
|
|
|
|
- context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.CompareGreaterThanOrEqual), typesCmpMul));
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.CompareGreaterThanOrEqual), types));
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.ConvertToInt32), typesCvt));
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.Xor), types));
|
|
|
|
|
|
- if (op.RegisterSize == RegisterSize.Int32)
|
|
|
+ context.EmitStvec(op.Rd);
|
|
|
+
|
|
|
+ if (scalar)
|
|
|
{
|
|
|
- context.Emit(OpCodes.Xor);
|
|
|
- context.Emit(OpCodes.Conv_U8);
|
|
|
+ EmitVectorZero32_128(context, op.Rd);
|
|
|
}
|
|
|
- else
|
|
|
+ else if (op.RegisterSize == RegisterSize.Simd64)
|
|
|
{
|
|
|
- context.Emit(OpCodes.Conv_I8);
|
|
|
- context.Emit(OpCodes.Xor);
|
|
|
+ EmitVectorZeroUpper(context, op.Rd);
|
|
|
}
|
|
|
-
|
|
|
- context.EmitStintzr(op.Rd);
|
|
|
}
|
|
|
- else /* if (op.Size == 1) */
|
|
|
+ else /* if (sizeF == 1) */
|
|
|
{
|
|
|
- Type[] typesCmpMul = new Type[] { typeof(Vector128<double>), typeof(Vector128<double>) };
|
|
|
- Type[] typesAnd = new Type[] { typeof(Vector128<long>), typeof(Vector128<long>) };
|
|
|
+ Type[] types = new Type[] { typeof(Vector128<double>), typeof(Vector128<double>) };
|
|
|
Type[] typesRndCvt = new Type[] { typeof(Vector128<double>) };
|
|
|
- Type[] typesCvt = new Type[] { typeof(Vector128<int>) };
|
|
|
+ Type[] typesSv = new Type[] { typeof(long), typeof(long) };
|
|
|
Type[] typesSav = new Type[] { typeof(long) };
|
|
|
|
|
|
- string nameCvt;
|
|
|
- long fpMaxVal;
|
|
|
-
|
|
|
- if (op.RegisterSize == RegisterSize.Int32)
|
|
|
- {
|
|
|
- nameCvt = nameof(Sse2.ConvertToInt32);
|
|
|
- fpMaxVal = 0x41E0000000000000L; // 2147483648.0000000d (2147483648)
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- nameCvt = nameof(Sse2.ConvertToInt64);
|
|
|
- fpMaxVal = 0x43E0000000000000L; // 9.2233720368547760E18d (9223372036854775808)
|
|
|
- }
|
|
|
-
|
|
|
context.EmitLdvec(op.Rn);
|
|
|
context.EmitLdvec(op.Rn);
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.CompareOrdered), typesCmpMul));
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.CompareOrdered), types));
|
|
|
|
|
|
context.EmitLdvec(op.Rn);
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.And), typesAnd));
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.And), types));
|
|
|
|
|
|
- if (isFixed)
|
|
|
+ if (op is OpCodeSimdShImm64 fixedOp)
|
|
|
{
|
|
|
- // BitConverter.Int64BitsToDouble(fpScaled) == Math.Pow(2d, op.FBits)
|
|
|
- long fpScaled = 0x4000000000000000L + (op.FBits - 1) * 0x10000000000000L;
|
|
|
+ int fBits = GetImmShr(fixedOp);
|
|
|
+
|
|
|
+ // BitConverter.Int64BitsToDouble(fpScaled) == Math.Pow(2d, fBits)
|
|
|
+ long fpScaled = 0x4000000000000000L + (fBits - 1) * 0x10000000000000L;
|
|
|
|
|
|
context.EmitLdc_I8(fpScaled);
|
|
|
context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav));
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.Multiply), typesCmpMul));
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.Multiply), types));
|
|
|
}
|
|
|
|
|
|
context.EmitCall(typeof(Sse41).GetMethod(GetSse41NameRnd(roundMode), typesRndCvt));
|
|
|
|
|
|
context.EmitStvectmp();
|
|
|
+
|
|
|
+ if (!scalar)
|
|
|
+ {
|
|
|
+ context.EmitLdvectmp();
|
|
|
+ context.EmitLdvectmp();
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.UnpackHigh), types));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.ConvertToInt64), typesRndCvt));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ context.EmitLdc_I8(0L);
|
|
|
+ }
|
|
|
+
|
|
|
context.EmitLdvectmp();
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameCvt, typesRndCvt));
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.ConvertToInt64), typesRndCvt));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetVector128), typesSv));
|
|
|
|
|
|
context.EmitLdvectmp();
|
|
|
|
|
|
- context.EmitLdc_I8(fpMaxVal);
|
|
|
+ context.EmitLdc_I8(0x43E0000000000000L); // 9.2233720368547760E18d (9223372036854775808)
|
|
|
context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav));
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.CompareGreaterThanOrEqual), typesCmpMul));
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.CompareGreaterThanOrEqual), types));
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.ConvertToInt32), typesCvt));
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.Xor), types));
|
|
|
|
|
|
- if (op.RegisterSize == RegisterSize.Int32)
|
|
|
- {
|
|
|
- context.Emit(OpCodes.Xor);
|
|
|
- context.Emit(OpCodes.Conv_U8);
|
|
|
- }
|
|
|
- else
|
|
|
+ context.EmitStvec(op.Rd);
|
|
|
+
|
|
|
+ if (scalar)
|
|
|
{
|
|
|
- context.Emit(OpCodes.Conv_I8);
|
|
|
- context.Emit(OpCodes.Xor);
|
|
|
+ EmitVectorZeroUpper(context, op.Rd);
|
|
|
}
|
|
|
-
|
|
|
- context.EmitStintzr(op.Rd);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private static void EmitSse41Fcvt_Signed(ILEmitterCtx context, RoundMode roundMode, bool isFixed, bool scalar)
|
|
|
+ private static void EmitSse41Fcvt_Unsigned(ILEmitterCtx context, RoundMode roundMode, bool scalar)
|
|
|
{
|
|
|
OpCodeSimd64 op = (OpCodeSimd64)context.CurrOp;
|
|
|
|
|
|
@@ -974,23 +953,23 @@ namespace ChocolArm64.Instructions
|
|
|
|
|
|
if (sizeF == 0)
|
|
|
{
|
|
|
- Type[] typesCmpMul = new Type[] { typeof(Vector128<float>), typeof(Vector128<float>) };
|
|
|
- Type[] typesAndXor = new Type[] { typeof(Vector128<long>), typeof(Vector128<long>) };
|
|
|
+ Type[] types = new Type[] { typeof(Vector128<float>), typeof(Vector128<float>) };
|
|
|
+ Type[] typesAdd = new Type[] { typeof(Vector128<int>), typeof(Vector128<int>) };
|
|
|
Type[] typesRndCvt = new Type[] { typeof(Vector128<float>) };
|
|
|
Type[] typesSav = new Type[] { typeof(int) };
|
|
|
|
|
|
context.EmitLdvec(op.Rn);
|
|
|
context.EmitLdvec(op.Rn);
|
|
|
|
|
|
- context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.CompareOrdered), typesCmpMul));
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.CompareOrdered), types));
|
|
|
|
|
|
context.EmitLdvec(op.Rn);
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.And), typesAndXor));
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.And), types));
|
|
|
|
|
|
- if (isFixed)
|
|
|
+ if (op is OpCodeSimdShImm64 fixedOp)
|
|
|
{
|
|
|
- int fBits = GetImmShr((OpCodeSimdShImm64)op);
|
|
|
+ int fBits = GetImmShr(fixedOp);
|
|
|
|
|
|
// BitConverter.Int32BitsToSingle(fpScaled) == MathF.Pow(2f, fBits)
|
|
|
int fpScaled = 0x40000000 + (fBits - 1) * 0x800000;
|
|
|
@@ -998,11 +977,19 @@ namespace ChocolArm64.Instructions
|
|
|
context.EmitLdc_I4(fpScaled);
|
|
|
context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav));
|
|
|
|
|
|
- context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.Multiply), typesCmpMul));
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.Multiply), types));
|
|
|
}
|
|
|
|
|
|
context.EmitCall(typeof(Sse41).GetMethod(GetSse41NameRnd(roundMode), typesRndCvt));
|
|
|
|
|
|
+ context.Emit(OpCodes.Dup);
|
|
|
+
|
|
|
+ VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleZero));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.CompareGreaterThan), types));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.And), types));
|
|
|
+
|
|
|
context.EmitStvectmp();
|
|
|
context.EmitLdvectmp();
|
|
|
|
|
|
@@ -1013,9 +1000,32 @@ namespace ChocolArm64.Instructions
|
|
|
context.EmitLdc_I4(0x4F000000); // 2.14748365E9f (2147483648)
|
|
|
context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav));
|
|
|
|
|
|
- context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.CompareGreaterThanOrEqual), typesCmpMul));
|
|
|
+ context.EmitStvectmp2();
|
|
|
+ context.EmitLdvectmp2();
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.Subtract), types));
|
|
|
+
|
|
|
+ context.Emit(OpCodes.Dup);
|
|
|
+
|
|
|
+ VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleZero));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.CompareGreaterThan), types));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.And), types));
|
|
|
+
|
|
|
+ context.EmitStvectmp();
|
|
|
+ context.EmitLdvectmp();
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.ConvertToVector128Int32), typesRndCvt));
|
|
|
+
|
|
|
+ context.EmitLdvectmp();
|
|
|
+ context.EmitLdvectmp2();
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.Xor), typesAndXor));
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.CompareGreaterThanOrEqual), types));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse).GetMethod(nameof(Sse.Xor), types));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.Add), typesAdd));
|
|
|
|
|
|
context.EmitStvec(op.Rd);
|
|
|
|
|
|
@@ -1030,24 +1040,24 @@ namespace ChocolArm64.Instructions
|
|
|
}
|
|
|
else /* if (sizeF == 1) */
|
|
|
{
|
|
|
- Type[] typesCmpMulUpk = new Type[] { typeof(Vector128<double>), typeof(Vector128<double>) };
|
|
|
- Type[] typesAndXor = new Type[] { typeof(Vector128<long>), typeof(Vector128<long>) };
|
|
|
- Type[] typesRndCvt = new Type[] { typeof(Vector128<double>) };
|
|
|
- Type[] typesSv = new Type[] { typeof(long), typeof(long) };
|
|
|
- Type[] typesSav = new Type[] { typeof(long) };
|
|
|
+ Type[] types = new Type[] { typeof(Vector128<double>), typeof(Vector128<double>) };
|
|
|
+ Type[] typesAdd = new Type[] { typeof(Vector128<long>), typeof(Vector128<long>) };
|
|
|
+ Type[] typesRndCvt = new Type[] { typeof(Vector128<double>) };
|
|
|
+ Type[] typesSv = new Type[] { typeof(long), typeof(long) };
|
|
|
+ Type[] typesSav = new Type[] { typeof(long) };
|
|
|
|
|
|
context.EmitLdvec(op.Rn);
|
|
|
context.EmitLdvec(op.Rn);
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.CompareOrdered), typesCmpMulUpk));
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.CompareOrdered), types));
|
|
|
|
|
|
context.EmitLdvec(op.Rn);
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.And), typesAndXor));
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.And), types));
|
|
|
|
|
|
- if (isFixed)
|
|
|
+ if (op is OpCodeSimdShImm64 fixedOp)
|
|
|
{
|
|
|
- int fBits = GetImmShr((OpCodeSimdShImm64)op);
|
|
|
+ int fBits = GetImmShr(fixedOp);
|
|
|
|
|
|
// BitConverter.Int64BitsToDouble(fpScaled) == Math.Pow(2d, fBits)
|
|
|
long fpScaled = 0x4000000000000000L + (fBits - 1) * 0x10000000000000L;
|
|
|
@@ -1055,19 +1065,34 @@ namespace ChocolArm64.Instructions
|
|
|
context.EmitLdc_I8(fpScaled);
|
|
|
context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav));
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.Multiply), typesCmpMulUpk));
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.Multiply), types));
|
|
|
}
|
|
|
|
|
|
context.EmitCall(typeof(Sse41).GetMethod(GetSse41NameRnd(roundMode), typesRndCvt));
|
|
|
|
|
|
+ context.Emit(OpCodes.Dup);
|
|
|
+
|
|
|
+ VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleZero));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.CompareGreaterThan), types));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.And), types));
|
|
|
+
|
|
|
context.EmitStvectmp();
|
|
|
- context.EmitLdvectmp();
|
|
|
|
|
|
- context.EmitLdvectmp();
|
|
|
+ if (!scalar)
|
|
|
+ {
|
|
|
+ context.EmitLdvectmp();
|
|
|
+ context.EmitLdvectmp();
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.UnpackHigh), typesCmpMulUpk));
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.UnpackHigh), types));
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.ConvertToInt64), typesRndCvt));
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.ConvertToInt64), typesRndCvt));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ context.EmitLdc_I8(0L);
|
|
|
+ }
|
|
|
|
|
|
context.EmitLdvectmp();
|
|
|
|
|
|
@@ -1080,9 +1105,49 @@ namespace ChocolArm64.Instructions
|
|
|
context.EmitLdc_I8(0x43E0000000000000L); // 9.2233720368547760E18d (9223372036854775808)
|
|
|
context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), typesSav));
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.CompareGreaterThanOrEqual), typesCmpMulUpk));
|
|
|
+ context.EmitStvectmp2();
|
|
|
+ context.EmitLdvectmp2();
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.Subtract), types));
|
|
|
+
|
|
|
+ context.Emit(OpCodes.Dup);
|
|
|
+
|
|
|
+ VectorHelper.EmitCall(context, nameof(VectorHelper.VectorSingleZero));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.CompareGreaterThan), types));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.And), types));
|
|
|
+
|
|
|
+ context.EmitStvectmp();
|
|
|
+
|
|
|
+ if (!scalar)
|
|
|
+ {
|
|
|
+ context.EmitLdvectmp();
|
|
|
+ context.EmitLdvectmp();
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.UnpackHigh), types));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.ConvertToInt64), typesRndCvt));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ context.EmitLdc_I8(0L);
|
|
|
+ }
|
|
|
+
|
|
|
+ context.EmitLdvectmp();
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.ConvertToInt64), typesRndCvt));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.SetVector128), typesSv));
|
|
|
+
|
|
|
+ context.EmitLdvectmp();
|
|
|
+ context.EmitLdvectmp2();
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.CompareGreaterThanOrEqual), types));
|
|
|
+
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.Xor), types));
|
|
|
|
|
|
- context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.Xor), typesAndXor));
|
|
|
+ context.EmitCall(typeof(Sse2).GetMethod(nameof(Sse2.Add), typesAdd));
|
|
|
|
|
|
context.EmitStvec(op.Rd);
|
|
|
|