mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-01 00:51:12 +00:00
replace jmp to rts with rts in double jump elimination pass
This commit is contained in:
parent
0fa2ec584e
commit
7784f174b7
@ -40,9 +40,13 @@ public class Pass5DoubleJumpElimination extends Pass5AsmOptimization {
|
|||||||
if(currentLabel != null) {
|
if(currentLabel != null) {
|
||||||
AsmInstruction asmInstruction = (AsmInstruction) line;
|
AsmInstruction asmInstruction = (AsmInstruction) line;
|
||||||
AsmInstructionType jmpType = AsmInstructionSet.getInstructionType("jmp", AsmAddressingMode.ABS, false);
|
AsmInstructionType jmpType = AsmInstructionSet.getInstructionType("jmp", AsmAddressingMode.ABS, false);
|
||||||
|
AsmInstructionType rtsType = AsmInstructionSet.getInstructionType("rts", AsmAddressingMode.NON, false);
|
||||||
if(asmInstruction.getType().equals(jmpType)) {
|
if(asmInstruction.getType().equals(jmpType)) {
|
||||||
immediateJumps.put(currentScope + "::" + currentLabel, asmInstruction.getParameter());
|
immediateJumps.put(currentScope + "::" + currentLabel, asmInstruction.getParameter());
|
||||||
}
|
}
|
||||||
|
if(asmInstruction.getType().equals(rtsType)) {
|
||||||
|
immediateJumps.put(currentScope + "::" + currentLabel, "rts");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
currentLabel = null;
|
currentLabel = null;
|
||||||
} else {
|
} else {
|
||||||
@ -62,7 +66,12 @@ public class Pass5DoubleJumpElimination extends Pass5AsmOptimization {
|
|||||||
AsmInstruction asmInstruction = (AsmInstruction) line;
|
AsmInstruction asmInstruction = (AsmInstruction) line;
|
||||||
if(asmInstruction.getType().isJump()) {
|
if(asmInstruction.getType().isJump()) {
|
||||||
String immediateJmpTarget = immediateJumps.get(currentScope + "::" + asmInstruction.getParameter());
|
String immediateJmpTarget = immediateJumps.get(currentScope + "::" + asmInstruction.getParameter());
|
||||||
if(immediateJmpTarget != null && !immediateJmpTarget.equals(asmInstruction.getParameter())) {
|
if (immediateJmpTarget == "rts" && asmInstruction.getType().getMnemnonic()=="jmp") {
|
||||||
|
getLog().append("Replacing jump to rts with rts in " + asmInstruction.toString());
|
||||||
|
AsmInstructionType rtsType = AsmInstructionSet.getInstructionType("rts", AsmAddressingMode.NON, false);
|
||||||
|
asmInstruction.setType(rtsType);
|
||||||
|
optimized = true;
|
||||||
|
} else if(immediateJmpTarget != null && immediateJmpTarget != "rts" && !immediateJmpTarget.equals(asmInstruction.getParameter())) {
|
||||||
getLog().append("Skipping double jump to " + immediateJmpTarget + " in " + asmInstruction.toString());
|
getLog().append("Skipping double jump to " + immediateJmpTarget + " in " + asmInstruction.toString());
|
||||||
asmInstruction.setParameter(immediateJmpTarget);
|
asmInstruction.setParameter(immediateJmpTarget);
|
||||||
optimized = true;
|
optimized = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user