1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-03-23 09:30:48 +00:00

Fixed two register allocation issues. 1. disallow two variables in the same phi-block to be allocated to the same register. 2. When analyzing potential registers call parameter phi statements are no longer examined.

This commit is contained in:
jespergravgaard 2017-08-06 15:41:06 +02:00
parent 0dae641df0
commit 3624e3ec27
6 changed files with 115 additions and 61 deletions

View File

@ -43,10 +43,32 @@ public class Pass3AssertNoCpuClobber extends Pass2Base {
// Find the registered clobbered by the ASM asmSegment
AsmClobber asmSegmentClobber = asmSegment.getClobber();
Collection<RegisterAllocation.Register> clobberRegisters = getClobberRegisters(asmSegmentClobber);
// Find vars assigned to in the statement
Collection<VariableRef> assignedVars = Pass3RegisterUpliftPotentialRegisterAnalysis.getAssignedVars(statement);
// Two assigned vars cannot use same register
if(assignedVars.size()>1) {
for (VariableRef assignedVar1 : assignedVars) {
for (VariableRef assignedVar2 : assignedVars) {
if (assignedVar1.equals(assignedVar2)) {
// Same variable - not relevant
continue;
}
RegisterAllocation.Register register1 = allocation.getRegister(assignedVar1);
RegisterAllocation.Register register2 = allocation.getRegister(assignedVar2);
if (register1.equals(register2)) {
if (verbose) {
getLog().append("Two assigned variables " + assignedVar1 + " and " + assignedVar2 + " clobbered by use of same register " + register1 + " in statement " + statement);
getLog().append(asm.toString(false));
}
clobberProblem = true;
}
}
}
}
// Find alive variables
List<VariableRef> aliveVars = new ArrayList<>(liveRangeVariables.getAlive(statement));
// Find vars assignedVars to
Collection<VariableRef> assignedVars = Pass3RegisterUpliftPotentialRegisterAnalysis.getAssignedVars(statement);
// Non-assigned alive variables must not be clobbered
for (VariableRef aliveVar : aliveVars) {
RegisterAllocation.Register aliveVarRegister = allocation.getRegister(aliveVar);
if (aliveVarRegister.isZp()) {
@ -74,7 +96,7 @@ public class Pass3AssertNoCpuClobber extends Pass2Base {
/**
* Get all CPU registers clobbered by the ASM generated from a specific statement in the program
*
* @param asm The assembler to check
* @param clobber The clobber
* @return The clobbered CPU registers
*/
public static Collection<RegisterAllocation.Register> getClobberRegisters(AsmClobber clobber) {

View File

@ -53,7 +53,7 @@ public class Pass3CodeGeneration {
while (statementsIt.hasNext()) {
Statement statement = statementsIt.next();
if(!(statement instanceof StatementPhiBlock)) {
generateStatementAsm(asm, block, statement, aluState);
generateStatementAsm(asm, block, statement, aluState, true);
}
}
}
@ -67,7 +67,7 @@ public class Pass3CodeGeneration {
* @param aluState State of the special ALU register. Used to generate composite fragments when two consecutive statements can be executed effectively.
* For example ADC $1100,x combines two statements $0 = $1100 staridx X, A = A+$0 .
*/
public void generateStatementAsm(AsmProgram asm, ControlFlowBlock block, Statement statement, AsmCodegenAluState aluState) {
public void generateStatementAsm(AsmProgram asm, ControlFlowBlock block, Statement statement, AsmCodegenAluState aluState, boolean genCallPhiEntry) {
asm.startSegment(statement.getIndex(), statement.toString(program));
@ -115,9 +115,11 @@ public class Pass3CodeGeneration {
asmFragment.generate(asm);
} else if (statement instanceof StatementCall) {
StatementCall call = (StatementCall) statement;
ControlFlowBlock callSuccessor = getGraph().getCallSuccessor(block);
if (callSuccessor != null && callSuccessor.hasPhiBlock()) {
genBlockPhiTransition(asm, block, callSuccessor);
if (genCallPhiEntry) {
ControlFlowBlock callSuccessor = getGraph().getCallSuccessor(block);
if (callSuccessor != null && callSuccessor.hasPhiBlock()) {
genBlockPhiTransition(asm, block, callSuccessor);
}
}
asm.addInstruction("jsr", AsmAddressingMode.ABS, call.getProcedure().getFullName());
} else if (statement instanceof StatementReturn) {

View File

@ -131,7 +131,7 @@ public class Pass3RegisterUpliftPotentialRegisterAnalysis extends Pass2Base {
AsmProgram asm = new AsmProgram();
asm.startSegment(statement.getIndex(), statement.toString(getProgram()));
Pass3CodeGeneration.AsmCodegenAluState aluState = new Pass3CodeGeneration.AsmCodegenAluState();
(new Pass3CodeGeneration(getProgram())).generateStatementAsm(asm, block, statement, aluState);
(new Pass3CodeGeneration(getProgram())).generateStatementAsm(asm, block, statement, aluState, false);
AsmClobber clobber = asm.getClobber();
Collection<RegisterAllocation.Register> clobberRegisters = Pass3AssertNoCpuClobber.getClobberRegisters(clobber);
Iterator<RegisterAllocation.Register> alwaysClobberIt = alwaysClobbered.iterator();

View File

@ -1,21 +1,21 @@
BBEGIN:
sum_from_BBEGIN:
lda #2
lda #1
ldx #1
jsr sum
B2:
stx 2
sta 2
sum_from_B2:
lda #13
lda #9
ldx #9
jsr sum
B3:
txa
clc
adc 2
BEND:
sum:
asl
tax
stx 255
clc
adc 255
sum__Breturn:
rts

View File

@ -442,17 +442,13 @@ sum__Breturn:
//SEG18 [7] return [ sum::return#0 s1#0 ]
rts
Statement [0] call sum param-assignment [ sum::return#0 s1#0 ] always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp byte:7 [ sum::return#0 ]
Removing always clobbered register reg byte a as potential for zp byte:4 [ s1#0 ]
Statement [2] call sum param-assignment [ sum::return#0 s1#0 ] always clobbers reg byte a
REGISTER UPLIFT POTENTIAL REGISTERS
Potential registers zp byte:2 [ sum::a#2 ] : zp byte:2 , reg byte a , reg byte x , reg byte y ,
Potential registers zp byte:3 [ sum::b#2 ] : zp byte:3 , reg byte a , reg byte x , reg byte y ,
Potential registers zp byte:4 [ s1#0 ] : zp byte:4 , reg byte x , reg byte y ,
Potential registers zp byte:4 [ s1#0 ] : zp byte:4 , reg byte a , reg byte x , reg byte y ,
Potential registers zp byte:5 [ s2#0 ] : zp byte:5 , reg byte a , reg byte x , reg byte y ,
Potential registers zp byte:6 [ s3#0 ] : zp byte:6 , reg byte a , reg byte x , reg byte y ,
Potential registers zp byte:7 [ sum::return#0 ] : zp byte:7 , reg byte x , reg byte y ,
Potential registers zp byte:7 [ sum::return#0 ] : zp byte:7 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [] ∞: zp byte:6 [ s3#0 ] 4: zp byte:5 [ s2#0 ] 0.57: zp byte:4 [ s1#0 ]
@ -474,6 +470,22 @@ Uplift attempt [] 80 allocation: zp byte:6 [ s3#0 ] reg byte y [ s2#0 ] zp byte:
Uplift attempt [] 77 allocation: reg byte a [ s3#0 ] reg byte y [ s2#0 ] zp byte:4 [ s1#0 ]
Uplift attempt [] 79 allocation: reg byte x [ s3#0 ] reg byte y [ s2#0 ] zp byte:4 [ s1#0 ]
Uplift attempt [] 79 allocation: reg byte y [ s3#0 ] reg byte y [ s2#0 ] zp byte:4 [ s1#0 ]
Uplift attempt [] clobber allocation: zp byte:6 [ s3#0 ] zp byte:5 [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: reg byte a [ s3#0 ] zp byte:5 [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: reg byte x [ s3#0 ] zp byte:5 [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: reg byte y [ s3#0 ] zp byte:5 [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: zp byte:6 [ s3#0 ] reg byte a [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: reg byte a [ s3#0 ] reg byte a [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: reg byte x [ s3#0 ] reg byte a [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: reg byte y [ s3#0 ] reg byte a [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: zp byte:6 [ s3#0 ] reg byte x [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: reg byte a [ s3#0 ] reg byte x [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: reg byte x [ s3#0 ] reg byte x [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: reg byte y [ s3#0 ] reg byte x [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: zp byte:6 [ s3#0 ] reg byte y [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: reg byte a [ s3#0 ] reg byte y [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: reg byte x [ s3#0 ] reg byte y [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] clobber allocation: reg byte y [ s3#0 ] reg byte y [ s2#0 ] reg byte a [ s1#0 ]
Uplift attempt [] 80 allocation: zp byte:6 [ s3#0 ] zp byte:5 [ s2#0 ] reg byte x [ s1#0 ]
Uplift attempt [] 77 allocation: reg byte a [ s3#0 ] zp byte:5 [ s2#0 ] reg byte x [ s1#0 ]
Uplift attempt [] 79 allocation: reg byte x [ s3#0 ] zp byte:5 [ s2#0 ] reg byte x [ s1#0 ]
@ -512,50 +524,66 @@ Uplift attempt [sum] 66 allocation: reg byte a [ sum::a#2 ] zp byte:3 [ sum::b#2
Uplift attempt [sum] 68 allocation: reg byte x [ sum::a#2 ] zp byte:3 [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 68 allocation: reg byte y [ sum::a#2 ] zp byte:3 [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 66 allocation: zp byte:2 [ sum::a#2 ] reg byte a [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 57 allocation: reg byte a [ sum::a#2 ] reg byte a [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] clobber allocation: reg byte a [ sum::a#2 ] reg byte a [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 63 allocation: reg byte x [ sum::a#2 ] reg byte a [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 63 allocation: reg byte y [ sum::a#2 ] reg byte a [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 68 allocation: zp byte:2 [ sum::a#2 ] reg byte x [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 63 allocation: reg byte a [ sum::a#2 ] reg byte x [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 59 allocation: reg byte x [ sum::a#2 ] reg byte x [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] clobber allocation: reg byte x [ sum::a#2 ] reg byte x [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 65 allocation: reg byte y [ sum::a#2 ] reg byte x [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 68 allocation: zp byte:2 [ sum::a#2 ] reg byte y [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 63 allocation: reg byte a [ sum::a#2 ] reg byte y [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 65 allocation: reg byte x [ sum::a#2 ] reg byte y [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 59 allocation: reg byte y [ sum::a#2 ] reg byte y [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] clobber allocation: reg byte y [ sum::a#2 ] reg byte y [ sum::b#2 ] zp byte:7 [ sum::return#0 ]
Uplift attempt [sum] 66 allocation: zp byte:2 [ sum::a#2 ] zp byte:3 [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] 57 allocation: reg byte a [ sum::a#2 ] zp byte:3 [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] 59 allocation: reg byte x [ sum::a#2 ] zp byte:3 [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] 59 allocation: reg byte y [ sum::a#2 ] zp byte:3 [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] 57 allocation: zp byte:2 [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] clobber allocation: reg byte a [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] 54 allocation: reg byte x [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] 54 allocation: reg byte y [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] 59 allocation: zp byte:2 [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] 54 allocation: reg byte a [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] clobber allocation: reg byte x [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] 56 allocation: reg byte y [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] 59 allocation: zp byte:2 [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] 54 allocation: reg byte a [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] 56 allocation: reg byte x [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] clobber allocation: reg byte y [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte a [ sum::return#0 ]
Uplift attempt [sum] 70 allocation: zp byte:2 [ sum::a#2 ] zp byte:3 [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 61 allocation: reg byte a [ sum::a#2 ] zp byte:3 [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 63 allocation: reg byte x [ sum::a#2 ] zp byte:3 [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 63 allocation: reg byte y [ sum::a#2 ] zp byte:3 [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 61 allocation: zp byte:2 [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 52 allocation: reg byte a [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] clobber allocation: reg byte a [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 58 allocation: reg byte x [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 58 allocation: reg byte y [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 63 allocation: zp byte:2 [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 58 allocation: reg byte a [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 54 allocation: reg byte x [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] clobber allocation: reg byte x [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 60 allocation: reg byte y [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 63 allocation: zp byte:2 [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 58 allocation: reg byte a [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 60 allocation: reg byte x [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 54 allocation: reg byte y [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] clobber allocation: reg byte y [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] 70 allocation: zp byte:2 [ sum::a#2 ] zp byte:3 [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 61 allocation: reg byte a [ sum::a#2 ] zp byte:3 [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 63 allocation: reg byte x [ sum::a#2 ] zp byte:3 [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 63 allocation: reg byte y [ sum::a#2 ] zp byte:3 [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 61 allocation: zp byte:2 [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 52 allocation: reg byte a [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] clobber allocation: reg byte a [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 58 allocation: reg byte x [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 58 allocation: reg byte y [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 63 allocation: zp byte:2 [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 58 allocation: reg byte a [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 54 allocation: reg byte x [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] clobber allocation: reg byte x [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 60 allocation: reg byte y [ sum::a#2 ] reg byte x [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 63 allocation: zp byte:2 [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 58 allocation: reg byte a [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 60 allocation: reg byte x [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplift attempt [sum] 54 allocation: reg byte y [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplifting [sum] best 52 combination reg byte a [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte x [ sum::return#0 ]
Uplift attempt [sum] clobber allocation: reg byte y [ sum::a#2 ] reg byte y [ sum::b#2 ] reg byte y [ sum::return#0 ]
Uplifting [sum] best 54 combination reg byte x [ sum::a#2 ] reg byte a [ sum::b#2 ] reg byte a [ sum::return#0 ]
Re-allocated ZP register from zp byte:4 to zp byte:2
Removing instruction jmp B2
Removing instruction jmp B3
@ -570,25 +598,25 @@ BBEGIN:
sum_from_BBEGIN:
//SEG3 [5] phi (byte) sum::b#2 = (byte) 2 -- aby=coby1
lda #2
//SEG4 [5] phi (byte) sum::a#2 = (byte) 1 -- aby=coby1
lda #1
//SEG4 [5] phi (byte) sum::a#2 = (byte) 1 -- xby=coby1
ldx #1
jsr sum
//SEG5 @2
B2:
//SEG6 [1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ] -- zpby1=xby
stx 2
//SEG6 [1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ] -- zpby1=aby
sta 2
//SEG7 [2] call sum param-assignment [ sum::return#0 s1#0 ]
//SEG8 [5] phi from @2 to sum
sum_from_B2:
//SEG9 [5] phi (byte) sum::b#2 = (byte) 13 -- aby=coby1
lda #13
//SEG10 [5] phi (byte) sum::a#2 = (byte) 9 -- aby=coby1
lda #9
//SEG10 [5] phi (byte) sum::a#2 = (byte) 9 -- xby=coby1
ldx #9
jsr sum
//SEG11 @3
B3:
//SEG12 [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ] -- aby=xby
txa
//SEG12 [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ]
// (byte) s2#0 = (byte) sum::return#0 // register copy reg byte a
//SEG13 [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] -- aby=zpby1_plus_aby
clc
adc 2
@ -596,9 +624,10 @@ B3:
BEND:
//SEG15 sum
sum:
//SEG16 [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] -- xby=aby_plus_aby
asl
tax
//SEG16 [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] -- aby=xby_plus_aby
stx 255
clc
adc 255
//SEG17 sum::@return
sum__Breturn:
//SEG18 [7] return [ sum::return#0 s1#0 ]
@ -618,18 +647,18 @@ FINAL SYMBOL TABLE
(byte()) sum((byte) sum::a , (byte) sum::b)
(label) sum::@return
(byte) sum::a
(byte) sum::a#2 reg byte a 2.0
(byte) sum::a#2 reg byte x 2.0
(byte) sum::b
(byte) sum::b#2 reg byte a 2.0
(byte) sum::return
(byte) sum::return#0 reg byte x 1.2000000000000002
(byte) sum::return#0 reg byte a 1.2000000000000002
reg byte a [ sum::a#2 ]
reg byte x [ sum::a#2 ]
reg byte a [ sum::b#2 ]
zp byte:2 [ s1#0 ]
reg byte a [ s2#0 ]
reg byte a [ s3#0 ]
reg byte x [ sum::return#0 ]
reg byte a [ sum::return#0 ]
FINAL CODE
//SEG0 @BEGIN
@ -639,25 +668,25 @@ BBEGIN:
sum_from_BBEGIN:
//SEG3 [5] phi (byte) sum::b#2 = (byte) 2 -- aby=coby1
lda #2
//SEG4 [5] phi (byte) sum::a#2 = (byte) 1 -- aby=coby1
lda #1
//SEG4 [5] phi (byte) sum::a#2 = (byte) 1 -- xby=coby1
ldx #1
jsr sum
//SEG5 @2
B2:
//SEG6 [1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ] -- zpby1=xby
stx 2
//SEG6 [1] (byte) s1#0 ← (byte) sum::return#0 [ sum::return#0 s1#0 ] -- zpby1=aby
sta 2
//SEG7 [2] call sum param-assignment [ sum::return#0 s1#0 ]
//SEG8 [5] phi from @2 to sum
sum_from_B2:
//SEG9 [5] phi (byte) sum::b#2 = (byte) 13 -- aby=coby1
lda #13
//SEG10 [5] phi (byte) sum::a#2 = (byte) 9 -- aby=coby1
lda #9
//SEG10 [5] phi (byte) sum::a#2 = (byte) 9 -- xby=coby1
ldx #9
jsr sum
//SEG11 @3
B3:
//SEG12 [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ] -- aby=xby
txa
//SEG12 [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ]
// (byte) s2#0 = (byte) sum::return#0 // register copy reg byte a
//SEG13 [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] -- aby=zpby1_plus_aby
clc
adc 2
@ -665,9 +694,10 @@ B3:
BEND:
//SEG15 sum
sum:
//SEG16 [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] -- xby=aby_plus_aby
asl
tax
//SEG16 [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] -- aby=xby_plus_aby
stx 255
clc
adc 255
//SEG17 sum::@return
sum__Breturn:
//SEG18 [7] return [ sum::return#0 s1#0 ]

View File

@ -11,15 +11,15 @@
(byte()) sum((byte) sum::a , (byte) sum::b)
(label) sum::@return
(byte) sum::a
(byte) sum::a#2 reg byte a 2.0
(byte) sum::a#2 reg byte x 2.0
(byte) sum::b
(byte) sum::b#2 reg byte a 2.0
(byte) sum::return
(byte) sum::return#0 reg byte x 1.2000000000000002
(byte) sum::return#0 reg byte a 1.2000000000000002
reg byte a [ sum::a#2 ]
reg byte x [ sum::a#2 ]
reg byte a [ sum::b#2 ]
zp byte:2 [ s1#0 ]
reg byte a [ s2#0 ]
reg byte a [ s3#0 ]
reg byte x [ sum::return#0 ]
reg byte a [ sum::return#0 ]