Remove all the calls to StaticCast methods (#605)
This commit is contained in:
parent
5001f78b1d
commit
504f4f4abf
9 changed files with 245 additions and 589 deletions
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue