From 364f2c710d104fb6b50a0357111751df4ca3b80e Mon Sep 17 00:00:00 2001 From: greggameplayer <33609333+greggameplayer@users.noreply.github.com> Date: Tue, 10 Jul 2018 18:48:05 +0200 Subject: [PATCH] add Fmaxp_V & Fminp_V functions --- .../Instruction/AInstEmitSimdArithmetic.cs | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs b/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs index 39331f965..caf6a7329 100644 --- a/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs +++ b/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs @@ -438,6 +438,49 @@ namespace ChocolArm64.Instruction } }); } + + public static void Fmaxp_V(AILEmitterCtx Context) + { + AOpCodeSimdReg Op = (AOpCodeSimdReg)Context.CurrOp; + + int SizeF = Op.Size & 1; + + int Bytes = Context.CurrOp.GetBitsCount() >> 3; + + int Elems = Bytes >> SizeF + 2; + int Half = Elems >> 1; + + for (int Index = 0; Index < Elems; Index++) + { + int Elem = (Index & (Half - 1)) << 1; + + EmitVectorExtractF(Context, Index < Half ? Op.Rn : Op.Rm, Elem + 0, SizeF); + EmitVectorExtractF(Context, Index < Half ? Op.Rn : Op.Rm, Elem + 1, SizeF); + + if (SizeF == 0) + { + AVectorHelper.EmitCall(Context, nameof(AVectorHelper.MaxF)); + } + else if (SizeF == 1) + { + AVectorHelper.EmitCall(Context, nameof(AVectorHelper.Max)); + } + else + { + throw new InvalidOperationException(); + } + + EmitVectorInsertTmpF(Context, Index, SizeF); + } + + Context.EmitLdvectmp(); + Context.EmitStvec(Op.Rd); + + if (Op.RegisterSize == ARegisterSize.SIMD64) + { + EmitVectorZeroUpper(Context, Op.Rd); + } + } public static void Fmin_S(AILEmitterCtx Context) { @@ -482,6 +525,50 @@ namespace ChocolArm64.Instruction } }); } + + public static void Fminp_V(AILEmitterCtx Context) + { + AOpCodeSimdReg Op = (AOpCodeSimdReg)Context.CurrOp; + + int SizeF = Op.Size & 1; + + int Bytes = Context.CurrOp.GetBitsCount() >> 3; + + int Elems = Bytes >> SizeF + 2; + int Half = Elems >> 1; + + for (int Index = 0; Index < Elems; Index++) + { + int Elem = (Index & (Half - 1)) << 1; + + EmitVectorExtractF(Context, Index < Half ? Op.Rn : Op.Rm, Elem + 0, SizeF); + EmitVectorExtractF(Context, Index < Half ? Op.Rn : Op.Rm, Elem + 1, SizeF); + + if (SizeF == 0) + { + AVectorHelper.EmitCall(Context, nameof(AVectorHelper.MinF)); + } + else if (SizeF == 1) + { + AVectorHelper.EmitCall(Context, nameof(AVectorHelper.Min)); + } + else + { + throw new InvalidOperationException(); + } + + EmitVectorInsertTmpF(Context, Index, SizeF); + } + + Context.EmitLdvectmp(); + Context.EmitStvec(Op.Rd); + + if (Op.RegisterSize == ARegisterSize.SIMD64) + { + EmitVectorZeroUpper(Context, Op.Rd); + } + } + public static void Fmaxnm_S(AILEmitterCtx Context) {