1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-01-10 12:31:09 +00:00

Working on predictability in output

This commit is contained in:
Jesper Gravgaard 2017-07-14 00:15:33 +02:00
parent 20cb48b07d
commit 5c1aa7a2e7

View File

@ -2,7 +2,7 @@ package dk.camelot64.kickc.icl;
import dk.camelot64.kickc.asm.*;
import java.util.Iterator;
import java.util.*;
/**
* Code Generation of 6502 Assembler from ICL/SSA Control Flow Graph
@ -107,7 +107,14 @@ public class Pass3CodeGeneration {
break;
}
StatementPhi phi = (StatementPhi) statement;
for (StatementPhi.PreviousSymbol previousSymbol : phi.getPreviousVersions()) {
List<StatementPhi.PreviousSymbol> previousVersions = new ArrayList<>(phi.getPreviousVersions());
Collections.sort(previousVersions, new Comparator<StatementPhi.PreviousSymbol>() {
@Override
public int compare(StatementPhi.PreviousSymbol o1, StatementPhi.PreviousSymbol o2) {
return o1.getBlock().getFullName().compareTo(o2.getBlock().getFullName());
}
});
for (StatementPhi.PreviousSymbol previousSymbol : previousVersions) {
if (previousSymbol.getBlock().equals(fromBlock.getLabel())) {
genAsmMove(asm, phi.getLValue(), previousSymbol.getRValue());
break;