0
0
Fork 0

Minor cpu fixes

This commit is contained in:
gdkchan 2018-02-18 16:01:21 -03:00
parent 3872ae034d
commit 5a0396efaf
4 changed files with 64 additions and 22 deletions

View file

@ -60,6 +60,8 @@ namespace ChocolArm64.Instruction
Context.Emit(OpCodes.And); Context.Emit(OpCodes.And);
EmitZeroCVFlags(Context);
Context.EmitZNFlagCheck(); Context.EmitZNFlagCheck();
EmitDataStoreS(Context); EmitDataStoreS(Context);
@ -79,6 +81,8 @@ namespace ChocolArm64.Instruction
if (SetFlags) if (SetFlags)
{ {
EmitZeroCVFlags(Context);
Context.EmitZNFlagCheck(); Context.EmitZNFlagCheck();
} }
@ -335,5 +339,13 @@ namespace ChocolArm64.Instruction
Context.Emit(OpCodes.Conv_I4); Context.Emit(OpCodes.Conv_I4);
} }
} }
private static void EmitZeroCVFlags(AILEmitterCtx Context)
{
Context.EmitLdc_I4(0);
Context.EmitLdc_I4(0);
Context.EmitStflg((int)APState.VBit);
Context.EmitStflg((int)APState.CBit);
}
} }
} }

View file

@ -1,6 +1,7 @@
using ChocolArm64.Decoder; using ChocolArm64.Decoder;
using ChocolArm64.State; using ChocolArm64.State;
using ChocolArm64.Translation; using ChocolArm64.Translation;
using System;
using System.Reflection.Emit; using System.Reflection.Emit;
using static ChocolArm64.Instruction.AInstEmitMemoryHelper; using static ChocolArm64.Instruction.AInstEmitMemoryHelper;
@ -85,38 +86,65 @@ namespace ChocolArm64.Instruction
{ {
AOpCodeSimdMemSs Op = (AOpCodeSimdMemSs)Context.CurrOp; AOpCodeSimdMemSs Op = (AOpCodeSimdMemSs)Context.CurrOp;
//TODO: Replicate mode.
int Offset = 0; int Offset = 0;
void EmitMemAddress()
{
Context.EmitLdarg(ATranslatedSub.MemoryArgIdx);
Context.EmitLdint(Op.Rn);
Context.EmitLdc_I8(Offset);
Context.Emit(OpCodes.Add);
}
if (Op.Replicate)
{
//Only loads uses the replicate mode.
if (!IsLoad)
{
throw new InvalidOperationException();
}
int Bytes = Context.CurrOp.GetBitsCount() >> 3;
for (int SElem = 0; SElem < Op.SElems; SElem++)
{
int Rt = (Op.Rt + SElem) & 0x1f;
for (int Index = 0; Index < (Bytes >> Op.Size); Index++)
{
EmitMemAddress();
EmitReadZxCall(Context, Op.Size);
EmitVectorInsert(Context, Rt, Index, Op.Size);
}
if (Op.RegisterSize == ARegisterSize.SIMD64)
{
EmitVectorZeroUpper(Context, Rt);
}
Offset += 1 << Op.Size;
}
}
else
{
for (int SElem = 0; SElem < Op.SElems; SElem++) for (int SElem = 0; SElem < Op.SElems; SElem++)
{ {
int Rt = (Op.Rt + SElem) & 0x1f; int Rt = (Op.Rt + SElem) & 0x1f;
if (IsLoad) if (IsLoad)
{ {
Context.EmitLdarg(ATranslatedSub.MemoryArgIdx); EmitMemAddress();
Context.EmitLdint(Op.Rn);
Context.EmitLdc_I8(Offset);
Context.Emit(OpCodes.Add);
EmitReadZxCall(Context, Op.Size); EmitReadZxCall(Context, Op.Size);
EmitVectorInsert(Context, Rt, Op.Index, Op.Size); EmitVectorInsert(Context, Rt, Op.Index, Op.Size);
if (Op.RegisterSize == ARegisterSize.SIMD64)
{
EmitVectorZeroUpper(Context, Rt);
}
} }
else else
{ {
Context.EmitLdarg(ATranslatedSub.MemoryArgIdx); EmitMemAddress();
Context.EmitLdint(Op.Rn);
Context.EmitLdc_I8(Offset);
Context.Emit(OpCodes.Add);
EmitVectorExtractZx(Context, Rt, Op.Index, Op.Size); EmitVectorExtractZx(Context, Rt, Op.Index, Op.Size);
@ -125,6 +153,7 @@ namespace ChocolArm64.Instruction
Offset += 1 << Op.Size; Offset += 1 << Op.Size;
} }
}
if (Op.WBack) if (Op.WBack)
{ {

View file

@ -2,6 +2,7 @@
using Gal.OpenGL; using Gal.OpenGL;
using System; using System;
using System.IO; using System.IO;
using ChocolArm64;
namespace Ryujinx namespace Ryujinx
{ {