diff options
Diffstat (limited to 'ARMeilleure/Instructions/InstEmitSystem32.cs')
-rw-r--r-- | ARMeilleure/Instructions/InstEmitSystem32.cs | 71 |
1 files changed, 47 insertions, 24 deletions
diff --git a/ARMeilleure/Instructions/InstEmitSystem32.cs b/ARMeilleure/Instructions/InstEmitSystem32.cs index ebf829a0..14f73c3a 100644 --- a/ARMeilleure/Instructions/InstEmitSystem32.cs +++ b/ARMeilleure/Instructions/InstEmitSystem32.cs @@ -3,6 +3,7 @@ using ARMeilleure.IntermediateRepresentation; using ARMeilleure.State; using ARMeilleure.Translation; using System; +using System.Reflection; using static ARMeilleure.Instructions.InstEmitHelper; using static ARMeilleure.IntermediateRepresentation.OperandHelper; @@ -18,6 +19,7 @@ namespace ARMeilleure.Instructions if (op.Coproc != 15) { InstEmit.Und(context); + return; } @@ -26,7 +28,8 @@ namespace ARMeilleure.Instructions throw new NotImplementedException($"Unknown MRC Opc1 0x{op.Opc1:X16} at 0x{op.Address:X16}."); } - Delegate dlg; + MethodInfo info; + switch (op.CRn) { case 13: // Process and Thread Info. @@ -34,13 +37,16 @@ namespace ARMeilleure.Instructions { throw new NotImplementedException($"Unknown MRC CRm 0x{op.CRm:X16} at 0x{op.Address:X16}."); } + switch (op.Opc2) { case 2: - dlg = new _Void_U32(NativeInterface.SetTpidrEl032); break; + 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: @@ -51,18 +57,20 @@ namespace ARMeilleure.Instructions { 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: + default: throw new NotImplementedException($"Unknown MRC 0x{op.RawOpCode:X8} at 0x{op.Address:X16}."); } - context.Call(dlg, GetIntA32(context, op.Rt)); + context.Call(info, GetIntA32(context, op.Rt)); } public static void Mrc(ArmEmitterContext context) @@ -72,6 +80,7 @@ namespace ARMeilleure.Instructions if (op.Coproc != 15) { InstEmit.Und(context); + return; } @@ -80,7 +89,8 @@ namespace ARMeilleure.Instructions throw new NotImplementedException($"Unknown MRC Opc1 0x{op.Opc1:X16} at 0x{op.Address:X16}."); } - Delegate dlg; + MethodInfo info; + switch (op.CRn) { case 13: // Process and Thread Info. @@ -88,30 +98,35 @@ namespace ARMeilleure.Instructions { throw new NotImplementedException($"Unknown MRC CRm 0x{op.CRm:X16} at 0x{op.Address:X16}."); } + switch (op.Opc2) { case 2: - dlg = new _U32(NativeInterface.GetTpidrEl032); break; + info = typeof(NativeInterface).GetMethod(nameof(NativeInterface.GetTpidrEl032)); break; + case 3: - dlg = new _U32(NativeInterface.GetTpidr32); break; + 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: + + 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(dlg)); - + EmitSetNzcv(context, context.Call(info)); + return; } else { - SetIntA32(context, op.Rt, context.Call(dlg)); + SetIntA32(context, op.Rt, context.Call(info)); } } @@ -122,28 +137,33 @@ namespace ARMeilleure.Instructions if (op.Coproc != 15) { InstEmit.Und(context); + return; } - var opc = op.MrrcOp; + int opc = op.MrrcOp; + + MethodInfo info; - Delegate dlg; switch (op.CRm) { case 14: // Timer. switch (opc) { case 0: - dlg = new _U64(NativeInterface.GetCntpctEl0); break; + 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: + + default: throw new NotImplementedException($"Unknown MRRC 0x{op.RawOpCode:X8} at 0x{op.Address:X16}."); } - Operand result = context.Call(dlg); + Operand result = context.Call(info); SetIntA32(context, op.Rt, context.ConvertI64ToI32(result)); SetIntA32(context, op.CRn, context.ConvertI64ToI32(context.ShiftRightUI(result, Const(32)))); @@ -162,16 +182,18 @@ namespace ARMeilleure.Instructions SetFlag(context, PState.CFlag, GetFpFlag(FPState.CFlag)); SetFlag(context, PState.ZFlag, GetFpFlag(FPState.ZFlag)); SetFlag(context, PState.NFlag, GetFpFlag(FPState.NFlag)); + return; } - Delegate dlg; + MethodInfo info; + switch (op.Sreg) { case 0b0000: // FPSID throw new NotImplementedException("Supervisor Only"); case 0b0001: // FPSCR - dlg = new _U32(NativeInterface.GetFpscr); break; + info = typeof(NativeInterface).GetMethod(nameof(NativeInterface.GetFpscr)); break; case 0b0101: // MVFR2 throw new NotImplementedException("MVFR2"); case 0b0110: // MVFR1 @@ -180,24 +202,25 @@ namespace ARMeilleure.Instructions throw new NotImplementedException("MVFR0"); case 0b1000: // FPEXC throw new NotImplementedException("Supervisor Only"); - default: + default: throw new NotImplementedException($"Unknown VMRS 0x{op.RawOpCode:X8} at 0x{op.Address:X16}."); } - SetIntA32(context, op.Rt, context.Call(dlg)); + SetIntA32(context, op.Rt, context.Call(info)); } public static void Vmsr(ArmEmitterContext context) { OpCode32SimdSpecial op = (OpCode32SimdSpecial)context.CurrOp; - Delegate dlg; + MethodInfo info; + switch (op.Sreg) { case 0b0000: // FPSID throw new NotImplementedException("Supervisor Only"); case 0b0001: // FPSCR - dlg = new _Void_U32(NativeInterface.SetFpscr); break; + info = typeof(NativeInterface).GetMethod(nameof(NativeInterface.SetFpscr)); break; case 0b0101: // MVFR2 throw new NotImplementedException("MVFR2"); case 0b0110: // MVFR1 @@ -206,11 +229,11 @@ namespace ARMeilleure.Instructions throw new NotImplementedException("MVFR0"); case 0b1000: // FPEXC throw new NotImplementedException("Supervisor Only"); - default: + default: throw new NotImplementedException($"Unknown VMSR 0x{op.RawOpCode:X8} at 0x{op.Address:X16}."); } - context.Call(dlg, GetIntA32(context, op.Rt)); + context.Call(info, GetIntA32(context, op.Rt)); } private static void EmitSetNzcv(ArmEmitterContext context, Operand t) |