1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-24 04:31:02 +00:00

Less logging during uplift.

This commit is contained in:
jespergravgaard 2017-08-07 17:17:14 +02:00
parent d640c53033
commit 9f5efab3ee
7 changed files with 324 additions and 10667 deletions

View File

@ -79,7 +79,7 @@ public class Compiler {
program.getLog().append(program.getRegisterUpliftProgram().toString((program.getVariableRegisterWeights())));
// Attempt uplifting registers through a lot of combinations
new Pass3RegisterUpliftCombinations(program).performUplift(10_000);
new Pass3RegisterUpliftCombinations(program).performUplift(30_000);
// Attempt uplifting registers one at a time to catch remaining potential not realized by combination search
new Pass3RegisterUpliftRemains(program).performUplift();

View File

@ -19,6 +19,10 @@ public class RegisterCombination {
allocation.put(equivalenceClass, register);
}
public RegisterAllocation.Register getRegister(LiveRangeEquivalenceClass equivalenceClass) {
return allocation.get(equivalenceClass);
}
/**
* Allocate the registers of the combination into the programs register allocation
*/

View File

@ -28,6 +28,9 @@ public class Pass3RegisterUpliftCombinations extends Pass2Base {
int countCombinations = 0;
while (combinationIterator.hasNext() && countCombinations<maxCombinations) {
countCombinations++;
if(countCombinations%10000==0) {
getLog().append("Uplift attempts ["+upliftScope.getScopeRef()+"] "+countCombinations+"/"+combinationIterator.getNumIterations()+" (limiting to "+maxCombinations+")");
}
RegisterCombination combination = combinationIterator.next();
// Reset register allocation to original zero page allocation
new Pass3RegistersFinalize(getProgram()).allocate(false);
@ -38,32 +41,32 @@ public class Pass3RegisterUpliftCombinations extends Pass2Base {
new Pass3CodeGeneration(getProgram()).generate();
} catch (AsmFragment.UnknownFragmentException e) {
unknownFragments.add(e.getFragmentSignature());
StringBuilder msg = new StringBuilder();
msg.append("Uplift attempt [" + upliftScope.getScopeRef() + "] ");
msg.append("missing fragment " + e.getFragmentSignature());
msg.append(" allocation: ").append(combination.toString());
getLog().append(msg.toString());
//StringBuilder msg = new StringBuilder();
//msg.append("Uplift attempt [" + upliftScope.getScopeRef() + "] ");
//msg.append("missing fragment " + e.getFragmentSignature());
//msg.append(" allocation: ").append(combination.toString());
//getLog().append(msg.toString());
continue;
} catch (AsmFragment.AluNotApplicableException e) {
StringBuilder msg = new StringBuilder();
msg.append("Uplift attempt [" + upliftScope.getScopeRef() + "] ");
msg.append("alu not applicable");
msg.append(" allocation: ").append(combination.toString());
getLog().append(msg.toString());
//StringBuilder msg = new StringBuilder();
//msg.append("Uplift attempt [" + upliftScope.getScopeRef() + "] ");
//msg.append("alu not applicable");
//msg.append(" allocation: ").append(combination.toString());
//getLog().append(msg.toString());
continue;
}
// If no clobber - Find value of the resulting allocation
boolean hasClobberProblem = new Pass3AssertNoCpuClobber(getProgram()).hasClobberProblem(false);
int combinationScore = getAsmScore(getProgram());
StringBuilder msg = new StringBuilder();
msg.append("Uplift attempt [" + upliftScope.getScopeRef() + "] ");
if (hasClobberProblem) {
msg.append("clobber");
} else {
msg.append(combinationScore);
}
msg.append(" allocation: ").append(combination.toString());
getLog().append(msg.toString());
//msg.append("Uplift attempt [" + upliftScope.getScopeRef() + "] ");
//if (hasClobberProblem) {
// msg.append("clobber");
//} else {
// msg.append(combinationScore);
//}
//msg.append(" allocation: ").append(combination.toString());
//getLog().append(msg.toString());
if (!hasClobberProblem) {
if (combinationScore < bestScore) {
bestScore = combinationScore;

View File

@ -45,32 +45,32 @@ public class Pass3RegisterUpliftRemains extends Pass2Base {
new Pass3CodeGeneration(getProgram()).generate();
} catch (AsmFragment.UnknownFragmentException e) {
unknownFragments.add(e.getFragmentSignature());
StringBuilder msg = new StringBuilder();
msg.append("Uplift remains attempt [" + equivalenceClass + "] ");
msg.append("missing fragment " + e.getFragmentSignature());
msg.append(" allocation: ").append(combination.toString());
getLog().append(msg.toString());
//StringBuilder msg = new StringBuilder();
//msg.append("Uplift remains attempt [" + equivalenceClass + "] ");
//msg.append("missing fragment " + e.getFragmentSignature());
//msg.append(" allocation: ").append(combination.toString());
//getLog().append(msg.toString());
continue;
} catch (AsmFragment.AluNotApplicableException e) {
StringBuilder msg = new StringBuilder();
msg.append("Uplift remains attempt [" + equivalenceClass + "] ");
msg.append("alu not applicable");
msg.append(" allocation: ").append(combination.toString());
getLog().append(msg.toString());
//StringBuilder msg = new StringBuilder();
//msg.append("Uplift remains attempt [" + equivalenceClass + "] ");
//msg.append("alu not applicable");
//msg.append(" allocation: ").append(combination.toString());
//getLog().append(msg.toString());
continue;
}
// If no clobber - Find value of the resulting allocation
boolean hasClobberProblem = new Pass3AssertNoCpuClobber(getProgram()).hasClobberProblem(false);
int combinationScore = getAsmScore(getProgram());
StringBuilder msg = new StringBuilder();
msg.append("Uplift remains attempt [" + equivalenceClass + "] ");
if (hasClobberProblem) {
msg.append("clobber");
} else {
msg.append(combinationScore);
}
msg.append(" allocation: ").append(combination.toString());
getLog().append(msg.toString());
//StringBuilder msg = new StringBuilder();
//msg.append("Uplift remains attempt [" + equivalenceClass + "] ");
//if (hasClobberProblem) {
// msg.append("clobber");
//} else {
// msg.append(combinationScore);
//}
//msg.append(" allocation: ").append(combination.toString());
//getLog().append(msg.toString());
if (!hasClobberProblem) {
if (combinationScore < bestScore) {
bestScore = combinationScore;
@ -79,8 +79,10 @@ public class Pass3RegisterUpliftRemains extends Pass2Base {
}
}
// Save the best combination in the equivalence class
bestCombination.store(equivalenceClassSet);
getLog().append("Uplifting remains [" + equivalenceClass + "] best " + bestScore + " combination " + bestCombination.toString());
if(!bestCombination.getRegister(equivalenceClass).isZp()) {
bestCombination.store(equivalenceClassSet);
getLog().append("Uplifting remains [" + equivalenceClass + "] best " + bestScore + " combination " + bestCombination.toString());
}
}
}

View File

@ -75,12 +75,12 @@ render__B2_from_B1:
render__B2_from_B5:
render__B2:
lda 7
sta 10
lda 2
sta 11
lda 2
sta 12
jsr findcol
render__B5:
lda 9
lda 10
ldy 7
sta (3),y
lda #230
@ -114,80 +114,75 @@ render__Breturn:
findcol:
findcol__B1_from_findcol:
lda #0
sta 9
ldy #255
ldx #0
sta 10
lda #255
sta 8
ldy #0
findcol__B1_from_B13:
findcol__B1:
lda 4096,x
sta 8
lda 4352,x
sta 12
lda 10
cmp 8
lda 4096,y
ldx 4352,y
cmp 11
beq findcol__B2
findcol__B3:
lda 10
cmp 8
bcc findcol__B6
cmp 11
bcs findcol__B6
findcol__B7:
lda 10
eor #255
sec
sbc 8
sta 8
adc 11
sta 9
findcol__B8_from_B7:
findcol__B8:
lda 11
cmp 12
bcc findcol__B9
cpx 12
bcs findcol__B9
findcol__B10:
lda 11
stx 255
lda 12
sec
sbc 12
sbc 255
clc
adc 8
sta 8
adc 9
tax
findcol__B11_from_B10:
findcol__B11:
cpy 8
bcs findcol__B12
cpx 8
bcc findcol__B12
findcol__B13_from_B11:
findcol__B13:
inx
cpx #6
iny
cpy #6
bcc findcol__B1_from_B13
findcol__Breturn_from_B13:
jmp findcol__Breturn
findcol__Breturn_from_B2:
lda #0
sta 9
sta 10
findcol__Breturn:
rts
findcol__B12:
lda 4608,x
sta 9
ldy 8
lda 4608,y
sta 10
stx 8
findcol__B13_from_B12:
jmp findcol__B13
findcol__B9:
lda 12
txa
sec
sbc 11
sbc 12
clc
adc 8
sta 8
adc 9
tax
findcol__B11_from_B9:
jmp findcol__B11
findcol__B6:
lda 8
sec
sbc 10
sta 8
sbc 11
sta 9
findcol__B8_from_B6:
jmp findcol__B8
findcol__B2:
lda 11
cmp 12
cpx 12
beq findcol__Breturn_from_B2
jmp findcol__B3
addpoint:

File diff suppressed because it is too large Load Diff

View File

@ -32,33 +32,33 @@
(label) findcol::@9
(label) findcol::@return
(byte) findcol::diff
(byte) findcol::diff#0 zp byte:8 20002.0
(byte) findcol::diff#1 zp byte:8 20002.0
(byte~) findcol::diff#13 reg byte y 20002.0
(byte) findcol::diff#2 zp byte:8 20002.0
(byte) findcol::diff#3 zp byte:8 20002.0
(byte) findcol::diff#4 zp byte:8 10001.0
(byte) findcol::diff#6 zp byte:8 13334.666666666666
(byte) findcol::diff#0 zp byte:9 20002.0
(byte) findcol::diff#1 zp byte:9 20002.0
(byte~) findcol::diff#13 zp byte:8 20002.0
(byte) findcol::diff#2 reg byte x 20002.0
(byte) findcol::diff#3 reg byte x 20002.0
(byte) findcol::diff#4 zp byte:9 10001.0
(byte) findcol::diff#6 reg byte x 13334.666666666666
(byte) findcol::i
(byte) findcol::i#1 reg byte x 15001.5
(byte) findcol::i#12 reg byte x 2631.842105263158
(byte) findcol::i#1 reg byte y 15001.5
(byte) findcol::i#12 reg byte y 2631.842105263158
(byte) findcol::mincol
(byte) findcol::mincol#1 zp byte:9 10001.0
(byte) findcol::mincol#11 zp byte:9 1250.125
(byte) findcol::mincol#2 zp byte:9 13334.666666666666
(byte) findcol::mincol#1 zp byte:10 10001.0
(byte) findcol::mincol#11 zp byte:10 1250.125
(byte) findcol::mincol#2 zp byte:10 13334.666666666666
(byte) findcol::mindiff
(byte) findcol::mindiff#10 reg byte y 1875.1875
(byte) findcol::mindiff#11 reg byte y 10001.0
(byte) findcol::mindiff#10 zp byte:8 1875.1875
(byte) findcol::mindiff#11 zp byte:8 10001.0
(byte) findcol::return
(byte) findcol::return#0 zp byte:9 343.8125
(byte) findcol::return#0 zp byte:10 343.8125
(byte) findcol::x
(byte) findcol::x#0 zp byte:10 1577.1153846153845
(byte) findcol::x#0 zp byte:11 1577.1153846153845
(byte) findcol::xp
(byte) findcol::xp#0 zp byte:8 10001.0
(byte) findcol::xp#0 reg byte a 10001.0
(byte) findcol::y
(byte) findcol::y#0 zp byte:11 1640.2
(byte) findcol::y#0 zp byte:12 1640.2
(byte) findcol::yp
(byte) findcol::yp#0 zp byte:12 6250.625
(byte) findcol::yp#0 reg byte x 6250.625
(void()) main()
(label) main::@1
(label) main::@3
@ -94,16 +94,18 @@ zp byte:2 [ render::y#2 render::y#1 addpoint::c#6 ]
zp ptr byte:3 [ render::colline#2 render::colline#1 ]
zp ptr byte:5 [ render::chrline#2 render::chrline#1 ]
zp byte:7 [ render::x#2 render::x#1 ]
reg byte x [ findcol::i#12 findcol::i#1 ]
reg byte y [ findcol::mindiff#10 findcol::mindiff#11 findcol::diff#13 ]
zp byte:8 [ findcol::diff#4 findcol::diff#0 findcol::diff#1 findcol::diff#6 findcol::diff#3 findcol::diff#2 findcol::xp#0 ]
zp byte:9 [ findcol::return#0 findcol::mincol#11 findcol::mincol#2 findcol::mincol#1 ]
reg byte y [ findcol::i#12 findcol::i#1 ]
zp byte:8 [ findcol::mindiff#10 findcol::mindiff#11 findcol::diff#13 ]
zp byte:9 [ findcol::diff#4 findcol::diff#0 findcol::diff#1 ]
reg byte x [ findcol::diff#6 findcol::diff#3 findcol::diff#2 ]
zp byte:10 [ findcol::return#0 findcol::mincol#11 findcol::mincol#2 findcol::mincol#1 ]
reg byte a [ addpoint::x#6 ]
reg byte y [ addpoint::idx#6 ]
reg byte x [ addpoint::y#6 ]
zp byte:10 [ findcol::x#0 ]
zp byte:11 [ findcol::y#0 ]
zp byte:11 [ findcol::x#0 ]
zp byte:12 [ findcol::y#0 ]
reg byte a [ render::col#0 ]
zp byte:12 [ findcol::yp#0 ]
reg byte a [ findcol::xp#0 ]
reg byte x [ findcol::yp#0 ]
reg byte a [ findcol::$10 ]
reg byte a [ findcol::$8 ]