aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Translator.cs
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2019-01-24 23:59:53 -0200
committerGitHub <noreply@github.com>2019-01-24 23:59:53 -0200
commit36b9ab0e48b6893c057a954e1ef3181b452add1c (patch)
tree16a4ae56019b55d0cb61f1aa105481933ada733e /ChocolArm64/Translator.cs
parent72157e03eb09d4fb5d6d004efc2d13d3194e8c90 (diff)
Add ARM32 support on the translator (#561)
* Remove ARM32 interpreter and add ARM32 support on the translator * Nits. * Rename Cond -> Condition * Align code again * Rename Data to Alu * Enable ARM32 support and handle undefined instructions * Use the IsThumb method to check if its a thumb opcode * Remove another 32-bits check
Diffstat (limited to 'ChocolArm64/Translator.cs')
-rw-r--r--ChocolArm64/Translator.cs41
1 files changed, 8 insertions, 33 deletions
diff --git a/ChocolArm64/Translator.cs b/ChocolArm64/Translator.cs
index 47a05ba2..af2586f4 100644
--- a/ChocolArm64/Translator.cs
+++ b/ChocolArm64/Translator.cs
@@ -4,7 +4,6 @@ using ChocolArm64.Memory;
using ChocolArm64.State;
using ChocolArm64.Translation;
using System;
-using System.Reflection.Emit;
namespace ChocolArm64
{
@@ -23,34 +22,10 @@ namespace ChocolArm64
internal void ExecuteSubroutine(CpuThread thread, long position)
{
- //TODO: Both the execute A32/A64 methods should be merged on the future,
- //when both ISAs are implemented with the interpreter and JIT.
- //As of now, A32 only has a interpreter and A64 a JIT.
- CpuThreadState state = thread.ThreadState;
- MemoryManager memory = thread.Memory;
-
- if (state.ExecutionMode == ExecutionMode.AArch32)
- {
- ExecuteSubroutineA32(state, memory);
- }
- else
- {
- ExecuteSubroutineA64(state, memory, position);
- }
- }
-
- private void ExecuteSubroutineA32(CpuThreadState state, MemoryManager memory)
- {
- do
- {
- OpCode64 opCode = Decoder.DecodeOpCode(state, memory, state.R15);
-
- opCode.Interpreter(state, memory, opCode);
- }
- while (state.R15 != 0 && state.Running);
+ ExecuteSubroutine(thread.ThreadState, thread.Memory, position);
}
- private void ExecuteSubroutineA64(CpuThreadState state, MemoryManager memory, long position)
+ private void ExecuteSubroutine(CpuThreadState state, MemoryManager memory, long position)
{
do
{
@@ -61,12 +36,12 @@ namespace ChocolArm64
if (!_cache.TryGetSubroutine(position, out TranslatedSub sub))
{
- sub = TranslateTier0(state, memory, position);
+ sub = TranslateTier0(memory, position, state.GetExecutionMode());
}
if (sub.ShouldReJit())
{
- TranslateTier1(state, memory, position);
+ TranslateTier1(memory, position, state.GetExecutionMode());
}
position = sub.Execute(state, memory);
@@ -79,9 +54,9 @@ namespace ChocolArm64
return _cache.HasSubroutine(position);
}
- private TranslatedSub TranslateTier0(CpuThreadState state, MemoryManager memory, long position)
+ private TranslatedSub TranslateTier0(MemoryManager memory, long position, ExecutionMode mode)
{
- Block block = Decoder.DecodeBasicBlock(state, memory, position);
+ Block block = Decoder.DecodeBasicBlock(memory, position, mode);
ILEmitterCtx context = new ILEmitterCtx(_cache, block);
@@ -98,9 +73,9 @@ namespace ChocolArm64
return subroutine;
}
- private void TranslateTier1(CpuThreadState state, MemoryManager memory, long position)
+ private void TranslateTier1(MemoryManager memory, long position, ExecutionMode mode)
{
- Block graph = Decoder.DecodeSubroutine(_cache, state, memory, position);
+ Block graph = Decoder.DecodeSubroutine(_cache, memory, position, mode);
ILEmitterCtx context = new ILEmitterCtx(_cache, graph);