From 39ae075e79a7a114f3cc17ad3748738226520122 Mon Sep 17 00:00:00 2001 From: NekokoTime <38867013+NekokoTime@users.noreply.github.com> Date: Thu, 10 May 2018 18:57:23 -0300 Subject: [PATCH] Update AInstEmitSimdArithmetic.cs --- .../Instruction/AInstEmitSimdArithmetic.cs | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs b/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs index 0dfe0bd31..7e58df011 100644 --- a/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs +++ b/ChocolArm64/Instruction/AInstEmitSimdArithmetic.cs @@ -10,34 +10,38 @@ using static ChocolArm64.Instruction.AInstEmitSimdHelper; namespace ChocolArm64.Instruction { - static partial class AInstEmit + class Program { - public static void Abs_S(AILEmitterCtx Context) + unsafe static void Main(string[] args) { - EmitScalarUnaryOpSx(Context, () => EmitAbs(Context)); + Vector128 test = Sse2.SetVector128(0, 0, 0, 0, 0, 0, 0, -1); + + Console.WriteLine(ExtractShortLow(test)); + Console.WriteLine(ExtractShortLow2(test)); } - public static void Abs_V(AILEmitterCtx Context) + private static int ExtractShortLow(Vector128 Vector) { - EmitVectorUnaryOpSx(Context, () => EmitAbs(Context)); + return Sse2.Extract(Vector, 0); } - private static void EmitAbs(AILEmitterCtx Context) + private static int ExtractShortLow2(Vector128 Vector) { - AILLabel LblTrue = new AILLabel(); - - Context.Emit(OpCodes.Dup); - Context.Emit(OpCodes.Ldc_I4_0); - Context.Emit(OpCodes.Bge_S, LblTrue); - - Context.Emit(OpCodes.Neg); - - Context.MarkLabel(LblTrue); + short tmp = Sse2.Extract(Vector, 0); + return tmp; } - + } +} public static void Add_S(AILEmitterCtx Context) { - EmitScalarBinaryOpZx(Context, () => Context.Emit(OpCodes.Add)); + if (AOptimizations.UseSse2) + { + EmitSse2Call(Context, nameof(Sse2.AddScalar)); + } + else + { + EmitScalarBinaryOpZx(Context, () => Context.Emit(OpCodes.Add)); + } } public static void Add_V(AILEmitterCtx Context) @@ -1125,7 +1129,14 @@ namespace ChocolArm64.Instruction public static void Sub_S(AILEmitterCtx Context) { - EmitScalarBinaryOpZx(Context, () => Context.Emit(OpCodes.Sub)); + if (AOptimizations.UseSse2) + { + EmitSse2Call(Context, nameof(Sse2.SubtractScalar)); + } + else + { + EmitScalarBinaryOpZx(Context, () => Context.Emit(OpCodes.Sub)); + } } public static void Sub_V(AILEmitterCtx Context)