diff options
| author | MS-DOS1999 <mgnjulien@gmail.com> | 2018-04-19 05:22:12 +0200 |
|---|---|---|
| committer | gdkchan <gab.dark.100@gmail.com> | 2018-04-19 00:22:12 -0300 |
| commit | 76a5972378b0c0980fa13fe23778a465b5e1900d (patch) | |
| tree | 8a12aa21ebe495ab3264fde886217a5afadd7db4 /ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs | |
| parent | 6e69cd9284c0ba4bb25560f83dcea298169bdf7b (diff) | |
Fix Fmin/max and add vector version, add and modifying fmin/max tests (#89)
Diffstat (limited to 'ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs')
| -rw-r--r-- | ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs | 80 |
1 files changed, 76 insertions, 4 deletions
diff --git a/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs b/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs index bc7ed890..6b65c156 100644 --- a/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs +++ b/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs @@ -211,17 +211,87 @@ namespace ChocolArm64.Instruction public static void Fmax_S(AILEmitterCtx Context) { + AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp; + EmitScalarBinaryOpF(Context, () => { - EmitBinaryMathCall(Context, nameof(Math.Max)); + if (Op.Size == 0) + { + ASoftFallback.EmitCall(Context, nameof(ASoftFallback.MaxF)); + } + else if (Op.Size == 1) + { + ASoftFallback.EmitCall(Context, nameof(ASoftFallback.Max)); + } + else + { + throw new InvalidOperationException(); + } + }); + } + + public static void Fmax_V(AILEmitterCtx Context) + { + AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp; + + EmitVectorBinaryOpF(Context, () => + { + if (Op.Size == 0) + { + ASoftFallback.EmitCall(Context, nameof(ASoftFallback.MaxF)); + } + else if (Op.Size == 1) + { + ASoftFallback.EmitCall(Context, nameof(ASoftFallback.Max)); + } + else + { + throw new InvalidOperationException(); + } }); } public static void Fmin_S(AILEmitterCtx Context) { + AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp; + EmitScalarBinaryOpF(Context, () => { - EmitBinaryMathCall(Context, nameof(Math.Min)); + if (Op.Size == 0) + { + ASoftFallback.EmitCall(Context, nameof(ASoftFallback.MinF)); + } + else if (Op.Size == 1) + { + ASoftFallback.EmitCall(Context, nameof(ASoftFallback.Min)); + } + else + { + throw new InvalidOperationException(); + } + }); + } + + public static void Fmin_V(AILEmitterCtx Context) + { + AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp; + + int SizeF = Op.Size & 1; + + EmitVectorBinaryOpF(Context, () => + { + if (SizeF == 0) + { + ASoftFallback.EmitCall(Context, nameof(ASoftFallback.MinF)); + } + else if (SizeF == 1) + { + ASoftFallback.EmitCall(Context, nameof(ASoftFallback.Min)); + } + else + { + throw new InvalidOperationException(); + } }); } @@ -510,17 +580,19 @@ namespace ChocolArm64.Instruction { AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp; + int SizeF = Op.Size & 1; + EmitVectorUnaryOpF(Context, () => { Context.EmitLdarg(ATranslatedSub.StateArgIdx); Context.EmitCallPropGet(typeof(AThreadState), nameof(AThreadState.Fpcr)); - if (Op.Size == 2) + if (SizeF == 0) { ASoftFallback.EmitCall(Context, nameof(ASoftFallback.RoundF)); } - else if (Op.Size == 3) + else if (SizeF == 1) { ASoftFallback.EmitCall(Context, nameof(ASoftFallback.Round)); } |
