mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-27 19:50:10 +00:00
Fixed clobber-problem with stack-parameter-passing return-values. Results are still not pushed. #316
This commit is contained in:
parent
dc08f86302
commit
6540d60e60
@ -5,11 +5,9 @@ import dk.camelot64.kickc.asm.AsmProgram;
|
|||||||
import dk.camelot64.kickc.fragment.AsmFragmentInstance;
|
import dk.camelot64.kickc.fragment.AsmFragmentInstance;
|
||||||
import dk.camelot64.kickc.fragment.AsmFragmentTemplateSynthesizer;
|
import dk.camelot64.kickc.fragment.AsmFragmentTemplateSynthesizer;
|
||||||
import dk.camelot64.kickc.model.*;
|
import dk.camelot64.kickc.model.*;
|
||||||
|
import dk.camelot64.kickc.model.statements.*;
|
||||||
import dk.camelot64.kickc.model.values.LValue;
|
import dk.camelot64.kickc.model.values.LValue;
|
||||||
import dk.camelot64.kickc.model.values.VariableRef;
|
import dk.camelot64.kickc.model.values.VariableRef;
|
||||||
import dk.camelot64.kickc.model.statements.Statement;
|
|
||||||
import dk.camelot64.kickc.model.statements.StatementAssignment;
|
|
||||||
import dk.camelot64.kickc.model.statements.StatementPhiBlock;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -39,8 +37,8 @@ public class Pass4RegisterUpliftPotentialRegisterAnalysis extends Pass2Base {
|
|||||||
variableRefs.add(phiVariable.getVariable());
|
variableRefs.add(phiVariable.getVariable());
|
||||||
}
|
}
|
||||||
return variableRefs;
|
return variableRefs;
|
||||||
} else if(statement instanceof StatementAssignment) {
|
} else if(statement instanceof StatementLValue) {
|
||||||
LValue lValue = ((StatementAssignment) statement).getlValue();
|
LValue lValue = ((StatementLValue) statement).getlValue();
|
||||||
if(lValue instanceof VariableRef) {
|
if(lValue instanceof VariableRef) {
|
||||||
variableRefs.add((VariableRef) lValue);
|
variableRefs.add((VariableRef) lValue);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class TestPrograms {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProcedureCallingConventionStack0() throws IOException, URISyntaxException {
|
public void testProcedureCallingConventionStack0() throws IOException, URISyntaxException {
|
||||||
compileAndCompare("procedure-callingconvention-stack-0"); //, log().verboseCreateSsa().verboseParse().verboseStatementSequence().verboseUplift().verboseLiveRanges().verboseSSAOptimize());
|
compileAndCompare("procedure-callingconvention-stack-0");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
.label SCREEN = $400
|
.label SCREEN = $400
|
||||||
.const STACK_BASE = $103
|
.const STACK_BASE = $103
|
||||||
main: {
|
main: {
|
||||||
.label _0 = 2
|
|
||||||
lda #'0'
|
lda #'0'
|
||||||
pha
|
pha
|
||||||
lda #7
|
lda #7
|
||||||
@ -13,7 +12,6 @@ main: {
|
|||||||
jsr plus
|
jsr plus
|
||||||
pla
|
pla
|
||||||
pla
|
pla
|
||||||
sta.z _0
|
|
||||||
sta SCREEN
|
sta SCREEN
|
||||||
rts
|
rts
|
||||||
}
|
}
|
||||||
|
@ -262,14 +262,11 @@ Uplift Scope [main] 2: zp ZP_BYTE:2 [ main::$0 ]
|
|||||||
Uplift Scope []
|
Uplift Scope []
|
||||||
|
|
||||||
Uplifting [plus] best 84 combination reg byte a [ plus::b#0 ] zp ZP_BYTE:3 [ plus::a#0 ] reg byte a [ plus::return#0 ]
|
Uplifting [plus] best 84 combination reg byte a [ plus::b#0 ] zp ZP_BYTE:3 [ plus::a#0 ] reg byte a [ plus::return#0 ]
|
||||||
Uplifting [main] best 84 combination zp ZP_BYTE:2 [ main::$0 ]
|
Uplifting [main] best 78 combination reg byte a [ main::$0 ]
|
||||||
Uplifting [] best 84 combination
|
Uplifting [] best 78 combination
|
||||||
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::$0 ]
|
|
||||||
Uplifting [main] best 84 combination zp ZP_BYTE:2 [ main::$0 ]
|
|
||||||
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ plus::a#0 ]
|
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ plus::a#0 ]
|
||||||
Uplifting [plus] best 84 combination zp ZP_BYTE:3 [ plus::a#0 ]
|
Uplifting [plus] best 78 combination zp ZP_BYTE:3 [ plus::a#0 ]
|
||||||
Coalescing zero page register [ zp ZP_BYTE:3 [ plus::a#0 ] ] with [ zp ZP_BYTE:2 [ main::$0 ] ]
|
Allocated (was zp ZP_BYTE:3) zp ZP_BYTE:2 [ plus::a#0 ]
|
||||||
Allocated (was zp ZP_BYTE:3) zp ZP_BYTE:2 [ plus::a#0 main::$0 ]
|
|
||||||
|
|
||||||
ASSEMBLER BEFORE OPTIMIZATION
|
ASSEMBLER BEFORE OPTIMIZATION
|
||||||
// File Comments
|
// File Comments
|
||||||
@ -299,7 +296,6 @@ bend_from_b1:
|
|||||||
bend:
|
bend:
|
||||||
// main
|
// main
|
||||||
main: {
|
main: {
|
||||||
.label _0 = 2
|
|
||||||
// [5] callprepare plus (byte) '0' (byte) 7
|
// [5] callprepare plus (byte) '0' (byte) 7
|
||||||
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
|
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
|
||||||
lda #'0'
|
lda #'0'
|
||||||
@ -313,11 +309,9 @@ main: {
|
|||||||
// [7] (byte~) main::$0 ← callfinalize plus
|
// [7] (byte~) main::$0 ← callfinalize plus
|
||||||
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
|
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
|
||||||
pla
|
pla
|
||||||
// [7] (byte~) main::$0 ← callfinalize plus -- vbuz1=_stackpullbyte_
|
// [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_
|
||||||
pla
|
pla
|
||||||
sta.z _0
|
// [8] *((const byte*) SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuaa
|
||||||
// [8] *((const byte*) SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuz1
|
|
||||||
lda.z _0
|
|
||||||
sta SCREEN
|
sta SCREEN
|
||||||
jmp breturn
|
jmp breturn
|
||||||
// main::@return
|
// main::@return
|
||||||
@ -355,8 +349,6 @@ Removing instruction jmp bend
|
|||||||
Removing instruction jmp breturn
|
Removing instruction jmp breturn
|
||||||
Removing instruction jmp breturn
|
Removing instruction jmp breturn
|
||||||
Succesful ASM optimization Pass5NextJumpElimination
|
Succesful ASM optimization Pass5NextJumpElimination
|
||||||
Removing instruction lda.z _0
|
|
||||||
Succesful ASM optimization Pass5UnnecesaryLoadElimination
|
|
||||||
Removing instruction b1_from_bbegin:
|
Removing instruction b1_from_bbegin:
|
||||||
Removing instruction b1:
|
Removing instruction b1:
|
||||||
Removing instruction main_from_b1:
|
Removing instruction main_from_b1:
|
||||||
@ -380,7 +372,7 @@ FINAL SYMBOL TABLE
|
|||||||
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
||||||
(const word) STACK_BASE STACK_BASE = (word) $103
|
(const word) STACK_BASE STACK_BASE = (word) $103
|
||||||
(void()) main()
|
(void()) main()
|
||||||
(byte~) main::$0 $0 zp ZP_BYTE:2 2.0
|
(byte~) main::$0 reg byte a 2.0
|
||||||
(label) main::@return
|
(label) main::@return
|
||||||
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
||||||
(label) plus::@return
|
(label) plus::@return
|
||||||
@ -393,13 +385,14 @@ __stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
|||||||
(byte) plus::return
|
(byte) plus::return
|
||||||
(byte) plus::return#0 reg byte a 2.0
|
(byte) plus::return#0 reg byte a 2.0
|
||||||
|
|
||||||
zp ZP_BYTE:2 [ plus::a#0 main::$0 ]
|
reg byte a [ main::$0 ]
|
||||||
|
zp ZP_BYTE:2 [ plus::a#0 ]
|
||||||
reg byte a [ plus::b#0 ]
|
reg byte a [ plus::b#0 ]
|
||||||
reg byte a [ plus::return#0 ]
|
reg byte a [ plus::return#0 ]
|
||||||
|
|
||||||
|
|
||||||
FINAL ASSEMBLER
|
FINAL ASSEMBLER
|
||||||
Score: 63
|
Score: 60
|
||||||
|
|
||||||
// File Comments
|
// File Comments
|
||||||
// Test a procedure with calling convention stack
|
// Test a procedure with calling convention stack
|
||||||
@ -419,7 +412,6 @@ Score: 63
|
|||||||
// @end
|
// @end
|
||||||
// main
|
// main
|
||||||
main: {
|
main: {
|
||||||
.label _0 = 2
|
|
||||||
// plus('0', 7)
|
// plus('0', 7)
|
||||||
// [5] callprepare plus (byte) '0' (byte) 7
|
// [5] callprepare plus (byte) '0' (byte) 7
|
||||||
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
|
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
|
||||||
@ -434,11 +426,10 @@ main: {
|
|||||||
// [7] (byte~) main::$0 ← callfinalize plus
|
// [7] (byte~) main::$0 ← callfinalize plus
|
||||||
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
|
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
|
||||||
pla
|
pla
|
||||||
// [7] (byte~) main::$0 ← callfinalize plus -- vbuz1=_stackpullbyte_
|
// [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_
|
||||||
pla
|
pla
|
||||||
sta.z _0
|
|
||||||
// SCREEN[0] = plus('0', 7)
|
// SCREEN[0] = plus('0', 7)
|
||||||
// [8] *((const byte*) SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuz1
|
// [8] *((const byte*) SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuaa
|
||||||
sta SCREEN
|
sta SCREEN
|
||||||
// main::@return
|
// main::@return
|
||||||
// }
|
// }
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
||||||
(const word) STACK_BASE STACK_BASE = (word) $103
|
(const word) STACK_BASE STACK_BASE = (word) $103
|
||||||
(void()) main()
|
(void()) main()
|
||||||
(byte~) main::$0 $0 zp ZP_BYTE:2 2.0
|
(byte~) main::$0 reg byte a 2.0
|
||||||
(label) main::@return
|
(label) main::@return
|
||||||
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
||||||
(label) plus::@return
|
(label) plus::@return
|
||||||
@ -18,6 +18,7 @@ __stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
|||||||
(byte) plus::return
|
(byte) plus::return
|
||||||
(byte) plus::return#0 reg byte a 2.0
|
(byte) plus::return#0 reg byte a 2.0
|
||||||
|
|
||||||
zp ZP_BYTE:2 [ plus::a#0 main::$0 ]
|
reg byte a [ main::$0 ]
|
||||||
|
zp ZP_BYTE:2 [ plus::a#0 ]
|
||||||
reg byte a [ plus::b#0 ]
|
reg byte a [ plus::b#0 ]
|
||||||
reg byte a [ plus::return#0 ]
|
reg byte a [ plus::return#0 ]
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
.label SCREEN = $400
|
.label SCREEN = $400
|
||||||
.const STACK_BASE = $103
|
.const STACK_BASE = $103
|
||||||
main: {
|
main: {
|
||||||
.label _0 = 2
|
|
||||||
lda #'0'
|
lda #'0'
|
||||||
pha
|
pha
|
||||||
lda #7
|
lda #7
|
||||||
@ -13,7 +12,6 @@ main: {
|
|||||||
jsr plus
|
jsr plus
|
||||||
pla
|
pla
|
||||||
pla
|
pla
|
||||||
sta.z _0
|
|
||||||
sta SCREEN
|
sta SCREEN
|
||||||
rts
|
rts
|
||||||
}
|
}
|
||||||
|
@ -262,14 +262,11 @@ Uplift Scope [main] 2: zp ZP_BYTE:2 [ main::$0 ]
|
|||||||
Uplift Scope []
|
Uplift Scope []
|
||||||
|
|
||||||
Uplifting [plus] best 84 combination reg byte a [ plus::b#0 ] zp ZP_BYTE:3 [ plus::a#0 ] reg byte a [ plus::return#0 ]
|
Uplifting [plus] best 84 combination reg byte a [ plus::b#0 ] zp ZP_BYTE:3 [ plus::a#0 ] reg byte a [ plus::return#0 ]
|
||||||
Uplifting [main] best 84 combination zp ZP_BYTE:2 [ main::$0 ]
|
Uplifting [main] best 78 combination reg byte a [ main::$0 ]
|
||||||
Uplifting [] best 84 combination
|
Uplifting [] best 78 combination
|
||||||
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::$0 ]
|
|
||||||
Uplifting [main] best 84 combination zp ZP_BYTE:2 [ main::$0 ]
|
|
||||||
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ plus::a#0 ]
|
Attempting to uplift remaining variables inzp ZP_BYTE:3 [ plus::a#0 ]
|
||||||
Uplifting [plus] best 84 combination zp ZP_BYTE:3 [ plus::a#0 ]
|
Uplifting [plus] best 78 combination zp ZP_BYTE:3 [ plus::a#0 ]
|
||||||
Coalescing zero page register [ zp ZP_BYTE:3 [ plus::a#0 ] ] with [ zp ZP_BYTE:2 [ main::$0 ] ]
|
Allocated (was zp ZP_BYTE:3) zp ZP_BYTE:2 [ plus::a#0 ]
|
||||||
Allocated (was zp ZP_BYTE:3) zp ZP_BYTE:2 [ plus::a#0 main::$0 ]
|
|
||||||
|
|
||||||
ASSEMBLER BEFORE OPTIMIZATION
|
ASSEMBLER BEFORE OPTIMIZATION
|
||||||
// File Comments
|
// File Comments
|
||||||
@ -299,7 +296,6 @@ bend_from_b1:
|
|||||||
bend:
|
bend:
|
||||||
// main
|
// main
|
||||||
main: {
|
main: {
|
||||||
.label _0 = 2
|
|
||||||
// [5] callprepare plus (byte) '0' (byte) 7
|
// [5] callprepare plus (byte) '0' (byte) 7
|
||||||
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
|
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
|
||||||
lda #'0'
|
lda #'0'
|
||||||
@ -313,11 +309,9 @@ main: {
|
|||||||
// [7] (byte~) main::$0 ← callfinalize plus
|
// [7] (byte~) main::$0 ← callfinalize plus
|
||||||
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
|
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
|
||||||
pla
|
pla
|
||||||
// [7] (byte~) main::$0 ← callfinalize plus -- vbuz1=_stackpullbyte_
|
// [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_
|
||||||
pla
|
pla
|
||||||
sta.z _0
|
// [8] *((const byte*) SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuaa
|
||||||
// [8] *((const byte*) SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuz1
|
|
||||||
lda.z _0
|
|
||||||
sta SCREEN
|
sta SCREEN
|
||||||
jmp breturn
|
jmp breturn
|
||||||
// main::@return
|
// main::@return
|
||||||
@ -355,8 +349,6 @@ Removing instruction jmp bend
|
|||||||
Removing instruction jmp breturn
|
Removing instruction jmp breturn
|
||||||
Removing instruction jmp breturn
|
Removing instruction jmp breturn
|
||||||
Succesful ASM optimization Pass5NextJumpElimination
|
Succesful ASM optimization Pass5NextJumpElimination
|
||||||
Removing instruction lda.z _0
|
|
||||||
Succesful ASM optimization Pass5UnnecesaryLoadElimination
|
|
||||||
Removing instruction b1_from_bbegin:
|
Removing instruction b1_from_bbegin:
|
||||||
Removing instruction b1:
|
Removing instruction b1:
|
||||||
Removing instruction main_from_b1:
|
Removing instruction main_from_b1:
|
||||||
@ -380,7 +372,7 @@ FINAL SYMBOL TABLE
|
|||||||
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
||||||
(const word) STACK_BASE STACK_BASE = (word) $103
|
(const word) STACK_BASE STACK_BASE = (word) $103
|
||||||
(void()) main()
|
(void()) main()
|
||||||
(byte~) main::$0 $0 zp ZP_BYTE:2 2.0
|
(byte~) main::$0 reg byte a 2.0
|
||||||
(label) main::@return
|
(label) main::@return
|
||||||
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
||||||
(label) plus::@return
|
(label) plus::@return
|
||||||
@ -393,13 +385,14 @@ __stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
|||||||
(byte) plus::return
|
(byte) plus::return
|
||||||
(byte) plus::return#0 reg byte a 2.0
|
(byte) plus::return#0 reg byte a 2.0
|
||||||
|
|
||||||
zp ZP_BYTE:2 [ plus::a#0 main::$0 ]
|
reg byte a [ main::$0 ]
|
||||||
|
zp ZP_BYTE:2 [ plus::a#0 ]
|
||||||
reg byte a [ plus::b#0 ]
|
reg byte a [ plus::b#0 ]
|
||||||
reg byte a [ plus::return#0 ]
|
reg byte a [ plus::return#0 ]
|
||||||
|
|
||||||
|
|
||||||
FINAL ASSEMBLER
|
FINAL ASSEMBLER
|
||||||
Score: 63
|
Score: 60
|
||||||
|
|
||||||
// File Comments
|
// File Comments
|
||||||
// Test a procedure with calling convention stack
|
// Test a procedure with calling convention stack
|
||||||
@ -419,7 +412,6 @@ Score: 63
|
|||||||
// @end
|
// @end
|
||||||
// main
|
// main
|
||||||
main: {
|
main: {
|
||||||
.label _0 = 2
|
|
||||||
// plus('0', 7)
|
// plus('0', 7)
|
||||||
// [5] callprepare plus (byte) '0' (byte) 7
|
// [5] callprepare plus (byte) '0' (byte) 7
|
||||||
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
|
// [5] callprepare plus (byte) '0' (byte) 7 -- _stackpushbyte_=vbuc1
|
||||||
@ -434,11 +426,10 @@ main: {
|
|||||||
// [7] (byte~) main::$0 ← callfinalize plus
|
// [7] (byte~) main::$0 ← callfinalize plus
|
||||||
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
|
// [7] (byte~) main::$0 ← callfinalize plus -- _stackpullbyte_1
|
||||||
pla
|
pla
|
||||||
// [7] (byte~) main::$0 ← callfinalize plus -- vbuz1=_stackpullbyte_
|
// [7] (byte~) main::$0 ← callfinalize plus -- vbuaa=_stackpullbyte_
|
||||||
pla
|
pla
|
||||||
sta.z _0
|
|
||||||
// SCREEN[0] = plus('0', 7)
|
// SCREEN[0] = plus('0', 7)
|
||||||
// [8] *((const byte*) SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuz1
|
// [8] *((const byte*) SCREEN#0) ← (byte~) main::$0 -- _deref_pbuc1=vbuaa
|
||||||
sta SCREEN
|
sta SCREEN
|
||||||
// main::@return
|
// main::@return
|
||||||
// }
|
// }
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
||||||
(const word) STACK_BASE STACK_BASE = (word) $103
|
(const word) STACK_BASE STACK_BASE = (word) $103
|
||||||
(void()) main()
|
(void()) main()
|
||||||
(byte~) main::$0 $0 zp ZP_BYTE:2 2.0
|
(byte~) main::$0 reg byte a 2.0
|
||||||
(label) main::@return
|
(label) main::@return
|
||||||
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
||||||
(label) plus::@return
|
(label) plus::@return
|
||||||
@ -18,6 +18,7 @@ __stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
|||||||
(byte) plus::return
|
(byte) plus::return
|
||||||
(byte) plus::return#0 reg byte a 2.0
|
(byte) plus::return#0 reg byte a 2.0
|
||||||
|
|
||||||
zp ZP_BYTE:2 [ plus::a#0 main::$0 ]
|
reg byte a [ main::$0 ]
|
||||||
|
zp ZP_BYTE:2 [ plus::a#0 ]
|
||||||
reg byte a [ plus::b#0 ]
|
reg byte a [ plus::b#0 ]
|
||||||
reg byte a [ plus::return#0 ]
|
reg byte a [ plus::return#0 ]
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
.label SCREEN = $400
|
.label SCREEN = $400
|
||||||
.const STACK_BASE = $103
|
.const STACK_BASE = $103
|
||||||
main: {
|
main: {
|
||||||
.label w = 2
|
|
||||||
ldy #0
|
ldy #0
|
||||||
b1:
|
b1:
|
||||||
tya
|
tya
|
||||||
@ -19,10 +18,9 @@ main: {
|
|||||||
jsr plus
|
jsr plus
|
||||||
pla
|
pla
|
||||||
pla
|
pla
|
||||||
sta.z w
|
sty.z $ff
|
||||||
tya
|
|
||||||
clc
|
clc
|
||||||
adc.z w
|
adc.z $ff
|
||||||
sta SCREEN
|
sta SCREEN
|
||||||
iny
|
iny
|
||||||
cpy #2
|
cpy #2
|
||||||
|
@ -403,16 +403,13 @@ Uplift Scope [main] 22.79: zp ZP_BYTE:2 [ main::a#2 main::a#1 ] 22: zp ZP_BYTE:5
|
|||||||
Uplift Scope [plus] 4: zp ZP_BYTE:7 [ plus::b#0 ] 2: zp ZP_BYTE:6 [ plus::a#0 ] 2: zp ZP_BYTE:8 [ plus::return#0 ]
|
Uplift Scope [plus] 4: zp ZP_BYTE:7 [ plus::b#0 ] 2: zp ZP_BYTE:6 [ plus::a#0 ] 2: zp ZP_BYTE:8 [ plus::return#0 ]
|
||||||
Uplift Scope []
|
Uplift Scope []
|
||||||
|
|
||||||
Uplifting [main] best 671 combination reg byte y [ main::a#2 main::a#1 ] reg byte a [ main::$2 ] reg byte x [ main::v#0 ] zp ZP_BYTE:4 [ main::w#0 ]
|
Uplifting [main] best 651 combination reg byte y [ main::a#2 main::a#1 ] reg byte a [ main::$2 ] reg byte x [ main::v#0 ] reg byte a [ main::w#0 ]
|
||||||
Limited combination testing to 100 combinations of 128 possible.
|
Limited combination testing to 100 combinations of 128 possible.
|
||||||
Uplifting [plus] best 662 combination reg byte a [ plus::b#0 ] zp ZP_BYTE:6 [ plus::a#0 ] reg byte a [ plus::return#0 ]
|
Uplifting [plus] best 642 combination reg byte a [ plus::b#0 ] zp ZP_BYTE:6 [ plus::a#0 ] reg byte a [ plus::return#0 ]
|
||||||
Uplifting [] best 662 combination
|
Uplifting [] best 642 combination
|
||||||
Attempting to uplift remaining variables inzp ZP_BYTE:4 [ main::w#0 ]
|
|
||||||
Uplifting [main] best 662 combination zp ZP_BYTE:4 [ main::w#0 ]
|
|
||||||
Attempting to uplift remaining variables inzp ZP_BYTE:6 [ plus::a#0 ]
|
Attempting to uplift remaining variables inzp ZP_BYTE:6 [ plus::a#0 ]
|
||||||
Uplifting [plus] best 662 combination zp ZP_BYTE:6 [ plus::a#0 ]
|
Uplifting [plus] best 642 combination zp ZP_BYTE:6 [ plus::a#0 ]
|
||||||
Coalescing zero page register [ zp ZP_BYTE:6 [ plus::a#0 ] ] with [ zp ZP_BYTE:4 [ main::w#0 ] ]
|
Allocated (was zp ZP_BYTE:6) zp ZP_BYTE:2 [ plus::a#0 ]
|
||||||
Allocated (was zp ZP_BYTE:6) zp ZP_BYTE:2 [ plus::a#0 main::w#0 ]
|
|
||||||
|
|
||||||
ASSEMBLER BEFORE OPTIMIZATION
|
ASSEMBLER BEFORE OPTIMIZATION
|
||||||
// File Comments
|
// File Comments
|
||||||
@ -443,7 +440,6 @@ bend_from_b1:
|
|||||||
bend:
|
bend:
|
||||||
// main
|
// main
|
||||||
main: {
|
main: {
|
||||||
.label w = 2
|
|
||||||
// [5] phi from main to main::@1 [phi:main->main::@1]
|
// [5] phi from main to main::@1 [phi:main->main::@1]
|
||||||
b1_from_main:
|
b1_from_main:
|
||||||
// [5] phi (byte) main::a#2 = (byte) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1
|
// [5] phi (byte) main::a#2 = (byte) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1
|
||||||
@ -472,13 +468,12 @@ main: {
|
|||||||
// [9] (byte) main::w#0 ← callfinalize plus
|
// [9] (byte) main::w#0 ← callfinalize plus
|
||||||
// [9] (byte) main::w#0 ← callfinalize plus -- _stackpullbyte_1
|
// [9] (byte) main::w#0 ← callfinalize plus -- _stackpullbyte_1
|
||||||
pla
|
pla
|
||||||
// [9] (byte) main::w#0 ← callfinalize plus -- vbuz1=_stackpullbyte_
|
// [9] (byte) main::w#0 ← callfinalize plus -- vbuaa=_stackpullbyte_
|
||||||
pla
|
pla
|
||||||
sta.z w
|
// [10] (byte~) main::$2 ← (byte) main::w#0 + (byte) main::a#2 -- vbuaa=vbuaa_plus_vbuyy
|
||||||
// [10] (byte~) main::$2 ← (byte) main::w#0 + (byte) main::a#2 -- vbuaa=vbuz1_plus_vbuyy
|
sty.z $ff
|
||||||
tya
|
|
||||||
clc
|
clc
|
||||||
adc.z w
|
adc.z $ff
|
||||||
// [11] *((const byte*) SCREEN#0) ← (byte~) main::$2 -- _deref_pbuc1=vbuaa
|
// [11] *((const byte*) SCREEN#0) ← (byte~) main::$2 -- _deref_pbuc1=vbuaa
|
||||||
sta SCREEN
|
sta SCREEN
|
||||||
// [12] (byte) main::a#1 ← ++ (byte) main::a#2 -- vbuyy=_inc_vbuyy
|
// [12] (byte) main::a#1 ← ++ (byte) main::a#2 -- vbuyy=_inc_vbuyy
|
||||||
@ -561,7 +556,7 @@ FINAL SYMBOL TABLE
|
|||||||
(byte) main::v
|
(byte) main::v
|
||||||
(byte) main::v#0 reg byte x 11.0
|
(byte) main::v#0 reg byte x 11.0
|
||||||
(byte) main::w
|
(byte) main::w
|
||||||
(byte) main::w#0 w zp ZP_BYTE:2 11.0
|
(byte) main::w#0 reg byte a 11.0
|
||||||
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
||||||
(label) plus::@return
|
(label) plus::@return
|
||||||
(const byte) plus::OFFSET_STACK_A OFFSET_STACK_A = (byte) 0
|
(const byte) plus::OFFSET_STACK_A OFFSET_STACK_A = (byte) 0
|
||||||
@ -575,14 +570,15 @@ __stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
|||||||
|
|
||||||
reg byte y [ main::a#2 main::a#1 ]
|
reg byte y [ main::a#2 main::a#1 ]
|
||||||
reg byte x [ main::v#0 ]
|
reg byte x [ main::v#0 ]
|
||||||
|
reg byte a [ main::w#0 ]
|
||||||
reg byte a [ main::$2 ]
|
reg byte a [ main::$2 ]
|
||||||
zp ZP_BYTE:2 [ plus::a#0 main::w#0 ]
|
zp ZP_BYTE:2 [ plus::a#0 ]
|
||||||
reg byte a [ plus::b#0 ]
|
reg byte a [ plus::b#0 ]
|
||||||
reg byte a [ plus::return#0 ]
|
reg byte a [ plus::return#0 ]
|
||||||
|
|
||||||
|
|
||||||
FINAL ASSEMBLER
|
FINAL ASSEMBLER
|
||||||
Score: 557
|
Score: 537
|
||||||
|
|
||||||
// File Comments
|
// File Comments
|
||||||
// Test a procedure with calling convention stack
|
// Test a procedure with calling convention stack
|
||||||
@ -603,7 +599,6 @@ Score: 557
|
|||||||
// @end
|
// @end
|
||||||
// main
|
// main
|
||||||
main: {
|
main: {
|
||||||
.label w = 2
|
|
||||||
// [5] phi from main to main::@1 [phi:main->main::@1]
|
// [5] phi from main to main::@1 [phi:main->main::@1]
|
||||||
// [5] phi (byte) main::a#2 = (byte) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1
|
// [5] phi (byte) main::a#2 = (byte) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1
|
||||||
ldy #0
|
ldy #0
|
||||||
@ -630,14 +625,13 @@ main: {
|
|||||||
// [9] (byte) main::w#0 ← callfinalize plus
|
// [9] (byte) main::w#0 ← callfinalize plus
|
||||||
// [9] (byte) main::w#0 ← callfinalize plus -- _stackpullbyte_1
|
// [9] (byte) main::w#0 ← callfinalize plus -- _stackpullbyte_1
|
||||||
pla
|
pla
|
||||||
// [9] (byte) main::w#0 ← callfinalize plus -- vbuz1=_stackpullbyte_
|
// [9] (byte) main::w#0 ← callfinalize plus -- vbuaa=_stackpullbyte_
|
||||||
pla
|
pla
|
||||||
sta.z w
|
|
||||||
// w+a
|
// w+a
|
||||||
// [10] (byte~) main::$2 ← (byte) main::w#0 + (byte) main::a#2 -- vbuaa=vbuz1_plus_vbuyy
|
// [10] (byte~) main::$2 ← (byte) main::w#0 + (byte) main::a#2 -- vbuaa=vbuaa_plus_vbuyy
|
||||||
tya
|
sty.z $ff
|
||||||
clc
|
clc
|
||||||
adc.z w
|
adc.z $ff
|
||||||
// SCREEN[i] = w+a
|
// SCREEN[i] = w+a
|
||||||
// [11] *((const byte*) SCREEN#0) ← (byte~) main::$2 -- _deref_pbuc1=vbuaa
|
// [11] *((const byte*) SCREEN#0) ← (byte~) main::$2 -- _deref_pbuc1=vbuaa
|
||||||
sta SCREEN
|
sta SCREEN
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
(byte) main::v
|
(byte) main::v
|
||||||
(byte) main::v#0 reg byte x 11.0
|
(byte) main::v#0 reg byte x 11.0
|
||||||
(byte) main::w
|
(byte) main::w
|
||||||
(byte) main::w#0 w zp ZP_BYTE:2 11.0
|
(byte) main::w#0 reg byte a 11.0
|
||||||
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
__stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
||||||
(label) plus::@return
|
(label) plus::@return
|
||||||
(const byte) plus::OFFSET_STACK_A OFFSET_STACK_A = (byte) 0
|
(const byte) plus::OFFSET_STACK_A OFFSET_STACK_A = (byte) 0
|
||||||
@ -29,7 +29,8 @@ __stackcall (byte()) plus((byte) plus::a , (byte) plus::b)
|
|||||||
|
|
||||||
reg byte y [ main::a#2 main::a#1 ]
|
reg byte y [ main::a#2 main::a#1 ]
|
||||||
reg byte x [ main::v#0 ]
|
reg byte x [ main::v#0 ]
|
||||||
|
reg byte a [ main::w#0 ]
|
||||||
reg byte a [ main::$2 ]
|
reg byte a [ main::$2 ]
|
||||||
zp ZP_BYTE:2 [ plus::a#0 main::w#0 ]
|
zp ZP_BYTE:2 [ plus::a#0 ]
|
||||||
reg byte a [ plus::b#0 ]
|
reg byte a [ plus::b#0 ]
|
||||||
reg byte a [ plus::return#0 ]
|
reg byte a [ plus::return#0 ]
|
||||||
|
Loading…
Reference in New Issue
Block a user