From bf5a70ecd8cb1bd3a176b3990aa3cb6bf76dfcde Mon Sep 17 00:00:00 2001 From: LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com> Date: Sun, 24 Jun 2018 13:42:35 +0200 Subject: [PATCH] Add EmitSse42Crc32() --- ChocolArm64/Instruction/AInstEmitHash.cs | 50 ++++++++---------------- 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/ChocolArm64/Instruction/AInstEmitHash.cs b/ChocolArm64/Instruction/AInstEmitHash.cs index a9f413d652..69bdbc480d 100644 --- a/ChocolArm64/Instruction/AInstEmitHash.cs +++ b/ChocolArm64/Instruction/AInstEmitHash.cs @@ -33,14 +33,7 @@ namespace ChocolArm64.Instruction { if (AOptimizations.UseSse42) { - AOpCodeAluRs Op = (AOpCodeAluRs)Context.CurrOp; - - Context.EmitLdintzr(Op.Rn); - Context.EmitLdintzr(Op.Rm); - - Context.EmitCall(typeof(Sse42).GetMethod(nameof(Sse42.Crc32), new Type[] { typeof(uint), typeof(byte) })); - - Context.EmitStintzr(Op.Rd); + EmitSse42Crc32(Context, typeof(uint), typeof(byte)); } else { @@ -52,14 +45,7 @@ namespace ChocolArm64.Instruction { if (AOptimizations.UseSse42) { - AOpCodeAluRs Op = (AOpCodeAluRs)Context.CurrOp; - - Context.EmitLdintzr(Op.Rn); - Context.EmitLdintzr(Op.Rm); - - Context.EmitCall(typeof(Sse42).GetMethod(nameof(Sse42.Crc32), new Type[] { typeof(uint), typeof(ushort) })); - - Context.EmitStintzr(Op.Rd); + EmitSse42Crc32(Context, typeof(uint), typeof(ushort)); } else { @@ -71,14 +57,7 @@ namespace ChocolArm64.Instruction { if (AOptimizations.UseSse42) { - AOpCodeAluRs Op = (AOpCodeAluRs)Context.CurrOp; - - Context.EmitLdintzr(Op.Rn); - Context.EmitLdintzr(Op.Rm); - - Context.EmitCall(typeof(Sse42).GetMethod(nameof(Sse42.Crc32), new Type[] { typeof(uint), typeof(uint) })); - - Context.EmitStintzr(Op.Rd); + EmitSse42Crc32(Context, typeof(uint), typeof(uint)); } else { @@ -90,14 +69,7 @@ namespace ChocolArm64.Instruction { if (AOptimizations.UseSse42) { - AOpCodeAluRs Op = (AOpCodeAluRs)Context.CurrOp; - - Context.EmitLdintzr(Op.Rn); - Context.EmitLdintzr(Op.Rm); - - Context.EmitCall(typeof(Sse42).GetMethod(nameof(Sse42.Crc32), new Type[] { typeof(ulong), typeof(ulong) })); - - Context.EmitStintzr(Op.Rd); + EmitSse42Crc32(Context, typeof(ulong), typeof(ulong)); } else { @@ -105,6 +77,18 @@ namespace ChocolArm64.Instruction } } + private static void EmitSse42Crc32(AILEmitterCtx Context, Type TCrc, Type TData) + { + AOpCodeAluRs Op = (AOpCodeAluRs)Context.CurrOp; + + Context.EmitLdintzr(Op.Rn); + Context.EmitLdintzr(Op.Rm); + + Context.EmitCall(typeof(Sse42).GetMethod(nameof(Sse42.Crc32), new Type[] { TCrc, TData })); + + Context.EmitStintzr(Op.Rd); + } + private static void EmitCrc32(AILEmitterCtx Context, string Name) { AOpCodeAluRs Op = (AOpCodeAluRs)Context.CurrOp; @@ -128,4 +112,4 @@ namespace ChocolArm64.Instruction Context.EmitStintzr(Op.Rd); } } -} \ No newline at end of file +}