mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-29 05:31:11 +00:00
Fixed problem with live variables and stack calls.
This commit is contained in:
parent
5d7533de5d
commit
25279aead3
@ -199,6 +199,13 @@ public class PassNCalcVariableReferenceInfos extends PassNCalcBase<VariableRefer
|
||||
findSuccessorClosure(block.getDefaultSuccessor(), successorClosure, visited);
|
||||
findSuccessorClosure(block.getConditionalSuccessor(), successorClosure, visited);
|
||||
findSuccessorClosure(block.getCallSuccessor(), successorClosure, visited);
|
||||
// Also handle stack-calls
|
||||
for(Statement statement : block.getStatements()) {
|
||||
if(statement instanceof StatementCallExecute) {
|
||||
final ProcedureRef calledProcRef = ((StatementCallExecute) statement).getProcedure();
|
||||
findSuccessorClosure(calledProcRef.getLabelRef(), successorClosure, visited);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ __bbegin:
|
||||
jsr main
|
||||
rts
|
||||
printother: {
|
||||
.label i = 2
|
||||
.label i = 3
|
||||
// for(char i:0..5)
|
||||
lda #0
|
||||
sta.z i
|
||||
@ -54,7 +54,7 @@ pval: {
|
||||
rts
|
||||
}
|
||||
main: {
|
||||
.label i = 3
|
||||
.label i = 4
|
||||
// for(char i:0..5)
|
||||
lda #0
|
||||
sta.z i
|
||||
|
@ -257,7 +257,7 @@ __stackcall (void()) printother()
|
||||
(byte) printother::i loadstore 14.25
|
||||
__stackcall (void()) printval()
|
||||
__stackcall (void()) pval()
|
||||
(byte) val loadstore 2.0
|
||||
(byte) val loadstore 0.26666666666666666
|
||||
|
||||
Initial phi equivalence classes
|
||||
Added variable val to live range equivalence class [ val ]
|
||||
@ -410,13 +410,13 @@ main: {
|
||||
// File Data
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement [0] (byte) val ← (byte) 0 [ ] ( [ ] ) always clobbers reg byte a
|
||||
Statement [6] (byte) printother::i ← (byte) 0 [ printother::i ] ( main:3::printother:31 [ main::i printother::i ] ) always clobbers reg byte a
|
||||
Statement [7] *((const byte*) SCREEN+(byte) $28 + (byte) printother::i) ← ++ *((const byte*) SCREEN+(byte) $28 + (byte) printother::i) [ printother::i ] ( main:3::printother:31 [ main::i printother::i ] ) always clobbers reg byte x
|
||||
Statement [9] if((byte) printother::i!=(byte) 6) goto printother::@1 [ printother::i ] ( main:3::printother:31 [ main::i printother::i ] ) always clobbers reg byte a
|
||||
Statement [13] *((const byte*) SCREEN) ← (byte) val [ ] ( main:3::pval:28::printval:22 [ main::i ] ) always clobbers reg byte a
|
||||
Statement [25] (byte) main::i ← (byte) 0 [ main::i ] ( main:3 [ main::i ] ) always clobbers reg byte a
|
||||
Statement [37] if((byte) main::i!=(byte) 6) goto main::@1 [ main::i ] ( main:3 [ main::i ] ) always clobbers reg byte a
|
||||
Statement [0] (byte) val ← (byte) 0 [ val ] ( [ val ] ) always clobbers reg byte a
|
||||
Statement [6] (byte) printother::i ← (byte) 0 [ printother::i ] ( main:3::printother:31 [ val main::i printother::i ] ) always clobbers reg byte a
|
||||
Statement [7] *((const byte*) SCREEN+(byte) $28 + (byte) printother::i) ← ++ *((const byte*) SCREEN+(byte) $28 + (byte) printother::i) [ printother::i ] ( main:3::printother:31 [ val main::i printother::i ] ) always clobbers reg byte x
|
||||
Statement [9] if((byte) printother::i!=(byte) 6) goto printother::@1 [ printother::i ] ( main:3::printother:31 [ val main::i printother::i ] ) always clobbers reg byte a
|
||||
Statement [13] *((const byte*) SCREEN) ← (byte) val [ val ] ( main:3::pval:28::printval:22 [ main::i val ] ) always clobbers reg byte a
|
||||
Statement [25] (byte) main::i ← (byte) 0 [ val main::i ] ( main:3 [ val main::i ] ) always clobbers reg byte a
|
||||
Statement [37] if((byte) main::i!=(byte) 6) goto main::@1 [ val main::i ] ( main:3 [ val main::i ] ) always clobbers reg byte a
|
||||
Potential registers zp[1]:2 [ val ] : zp[1]:2 ,
|
||||
Potential registers zp[1]:3 [ printother::i ] : zp[1]:3 ,
|
||||
Potential registers zp[1]:4 [ main::i ] : zp[1]:4 ,
|
||||
@ -424,7 +424,7 @@ Potential registers zp[1]:4 [ main::i ] : zp[1]:4 ,
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [printother] 14.25: zp[1]:3 [ printother::i ]
|
||||
Uplift Scope [main] 2.69: zp[1]:4 [ main::i ]
|
||||
Uplift Scope [] 2: zp[1]:2 [ val ]
|
||||
Uplift Scope [] 0.27: zp[1]:2 [ val ]
|
||||
Uplift Scope [pval]
|
||||
Uplift Scope [ival]
|
||||
Uplift Scope [printval]
|
||||
@ -443,9 +443,6 @@ Attempting to uplift remaining variables inzp[1]:4 [ main::i ]
|
||||
Uplifting [main] best 722 combination zp[1]:4 [ main::i ]
|
||||
Attempting to uplift remaining variables inzp[1]:2 [ val ]
|
||||
Uplifting [] best 722 combination zp[1]:2 [ val ]
|
||||
Coalescing zero page register [ zp[1]:3 [ printother::i ] ] with [ zp[1]:2 [ val ] ]
|
||||
Allocated (was zp[1]:3) zp[1]:2 [ printother::i val ]
|
||||
Allocated (was zp[1]:4) zp[1]:3 [ main::i ]
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
// File Comments
|
||||
@ -479,7 +476,7 @@ __bend_from___b1:
|
||||
__bend:
|
||||
// printother
|
||||
printother: {
|
||||
.label i = 2
|
||||
.label i = 3
|
||||
// [6] (byte) printother::i ← (byte) 0 -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta.z i
|
||||
@ -548,7 +545,7 @@ pval: {
|
||||
}
|
||||
// main
|
||||
main: {
|
||||
.label i = 3
|
||||
.label i = 4
|
||||
// [25] (byte) main::i ← (byte) 0 -- vbuz1=vbuc1
|
||||
lda #0
|
||||
sta.z i
|
||||
@ -626,19 +623,20 @@ __stackcall (void()) ival()
|
||||
__stackcall (void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte) main::i loadstore zp[1]:3 2.6923076923076925
|
||||
(byte) main::i loadstore zp[1]:4 2.6923076923076925
|
||||
__stackcall (void()) printother()
|
||||
(label) printother::@1
|
||||
(label) printother::@return
|
||||
(byte) printother::i loadstore zp[1]:2 14.25
|
||||
(byte) printother::i loadstore zp[1]:3 14.25
|
||||
__stackcall (void()) printval()
|
||||
(label) printval::@return
|
||||
__stackcall (void()) pval()
|
||||
(label) pval::@return
|
||||
(byte) val loadstore zp[1]:2 2.0
|
||||
(byte) val loadstore zp[1]:2 0.26666666666666666
|
||||
|
||||
zp[1]:2 [ printother::i val ]
|
||||
zp[1]:3 [ main::i ]
|
||||
zp[1]:2 [ val ]
|
||||
zp[1]:3 [ printother::i ]
|
||||
zp[1]:4 [ main::i ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
@ -671,7 +669,7 @@ __bbegin:
|
||||
// @end
|
||||
// printother
|
||||
printother: {
|
||||
.label i = 2
|
||||
.label i = 3
|
||||
// for(char i:0..5)
|
||||
// [6] (byte) printother::i ← (byte) 0 -- vbuz1=vbuc1
|
||||
lda #0
|
||||
@ -741,7 +739,7 @@ pval: {
|
||||
}
|
||||
// main
|
||||
main: {
|
||||
.label i = 3
|
||||
.label i = 4
|
||||
// for(char i:0..5)
|
||||
// [25] (byte) main::i ← (byte) 0 -- vbuz1=vbuc1
|
||||
lda #0
|
||||
|
@ -9,16 +9,17 @@ __stackcall (void()) ival()
|
||||
__stackcall (void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte) main::i loadstore zp[1]:3 2.6923076923076925
|
||||
(byte) main::i loadstore zp[1]:4 2.6923076923076925
|
||||
__stackcall (void()) printother()
|
||||
(label) printother::@1
|
||||
(label) printother::@return
|
||||
(byte) printother::i loadstore zp[1]:2 14.25
|
||||
(byte) printother::i loadstore zp[1]:3 14.25
|
||||
__stackcall (void()) printval()
|
||||
(label) printval::@return
|
||||
__stackcall (void()) pval()
|
||||
(label) pval::@return
|
||||
(byte) val loadstore zp[1]:2 2.0
|
||||
(byte) val loadstore zp[1]:2 0.26666666666666666
|
||||
|
||||
zp[1]:2 [ printother::i val ]
|
||||
zp[1]:3 [ main::i ]
|
||||
zp[1]:2 [ val ]
|
||||
zp[1]:3 [ printother::i ]
|
||||
zp[1]:4 [ main::i ]
|
||||
|
Loading…
x
Reference in New Issue
Block a user