2018-02-17 21:06:11 +00:00
|
|
|
using ChocolArm64.Decoder;
|
|
|
|
using ChocolArm64.State;
|
|
|
|
using ChocolArm64.Translation;
|
|
|
|
using System;
|
|
|
|
using System.Reflection.Emit;
|
2018-05-11 23:10:27 +00:00
|
|
|
using System.Runtime.Intrinsics.X86;
|
2018-02-17 21:06:11 +00:00
|
|
|
|
2018-02-20 17:39:03 +00:00
|
|
|
using static ChocolArm64.Instruction.AInstEmitAluHelper;
|
2018-02-17 21:06:11 +00:00
|
|
|
using static ChocolArm64.Instruction.AInstEmitSimdHelper;
|
|
|
|
|
|
|
|
namespace ChocolArm64.Instruction
|
|
|
|
{
|
|
|
|
static partial class AInstEmit
|
|
|
|
{
|
2018-06-18 17:55:26 +00:00
|
|
|
public static void Cmeq_S(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
EmitCmp(Context, OpCodes.Beq_S, Scalar: true);
|
|
|
|
}
|
|
|
|
|
2018-02-17 21:06:11 +00:00
|
|
|
public static void Cmeq_V(AILEmitterCtx Context)
|
|
|
|
{
|
Add Sse Opt. for Cmeq_V_2D, Cmgt_V_2D (Reg). Add Sse Opt. for Crc32cb, Crc32ch, Crc32cw, Crc32cx. Add 10 simple tests for Fcmgt, Fcmge, Fcmeq, Fcmle, Fcmlt (S, V) (Reg, Zero). Add 2 Cnt_V tests. (#183)
* Add files via upload
* Add files via upload
* Add files via upload
* CPE
* Add EmitSse42Crc32()
* Update CpuTestSimdCmp.cs
* Update Pseudocode.cs
* Update Instructions.cs
* Update CpuTestSimd.cs
* Update Instructions.cs
2018-06-26 01:32:29 +00:00
|
|
|
if (Context.CurrOp is AOpCodeSimdReg Op)
|
|
|
|
{
|
|
|
|
if (Op.Size < 3 && AOptimizations.UseSse2)
|
|
|
|
{
|
Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics (#405)
* Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics, some CQ improvements
* Remove useless space
* Address PR feedback
* Revert EmitVectorZero32_128 changes
2018-09-27 02:30:21 +00:00
|
|
|
EmitSse2Op(Context, nameof(Sse2.CompareEqual));
|
Add Sse Opt. for Cmeq_V_2D, Cmgt_V_2D (Reg). Add Sse Opt. for Crc32cb, Crc32ch, Crc32cw, Crc32cx. Add 10 simple tests for Fcmgt, Fcmge, Fcmeq, Fcmle, Fcmlt (S, V) (Reg, Zero). Add 2 Cnt_V tests. (#183)
* Add files via upload
* Add files via upload
* Add files via upload
* CPE
* Add EmitSse42Crc32()
* Update CpuTestSimdCmp.cs
* Update Pseudocode.cs
* Update Instructions.cs
* Update CpuTestSimd.cs
* Update Instructions.cs
2018-06-26 01:32:29 +00:00
|
|
|
}
|
|
|
|
else if (Op.Size == 3 && AOptimizations.UseSse41)
|
|
|
|
{
|
Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics (#405)
* Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics, some CQ improvements
* Remove useless space
* Address PR feedback
* Revert EmitVectorZero32_128 changes
2018-09-27 02:30:21 +00:00
|
|
|
EmitSse41Op(Context, nameof(Sse41.CompareEqual));
|
Add Sse Opt. for Cmeq_V_2D, Cmgt_V_2D (Reg). Add Sse Opt. for Crc32cb, Crc32ch, Crc32cw, Crc32cx. Add 10 simple tests for Fcmgt, Fcmge, Fcmeq, Fcmle, Fcmlt (S, V) (Reg, Zero). Add 2 Cnt_V tests. (#183)
* Add files via upload
* Add files via upload
* Add files via upload
* CPE
* Add EmitSse42Crc32()
* Update CpuTestSimdCmp.cs
* Update Pseudocode.cs
* Update Instructions.cs
* Update CpuTestSimd.cs
* Update Instructions.cs
2018-06-26 01:32:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EmitCmp(Context, OpCodes.Beq_S, Scalar: false);
|
|
|
|
}
|
2018-05-11 23:10:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-18 17:55:26 +00:00
|
|
|
EmitCmp(Context, OpCodes.Beq_S, Scalar: false);
|
2018-05-11 23:10:27 +00:00
|
|
|
}
|
2018-02-17 21:06:11 +00:00
|
|
|
}
|
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
public static void Cmge_S(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
EmitCmp(Context, OpCodes.Bge_S, Scalar: true);
|
|
|
|
}
|
|
|
|
|
2018-02-17 21:06:11 +00:00
|
|
|
public static void Cmge_V(AILEmitterCtx Context)
|
|
|
|
{
|
2018-06-18 17:55:26 +00:00
|
|
|
EmitCmp(Context, OpCodes.Bge_S, Scalar: false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Cmgt_S(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
EmitCmp(Context, OpCodes.Bgt_S, Scalar: true);
|
2018-02-17 21:06:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void Cmgt_V(AILEmitterCtx Context)
|
|
|
|
{
|
Add Sse Opt. for Cmeq_V_2D, Cmgt_V_2D (Reg). Add Sse Opt. for Crc32cb, Crc32ch, Crc32cw, Crc32cx. Add 10 simple tests for Fcmgt, Fcmge, Fcmeq, Fcmle, Fcmlt (S, V) (Reg, Zero). Add 2 Cnt_V tests. (#183)
* Add files via upload
* Add files via upload
* Add files via upload
* CPE
* Add EmitSse42Crc32()
* Update CpuTestSimdCmp.cs
* Update Pseudocode.cs
* Update Instructions.cs
* Update CpuTestSimd.cs
* Update Instructions.cs
2018-06-26 01:32:29 +00:00
|
|
|
if (Context.CurrOp is AOpCodeSimdReg Op)
|
|
|
|
{
|
|
|
|
if (Op.Size < 3 && AOptimizations.UseSse2)
|
|
|
|
{
|
Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics (#405)
* Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics, some CQ improvements
* Remove useless space
* Address PR feedback
* Revert EmitVectorZero32_128 changes
2018-09-27 02:30:21 +00:00
|
|
|
EmitSse2Op(Context, nameof(Sse2.CompareGreaterThan));
|
Add Sse Opt. for Cmeq_V_2D, Cmgt_V_2D (Reg). Add Sse Opt. for Crc32cb, Crc32ch, Crc32cw, Crc32cx. Add 10 simple tests for Fcmgt, Fcmge, Fcmeq, Fcmle, Fcmlt (S, V) (Reg, Zero). Add 2 Cnt_V tests. (#183)
* Add files via upload
* Add files via upload
* Add files via upload
* CPE
* Add EmitSse42Crc32()
* Update CpuTestSimdCmp.cs
* Update Pseudocode.cs
* Update Instructions.cs
* Update CpuTestSimd.cs
* Update Instructions.cs
2018-06-26 01:32:29 +00:00
|
|
|
}
|
|
|
|
else if (Op.Size == 3 && AOptimizations.UseSse42)
|
|
|
|
{
|
Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics (#405)
* Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics, some CQ improvements
* Remove useless space
* Address PR feedback
* Revert EmitVectorZero32_128 changes
2018-09-27 02:30:21 +00:00
|
|
|
EmitSse42Op(Context, nameof(Sse42.CompareGreaterThan));
|
Add Sse Opt. for Cmeq_V_2D, Cmgt_V_2D (Reg). Add Sse Opt. for Crc32cb, Crc32ch, Crc32cw, Crc32cx. Add 10 simple tests for Fcmgt, Fcmge, Fcmeq, Fcmle, Fcmlt (S, V) (Reg, Zero). Add 2 Cnt_V tests. (#183)
* Add files via upload
* Add files via upload
* Add files via upload
* CPE
* Add EmitSse42Crc32()
* Update CpuTestSimdCmp.cs
* Update Pseudocode.cs
* Update Instructions.cs
* Update CpuTestSimd.cs
* Update Instructions.cs
2018-06-26 01:32:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EmitCmp(Context, OpCodes.Bgt_S, Scalar: false);
|
|
|
|
}
|
2018-05-11 23:10:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-18 17:55:26 +00:00
|
|
|
EmitCmp(Context, OpCodes.Bgt_S, Scalar: false);
|
2018-05-11 23:10:27 +00:00
|
|
|
}
|
2018-02-17 21:06:11 +00:00
|
|
|
}
|
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
public static void Cmhi_S(AILEmitterCtx Context)
|
2018-02-17 21:06:11 +00:00
|
|
|
{
|
2018-06-18 17:55:26 +00:00
|
|
|
EmitCmp(Context, OpCodes.Bgt_Un_S, Scalar: true);
|
2018-02-17 21:06:11 +00:00
|
|
|
}
|
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
public static void Cmhi_V(AILEmitterCtx Context)
|
2018-02-17 21:06:11 +00:00
|
|
|
{
|
2018-06-18 17:55:26 +00:00
|
|
|
EmitCmp(Context, OpCodes.Bgt_Un_S, Scalar: false);
|
2018-02-17 21:06:11 +00:00
|
|
|
}
|
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
public static void Cmhs_S(AILEmitterCtx Context)
|
2018-02-17 21:06:11 +00:00
|
|
|
{
|
2018-06-18 17:55:26 +00:00
|
|
|
EmitCmp(Context, OpCodes.Bge_Un_S, Scalar: true);
|
2018-02-17 21:06:11 +00:00
|
|
|
}
|
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
public static void Cmhs_V(AILEmitterCtx Context)
|
2018-02-17 21:06:11 +00:00
|
|
|
{
|
2018-06-18 17:55:26 +00:00
|
|
|
EmitCmp(Context, OpCodes.Bge_Un_S, Scalar: false);
|
2018-02-17 21:06:11 +00:00
|
|
|
}
|
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
public static void Cmle_S(AILEmitterCtx Context)
|
2018-03-02 22:21:54 +00:00
|
|
|
{
|
2018-06-18 17:55:26 +00:00
|
|
|
EmitCmp(Context, OpCodes.Ble_S, Scalar: true);
|
|
|
|
}
|
2018-03-02 22:21:54 +00:00
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
public static void Cmle_V(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
EmitCmp(Context, OpCodes.Ble_S, Scalar: false);
|
|
|
|
}
|
2018-03-02 22:21:54 +00:00
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
public static void Cmlt_S(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
EmitCmp(Context, OpCodes.Blt_S, Scalar: true);
|
|
|
|
}
|
2018-03-02 22:21:54 +00:00
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
public static void Cmlt_V(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
EmitCmp(Context, OpCodes.Blt_S, Scalar: false);
|
|
|
|
}
|
2018-03-02 22:21:54 +00:00
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
public static void Cmtst_S(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
EmitCmtst(Context, Scalar: true);
|
|
|
|
}
|
2018-03-02 22:21:54 +00:00
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
public static void Cmtst_V(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
EmitCmtst(Context, Scalar: false);
|
2018-03-02 22:21:54 +00:00
|
|
|
}
|
|
|
|
|
2018-02-17 21:06:11 +00:00
|
|
|
public static void Fccmp_S(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
AOpCodeSimdFcond Op = (AOpCodeSimdFcond)Context.CurrOp;
|
|
|
|
|
|
|
|
AILLabel LblTrue = new AILLabel();
|
|
|
|
AILLabel LblEnd = new AILLabel();
|
|
|
|
|
|
|
|
Context.EmitCondBranch(LblTrue, Op.Cond);
|
|
|
|
|
2018-02-20 17:39:03 +00:00
|
|
|
EmitSetNZCV(Context, Op.NZCV);
|
2018-02-17 21:06:11 +00:00
|
|
|
|
2018-02-20 17:39:03 +00:00
|
|
|
Context.Emit(OpCodes.Br, LblEnd);
|
2018-02-17 21:06:11 +00:00
|
|
|
|
|
|
|
Context.MarkLabel(LblTrue);
|
|
|
|
|
|
|
|
Fcmp_S(Context);
|
|
|
|
|
|
|
|
Context.MarkLabel(LblEnd);
|
|
|
|
}
|
|
|
|
|
2018-02-20 17:39:03 +00:00
|
|
|
public static void Fccmpe_S(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
Fccmp_S(Context);
|
|
|
|
}
|
|
|
|
|
2018-04-06 02:28:12 +00:00
|
|
|
public static void Fcmeq_S(AILEmitterCtx Context)
|
|
|
|
{
|
Add Sse Opt. for Cmeq_V_2D, Cmgt_V_2D (Reg). Add Sse Opt. for Crc32cb, Crc32ch, Crc32cw, Crc32cx. Add 10 simple tests for Fcmgt, Fcmge, Fcmeq, Fcmle, Fcmlt (S, V) (Reg, Zero). Add 2 Cnt_V tests. (#183)
* Add files via upload
* Add files via upload
* Add files via upload
* CPE
* Add EmitSse42Crc32()
* Update CpuTestSimdCmp.cs
* Update Pseudocode.cs
* Update Instructions.cs
* Update CpuTestSimd.cs
* Update Instructions.cs
2018-06-26 01:32:29 +00:00
|
|
|
if (Context.CurrOp is AOpCodeSimdReg && AOptimizations.UseSse
|
|
|
|
&& AOptimizations.UseSse2)
|
2018-05-11 23:10:27 +00:00
|
|
|
{
|
Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics (#405)
* Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics, some CQ improvements
* Remove useless space
* Address PR feedback
* Revert EmitVectorZero32_128 changes
2018-09-27 02:30:21 +00:00
|
|
|
EmitScalarSseOrSse2OpF(Context, nameof(Sse.CompareEqualScalar));
|
2018-05-11 23:10:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EmitScalarFcmp(Context, OpCodes.Beq_S);
|
|
|
|
}
|
2018-04-06 02:28:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void Fcmeq_V(AILEmitterCtx Context)
|
|
|
|
{
|
Add Sse Opt. for Cmeq_V_2D, Cmgt_V_2D (Reg). Add Sse Opt. for Crc32cb, Crc32ch, Crc32cw, Crc32cx. Add 10 simple tests for Fcmgt, Fcmge, Fcmeq, Fcmle, Fcmlt (S, V) (Reg, Zero). Add 2 Cnt_V tests. (#183)
* Add files via upload
* Add files via upload
* Add files via upload
* CPE
* Add EmitSse42Crc32()
* Update CpuTestSimdCmp.cs
* Update Pseudocode.cs
* Update Instructions.cs
* Update CpuTestSimd.cs
* Update Instructions.cs
2018-06-26 01:32:29 +00:00
|
|
|
if (Context.CurrOp is AOpCodeSimdReg && AOptimizations.UseSse
|
|
|
|
&& AOptimizations.UseSse2)
|
2018-05-11 23:10:27 +00:00
|
|
|
{
|
Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics (#405)
* Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics, some CQ improvements
* Remove useless space
* Address PR feedback
* Revert EmitVectorZero32_128 changes
2018-09-27 02:30:21 +00:00
|
|
|
EmitVectorSseOrSse2OpF(Context, nameof(Sse.CompareEqual));
|
2018-05-11 23:10:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EmitVectorFcmp(Context, OpCodes.Beq_S);
|
|
|
|
}
|
2018-04-06 02:28:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void Fcmge_S(AILEmitterCtx Context)
|
|
|
|
{
|
Add Sse Opt. for Cmeq_V_2D, Cmgt_V_2D (Reg). Add Sse Opt. for Crc32cb, Crc32ch, Crc32cw, Crc32cx. Add 10 simple tests for Fcmgt, Fcmge, Fcmeq, Fcmle, Fcmlt (S, V) (Reg, Zero). Add 2 Cnt_V tests. (#183)
* Add files via upload
* Add files via upload
* Add files via upload
* CPE
* Add EmitSse42Crc32()
* Update CpuTestSimdCmp.cs
* Update Pseudocode.cs
* Update Instructions.cs
* Update CpuTestSimd.cs
* Update Instructions.cs
2018-06-26 01:32:29 +00:00
|
|
|
if (Context.CurrOp is AOpCodeSimdReg && AOptimizations.UseSse
|
|
|
|
&& AOptimizations.UseSse2)
|
2018-05-11 23:10:27 +00:00
|
|
|
{
|
Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics (#405)
* Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics, some CQ improvements
* Remove useless space
* Address PR feedback
* Revert EmitVectorZero32_128 changes
2018-09-27 02:30:21 +00:00
|
|
|
EmitScalarSseOrSse2OpF(Context, nameof(Sse.CompareGreaterThanOrEqualScalar));
|
2018-05-11 23:10:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EmitScalarFcmp(Context, OpCodes.Bge_S);
|
|
|
|
}
|
2018-04-06 02:28:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void Fcmge_V(AILEmitterCtx Context)
|
|
|
|
{
|
Add Sse Opt. for Cmeq_V_2D, Cmgt_V_2D (Reg). Add Sse Opt. for Crc32cb, Crc32ch, Crc32cw, Crc32cx. Add 10 simple tests for Fcmgt, Fcmge, Fcmeq, Fcmle, Fcmlt (S, V) (Reg, Zero). Add 2 Cnt_V tests. (#183)
* Add files via upload
* Add files via upload
* Add files via upload
* CPE
* Add EmitSse42Crc32()
* Update CpuTestSimdCmp.cs
* Update Pseudocode.cs
* Update Instructions.cs
* Update CpuTestSimd.cs
* Update Instructions.cs
2018-06-26 01:32:29 +00:00
|
|
|
if (Context.CurrOp is AOpCodeSimdReg && AOptimizations.UseSse
|
|
|
|
&& AOptimizations.UseSse2)
|
2018-05-11 23:10:27 +00:00
|
|
|
{
|
Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics (#405)
* Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics, some CQ improvements
* Remove useless space
* Address PR feedback
* Revert EmitVectorZero32_128 changes
2018-09-27 02:30:21 +00:00
|
|
|
EmitVectorSseOrSse2OpF(Context, nameof(Sse.CompareGreaterThanOrEqual));
|
2018-05-11 23:10:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EmitVectorFcmp(Context, OpCodes.Bge_S);
|
|
|
|
}
|
2018-04-06 02:28:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void Fcmgt_S(AILEmitterCtx Context)
|
|
|
|
{
|
Add Sse Opt. for Cmeq_V_2D, Cmgt_V_2D (Reg). Add Sse Opt. for Crc32cb, Crc32ch, Crc32cw, Crc32cx. Add 10 simple tests for Fcmgt, Fcmge, Fcmeq, Fcmle, Fcmlt (S, V) (Reg, Zero). Add 2 Cnt_V tests. (#183)
* Add files via upload
* Add files via upload
* Add files via upload
* CPE
* Add EmitSse42Crc32()
* Update CpuTestSimdCmp.cs
* Update Pseudocode.cs
* Update Instructions.cs
* Update CpuTestSimd.cs
* Update Instructions.cs
2018-06-26 01:32:29 +00:00
|
|
|
if (Context.CurrOp is AOpCodeSimdReg && AOptimizations.UseSse
|
|
|
|
&& AOptimizations.UseSse2)
|
2018-05-11 23:10:27 +00:00
|
|
|
{
|
Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics (#405)
* Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics, some CQ improvements
* Remove useless space
* Address PR feedback
* Revert EmitVectorZero32_128 changes
2018-09-27 02:30:21 +00:00
|
|
|
EmitScalarSseOrSse2OpF(Context, nameof(Sse.CompareGreaterThanScalar));
|
2018-05-11 23:10:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EmitScalarFcmp(Context, OpCodes.Bgt_S);
|
|
|
|
}
|
2018-04-06 02:28:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void Fcmgt_V(AILEmitterCtx Context)
|
|
|
|
{
|
Add Sse Opt. for Cmeq_V_2D, Cmgt_V_2D (Reg). Add Sse Opt. for Crc32cb, Crc32ch, Crc32cw, Crc32cx. Add 10 simple tests for Fcmgt, Fcmge, Fcmeq, Fcmle, Fcmlt (S, V) (Reg, Zero). Add 2 Cnt_V tests. (#183)
* Add files via upload
* Add files via upload
* Add files via upload
* CPE
* Add EmitSse42Crc32()
* Update CpuTestSimdCmp.cs
* Update Pseudocode.cs
* Update Instructions.cs
* Update CpuTestSimd.cs
* Update Instructions.cs
2018-06-26 01:32:29 +00:00
|
|
|
if (Context.CurrOp is AOpCodeSimdReg && AOptimizations.UseSse
|
|
|
|
&& AOptimizations.UseSse2)
|
2018-05-11 23:10:27 +00:00
|
|
|
{
|
Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics (#405)
* Optimize BIC, BSL, BIT, BIF, XTN, ZIP, DUP (Gp), FMADD (Scalar) and FCVT (Scalar) using SSE intrinsics, some CQ improvements
* Remove useless space
* Address PR feedback
* Revert EmitVectorZero32_128 changes
2018-09-27 02:30:21 +00:00
|
|
|
EmitVectorSseOrSse2OpF(Context, nameof(Sse.CompareGreaterThan));
|
2018-05-11 23:10:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EmitVectorFcmp(Context, OpCodes.Bgt_S);
|
|
|
|
}
|
2018-04-06 02:28:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void Fcmle_S(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
EmitScalarFcmp(Context, OpCodes.Ble_S);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Fcmle_V(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
EmitVectorFcmp(Context, OpCodes.Ble_S);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Fcmlt_S(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
EmitScalarFcmp(Context, OpCodes.Blt_S);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Fcmlt_V(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
EmitVectorFcmp(Context, OpCodes.Blt_S);
|
|
|
|
}
|
|
|
|
|
2018-02-17 21:06:11 +00:00
|
|
|
public static void Fcmp_S(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
AOpCodeSimdReg Op = (AOpCodeSimdReg)Context.CurrOp;
|
|
|
|
|
|
|
|
bool CmpWithZero = !(Op is AOpCodeSimdFcond) ? Op.Bit3 : false;
|
|
|
|
|
2018-04-06 02:28:12 +00:00
|
|
|
//Handle NaN case.
|
|
|
|
//If any number is NaN, then NZCV = 0011.
|
2018-02-20 17:39:03 +00:00
|
|
|
if (CmpWithZero)
|
|
|
|
{
|
|
|
|
EmitNaNCheck(Context, Op.Rn);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EmitNaNCheck(Context, Op.Rn);
|
|
|
|
EmitNaNCheck(Context, Op.Rm);
|
|
|
|
|
|
|
|
Context.Emit(OpCodes.Or);
|
|
|
|
}
|
|
|
|
|
|
|
|
AILLabel LblNaN = new AILLabel();
|
|
|
|
AILLabel LblEnd = new AILLabel();
|
|
|
|
|
|
|
|
Context.Emit(OpCodes.Brtrue_S, LblNaN);
|
|
|
|
|
2018-02-17 21:06:11 +00:00
|
|
|
void EmitLoadOpers()
|
|
|
|
{
|
|
|
|
EmitVectorExtractF(Context, Op.Rn, 0, Op.Size);
|
|
|
|
|
|
|
|
if (CmpWithZero)
|
|
|
|
{
|
2018-04-06 02:28:12 +00:00
|
|
|
if (Op.Size == 0)
|
|
|
|
{
|
|
|
|
Context.EmitLdc_R4(0);
|
|
|
|
}
|
|
|
|
else /* if (SizeF == 1) */
|
|
|
|
{
|
|
|
|
Context.EmitLdc_R8(0);
|
|
|
|
}
|
2018-02-17 21:06:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EmitVectorExtractF(Context, Op.Rm, 0, Op.Size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Z = Rn == Rm
|
|
|
|
EmitLoadOpers();
|
2018-02-20 17:39:03 +00:00
|
|
|
|
2018-02-17 21:06:11 +00:00
|
|
|
Context.Emit(OpCodes.Ceq);
|
|
|
|
Context.Emit(OpCodes.Dup);
|
|
|
|
|
|
|
|
Context.EmitStflg((int)APState.ZBit);
|
|
|
|
|
|
|
|
//C = Rn >= Rm
|
|
|
|
EmitLoadOpers();
|
|
|
|
|
|
|
|
Context.Emit(OpCodes.Cgt);
|
|
|
|
Context.Emit(OpCodes.Or);
|
|
|
|
|
|
|
|
Context.EmitStflg((int)APState.CBit);
|
|
|
|
|
|
|
|
//N = Rn < Rm
|
|
|
|
EmitLoadOpers();
|
|
|
|
|
|
|
|
Context.Emit(OpCodes.Clt);
|
|
|
|
|
|
|
|
Context.EmitStflg((int)APState.NBit);
|
|
|
|
|
2018-02-20 17:39:03 +00:00
|
|
|
//V = 0
|
|
|
|
Context.EmitLdc_I4(0);
|
2018-02-17 21:06:11 +00:00
|
|
|
|
2018-02-20 17:39:03 +00:00
|
|
|
Context.EmitStflg((int)APState.VBit);
|
2018-02-17 21:06:11 +00:00
|
|
|
|
2018-02-20 17:39:03 +00:00
|
|
|
Context.Emit(OpCodes.Br_S, LblEnd);
|
2018-02-17 21:06:11 +00:00
|
|
|
|
2018-02-20 17:39:03 +00:00
|
|
|
Context.MarkLabel(LblNaN);
|
2018-02-17 21:06:11 +00:00
|
|
|
|
2018-02-20 17:39:03 +00:00
|
|
|
EmitSetNZCV(Context, 0b0011);
|
2018-02-17 21:06:11 +00:00
|
|
|
|
2018-02-20 17:39:03 +00:00
|
|
|
Context.MarkLabel(LblEnd);
|
2018-02-17 21:06:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void Fcmpe_S(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
Fcmp_S(Context);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void EmitNaNCheck(AILEmitterCtx Context, int Reg)
|
|
|
|
{
|
|
|
|
IAOpCodeSimd Op = (IAOpCodeSimd)Context.CurrOp;
|
|
|
|
|
|
|
|
EmitVectorExtractF(Context, Reg, 0, Op.Size);
|
|
|
|
|
|
|
|
if (Op.Size == 0)
|
|
|
|
{
|
|
|
|
Context.EmitCall(typeof(float), nameof(float.IsNaN));
|
|
|
|
}
|
|
|
|
else if (Op.Size == 1)
|
|
|
|
{
|
|
|
|
Context.EmitCall(typeof(double), nameof(double.IsNaN));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
throw new InvalidOperationException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
private static void EmitCmp(AILEmitterCtx Context, OpCode ILOp, bool Scalar)
|
2018-02-17 21:06:11 +00:00
|
|
|
{
|
|
|
|
AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp;
|
|
|
|
|
2018-07-14 16:13:02 +00:00
|
|
|
int Bytes = Op.GetBitsCount() >> 3;
|
2018-07-19 00:06:28 +00:00
|
|
|
int Elems = !Scalar ? Bytes >> Op.Size : 1;
|
2018-02-17 21:06:11 +00:00
|
|
|
|
|
|
|
ulong SzMask = ulong.MaxValue >> (64 - (8 << Op.Size));
|
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
for (int Index = 0; Index < Elems; Index++)
|
2018-02-17 21:06:11 +00:00
|
|
|
{
|
|
|
|
EmitVectorExtractSx(Context, Op.Rn, Index, Op.Size);
|
|
|
|
|
|
|
|
if (Op is AOpCodeSimdReg BinOp)
|
|
|
|
{
|
|
|
|
EmitVectorExtractSx(Context, BinOp.Rm, Index, Op.Size);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Context.EmitLdc_I8(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
AILLabel LblTrue = new AILLabel();
|
|
|
|
AILLabel LblEnd = new AILLabel();
|
|
|
|
|
|
|
|
Context.Emit(ILOp, LblTrue);
|
|
|
|
|
|
|
|
EmitVectorInsert(Context, Op.Rd, Index, Op.Size, 0);
|
|
|
|
|
|
|
|
Context.Emit(OpCodes.Br_S, LblEnd);
|
|
|
|
|
|
|
|
Context.MarkLabel(LblTrue);
|
|
|
|
|
|
|
|
EmitVectorInsert(Context, Op.Rd, Index, Op.Size, (long)SzMask);
|
|
|
|
|
|
|
|
Context.MarkLabel(LblEnd);
|
|
|
|
}
|
|
|
|
|
2018-06-18 17:55:26 +00:00
|
|
|
if ((Op.RegisterSize == ARegisterSize.SIMD64) || Scalar)
|
|
|
|
{
|
|
|
|
EmitVectorZeroUpper(Context, Op.Rd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void EmitCmtst(AILEmitterCtx Context, bool Scalar)
|
|
|
|
{
|
|
|
|
AOpCodeSimdReg Op = (AOpCodeSimdReg)Context.CurrOp;
|
|
|
|
|
2018-07-14 16:13:02 +00:00
|
|
|
int Bytes = Op.GetBitsCount() >> 3;
|
2018-07-19 00:06:28 +00:00
|
|
|
int Elems = !Scalar ? Bytes >> Op.Size : 1;
|
2018-06-18 17:55:26 +00:00
|
|
|
|
|
|
|
ulong SzMask = ulong.MaxValue >> (64 - (8 << Op.Size));
|
|
|
|
|
|
|
|
for (int Index = 0; Index < Elems; Index++)
|
|
|
|
{
|
|
|
|
EmitVectorExtractZx(Context, Op.Rn, Index, Op.Size);
|
|
|
|
EmitVectorExtractZx(Context, Op.Rm, Index, Op.Size);
|
|
|
|
|
|
|
|
AILLabel LblTrue = new AILLabel();
|
|
|
|
AILLabel LblEnd = new AILLabel();
|
|
|
|
|
|
|
|
Context.Emit(OpCodes.And);
|
|
|
|
|
|
|
|
Context.EmitLdc_I8(0);
|
|
|
|
|
|
|
|
Context.Emit(OpCodes.Bne_Un_S, LblTrue);
|
|
|
|
|
|
|
|
EmitVectorInsert(Context, Op.Rd, Index, Op.Size, 0);
|
|
|
|
|
|
|
|
Context.Emit(OpCodes.Br_S, LblEnd);
|
|
|
|
|
|
|
|
Context.MarkLabel(LblTrue);
|
|
|
|
|
|
|
|
EmitVectorInsert(Context, Op.Rd, Index, Op.Size, (long)SzMask);
|
|
|
|
|
|
|
|
Context.MarkLabel(LblEnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((Op.RegisterSize == ARegisterSize.SIMD64) || Scalar)
|
2018-02-17 21:06:11 +00:00
|
|
|
{
|
|
|
|
EmitVectorZeroUpper(Context, Op.Rd);
|
|
|
|
}
|
|
|
|
}
|
2018-04-06 02:28:12 +00:00
|
|
|
|
|
|
|
private static void EmitScalarFcmp(AILEmitterCtx Context, OpCode ILOp)
|
|
|
|
{
|
2018-04-06 13:20:17 +00:00
|
|
|
EmitFcmp(Context, ILOp, 0, Scalar: true);
|
2018-04-06 02:28:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void EmitVectorFcmp(AILEmitterCtx Context, OpCode ILOp)
|
|
|
|
{
|
|
|
|
AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp;
|
|
|
|
|
|
|
|
int SizeF = Op.Size & 1;
|
|
|
|
|
2018-07-14 16:13:02 +00:00
|
|
|
int Bytes = Op.GetBitsCount() >> 3;
|
2018-04-06 02:28:12 +00:00
|
|
|
|
|
|
|
for (int Index = 0; Index < Bytes >> SizeF + 2; Index++)
|
|
|
|
{
|
2018-04-06 13:20:17 +00:00
|
|
|
EmitFcmp(Context, ILOp, Index, Scalar: false);
|
2018-04-06 02:28:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Op.RegisterSize == ARegisterSize.SIMD64)
|
|
|
|
{
|
|
|
|
EmitVectorZeroUpper(Context, Op.Rd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-06 13:20:17 +00:00
|
|
|
private static void EmitFcmp(AILEmitterCtx Context, OpCode ILOp, int Index, bool Scalar)
|
2018-04-06 02:28:12 +00:00
|
|
|
{
|
|
|
|
AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp;
|
|
|
|
|
|
|
|
int SizeF = Op.Size & 1;
|
|
|
|
|
|
|
|
ulong SzMask = ulong.MaxValue >> (64 - (32 << SizeF));
|
|
|
|
|
|
|
|
EmitVectorExtractF(Context, Op.Rn, Index, SizeF);
|
|
|
|
|
|
|
|
if (Op is AOpCodeSimdReg BinOp)
|
|
|
|
{
|
|
|
|
EmitVectorExtractF(Context, BinOp.Rm, Index, SizeF);
|
|
|
|
}
|
|
|
|
else if (SizeF == 0)
|
|
|
|
{
|
|
|
|
Context.EmitLdc_R4(0);
|
|
|
|
}
|
|
|
|
else /* if (SizeF == 1) */
|
|
|
|
{
|
|
|
|
Context.EmitLdc_R8(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
AILLabel LblTrue = new AILLabel();
|
|
|
|
AILLabel LblEnd = new AILLabel();
|
|
|
|
|
|
|
|
Context.Emit(ILOp, LblTrue);
|
|
|
|
|
2018-04-06 13:20:17 +00:00
|
|
|
if (Scalar)
|
|
|
|
{
|
|
|
|
EmitVectorZeroAll(Context, Op.Rd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EmitVectorInsert(Context, Op.Rd, Index, SizeF + 2, 0);
|
|
|
|
}
|
2018-04-06 02:28:12 +00:00
|
|
|
|
|
|
|
Context.Emit(OpCodes.Br_S, LblEnd);
|
|
|
|
|
|
|
|
Context.MarkLabel(LblTrue);
|
|
|
|
|
2018-04-06 13:20:17 +00:00
|
|
|
if (Scalar)
|
|
|
|
{
|
|
|
|
EmitVectorInsert(Context, Op.Rd, Index, 3, (long)SzMask);
|
|
|
|
|
|
|
|
EmitVectorZeroUpper(Context, Op.Rd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EmitVectorInsert(Context, Op.Rd, Index, SizeF + 2, (long)SzMask);
|
|
|
|
}
|
2018-04-06 02:28:12 +00:00
|
|
|
|
|
|
|
Context.MarkLabel(LblEnd);
|
|
|
|
}
|
2018-02-17 21:06:11 +00:00
|
|
|
}
|
2018-07-19 00:06:28 +00:00
|
|
|
}
|