1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-04-06 15:41:05 +00:00

Fixed removal of unused vars.

This commit is contained in:
Jesper Gravgaard 2020-02-13 13:46:54 +01:00
parent f106f953a8
commit f92e750b61
10 changed files with 81 additions and 160 deletions

View File

@ -44,7 +44,7 @@ public class PassNEliminateUnusedVars extends Pass2SsaOptimization {
if(variable == null) {
// Already deleted
eliminate = true;
} else if(!variable.isVolatile() && !variable.isExport()) {
} else if(!variable.isExport()) {
// Not volatile
eliminate = true;
} else if(variable.isStruct()) {

View File

@ -1,6 +1,5 @@
Resolved forward reference irq to interrupt(KERNEL_MIN)(void()) irq()
Resolved forward reference framedone to (bool) framedone
Eliminating unused variable with no statement (bool) framedone
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@6

View File

@ -22,7 +22,6 @@ Warning! Adding boolean cast to non-boolean condition (struct node*) sum::curren
Warning! Adding boolean cast to non-boolean sub-expression (byte) print_str_lines::ch
Identified constant variable (byte*) HEAP_TOP
Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx
Eliminating unused variable with no statement (word) rand_seed
Culled Empty Block (label) @1
Culled Empty Block (label) @2
Culled Empty Block (label) @3

View File

@ -16,7 +16,6 @@ Warning! Adding boolean cast to non-boolean condition (byte) sum::i
Warning! Adding boolean cast to non-boolean sub-expression (byte) print_str_lines::ch
Identified constant variable (byte*) HEAP_TOP
Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx
Eliminating unused variable with no statement (word) rand_seed
Culled Empty Block (label) @1
Culled Empty Block (label) @2
Culled Empty Block (label) @3

View File

@ -15,7 +15,6 @@ Warning! Adding boolean cast to non-boolean condition *((byte*) print_str_at::st
Warning! Adding boolean cast to non-boolean sub-expression (byte) print_str_lines::ch
Identified constant variable (byte*) HEAP_TOP
Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx
Eliminating unused variable with no statement (word) rand_seed
Culled Empty Block (label) @1
Culled Empty Block (label) @2
Culled Empty Block (label) @3

View File

@ -8,13 +8,6 @@
.const SIZEOF_WORD = 2
.const SIZEOF_POINTER = 2
main: {
.label b = 2
.label w = 3
// Simple types
lda #0
sta.z b
sta.z w
sta.z w+1
lda #'0'+SIZEOF_NUMBER
sta SCREEN
lda #'0'+SIZEOF_BYTE

View File

@ -10,17 +10,15 @@
(void()) main()
main: scope:[main] from @1
[4] (byte) main::b ← (byte) 0
[5] (word) main::w ← (word) 0
[6] *((const byte*) SCREEN) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[7] *((const byte*) SCREEN+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE
[8] *((const byte*) SCREEN+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE
[9] *((const byte*) SCREEN+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[10] *((const byte*) SCREEN+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[11] *((const byte*) SCREEN+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD
[12] *((const byte*) SCREEN+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER
[13] *((const byte*) SCREEN+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER
[4] *((const byte*) SCREEN) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[5] *((const byte*) SCREEN+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE
[6] *((const byte*) SCREEN+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE
[7] *((const byte*) SCREEN+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[8] *((const byte*) SCREEN+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[9] *((const byte*) SCREEN+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD
[10] *((const byte*) SCREEN+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER
[11] *((const byte*) SCREEN+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER
to:main::@return
main::@return: scope:[main] from main
[14] return
[12] return
to:@return

View File

@ -15,8 +15,6 @@ CONTROL FLOW GRAPH SSA
(void()) main()
main: scope:[main] from @1
(byte) main::idx#0 ← (byte) 0
(byte) main::b ← (byte) 0
(word) main::w ← (word) 0
(byte~) main::$0 ← sizeof (number) 0
(byte~) main::$1 ← (byte) '0' + (byte~) main::$0
*((const byte*) SCREEN + (byte) main::idx#0) ← (byte~) main::$1
@ -90,7 +88,6 @@ SYMBOL TABLE SSA
(byte~) main::$8
(byte~) main::$9
(label) main::@return
(byte) main::b loadstore
(byte) main::idx
(byte) main::idx#0
(byte) main::idx#1
@ -103,12 +100,11 @@ SYMBOL TABLE SSA
(byte) main::idx#7
(byte) main::idx#8
(byte) main::idx#9
(word) main::w loadstore
Simplifying constant pointer cast (byte*) 1024
Successful SSA optimization PassNCastSimplification
Constant right-side identified [3] (byte~) main::$0 ← sizeof (number) 0
Constant right-side identified [20] (byte~) main::$9 ← sizeof (number) $43ff
Constant right-side identified [1] (byte~) main::$0 ← sizeof (number) 0
Constant right-side identified [18] (byte~) main::$9 ← sizeof (number) $43ff
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#0 = 0
Constant (const byte) main::$0 = sizeof 0
@ -120,22 +116,22 @@ Constant (const byte) main::$11 = SIZEOF_WORD
Constant (const byte) main::$13 = SIZEOF_POINTER
Constant (const byte) main::$15 = SIZEOF_POINTER
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero SCREEN in [5] *((const byte*) SCREEN + (const byte) main::idx#0) ← (byte~) main::$1
Simplifying expression containing zero SCREEN in [3] *((const byte*) SCREEN + (const byte) main::idx#0) ← (byte~) main::$1
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (byte) main::idx#10 and assignment [27] (byte) main::idx#10 ← ++ (byte) main::idx#9
Eliminating unused variable (byte) main::idx#10 and assignment [25] (byte) main::idx#10 ← ++ (byte) main::idx#9
Successful SSA optimization PassNEliminateUnusedVars
Resolving sizeof() sizeof (number) 0
Resolving sizeof() sizeof (number) $43ff
Successful SSA optimization PassNSizeOfSimplification
Constant right-side identified [2] (byte~) main::$1 ← (byte) '0' + (const byte) main::$0
Constant right-side identified [4] (byte) main::idx#1 ← ++ (const byte) main::idx#0
Constant right-side identified [5] (byte~) main::$3 ← (byte) '0' + (const byte) main::$2
Constant right-side identified [8] (byte~) main::$5 ← (byte) '0' + (const byte) main::$4
Constant right-side identified [11] (byte~) main::$8 ← (byte) '0' + (const byte) main::$7
Constant right-side identified [15] (byte~) main::$10 ← (byte) '0' + (const byte) main::$9
Constant right-side identified [18] (byte~) main::$12 ← (byte) '0' + (const byte) main::$11
Constant right-side identified [22] (byte~) main::$14 ← (byte) '0' + (const byte) main::$13
Constant right-side identified [25] (byte~) main::$16 ← (byte) '0' + (const byte) main::$15
Constant right-side identified [0] (byte~) main::$1 ← (byte) '0' + (const byte) main::$0
Constant right-side identified [2] (byte) main::idx#1 ← ++ (const byte) main::idx#0
Constant right-side identified [3] (byte~) main::$3 ← (byte) '0' + (const byte) main::$2
Constant right-side identified [6] (byte~) main::$5 ← (byte) '0' + (const byte) main::$4
Constant right-side identified [9] (byte~) main::$8 ← (byte) '0' + (const byte) main::$7
Constant right-side identified [13] (byte~) main::$10 ← (byte) '0' + (const byte) main::$9
Constant right-side identified [16] (byte~) main::$12 ← (byte) '0' + (const byte) main::$11
Constant right-side identified [20] (byte~) main::$14 ← (byte) '0' + (const byte) main::$13
Constant right-side identified [23] (byte~) main::$16 ← (byte) '0' + (const byte) main::$15
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::$1 = '0'+main::$0
Constant (const byte) main::idx#1 = ++main::idx#0
@ -147,35 +143,35 @@ Constant (const byte) main::$12 = '0'+main::$11
Constant (const byte) main::$14 = '0'+main::$13
Constant (const byte) main::$16 = '0'+main::$15
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [4] (byte) main::idx#2 ← ++ (const byte) main::idx#1
Constant right-side identified [2] (byte) main::idx#2 ← ++ (const byte) main::idx#1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#2 = ++main::idx#1
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [5] (byte) main::idx#3 ← ++ (const byte) main::idx#2
Constant right-side identified [3] (byte) main::idx#3 ← ++ (const byte) main::idx#2
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#3 = ++main::idx#2
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [6] (byte) main::idx#4 ← ++ (const byte) main::idx#3
Constant right-side identified [4] (byte) main::idx#4 ← ++ (const byte) main::idx#3
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#4 = ++main::idx#3
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [6] (byte) main::idx#5 ← ++ (const byte) main::idx#4
Constant right-side identified [4] (byte) main::idx#5 ← ++ (const byte) main::idx#4
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#5 = ++main::idx#4
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [7] (byte) main::idx#6 ← ++ (const byte) main::idx#5
Constant right-side identified [5] (byte) main::idx#6 ← ++ (const byte) main::idx#5
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#6 = ++main::idx#5
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [8] (byte) main::idx#7 ← ++ (const byte) main::idx#6
Constant right-side identified [6] (byte) main::idx#7 ← ++ (const byte) main::idx#6
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#7 = ++main::idx#6
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [8] (byte) main::idx#8 ← ++ (const byte) main::idx#7
Constant right-side identified [6] (byte) main::idx#8 ← ++ (const byte) main::idx#7
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#8 = ++main::idx#7
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [9] (byte) main::idx#9 ← ++ (const byte) main::idx#8
Constant right-side identified [7] (byte) main::idx#9 ← ++ (const byte) main::idx#8
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#9 = ++main::idx#8
Successful SSA optimization Pass2ConstantIdentification
@ -269,36 +265,26 @@ FINAL CONTROL FLOW GRAPH
(void()) main()
main: scope:[main] from @1
[4] (byte) main::b ← (byte) 0
[5] (word) main::w ← (word) 0
[6] *((const byte*) SCREEN) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[7] *((const byte*) SCREEN+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE
[8] *((const byte*) SCREEN+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE
[9] *((const byte*) SCREEN+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[10] *((const byte*) SCREEN+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[11] *((const byte*) SCREEN+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD
[12] *((const byte*) SCREEN+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER
[13] *((const byte*) SCREEN+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER
[4] *((const byte*) SCREEN) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[5] *((const byte*) SCREEN+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE
[6] *((const byte*) SCREEN+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE
[7] *((const byte*) SCREEN+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[8] *((const byte*) SCREEN+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[9] *((const byte*) SCREEN+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD
[10] *((const byte*) SCREEN+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER
[11] *((const byte*) SCREEN+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER
to:main::@return
main::@return: scope:[main] from main
[14] return
[12] return
to:@return
VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::b loadstore 20.0
(byte) main::idx
(word) main::w loadstore 20.0
Initial phi equivalence classes
Added variable main::b to live range equivalence class [ main::b ]
Added variable main::w to live range equivalence class [ main::w ]
Complete equivalence classes
[ main::b ]
[ main::w ]
Allocated zp[1]:2 [ main::b ]
Allocated zp[2]:3 [ main::w ]
INITIAL ASM
Target platform is c64basic / MOS6502X
@ -330,71 +316,54 @@ __bend_from___b1:
__bend:
// main
main: {
.label b = 2
.label w = 3
// [4] (byte) main::b ← (byte) 0 -- vbuz1=vbuc1
// Simple types
lda #0
sta.z b
// [5] (word) main::w ← (word) 0 -- vwuz1=vwuc1
lda #<0
sta.z w
lda #>0
sta.z w+1
// [6] *((const byte*) SCREEN) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
// [4] *((const byte*) SCREEN) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
sta SCREEN
// [7] *((const byte*) SCREEN+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
// [5] *((const byte*) SCREEN+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_BYTE
sta SCREEN+1
// [8] *((const byte*) SCREEN+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
// [6] *((const byte*) SCREEN+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_BYTE
sta SCREEN+2
// [9] *((const byte*) SCREEN+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
// [7] *((const byte*) SCREEN+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
sta SCREEN+3
// [10] *((const byte*) SCREEN+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
// [8] *((const byte*) SCREEN+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
sta SCREEN+5
// [11] *((const byte*) SCREEN+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
// [9] *((const byte*) SCREEN+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_WORD
sta SCREEN+6
// [12] *((const byte*) SCREEN+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
// [10] *((const byte*) SCREEN+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_POINTER
sta SCREEN+8
// [13] *((const byte*) SCREEN+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
// [11] *((const byte*) SCREEN+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_POINTER
sta SCREEN+9
jmp __breturn
// main::@return
__breturn:
// [14] return
// [12] return
rts
}
// File Data
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] (byte) main::b ← (byte) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [5] (word) main::w ← (word) 0 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [6] *((const byte*) SCREEN) ← (byte) '0'+(const byte) SIZEOF_NUMBER [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] *((const byte*) SCREEN+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [8] *((const byte*) SCREEN+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [9] *((const byte*) SCREEN+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [10] *((const byte*) SCREEN+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [11] *((const byte*) SCREEN+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [12] *((const byte*) SCREEN+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [13] *((const byte*) SCREEN+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER [ ] ( main:2 [ ] ) always clobbers reg byte a
Potential registers zp[1]:2 [ main::b ] : zp[1]:2 ,
Potential registers zp[2]:3 [ main::w ] : zp[2]:3 ,
Statement [4] *((const byte*) SCREEN) ← (byte) '0'+(const byte) SIZEOF_NUMBER [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [5] *((const byte*) SCREEN+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [6] *((const byte*) SCREEN+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] *((const byte*) SCREEN+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [8] *((const byte*) SCREEN+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [9] *((const byte*) SCREEN+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [10] *((const byte*) SCREEN+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [11] *((const byte*) SCREEN+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER [ ] ( main:2 [ ] ) always clobbers reg byte a
REGISTER UPLIFT SCOPES
Uplift Scope [main] 20: zp[1]:2 [ main::b ] 20: zp[2]:3 [ main::w ]
Uplift Scope [main]
Uplift Scope []
Uplifting [main] best 84 combination zp[1]:2 [ main::b ] zp[2]:3 [ main::w ]
Uplifting [] best 84 combination
Attempting to uplift remaining variables inzp[1]:2 [ main::b ]
Uplifting [main] best 84 combination zp[1]:2 [ main::b ]
Uplifting [main] best 69 combination
Uplifting [] best 69 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -425,45 +394,34 @@ __bend_from___b1:
__bend:
// main
main: {
.label b = 2
.label w = 3
// [4] (byte) main::b ← (byte) 0 -- vbuz1=vbuc1
// Simple types
lda #0
sta.z b
// [5] (word) main::w ← (word) 0 -- vwuz1=vwuc1
lda #<0
sta.z w
lda #>0
sta.z w+1
// [6] *((const byte*) SCREEN) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
// [4] *((const byte*) SCREEN) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
sta SCREEN
// [7] *((const byte*) SCREEN+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
// [5] *((const byte*) SCREEN+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_BYTE
sta SCREEN+1
// [8] *((const byte*) SCREEN+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
// [6] *((const byte*) SCREEN+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_BYTE
sta SCREEN+2
// [9] *((const byte*) SCREEN+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
// [7] *((const byte*) SCREEN+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
sta SCREEN+3
// [10] *((const byte*) SCREEN+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
// [8] *((const byte*) SCREEN+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
sta SCREEN+5
// [11] *((const byte*) SCREEN+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
// [9] *((const byte*) SCREEN+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_WORD
sta SCREEN+6
// [12] *((const byte*) SCREEN+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
// [10] *((const byte*) SCREEN+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_POINTER
sta SCREEN+8
// [13] *((const byte*) SCREEN+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
// [11] *((const byte*) SCREEN+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_POINTER
sta SCREEN+9
jmp __breturn
// main::@return
__breturn:
// [14] return
// [12] return
rts
}
// File Data
@ -473,8 +431,6 @@ Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #<0
Removing instruction lda #>0
Removing instruction lda #'0'+SIZEOF_BYTE
Removing instruction lda #'0'+SIZEOF_NUMBER
Removing instruction lda #'0'+SIZEOF_POINTER
@ -504,16 +460,12 @@ FINAL SYMBOL TABLE
(const byte) SIZEOF_WORD = (byte) 2
(void()) main()
(label) main::@return
(byte) main::b loadstore zp[1]:2 20.0
(byte) main::idx
(word) main::w loadstore zp[2]:3 20.0
zp[1]:2 [ main::b ]
zp[2]:3 [ main::w ]
FINAL ASSEMBLER
Score: 59
Score: 48
// File Comments
// Tests the sizeof() operator on values/expressions
@ -535,49 +487,38 @@ Score: 59
// @end
// main
main: {
.label b = 2
.label w = 3
// b = 0
// [4] (byte) main::b ← (byte) 0 -- vbuz1=vbuc1
// Simple types
lda #0
sta.z b
// w = 0
// [5] (word) main::w ← (word) 0 -- vwuz1=vwuc1
sta.z w
sta.z w+1
// SCREEN[idx++] = '0'+sizeof(0)
// [6] *((const byte*) SCREEN) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
// [4] *((const byte*) SCREEN) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
sta SCREEN
// SCREEN[idx++] = '0'+sizeof(idx)
// [7] *((const byte*) SCREEN+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
// [5] *((const byte*) SCREEN+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_BYTE
sta SCREEN+1
// SCREEN[idx++] = '0'+sizeof(b)
// [8] *((const byte*) SCREEN+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
// [6] *((const byte*) SCREEN+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
sta SCREEN+2
// SCREEN[idx++] = '0'+sizeof(b*2)
// [9] *((const byte*) SCREEN+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
// [7] *((const byte*) SCREEN+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
sta SCREEN+3
// SCREEN[idx++] = '0'+sizeof($43ff)
// [10] *((const byte*) SCREEN+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
// [8] *((const byte*) SCREEN+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
sta SCREEN+5
// SCREEN[idx++] = '0'+sizeof(w)
// [11] *((const byte*) SCREEN+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
// [9] *((const byte*) SCREEN+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_WORD
sta SCREEN+6
// SCREEN[idx++] = '0'+sizeof(bp)
// [12] *((const byte*) SCREEN+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
// [10] *((const byte*) SCREEN+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_POINTER
sta SCREEN+8
// SCREEN[idx++] = '0'+sizeof(wp)
// [13] *((const byte*) SCREEN+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
// [11] *((const byte*) SCREEN+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
sta SCREEN+9
// main::@return
// }
// [14] return
// [12] return
rts
}
// File Data

View File

@ -8,9 +8,5 @@
(const byte) SIZEOF_WORD = (byte) 2
(void()) main()
(label) main::@return
(byte) main::b loadstore zp[1]:2 20.0
(byte) main::idx
(word) main::w loadstore zp[2]:3 20.0
zp[1]:2 [ main::b ]
zp[2]:3 [ main::w ]

View File

@ -605,14 +605,11 @@ Eliminating unused constant (const signed byte) testSigned::$4
Eliminating unused constant (const signed byte) testSigned::$6
Eliminating unused constant (const byte) idx#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused variable with no statement (byte) testUnsigned::ubv1
Eliminating unused variable with no statement (signed byte) testSigned::sbv1
Eliminating unused variable (byte) testUnsigned::ubv1 and assignment [5] (byte) testUnsigned::ubv1 ← (byte) $fa
Eliminating unused variable (signed byte) testSigned::sbv1 and assignment [56] (signed byte) testSigned::sbv1 ← (signed byte) -$78
Eliminating unused constant (const byte) testUnsigned::ubc1
Eliminating unused constant (const signed byte) testSigned::sbc1
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused variable testUnsigned::ubv1(null) and assignment [5] testUnsigned::ubv1(null) ← (byte) $fa
Eliminating unused variable testSigned::sbv1(null) and assignment [56] testSigned::sbv1(null) ← (signed byte) -$78
Successful SSA optimization PassNEliminateUnusedVars
Constant right-side identified [6] (byte) idx#10 ← ++ (const byte) idx#1
Constant right-side identified [29] (byte) idx#22 ← ++ (const byte) idx#3
Constant right-side identified [56] (byte) idx#34 ← ++ (const byte) idx#5