From b56e6badcd35e07bbbfea2fa9ce3041dc3f031db Mon Sep 17 00:00:00 2001 From: LDj3SNuD <35856442+LDj3SNuD@users.noreply.github.com> Date: Mon, 2 Jul 2018 02:04:06 +0200 Subject: [PATCH] Update AInstEmitSimdLogical.cs --- .../Instruction/AInstEmitSimdLogical.cs | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/ChocolArm64/Instruction/AInstEmitSimdLogical.cs b/ChocolArm64/Instruction/AInstEmitSimdLogical.cs index 163151f84d..8475a8a474 100644 --- a/ChocolArm64/Instruction/AInstEmitSimdLogical.cs +++ b/ChocolArm64/Instruction/AInstEmitSimdLogical.cs @@ -56,8 +56,9 @@ namespace ChocolArm64.Instruction AOpCodeSimdReg Op = (AOpCodeSimdReg)Context.CurrOp; int Bytes = Context.CurrOp.GetBitsCount() >> 3; + int Elems = Bytes >> Op.Size; - for (int Index = 0; Index < (Bytes >> Op.Size); Index++) + for (int Index = 0; Index < Elems; Index++) { EmitVectorExtractZx(Context, Op.Rd, Index, Op.Size); EmitVectorExtractZx(Context, Op.Rn, Index, Op.Size); @@ -145,6 +146,31 @@ namespace ChocolArm64.Instruction EmitVectorImmBinaryOp(Context, () => Context.Emit(OpCodes.Or)); } + public static void Rbit_V(AILEmitterCtx Context) + { + AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp; + + int Elems = Op.RegisterSize == ARegisterSize.SIMD128 ? 16 : 8; + + for (int Index = 0; Index < Elems; Index++) + { + EmitVectorExtractZx(Context, Op.Rn, Index, 0); + + Context.Emit(OpCodes.Conv_U4); + + ASoftFallback.EmitCall(Context, nameof(ASoftFallback.ReverseBits8)); + + Context.Emit(OpCodes.Conv_U8); + + EmitVectorInsert(Context, Op.Rd, Index, 0); + } + + if (Op.RegisterSize == ARegisterSize.SIMD64) + { + EmitVectorZeroUpper(Context, Op.Rd); + } + } + public static void Rev16_V(AILEmitterCtx Context) { EmitRev_V(Context, ContainerSize: 1); @@ -164,18 +190,17 @@ namespace ChocolArm64.Instruction { AOpCodeSimd Op = (AOpCodeSimd)Context.CurrOp; - int Bytes = Context.CurrOp.GetBitsCount() >> 3; - - int Elems = Bytes >> Op.Size; - if (Op.Size >= ContainerSize) { throw new InvalidOperationException(); } + int Bytes = Context.CurrOp.GetBitsCount() >> 3; + int Elems = Bytes >> Op.Size; + int ContainerMask = (1 << (ContainerSize - Op.Size)) - 1; - for (int Index = 0; Index < (Bytes >> Op.Size); Index++) + for (int Index = 0; Index < Elems; Index++) { int RevIndex = Index ^ ContainerMask;