mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-30 19:12:06 +00:00
5e724cf24e
* Delete DelegateTypes.cs * Delete DelegateCache.cs * Add files via upload * Update Horizon.cs * Update Program.cs * Update MainWindow.cs * Update Aot.cs * Update RelocEntry.cs * Update Translator.cs * Update MemoryManager.cs * Update InstEmitMemoryHelper.cs * Update Delegates.cs * Nit. * Nit. * Nit. * 10 fewer MSIL bytes for us * Add comment. Nits. * Update Translator.cs * Update Aot.cs * Nits. * Opt.. * Opt.. * Opt.. * Opt.. * Allow to change compression level. * Update MemoryManager.cs * Update Translator.cs * Manage corner cases during the save phase. Nits. * Update Aot.cs * Translator response tweak for Aot disabled. Nit. * Nit. * Nits. * Create DelegateHelpers.cs * Update Delegates.cs * Nit. * Nit. * Nits. * Fix due to #784. * Fixes due to #757 & #841. * Fix due to #846. * Fix due to #847. * Use MethodInfo for managed method calls. Use IR methods instead of managed methods about Max/Min (S/U). Follow-ups & Nits. * Add missing exception messages. Reintroduce slow path for Fmov_Vi. Implement slow path for Fmov_Si. * Switch to the new folder structure. Nits. * Impl. index-based relocation information. Impl. cache file version field. * Nit. * Address gdkchan comments. Mainly: - fixed cache file corruption issue on exit; - exposed a way to disable AOT on the GUI. * Address AcK77 comment. * Address Thealexbarney, jduncanator & emmauss comments. Header magic, CpuId (FI) & Aot -> Ptc. * Adaptation to the new application reloading system. Improvements to the call system of managed methods. Follow-ups. Nits. * Get the same boot times as on master when PTC is disabled. * Profiled Aot. * A32 support (#897). * #975 support (1 of 2). * #975 support (2 of 2). * Rebase fix & nits. * Some fixes and nits (still one bug left). * One fix & nits. * Tests fix (by gdk) & nits. * Support translations not only in high quality and rejit. Nits. * Added possibility to skip translations and continue execution, using `ESC` key. * Update SettingsWindow.cs * Update GLRenderer.cs * Update Ptc.cs * Disabled Profiled PTC by default as requested in the past by gdk. * Fix rejit bug. Increased number of parallel translations. Add stack unwinding stuffs support (1 of 2). Nits. * Add stack unwinding stuffs support (2 of 2). Tuned number of parallel translations. * Restored the ability to assemble jumps with 8-bit offset when Profiled PTC is disabled or during profiling. Modifications due to rebase. Nits. * Limited profiling of the functions to be translated to the addresses belonging to the range of static objects only. * Nits. * Nits. * Update Delegates.cs * Nit. * Update InstEmitSimdArithmetic.cs * Address riperiperi comments. * Fixed the issue of unjustifiably longer boot times at the second boot than at the first boot, measured at the same time or reference point and with the same number of translated functions. * Implemented a simple redundant load/save mechanism. Halved the value of Decoder.MaxInstsPerFunction more appropriate for the current performance of the Translator. Replaced by Logger.PrintError to Logger.PrintDebug in TexturePool.cs about the supposed invalid texture format to avoid the spawn of the log. Nits. * Nit. Improved Logger.PrintError in TexturePool.cs to avoid log spawn. Added missing code for FZ handling (in output) for fp max/min instructions (slow paths). * Add configuration migration for PTC Co-authored-by: Thog <me@thog.eu>
259 lines
8.9 KiB
C#
259 lines
8.9 KiB
C#
using ARMeilleure.Decoders;
|
|
using ARMeilleure.IntermediateRepresentation;
|
|
using ARMeilleure.State;
|
|
using ARMeilleure.Translation;
|
|
using System;
|
|
using System.Reflection;
|
|
|
|
using static ARMeilleure.Instructions.InstEmitHelper;
|
|
using static ARMeilleure.IntermediateRepresentation.OperandHelper;
|
|
|
|
namespace ARMeilleure.Instructions
|
|
{
|
|
static partial class InstEmit32
|
|
{
|
|
public static void Mcr(ArmEmitterContext context)
|
|
{
|
|
OpCode32System op = (OpCode32System)context.CurrOp;
|
|
|
|
if (op.Coproc != 15)
|
|
{
|
|
InstEmit.Und(context);
|
|
|
|
return;
|
|
}
|
|
|
|
if (op.Opc1 != 0)
|
|
{
|
|
throw new NotImplementedException($"Unknown MRC Opc1 0x{op.Opc1:X16} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
MethodInfo info;
|
|
|
|
switch (op.CRn)
|
|
{
|
|
case 13: // Process and Thread Info.
|
|
if (op.CRm != 0)
|
|
{
|
|
throw new NotImplementedException($"Unknown MRC CRm 0x{op.CRm:X16} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
switch (op.Opc2)
|
|
{
|
|
case 2:
|
|
info = typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetTpidrEl032)); break;
|
|
|
|
default:
|
|
throw new NotImplementedException($"Unknown MRC Opc2 0x{op.Opc2:X16} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
break;
|
|
|
|
case 7:
|
|
switch (op.CRm) // Cache and Memory barrier.
|
|
{
|
|
case 10:
|
|
switch (op.Opc2)
|
|
{
|
|
case 5: // Data Memory Barrier Register.
|
|
return; // No-op.
|
|
|
|
default:
|
|
throw new NotImplementedException($"Unknown MRC Opc2 0x{op.Opc2:X16} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
default:
|
|
throw new NotImplementedException($"Unknown MRC CRm 0x{op.CRm:X16} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
default:
|
|
throw new NotImplementedException($"Unknown MRC 0x{op.RawOpCode:X8} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
context.Call(info, GetIntA32(context, op.Rt));
|
|
}
|
|
|
|
public static void Mrc(ArmEmitterContext context)
|
|
{
|
|
OpCode32System op = (OpCode32System)context.CurrOp;
|
|
|
|
if (op.Coproc != 15)
|
|
{
|
|
InstEmit.Und(context);
|
|
|
|
return;
|
|
}
|
|
|
|
if (op.Opc1 != 0)
|
|
{
|
|
throw new NotImplementedException($"Unknown MRC Opc1 0x{op.Opc1:X16} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
MethodInfo info;
|
|
|
|
switch (op.CRn)
|
|
{
|
|
case 13: // Process and Thread Info.
|
|
if (op.CRm != 0)
|
|
{
|
|
throw new NotImplementedException($"Unknown MRC CRm 0x{op.CRm:X16} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
switch (op.Opc2)
|
|
{
|
|
case 2:
|
|
info = typeof(NativeInterface).GetMethod(nameof(NativeInterface.GetTpidrEl032)); break;
|
|
|
|
case 3:
|
|
info = typeof(NativeInterface).GetMethod(nameof(NativeInterface.GetTpidr32)); break;
|
|
|
|
default:
|
|
throw new NotImplementedException($"Unknown MRC Opc2 0x{op.Opc2:X16} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
throw new NotImplementedException($"Unknown MRC 0x{op.RawOpCode:X8} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
if (op.Rt == RegisterAlias.Aarch32Pc)
|
|
{
|
|
// Special behavior: copy NZCV flags into APSR.
|
|
EmitSetNzcv(context, context.Call(info));
|
|
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
SetIntA32(context, op.Rt, context.Call(info));
|
|
}
|
|
}
|
|
|
|
public static void Mrrc(ArmEmitterContext context)
|
|
{
|
|
OpCode32System op = (OpCode32System)context.CurrOp;
|
|
|
|
if (op.Coproc != 15)
|
|
{
|
|
InstEmit.Und(context);
|
|
|
|
return;
|
|
}
|
|
|
|
int opc = op.MrrcOp;
|
|
|
|
MethodInfo info;
|
|
|
|
switch (op.CRm)
|
|
{
|
|
case 14: // Timer.
|
|
switch (opc)
|
|
{
|
|
case 0:
|
|
info = typeof(NativeInterface).GetMethod(nameof(NativeInterface.GetCntpctEl0)); break;
|
|
|
|
default:
|
|
throw new NotImplementedException($"Unknown MRRC Opc1 0x{opc:X16} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
throw new NotImplementedException($"Unknown MRRC 0x{op.RawOpCode:X8} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
Operand result = context.Call(info);
|
|
|
|
SetIntA32(context, op.Rt, context.ConvertI64ToI32(result));
|
|
SetIntA32(context, op.CRn, context.ConvertI64ToI32(context.ShiftRightUI(result, Const(32))));
|
|
}
|
|
|
|
public static void Nop(ArmEmitterContext context) { }
|
|
|
|
public static void Vmrs(ArmEmitterContext context)
|
|
{
|
|
OpCode32SimdSpecial op = (OpCode32SimdSpecial)context.CurrOp;
|
|
|
|
if (op.Rt == RegisterAlias.Aarch32Pc && op.Sreg == 0b0001)
|
|
{
|
|
// Special behavior: copy NZCV flags into APSR.
|
|
SetFlag(context, PState.VFlag, GetFpFlag(FPState.VFlag));
|
|
SetFlag(context, PState.CFlag, GetFpFlag(FPState.CFlag));
|
|
SetFlag(context, PState.ZFlag, GetFpFlag(FPState.ZFlag));
|
|
SetFlag(context, PState.NFlag, GetFpFlag(FPState.NFlag));
|
|
|
|
return;
|
|
}
|
|
|
|
MethodInfo info;
|
|
|
|
switch (op.Sreg)
|
|
{
|
|
case 0b0000: // FPSID
|
|
throw new NotImplementedException("Supervisor Only");
|
|
case 0b0001: // FPSCR
|
|
info = typeof(NativeInterface).GetMethod(nameof(NativeInterface.GetFpscr)); break;
|
|
case 0b0101: // MVFR2
|
|
throw new NotImplementedException("MVFR2");
|
|
case 0b0110: // MVFR1
|
|
throw new NotImplementedException("MVFR1");
|
|
case 0b0111: // MVFR0
|
|
throw new NotImplementedException("MVFR0");
|
|
case 0b1000: // FPEXC
|
|
throw new NotImplementedException("Supervisor Only");
|
|
default:
|
|
throw new NotImplementedException($"Unknown VMRS 0x{op.RawOpCode:X8} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
SetIntA32(context, op.Rt, context.Call(info));
|
|
}
|
|
|
|
public static void Vmsr(ArmEmitterContext context)
|
|
{
|
|
OpCode32SimdSpecial op = (OpCode32SimdSpecial)context.CurrOp;
|
|
|
|
MethodInfo info;
|
|
|
|
switch (op.Sreg)
|
|
{
|
|
case 0b0000: // FPSID
|
|
throw new NotImplementedException("Supervisor Only");
|
|
case 0b0001: // FPSCR
|
|
info = typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpscr)); break;
|
|
case 0b0101: // MVFR2
|
|
throw new NotImplementedException("MVFR2");
|
|
case 0b0110: // MVFR1
|
|
throw new NotImplementedException("MVFR1");
|
|
case 0b0111: // MVFR0
|
|
throw new NotImplementedException("MVFR0");
|
|
case 0b1000: // FPEXC
|
|
throw new NotImplementedException("Supervisor Only");
|
|
default:
|
|
throw new NotImplementedException($"Unknown VMSR 0x{op.RawOpCode:X8} at 0x{op.Address:X16}.");
|
|
}
|
|
|
|
context.Call(info, GetIntA32(context, op.Rt));
|
|
}
|
|
|
|
private static void EmitSetNzcv(ArmEmitterContext context, Operand t)
|
|
{
|
|
Operand v = context.ShiftRightUI(t, Const((int)PState.VFlag));
|
|
v = context.BitwiseAnd(v, Const(1));
|
|
|
|
Operand c = context.ShiftRightUI(t, Const((int)PState.CFlag));
|
|
c = context.BitwiseAnd(c, Const(1));
|
|
|
|
Operand z = context.ShiftRightUI(t, Const((int)PState.ZFlag));
|
|
z = context.BitwiseAnd(z, Const(1));
|
|
|
|
Operand n = context.ShiftRightUI(t, Const((int)PState.NFlag));
|
|
n = context.BitwiseAnd(n, Const(1));
|
|
|
|
SetFlag(context, PState.VFlag, v);
|
|
SetFlag(context, PState.CFlag, c);
|
|
SetFlag(context, PState.ZFlag, z);
|
|
SetFlag(context, PState.NFlag, n);
|
|
}
|
|
}
|
|
}
|