aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Translation
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-02-25 22:14:58 -0300
committergdkchan <gab.dark.100@gmail.com>2018-02-25 22:14:58 -0300
commit950011c90fe28fe9edd8ebe0d0a771f6adcff7a1 (patch)
tree407416f5ee2a157d06ce2fa267671b7e2d1e0946 /ChocolArm64/Translation
parente174100474fcfe484cc8e93c4db447886096615d (diff)
Added initial support for function names from symbol table on the cpu with tracing, fix wrong ImageEnd on executables with MOD0, fix issue on the CPU on input elimination for instruction with more than one register store
Diffstat (limited to 'ChocolArm64/Translation')
-rw-r--r--ChocolArm64/Translation/AILBarrier.cs7
-rw-r--r--ChocolArm64/Translation/AILBlock.cs27
-rw-r--r--ChocolArm64/Translation/AILEmitterCtx.cs10
-rw-r--r--ChocolArm64/Translation/AILOpCodeLoad.cs6
-rw-r--r--ChocolArm64/Translation/AILOpCodeStore.cs4
-rw-r--r--ChocolArm64/Translation/ALocalAlloc.cs8
6 files changed, 39 insertions, 23 deletions
diff --git a/ChocolArm64/Translation/AILBarrier.cs b/ChocolArm64/Translation/AILBarrier.cs
new file mode 100644
index 00000000..25b08de3
--- /dev/null
+++ b/ChocolArm64/Translation/AILBarrier.cs
@@ -0,0 +1,7 @@
+namespace ChocolArm64.Translation
+{
+ struct AILBarrier : IAILEmit
+ {
+ public void Emit(AILEmitter Context) { }
+ }
+} \ No newline at end of file
diff --git a/ChocolArm64/Translation/AILBlock.cs b/ChocolArm64/Translation/AILBlock.cs
index bed195aa..e580e09c 100644
--- a/ChocolArm64/Translation/AILBlock.cs
+++ b/ChocolArm64/Translation/AILBlock.cs
@@ -4,11 +4,13 @@ namespace ChocolArm64.Translation
{
class AILBlock : IAILEmit
{
- public long IntInputs { get; private set; }
- public long IntOutputs { get; private set; }
+ public long IntInputs { get; private set; }
+ public long IntOutputs { get; private set; }
+ public long IntAwOutputs { get; private set; }
- public long VecInputs { get; private set; }
- public long VecOutputs { get; private set; }
+ public long VecInputs { get; private set; }
+ public long VecOutputs { get; private set; }
+ public long VecAwOutputs { get; private set; }
public bool HasStateStore { get; private set; }
@@ -24,13 +26,22 @@ namespace ChocolArm64.Translation
public void Add(IAILEmit ILEmitter)
{
- if (ILEmitter is AILOpCodeLoad Ld && AILEmitter.IsRegIndex(Ld.Index))
+ if (ILEmitter is AILBarrier)
+ {
+ //Those barriers are used to separate the groups of CIL
+ //opcodes emitted by each ARM instruction.
+ //We can only consider the new outputs for doing input elimination
+ //after all the CIL opcodes used by the instruction being emitted.
+ IntAwOutputs = IntOutputs;
+ VecAwOutputs = VecOutputs;
+ }
+ else if (ILEmitter is AILOpCodeLoad Ld && AILEmitter.IsRegIndex(Ld.Index))
{
switch (Ld.IoType)
{
- case AIoType.Flag: IntInputs |= ((1L << Ld.Index) << 32) & ~IntOutputs; break;
- case AIoType.Int: IntInputs |= (1L << Ld.Index) & ~IntOutputs; break;
- case AIoType.Vector: VecInputs |= (1L << Ld.Index) & ~VecOutputs; break;
+ case AIoType.Flag: IntInputs |= ((1L << Ld.Index) << 32) & ~IntAwOutputs; break;
+ case AIoType.Int: IntInputs |= (1L << Ld.Index) & ~IntAwOutputs; break;
+ case AIoType.Vector: VecInputs |= (1L << Ld.Index) & ~VecAwOutputs; break;
}
}
else if (ILEmitter is AILOpCodeStore St)
diff --git a/ChocolArm64/Translation/AILEmitterCtx.cs b/ChocolArm64/Translation/AILEmitterCtx.cs
index 9199eddc..ffcfa851 100644
--- a/ChocolArm64/Translation/AILEmitterCtx.cs
+++ b/ChocolArm64/Translation/AILEmitterCtx.cs
@@ -39,14 +39,16 @@ namespace ChocolArm64.Translation
private const int Tmp4Index = -4;
private const int Tmp5Index = -5;
- public AILEmitterCtx(ATranslator Translator, ABlock[] Graph, ABlock Root)
+ public AILEmitterCtx(
+ ATranslator Translator,
+ ABlock[] Graph,
+ ABlock Root,
+ string SubName)
{
this.Translator = Translator;
this.Graph = Graph;
this.Root = Root;
- string SubName = $"Sub{Root.Position:X16}";
-
Labels = new Dictionary<long, AILLabel>();
Emitter = new AILEmitter(Graph, Root, SubName);
@@ -92,6 +94,8 @@ namespace ChocolArm64.Translation
}
CurrOp.Emitter(this);
+
+ ILBlock.Add(new AILBarrier());
}
public bool TryOptEmitSubroutineCall()
diff --git a/ChocolArm64/Translation/AILOpCodeLoad.cs b/ChocolArm64/Translation/AILOpCodeLoad.cs
index 7cb431e2..d60ce539 100644
--- a/ChocolArm64/Translation/AILOpCodeLoad.cs
+++ b/ChocolArm64/Translation/AILOpCodeLoad.cs
@@ -11,12 +11,10 @@ namespace ChocolArm64.Translation
public ARegisterSize RegisterSize { get; private set; }
- public AILOpCodeLoad(int Index, AIoType IoType) : this(Index, IoType, ARegisterSize.Int64) { }
-
- public AILOpCodeLoad(int Index, AIoType IoType, ARegisterSize RegisterSize)
+ public AILOpCodeLoad(int Index, AIoType IoType, ARegisterSize RegisterSize = 0)
{
- this.IoType = IoType;
this.Index = Index;
+ this.IoType = IoType;
this.RegisterSize = RegisterSize;
}
diff --git a/ChocolArm64/Translation/AILOpCodeStore.cs b/ChocolArm64/Translation/AILOpCodeStore.cs
index c4ea53ab..a0feb437 100644
--- a/ChocolArm64/Translation/AILOpCodeStore.cs
+++ b/ChocolArm64/Translation/AILOpCodeStore.cs
@@ -11,10 +11,10 @@ namespace ChocolArm64.Translation
public ARegisterSize RegisterSize { get; private set; }
- public AILOpCodeStore(int Index, AIoType IoType, ARegisterSize RegisterSize = ARegisterSize.Int64)
+ public AILOpCodeStore(int Index, AIoType IoType, ARegisterSize RegisterSize = 0)
{
- this.IoType = IoType;
this.Index = Index;
+ this.IoType = IoType;
this.RegisterSize = RegisterSize;
}
diff --git a/ChocolArm64/Translation/ALocalAlloc.cs b/ChocolArm64/Translation/ALocalAlloc.cs
index 0661ddc8..f23af9c7 100644
--- a/ChocolArm64/Translation/ALocalAlloc.cs
+++ b/ChocolArm64/Translation/ALocalAlloc.cs
@@ -67,7 +67,7 @@ namespace ChocolArm64.Translation
public long VecOutputs;
}
- private const int MaxOptGraphLength = 120;
+ private const int MaxOptGraphLength = 55;
public ALocalAlloc(AILBlock[] Graph, AILBlock Root)
{
@@ -149,11 +149,7 @@ namespace ChocolArm64.Translation
if (RetTarget)
{
- BlkIO.Entry = Block;
- BlkIO.IntInputs = 0;
- BlkIO.VecInputs = 0;
- BlkIO.IntOutputs = 0;
- BlkIO.VecOutputs = 0;
+ BlkIO.Entry = Block;
}
else
{