From b2549d83bfb2716035a6d01e988c128a7135c44a Mon Sep 17 00:00:00 2001 From: gdkchan Date: Sat, 24 Mar 2018 00:23:42 -0300 Subject: [PATCH] Add FNMADD instruction --- ChocolArm64/AOpCodeTable.cs | 1 + .../Instruction/AInstEmitSimdArithmetic.cs | 71 ++++++++++++------- 2 files changed, 47 insertions(+), 25 deletions(-) diff --git a/ChocolArm64/AOpCodeTable.cs b/ChocolArm64/AOpCodeTable.cs index 395929d0..bd19bc27 100644 --- a/ChocolArm64/AOpCodeTable.cs +++ b/ChocolArm64/AOpCodeTable.cs @@ -206,6 +206,7 @@ namespace ChocolArm64 Set("0>1011100<1xxxxx110111xxxxxxxxxx", AInstEmit.Fmul_V, typeof(AOpCodeSimdReg)); Set("0x0011111< Context.Emit(OpCodes.Neg)); } - public static void Fnmul_S(AILEmitterCtx Context) + public static void Fnmadd_S(AILEmitterCtx Context) { - EmitScalarBinaryOpF(Context, () => - { - Context.Emit(OpCodes.Mul); - Context.Emit(OpCodes.Neg); - }); + AOpCodeSimdReg Op = (AOpCodeSimdReg)Context.CurrOp; + + int SizeF = Op.Size & 1; + + EmitVectorExtractF(Context, Op.Rn, 0, SizeF); + + Context.Emit(OpCodes.Neg); + + EmitVectorExtractF(Context, Op.Rm, 0, SizeF); + + Context.Emit(OpCodes.Mul); + + EmitVectorExtractF(Context, Op.Ra, 0, SizeF); + + Context.Emit(OpCodes.Sub); + + EmitScalarSetF(Context, Op.Rd, SizeF); } public static void Fnmsub_S(AILEmitterCtx Context) @@ -248,6 +260,34 @@ namespace ChocolArm64.Instruction EmitScalarSetF(Context, Op.Rd, SizeF); } + public static void Fnmul_S(AILEmitterCtx Context) + { + EmitScalarBinaryOpF(Context, () => + { + Context.Emit(OpCodes.Mul); + Context.Emit(OpCodes.Neg); + }); + } + + public static void Frinta_S(AILEmitterCtx Context) + { + AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp; + + EmitVectorExtractF(Context, Op.Rn, 0, Op.Size); + + EmitRoundMathCall(Context, MidpointRounding.AwayFromZero); + + EmitScalarSetF(Context, Op.Rd, Op.Size); + } + + public static void Frinta_V(AILEmitterCtx Context) + { + EmitVectorUnaryOpF(Context, () => + { + EmitRoundMathCall(Context, MidpointRounding.AwayFromZero); + }); + } + public static void Frinti_S(AILEmitterCtx Context) { AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp; @@ -298,25 +338,6 @@ namespace ChocolArm64.Instruction }); } - public static void Frinta_S(AILEmitterCtx Context) - { - AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp; - - EmitVectorExtractF(Context, Op.Rn, 0, Op.Size); - - EmitRoundMathCall(Context, MidpointRounding.AwayFromZero); - - EmitScalarSetF(Context, Op.Rd, Op.Size); - } - - public static void Frinta_V(AILEmitterCtx Context) - { - EmitVectorUnaryOpF(Context, () => - { - EmitRoundMathCall(Context, MidpointRounding.AwayFromZero); - }); - } - public static void Frintm_S(AILEmitterCtx Context) { EmitScalarUnaryOpF(Context, () =>