mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-19 14:31:25 +00:00
Added a new constant test
This commit is contained in:
parent
a09ca15dbf
commit
525ac454cc
20
src/main/java/dk/camelot64/kickc/test/ref/constantmin.asm
Normal file
20
src/main/java/dk/camelot64/kickc/test/ref/constantmin.asm
Normal file
@ -0,0 +1,20 @@
|
||||
.const SCREEN = $400
|
||||
.const STAR = $51
|
||||
.const VIC = $d000
|
||||
.const RED = $2
|
||||
.const BGCOL = (VIC+($10*$2))+$1
|
||||
jsr main
|
||||
main: {
|
||||
lda #STAR
|
||||
sta SCREEN
|
||||
lda #RED
|
||||
sta BGCOL
|
||||
ldx #$28
|
||||
b1:
|
||||
lda #STAR+$1
|
||||
sta SCREEN,x
|
||||
inx
|
||||
cpx #$50
|
||||
bne b1
|
||||
rts
|
||||
}
|
17
src/main/java/dk/camelot64/kickc/test/ref/constantmin.cfg
Normal file
17
src/main/java/dk/camelot64/kickc/test/ref/constantmin.cfg
Normal file
@ -0,0 +1,17 @@
|
||||
@begin: scope:[] from
|
||||
[0] call main param-assignment [ ]
|
||||
to:@end
|
||||
@end: scope:[] from @begin
|
||||
main: scope:[main] from @begin
|
||||
[1] *((const byte*) SCREEN#0) ← (const byte) STAR#0 [ ]
|
||||
[2] *((const byte*) BGCOL#0) ← (const byte) RED#0 [ ]
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[3] (byte) main::i#2 ← phi( main/(byte) 40 main::@1/(byte) main::i#1 ) [ main::i#2 ]
|
||||
[4] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) STAR#0+(byte) 1 [ main::i#2 ]
|
||||
[5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
|
||||
[6] if((byte) main::i#1!=(byte) 80) goto main::@1 [ main::i#1 ]
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[7] return [ ]
|
||||
to:@return
|
972
src/main/java/dk/camelot64/kickc/test/ref/constantmin.log
Normal file
972
src/main/java/dk/camelot64/kickc/test/ref/constantmin.log
Normal file
@ -0,0 +1,972 @@
|
||||
const byte* SCREEN = $0400;
|
||||
const byte STAR = 81;
|
||||
|
||||
byte* VIC = $d000;
|
||||
byte* BGCOL = VIC+$10*2+1;
|
||||
byte RED = 2;
|
||||
|
||||
main();
|
||||
|
||||
void main() {
|
||||
*SCREEN = STAR;
|
||||
*BGCOL = RED;
|
||||
for(byte i: 40..79) {
|
||||
SCREEN[i] = (STAR+1);
|
||||
}
|
||||
}
|
||||
PROGRAM
|
||||
(byte*) SCREEN ← (word) 1024
|
||||
(byte) STAR ← (byte) 81
|
||||
(byte*) VIC ← (word) 53248
|
||||
(byte~) $0 ← (byte) 16 * (byte) 2
|
||||
(byte*~) $1 ← (byte*) VIC + (byte~) $0
|
||||
(byte*~) $2 ← (byte*~) $1 + (byte) 1
|
||||
(byte*) BGCOL ← (byte*~) $2
|
||||
(byte) RED ← (byte) 2
|
||||
(void~) $3 ← call main
|
||||
proc (void()) main()
|
||||
*((byte*) SCREEN) ← (byte) STAR
|
||||
*((byte*) BGCOL) ← (byte) RED
|
||||
(byte) main::i ← (byte) 40
|
||||
main::@1:
|
||||
(byte~) main::$0 ← (byte) STAR + (byte) 1
|
||||
*((byte*) SCREEN + (byte) main::i) ← (byte~) main::$0
|
||||
(byte) main::i ← ++ (byte) main::i
|
||||
(boolean~) main::$1 ← (byte) main::i != (byte) 80
|
||||
if((boolean~) main::$1) goto main::@1
|
||||
main::@return:
|
||||
return
|
||||
endproc // main()
|
||||
|
||||
SYMBOLS
|
||||
(byte~) $0
|
||||
(byte*~) $1
|
||||
(byte*~) $2
|
||||
(void~) $3
|
||||
(byte*) BGCOL
|
||||
(byte) RED
|
||||
(byte*) SCREEN
|
||||
(byte) STAR
|
||||
(byte*) VIC
|
||||
(void()) main()
|
||||
(byte~) main::$0
|
||||
(boolean~) main::$1
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte) main::i
|
||||
|
||||
INITIAL CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
(byte*) SCREEN ← (word) 1024
|
||||
(byte) STAR ← (byte) 81
|
||||
(byte*) VIC ← (word) 53248
|
||||
(byte~) $0 ← (byte) 16 * (byte) 2
|
||||
(byte*~) $1 ← (byte*) VIC + (byte~) $0
|
||||
(byte*~) $2 ← (byte*~) $1 + (byte) 1
|
||||
(byte*) BGCOL ← (byte*~) $2
|
||||
(byte) RED ← (byte) 2
|
||||
(void~) $3 ← call main
|
||||
to:@1
|
||||
main: scope:[main] from
|
||||
*((byte*) SCREEN) ← (byte) STAR
|
||||
*((byte*) BGCOL) ← (byte) RED
|
||||
(byte) main::i ← (byte) 40
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte~) main::$0 ← (byte) STAR + (byte) 1
|
||||
*((byte*) SCREEN + (byte) main::i) ← (byte~) main::$0
|
||||
(byte) main::i ← ++ (byte) main::i
|
||||
(boolean~) main::$1 ← (byte) main::i != (byte) 80
|
||||
if((boolean~) main::$1) goto main::@1
|
||||
to:main::@2
|
||||
main::@2: scope:[main] from main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@2
|
||||
return
|
||||
to:@return
|
||||
@1: scope:[] from @begin
|
||||
to:@end
|
||||
@end: scope:[] from @1
|
||||
|
||||
Removing empty block main::@2
|
||||
Removing empty block @1
|
||||
CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
(byte*) SCREEN ← (word) 1024
|
||||
(byte) STAR ← (byte) 81
|
||||
(byte*) VIC ← (word) 53248
|
||||
(byte~) $0 ← (byte) 16 * (byte) 2
|
||||
(byte*~) $1 ← (byte*) VIC + (byte~) $0
|
||||
(byte*~) $2 ← (byte*~) $1 + (byte) 1
|
||||
(byte*) BGCOL ← (byte*~) $2
|
||||
(byte) RED ← (byte) 2
|
||||
(void~) $3 ← call main
|
||||
to:@end
|
||||
main: scope:[main] from
|
||||
*((byte*) SCREEN) ← (byte) STAR
|
||||
*((byte*) BGCOL) ← (byte) RED
|
||||
(byte) main::i ← (byte) 40
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte~) main::$0 ← (byte) STAR + (byte) 1
|
||||
*((byte*) SCREEN + (byte) main::i) ← (byte~) main::$0
|
||||
(byte) main::i ← ++ (byte) main::i
|
||||
(boolean~) main::$1 ← (byte) main::i != (byte) 80
|
||||
if((boolean~) main::$1) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@end: scope:[] from @begin
|
||||
|
||||
PROCEDURE MODIFY VARIABLE ANALYSIS
|
||||
|
||||
CONTROL FLOW GRAPH WITH ASSIGNMENT CALL
|
||||
@begin: scope:[] from
|
||||
(byte*) SCREEN ← (word) 1024
|
||||
(byte) STAR ← (byte) 81
|
||||
(byte*) VIC ← (word) 53248
|
||||
(byte~) $0 ← (byte) 16 * (byte) 2
|
||||
(byte*~) $1 ← (byte*) VIC + (byte~) $0
|
||||
(byte*~) $2 ← (byte*~) $1 + (byte) 1
|
||||
(byte*) BGCOL ← (byte*~) $2
|
||||
(byte) RED ← (byte) 2
|
||||
call main param-assignment
|
||||
to:@2
|
||||
@2: scope:[] from @begin
|
||||
to:@end
|
||||
main: scope:[main] from @begin
|
||||
*((byte*) SCREEN) ← (byte) STAR
|
||||
*((byte*) BGCOL) ← (byte) RED
|
||||
(byte) main::i ← (byte) 40
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte~) main::$0 ← (byte) STAR + (byte) 1
|
||||
*((byte*) SCREEN + (byte) main::i) ← (byte~) main::$0
|
||||
(byte) main::i ← ++ (byte) main::i
|
||||
(boolean~) main::$1 ← (byte) main::i != (byte) 80
|
||||
if((boolean~) main::$1) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@end: scope:[] from @2
|
||||
|
||||
Completing Phi functions...
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@begin: scope:[] from
|
||||
(byte*) SCREEN#0 ← (word) 1024
|
||||
(byte) STAR#0 ← (byte) 81
|
||||
(byte*) VIC#0 ← (word) 53248
|
||||
(byte~) $0 ← (byte) 16 * (byte) 2
|
||||
(byte*~) $1 ← (byte*) VIC#0 + (byte~) $0
|
||||
(byte*~) $2 ← (byte*~) $1 + (byte) 1
|
||||
(byte*) BGCOL#0 ← (byte*~) $2
|
||||
(byte) RED#0 ← (byte) 2
|
||||
call main param-assignment
|
||||
to:@2
|
||||
@2: scope:[] from @begin
|
||||
to:@end
|
||||
main: scope:[main] from @begin
|
||||
(byte*) BGCOL#1 ← phi( @begin/(byte*) BGCOL#0 )
|
||||
(byte) RED#1 ← phi( @begin/(byte) RED#0 )
|
||||
(byte*) SCREEN#1 ← phi( @begin/(byte*) SCREEN#0 )
|
||||
(byte) STAR#1 ← phi( @begin/(byte) STAR#0 )
|
||||
*((byte*) SCREEN#1) ← (byte) STAR#1
|
||||
*((byte*) BGCOL#1) ← (byte) RED#1
|
||||
(byte) main::i#0 ← (byte) 40
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#1 main::@1/(byte*) SCREEN#2 )
|
||||
(byte) STAR#2 ← phi( main/(byte) STAR#1 main::@1/(byte) STAR#2 )
|
||||
(byte~) main::$0 ← (byte) STAR#2 + (byte) 1
|
||||
*((byte*) SCREEN#2 + (byte) main::i#2) ← (byte~) main::$0
|
||||
(byte) main::i#1 ← ++ (byte) main::i#2
|
||||
(boolean~) main::$1 ← (byte) main::i#1 != (byte) 80
|
||||
if((boolean~) main::$1) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@end: scope:[] from @2
|
||||
|
||||
CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN
|
||||
@begin: scope:[] from
|
||||
(byte*) SCREEN#0 ← (word) 1024
|
||||
(byte) STAR#0 ← (byte) 81
|
||||
(byte*) VIC#0 ← (word) 53248
|
||||
(byte~) $0 ← (byte) 16 * (byte) 2
|
||||
(byte*~) $1 ← (byte*) VIC#0 + (byte~) $0
|
||||
(byte*~) $2 ← (byte*~) $1 + (byte) 1
|
||||
(byte*) BGCOL#0 ← (byte*~) $2
|
||||
(byte) RED#0 ← (byte) 2
|
||||
call main param-assignment
|
||||
to:@2
|
||||
@2: scope:[] from @begin
|
||||
to:@end
|
||||
main: scope:[main] from @begin
|
||||
(byte*) BGCOL#1 ← phi( @begin/(byte*) BGCOL#0 )
|
||||
(byte) RED#1 ← phi( @begin/(byte) RED#0 )
|
||||
(byte*) SCREEN#1 ← phi( @begin/(byte*) SCREEN#0 )
|
||||
(byte) STAR#1 ← phi( @begin/(byte) STAR#0 )
|
||||
*((byte*) SCREEN#1) ← (byte) STAR#1
|
||||
*((byte*) BGCOL#1) ← (byte) RED#1
|
||||
(byte) main::i#0 ← (byte) 40
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#1 main::@1/(byte*) SCREEN#2 )
|
||||
(byte) STAR#2 ← phi( main/(byte) STAR#1 main::@1/(byte) STAR#2 )
|
||||
(byte~) main::$0 ← (byte) STAR#2 + (byte) 1
|
||||
*((byte*) SCREEN#2 + (byte) main::i#2) ← (byte~) main::$0
|
||||
(byte) main::i#1 ← ++ (byte) main::i#2
|
||||
(boolean~) main::$1 ← (byte) main::i#1 != (byte) 80
|
||||
if((boolean~) main::$1) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@end: scope:[] from @2
|
||||
|
||||
INITIAL SSA SYMBOL TABLE
|
||||
(byte~) $0
|
||||
(byte*~) $1
|
||||
(byte*~) $2
|
||||
(label) @2
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) BGCOL
|
||||
(byte*) BGCOL#0
|
||||
(byte*) BGCOL#1
|
||||
(byte) RED
|
||||
(byte) RED#0
|
||||
(byte) RED#1
|
||||
(byte*) SCREEN
|
||||
(byte*) SCREEN#0
|
||||
(byte*) SCREEN#1
|
||||
(byte*) SCREEN#2
|
||||
(byte) STAR
|
||||
(byte) STAR#0
|
||||
(byte) STAR#1
|
||||
(byte) STAR#2
|
||||
(byte*) VIC
|
||||
(byte*) VIC#0
|
||||
(void()) main()
|
||||
(byte~) main::$0
|
||||
(boolean~) main::$1
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte) main::i
|
||||
(byte) main::i#0
|
||||
(byte) main::i#1
|
||||
(byte) main::i#2
|
||||
|
||||
Culled Empty Block (label) @2
|
||||
Succesful SSA optimization Pass2CullEmptyBlocks
|
||||
CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
(byte*) SCREEN#0 ← (word) 1024
|
||||
(byte) STAR#0 ← (byte) 81
|
||||
(byte*) VIC#0 ← (word) 53248
|
||||
(byte~) $0 ← (byte) 16 * (byte) 2
|
||||
(byte*~) $1 ← (byte*) VIC#0 + (byte~) $0
|
||||
(byte*~) $2 ← (byte*~) $1 + (byte) 1
|
||||
(byte*) BGCOL#0 ← (byte*~) $2
|
||||
(byte) RED#0 ← (byte) 2
|
||||
call main param-assignment
|
||||
to:@end
|
||||
main: scope:[main] from @begin
|
||||
(byte*) BGCOL#1 ← phi( @begin/(byte*) BGCOL#0 )
|
||||
(byte) RED#1 ← phi( @begin/(byte) RED#0 )
|
||||
(byte*) SCREEN#1 ← phi( @begin/(byte*) SCREEN#0 )
|
||||
(byte) STAR#1 ← phi( @begin/(byte) STAR#0 )
|
||||
*((byte*) SCREEN#1) ← (byte) STAR#1
|
||||
*((byte*) BGCOL#1) ← (byte) RED#1
|
||||
(byte) main::i#0 ← (byte) 40
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#1 main::@1/(byte*) SCREEN#2 )
|
||||
(byte) STAR#2 ← phi( main/(byte) STAR#1 main::@1/(byte) STAR#2 )
|
||||
(byte~) main::$0 ← (byte) STAR#2 + (byte) 1
|
||||
*((byte*) SCREEN#2 + (byte) main::i#2) ← (byte~) main::$0
|
||||
(byte) main::i#1 ← ++ (byte) main::i#2
|
||||
(boolean~) main::$1 ← (byte) main::i#1 != (byte) 80
|
||||
if((boolean~) main::$1) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@end: scope:[] from @begin
|
||||
|
||||
Alias (byte*) BGCOL#0 = (byte*~) $2 (byte*) BGCOL#1
|
||||
Alias (byte) STAR#0 = (byte) STAR#1
|
||||
Alias (byte*) SCREEN#0 = (byte*) SCREEN#1
|
||||
Alias (byte) RED#0 = (byte) RED#1
|
||||
Succesful SSA optimization Pass2AliasElimination
|
||||
CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
(byte*) SCREEN#0 ← (word) 1024
|
||||
(byte) STAR#0 ← (byte) 81
|
||||
(byte*) VIC#0 ← (word) 53248
|
||||
(byte~) $0 ← (byte) 16 * (byte) 2
|
||||
(byte*~) $1 ← (byte*) VIC#0 + (byte~) $0
|
||||
(byte*) BGCOL#0 ← (byte*~) $1 + (byte) 1
|
||||
(byte) RED#0 ← (byte) 2
|
||||
call main param-assignment
|
||||
to:@end
|
||||
main: scope:[main] from @begin
|
||||
*((byte*) SCREEN#0) ← (byte) STAR#0
|
||||
*((byte*) BGCOL#0) ← (byte) RED#0
|
||||
(byte) main::i#0 ← (byte) 40
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#0 main::@1/(byte*) SCREEN#2 )
|
||||
(byte) STAR#2 ← phi( main/(byte) STAR#0 main::@1/(byte) STAR#2 )
|
||||
(byte~) main::$0 ← (byte) STAR#2 + (byte) 1
|
||||
*((byte*) SCREEN#2 + (byte) main::i#2) ← (byte~) main::$0
|
||||
(byte) main::i#1 ← ++ (byte) main::i#2
|
||||
(boolean~) main::$1 ← (byte) main::i#1 != (byte) 80
|
||||
if((boolean~) main::$1) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@end: scope:[] from @begin
|
||||
|
||||
Self Phi Eliminated (byte) STAR#2
|
||||
Self Phi Eliminated (byte*) SCREEN#2
|
||||
Succesful SSA optimization Pass2SelfPhiElimination
|
||||
CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
(byte*) SCREEN#0 ← (word) 1024
|
||||
(byte) STAR#0 ← (byte) 81
|
||||
(byte*) VIC#0 ← (word) 53248
|
||||
(byte~) $0 ← (byte) 16 * (byte) 2
|
||||
(byte*~) $1 ← (byte*) VIC#0 + (byte~) $0
|
||||
(byte*) BGCOL#0 ← (byte*~) $1 + (byte) 1
|
||||
(byte) RED#0 ← (byte) 2
|
||||
call main param-assignment
|
||||
to:@end
|
||||
main: scope:[main] from @begin
|
||||
*((byte*) SCREEN#0) ← (byte) STAR#0
|
||||
*((byte*) BGCOL#0) ← (byte) RED#0
|
||||
(byte) main::i#0 ← (byte) 40
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#0 )
|
||||
(byte) STAR#2 ← phi( main/(byte) STAR#0 )
|
||||
(byte~) main::$0 ← (byte) STAR#2 + (byte) 1
|
||||
*((byte*) SCREEN#2 + (byte) main::i#2) ← (byte~) main::$0
|
||||
(byte) main::i#1 ← ++ (byte) main::i#2
|
||||
(boolean~) main::$1 ← (byte) main::i#1 != (byte) 80
|
||||
if((boolean~) main::$1) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@end: scope:[] from @begin
|
||||
|
||||
Simple Condition (boolean~) main::$1 if((byte) main::i#1!=(byte) 80) goto main::@1
|
||||
Succesful SSA optimization Pass2ConditionalJumpSimplification
|
||||
CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
(byte*) SCREEN#0 ← (word) 1024
|
||||
(byte) STAR#0 ← (byte) 81
|
||||
(byte*) VIC#0 ← (word) 53248
|
||||
(byte~) $0 ← (byte) 16 * (byte) 2
|
||||
(byte*~) $1 ← (byte*) VIC#0 + (byte~) $0
|
||||
(byte*) BGCOL#0 ← (byte*~) $1 + (byte) 1
|
||||
(byte) RED#0 ← (byte) 2
|
||||
call main param-assignment
|
||||
to:@end
|
||||
main: scope:[main] from @begin
|
||||
*((byte*) SCREEN#0) ← (byte) STAR#0
|
||||
*((byte*) BGCOL#0) ← (byte) RED#0
|
||||
(byte) main::i#0 ← (byte) 40
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#0 )
|
||||
(byte) STAR#2 ← phi( main/(byte) STAR#0 )
|
||||
(byte~) main::$0 ← (byte) STAR#2 + (byte) 1
|
||||
*((byte*) SCREEN#2 + (byte) main::i#2) ← (byte~) main::$0
|
||||
(byte) main::i#1 ← ++ (byte) main::i#2
|
||||
if((byte) main::i#1!=(byte) 80) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@end: scope:[] from @begin
|
||||
|
||||
Constant (const byte*) SCREEN#0
|
||||
Constant (const byte) STAR#0
|
||||
Constant (const byte*) VIC#0
|
||||
Constant (const byte) $0
|
||||
Constant (const byte) RED#0
|
||||
Constant (const byte) main::i#0
|
||||
Succesful SSA optimization Pass2ConstantIdentification
|
||||
CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
(byte*~) $1 ← (const byte*) VIC#0 + (const byte) $0
|
||||
(byte*) BGCOL#0 ← (byte*~) $1 + (byte) 1
|
||||
call main param-assignment
|
||||
to:@end
|
||||
main: scope:[main] from @begin
|
||||
*((const byte*) SCREEN#0) ← (const byte) STAR#0
|
||||
*((byte*) BGCOL#0) ← (const byte) RED#0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
(byte*) SCREEN#2 ← phi( main/(const byte*) SCREEN#0 )
|
||||
(byte) STAR#2 ← phi( main/(const byte) STAR#0 )
|
||||
(byte~) main::$0 ← (byte) STAR#2 + (byte) 1
|
||||
*((byte*) SCREEN#2 + (byte) main::i#2) ← (byte~) main::$0
|
||||
(byte) main::i#1 ← ++ (byte) main::i#2
|
||||
if((byte) main::i#1!=(byte) 80) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@end: scope:[] from @begin
|
||||
|
||||
Redundant Phi (byte) STAR#2 (const byte) STAR#0
|
||||
Redundant Phi (byte*) SCREEN#2 (const byte*) SCREEN#0
|
||||
Succesful SSA optimization Pass2RedundantPhiElimination
|
||||
CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
(byte*~) $1 ← (const byte*) VIC#0 + (const byte) $0
|
||||
(byte*) BGCOL#0 ← (byte*~) $1 + (byte) 1
|
||||
call main param-assignment
|
||||
to:@end
|
||||
main: scope:[main] from @begin
|
||||
*((const byte*) SCREEN#0) ← (const byte) STAR#0
|
||||
*((byte*) BGCOL#0) ← (const byte) RED#0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
(byte~) main::$0 ← (const byte) STAR#0 + (byte) 1
|
||||
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (byte~) main::$0
|
||||
(byte) main::i#1 ← ++ (byte) main::i#2
|
||||
if((byte) main::i#1!=(byte) 80) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@end: scope:[] from @begin
|
||||
|
||||
Constant (const byte*) $1
|
||||
Constant (const byte) main::$0
|
||||
Succesful SSA optimization Pass2ConstantIdentification
|
||||
CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
(byte*) BGCOL#0 ← (const byte*) $1 + (byte) 1
|
||||
call main param-assignment
|
||||
to:@end
|
||||
main: scope:[main] from @begin
|
||||
*((const byte*) SCREEN#0) ← (const byte) STAR#0
|
||||
*((byte*) BGCOL#0) ← (const byte) RED#0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) main::$0
|
||||
(byte) main::i#1 ← ++ (byte) main::i#2
|
||||
if((byte) main::i#1!=(byte) 80) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@end: scope:[] from @begin
|
||||
|
||||
Constant (const byte*) BGCOL#0
|
||||
Succesful SSA optimization Pass2ConstantIdentification
|
||||
CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
call main param-assignment
|
||||
to:@end
|
||||
main: scope:[main] from @begin
|
||||
*((const byte*) SCREEN#0) ← (const byte) STAR#0
|
||||
*((const byte*) BGCOL#0) ← (const byte) RED#0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(const byte) main::i#0 main::@1/(byte) main::i#1 )
|
||||
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) main::$0
|
||||
(byte) main::i#1 ← ++ (byte) main::i#2
|
||||
if((byte) main::i#1!=(byte) 80) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@end: scope:[] from @begin
|
||||
|
||||
Constant inlined $1 = (const byte*) VIC#0+(byte) 16*(byte) 2
|
||||
Constant inlined $0 = (byte) 16*(byte) 2
|
||||
Constant inlined main::i#0 = (byte) 40
|
||||
Constant inlined main::$0 = (const byte) STAR#0+(byte) 1
|
||||
Succesful SSA optimization Pass2ConstantInlining
|
||||
CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
call main param-assignment
|
||||
to:@end
|
||||
main: scope:[main] from @begin
|
||||
*((const byte*) SCREEN#0) ← (const byte) STAR#0
|
||||
*((const byte*) BGCOL#0) ← (const byte) RED#0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
(byte) main::i#2 ← phi( main/(byte) 40 main::@1/(byte) main::i#1 )
|
||||
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) STAR#0+(byte) 1
|
||||
(byte) main::i#1 ← ++ (byte) main::i#2
|
||||
if((byte) main::i#1!=(byte) 80) goto main::@1
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
@end: scope:[] from @begin
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) BGCOL
|
||||
(const byte*) BGCOL#0 = (const byte*) VIC#0+(byte) 16*(byte) 2+(byte) 1
|
||||
(byte) RED
|
||||
(const byte) RED#0 = (byte) 2
|
||||
(byte*) SCREEN
|
||||
(const byte*) SCREEN#0 = (word) 1024
|
||||
(byte) STAR
|
||||
(const byte) STAR#0 = (byte) 81
|
||||
(byte*) VIC
|
||||
(const byte*) VIC#0 = (word) 53248
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte) main::i
|
||||
(byte) main::i#1
|
||||
(byte) main::i#2
|
||||
|
||||
Block Sequence Planned @begin @end main main::@1 main::@return
|
||||
Added new block during phi lifting main::@3(between main::@1 and main::@1)
|
||||
Block Sequence Planned @begin @end main main::@1 main::@return main::@3
|
||||
CONTROL FLOW GRAPH - PHI LIFTED
|
||||
@begin: scope:[] from
|
||||
call main param-assignment
|
||||
to:@end
|
||||
@end: scope:[] from @begin
|
||||
main: scope:[main] from @begin
|
||||
*((const byte*) SCREEN#0) ← (const byte) STAR#0
|
||||
*((const byte*) BGCOL#0) ← (const byte) RED#0
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@3
|
||||
(byte) main::i#2 ← phi( main/(byte) 40 main::@3/(byte~) main::i#3 )
|
||||
*((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) STAR#0+(byte) 1
|
||||
(byte) main::i#1 ← ++ (byte) main::i#2
|
||||
if((byte) main::i#1!=(byte) 80) goto main::@3
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
return
|
||||
to:@return
|
||||
main::@3: scope:[main] from main::@1
|
||||
(byte~) main::i#3 ← (byte) main::i#1
|
||||
to:main::@1
|
||||
|
||||
CALL GRAPH
|
||||
Calls in [] to 0:main
|
||||
|
||||
Propagating live ranges...
|
||||
Propagating live ranges...
|
||||
CONTROL FLOW GRAPH - LIVE RANGES FOUND
|
||||
@begin: scope:[] from
|
||||
[0] call main param-assignment [ ]
|
||||
to:@end
|
||||
@end: scope:[] from @begin
|
||||
main: scope:[main] from @begin
|
||||
[1] *((const byte*) SCREEN#0) ← (const byte) STAR#0 [ ]
|
||||
[2] *((const byte*) BGCOL#0) ← (const byte) RED#0 [ ]
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@3
|
||||
[3] (byte) main::i#2 ← phi( main/(byte) 40 main::@3/(byte~) main::i#3 ) [ main::i#2 ]
|
||||
[4] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) STAR#0+(byte) 1 [ main::i#2 ]
|
||||
[5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
|
||||
[6] if((byte) main::i#1!=(byte) 80) goto main::@3 [ main::i#1 ]
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[7] return [ ]
|
||||
to:@return
|
||||
main::@3: scope:[main] from main::@1
|
||||
[8] (byte~) main::i#3 ← (byte) main::i#1 [ main::i#3 ]
|
||||
to:main::@1
|
||||
|
||||
Created 1 initial phi equivalence classes
|
||||
Coalesced [8] main::i#3 ← main::i#1
|
||||
Coalesced down to 1 phi equivalence classes
|
||||
Culled Empty Block (label) main::@3
|
||||
Block Sequence Planned @begin @end main main::@1 main::@return
|
||||
Propagating live ranges...
|
||||
Propagating live ranges...
|
||||
CONTROL FLOW GRAPH - PHI MEM COALESCED
|
||||
@begin: scope:[] from
|
||||
[0] call main param-assignment [ ]
|
||||
to:@end
|
||||
@end: scope:[] from @begin
|
||||
main: scope:[main] from @begin
|
||||
[1] *((const byte*) SCREEN#0) ← (const byte) STAR#0 [ ]
|
||||
[2] *((const byte*) BGCOL#0) ← (const byte) RED#0 [ ]
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@1
|
||||
[3] (byte) main::i#2 ← phi( main/(byte) 40 main::@1/(byte) main::i#1 ) [ main::i#2 ]
|
||||
[4] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) STAR#0+(byte) 1 [ main::i#2 ]
|
||||
[5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ]
|
||||
[6] if((byte) main::i#1!=(byte) 80) goto main::@1 [ main::i#1 ]
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@1
|
||||
[7] return [ ]
|
||||
to:@return
|
||||
|
||||
DOMINATORS
|
||||
@begin dominated by @begin
|
||||
@end dominated by @end @begin
|
||||
main dominated by @begin main
|
||||
main::@1 dominated by @begin main::@1 main
|
||||
main::@return dominated by main::@return @begin main::@1 main
|
||||
|
||||
Found back edge: Loop head: main::@1 tails: main::@1 blocks: null
|
||||
Populated: Loop head: main::@1 tails: main::@1 blocks: main::@1
|
||||
NATURAL LOOPS
|
||||
Loop head: main::@1 tails: main::@1 blocks: main::@1
|
||||
|
||||
Found 0 loops in scope []
|
||||
Found 1 loops in scope [main]
|
||||
Loop head: main::@1 tails: main::@1 blocks: main::@1
|
||||
NATURAL LOOPS WITH DEPTH
|
||||
Loop head: main::@1 tails: main::@1 blocks: main::@1 depth: 1
|
||||
|
||||
|
||||
VARIABLE REGISTER WEIGHTS
|
||||
(byte*) BGCOL
|
||||
(byte) RED
|
||||
(byte*) SCREEN
|
||||
(byte) STAR
|
||||
(byte*) VIC
|
||||
(void()) main()
|
||||
(byte) main::i
|
||||
(byte) main::i#1 16.5
|
||||
(byte) main::i#2 16.5
|
||||
|
||||
Initial phi equivalence classes
|
||||
[ main::i#2 main::i#1 ]
|
||||
Complete equivalence classes
|
||||
[ main::i#2 main::i#1 ]
|
||||
Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
INITIAL ASM
|
||||
//SEG0 Global Constants & labels
|
||||
.const SCREEN = $400
|
||||
.const STAR = $51
|
||||
.const VIC = $d000
|
||||
.const RED = $2
|
||||
.const BGCOL = (VIC+($10*$2))+$1
|
||||
//SEG1 @begin
|
||||
bbegin:
|
||||
//SEG2 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
jmp bend
|
||||
//SEG3 @end
|
||||
bend:
|
||||
//SEG4 main
|
||||
main: {
|
||||
.label i = 2
|
||||
//SEG5 [1] *((const byte*) SCREEN#0) ← (const byte) STAR#0 [ ] -- _star_cowo1=coby2
|
||||
lda #STAR
|
||||
sta SCREEN
|
||||
//SEG6 [2] *((const byte*) BGCOL#0) ← (const byte) RED#0 [ ] -- _star_cowo1=coby2
|
||||
lda #RED
|
||||
sta BGCOL
|
||||
//SEG7 [3] phi from main to main::@1
|
||||
b1_from_main:
|
||||
//SEG8 [3] phi (byte) main::i#2 = (byte) 40 -- zpby1=coby1
|
||||
lda #$28
|
||||
sta i
|
||||
jmp b1
|
||||
//SEG9 [3] phi from main::@1 to main::@1
|
||||
b1_from_b1:
|
||||
//SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
jmp b1
|
||||
//SEG11 main::@1
|
||||
b1:
|
||||
//SEG12 [4] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) STAR#0+(byte) 1 [ main::i#2 ] -- cowo1_staridx_zpby1=coby2
|
||||
lda #STAR+$1
|
||||
ldx i
|
||||
sta SCREEN,x
|
||||
//SEG13 [5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- zpby1=_inc_zpby1
|
||||
inc i
|
||||
//SEG14 [6] if((byte) main::i#1!=(byte) 80) goto main::@1 [ main::i#1 ] -- zpby1_neq_coby1_then_la1
|
||||
lda i
|
||||
cmp #$50
|
||||
bne b1_from_b1
|
||||
jmp breturn
|
||||
//SEG15 main::@return
|
||||
breturn:
|
||||
//SEG16 [7] return [ ]
|
||||
rts
|
||||
}
|
||||
|
||||
Statement [1] *((const byte*) SCREEN#0) ← (const byte) STAR#0 [ ] always clobbers reg byte a
|
||||
Statement [2] *((const byte*) BGCOL#0) ← (const byte) RED#0 [ ] always clobbers reg byte a
|
||||
Statement [4] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) STAR#0+(byte) 1 [ main::i#2 ] always clobbers reg byte a
|
||||
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
Statement [1] *((const byte*) SCREEN#0) ← (const byte) STAR#0 [ ] always clobbers reg byte a
|
||||
Statement [2] *((const byte*) BGCOL#0) ← (const byte) RED#0 [ ] always clobbers reg byte a
|
||||
Statement [4] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) STAR#0+(byte) 1 [ main::i#2 ] always clobbers reg byte a
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [main] 33: zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
Uplift Scope []
|
||||
|
||||
Uplifting [main] best 272 combination reg byte x [ main::i#2 main::i#1 ]
|
||||
Uplifting [] best 272 combination
|
||||
Removing instruction jmp bend
|
||||
Removing instruction jmp b1
|
||||
Removing instruction jmp breturn
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 Global Constants & labels
|
||||
.const SCREEN = $400
|
||||
.const STAR = $51
|
||||
.const VIC = $d000
|
||||
.const RED = $2
|
||||
.const BGCOL = (VIC+($10*$2))+$1
|
||||
//SEG1 @begin
|
||||
bbegin:
|
||||
//SEG2 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG3 @end
|
||||
bend:
|
||||
//SEG4 main
|
||||
main: {
|
||||
//SEG5 [1] *((const byte*) SCREEN#0) ← (const byte) STAR#0 [ ] -- _star_cowo1=coby2
|
||||
lda #STAR
|
||||
sta SCREEN
|
||||
//SEG6 [2] *((const byte*) BGCOL#0) ← (const byte) RED#0 [ ] -- _star_cowo1=coby2
|
||||
lda #RED
|
||||
sta BGCOL
|
||||
//SEG7 [3] phi from main to main::@1
|
||||
b1_from_main:
|
||||
//SEG8 [3] phi (byte) main::i#2 = (byte) 40 -- xby=coby1
|
||||
ldx #$28
|
||||
jmp b1
|
||||
//SEG9 [3] phi from main::@1 to main::@1
|
||||
b1_from_b1:
|
||||
//SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG11 main::@1
|
||||
b1:
|
||||
//SEG12 [4] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) STAR#0+(byte) 1 [ main::i#2 ] -- cowo1_staridx_xby=coby2
|
||||
lda #STAR+$1
|
||||
sta SCREEN,x
|
||||
//SEG13 [5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG14 [6] if((byte) main::i#1!=(byte) 80) goto main::@1 [ main::i#1 ] -- xby_neq_coby1_then_la1
|
||||
cpx #$50
|
||||
bne b1_from_b1
|
||||
//SEG15 main::@return
|
||||
breturn:
|
||||
//SEG16 [7] return [ ]
|
||||
rts
|
||||
}
|
||||
|
||||
Replacing label b1_from_b1 with b1
|
||||
Removing instruction b1_from_b1:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 Global Constants & labels
|
||||
.const SCREEN = $400
|
||||
.const STAR = $51
|
||||
.const VIC = $d000
|
||||
.const RED = $2
|
||||
.const BGCOL = (VIC+($10*$2))+$1
|
||||
//SEG1 @begin
|
||||
bbegin:
|
||||
//SEG2 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG3 @end
|
||||
bend:
|
||||
//SEG4 main
|
||||
main: {
|
||||
//SEG5 [1] *((const byte*) SCREEN#0) ← (const byte) STAR#0 [ ] -- _star_cowo1=coby2
|
||||
lda #STAR
|
||||
sta SCREEN
|
||||
//SEG6 [2] *((const byte*) BGCOL#0) ← (const byte) RED#0 [ ] -- _star_cowo1=coby2
|
||||
lda #RED
|
||||
sta BGCOL
|
||||
//SEG7 [3] phi from main to main::@1
|
||||
b1_from_main:
|
||||
//SEG8 [3] phi (byte) main::i#2 = (byte) 40 -- xby=coby1
|
||||
ldx #$28
|
||||
jmp b1
|
||||
//SEG9 [3] phi from main::@1 to main::@1
|
||||
//SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG11 main::@1
|
||||
b1:
|
||||
//SEG12 [4] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) STAR#0+(byte) 1 [ main::i#2 ] -- cowo1_staridx_xby=coby2
|
||||
lda #STAR+$1
|
||||
sta SCREEN,x
|
||||
//SEG13 [5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG14 [6] if((byte) main::i#1!=(byte) 80) goto main::@1 [ main::i#1 ] -- xby_neq_coby1_then_la1
|
||||
cpx #$50
|
||||
bne b1
|
||||
//SEG15 main::@return
|
||||
breturn:
|
||||
//SEG16 [7] return [ ]
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction bbegin:
|
||||
Removing instruction bend:
|
||||
Removing instruction b1_from_main:
|
||||
Removing instruction breturn:
|
||||
Succesful ASM optimization Pass5UnusedLabelElimination
|
||||
ASSEMBLER
|
||||
//SEG0 Global Constants & labels
|
||||
.const SCREEN = $400
|
||||
.const STAR = $51
|
||||
.const VIC = $d000
|
||||
.const RED = $2
|
||||
.const BGCOL = (VIC+($10*$2))+$1
|
||||
//SEG1 @begin
|
||||
//SEG2 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG3 @end
|
||||
//SEG4 main
|
||||
main: {
|
||||
//SEG5 [1] *((const byte*) SCREEN#0) ← (const byte) STAR#0 [ ] -- _star_cowo1=coby2
|
||||
lda #STAR
|
||||
sta SCREEN
|
||||
//SEG6 [2] *((const byte*) BGCOL#0) ← (const byte) RED#0 [ ] -- _star_cowo1=coby2
|
||||
lda #RED
|
||||
sta BGCOL
|
||||
//SEG7 [3] phi from main to main::@1
|
||||
//SEG8 [3] phi (byte) main::i#2 = (byte) 40 -- xby=coby1
|
||||
ldx #$28
|
||||
jmp b1
|
||||
//SEG9 [3] phi from main::@1 to main::@1
|
||||
//SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG11 main::@1
|
||||
b1:
|
||||
//SEG12 [4] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) STAR#0+(byte) 1 [ main::i#2 ] -- cowo1_staridx_xby=coby2
|
||||
lda #STAR+$1
|
||||
sta SCREEN,x
|
||||
//SEG13 [5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG14 [6] if((byte) main::i#1!=(byte) 80) goto main::@1 [ main::i#1 ] -- xby_neq_coby1_then_la1
|
||||
cpx #$50
|
||||
bne b1
|
||||
//SEG15 main::@return
|
||||
//SEG16 [7] return [ ]
|
||||
rts
|
||||
}
|
||||
|
||||
Removing instruction jmp b1
|
||||
Succesful ASM optimization Pass5NextJumpElimination
|
||||
ASSEMBLER
|
||||
//SEG0 Global Constants & labels
|
||||
.const SCREEN = $400
|
||||
.const STAR = $51
|
||||
.const VIC = $d000
|
||||
.const RED = $2
|
||||
.const BGCOL = (VIC+($10*$2))+$1
|
||||
//SEG1 @begin
|
||||
//SEG2 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG3 @end
|
||||
//SEG4 main
|
||||
main: {
|
||||
//SEG5 [1] *((const byte*) SCREEN#0) ← (const byte) STAR#0 [ ] -- _star_cowo1=coby2
|
||||
lda #STAR
|
||||
sta SCREEN
|
||||
//SEG6 [2] *((const byte*) BGCOL#0) ← (const byte) RED#0 [ ] -- _star_cowo1=coby2
|
||||
lda #RED
|
||||
sta BGCOL
|
||||
//SEG7 [3] phi from main to main::@1
|
||||
//SEG8 [3] phi (byte) main::i#2 = (byte) 40 -- xby=coby1
|
||||
ldx #$28
|
||||
//SEG9 [3] phi from main::@1 to main::@1
|
||||
//SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG11 main::@1
|
||||
b1:
|
||||
//SEG12 [4] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) STAR#0+(byte) 1 [ main::i#2 ] -- cowo1_staridx_xby=coby2
|
||||
lda #STAR+$1
|
||||
sta SCREEN,x
|
||||
//SEG13 [5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG14 [6] if((byte) main::i#1!=(byte) 80) goto main::@1 [ main::i#1 ] -- xby_neq_coby1_then_la1
|
||||
cpx #$50
|
||||
bne b1
|
||||
//SEG15 main::@return
|
||||
//SEG16 [7] return [ ]
|
||||
rts
|
||||
}
|
||||
|
||||
FINAL SYMBOL TABLE
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) BGCOL
|
||||
(const byte*) BGCOL#0 = (const byte*) VIC#0+(byte) 16*(byte) 2+(byte) 1
|
||||
(byte) RED
|
||||
(const byte) RED#0 = (byte) 2
|
||||
(byte*) SCREEN
|
||||
(const byte*) SCREEN#0 = (word) 1024
|
||||
(byte) STAR
|
||||
(const byte) STAR#0 = (byte) 81
|
||||
(byte*) VIC
|
||||
(const byte*) VIC#0 = (word) 53248
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 16.5
|
||||
(byte) main::i#2 reg byte x 16.5
|
||||
|
||||
reg byte x [ main::i#2 main::i#1 ]
|
||||
|
||||
FINAL CODE
|
||||
//SEG0 Global Constants & labels
|
||||
.const SCREEN = $400
|
||||
.const STAR = $51
|
||||
.const VIC = $d000
|
||||
.const RED = $2
|
||||
.const BGCOL = (VIC+($10*$2))+$1
|
||||
//SEG1 @begin
|
||||
//SEG2 [0] call main param-assignment [ ]
|
||||
jsr main
|
||||
//SEG3 @end
|
||||
//SEG4 main
|
||||
main: {
|
||||
//SEG5 [1] *((const byte*) SCREEN#0) ← (const byte) STAR#0 [ ] -- _star_cowo1=coby2
|
||||
lda #STAR
|
||||
sta SCREEN
|
||||
//SEG6 [2] *((const byte*) BGCOL#0) ← (const byte) RED#0 [ ] -- _star_cowo1=coby2
|
||||
lda #RED
|
||||
sta BGCOL
|
||||
//SEG7 [3] phi from main to main::@1
|
||||
//SEG8 [3] phi (byte) main::i#2 = (byte) 40 -- xby=coby1
|
||||
ldx #$28
|
||||
//SEG9 [3] phi from main::@1 to main::@1
|
||||
//SEG10 [3] phi (byte) main::i#2 = (byte) main::i#1 -- register_copy
|
||||
//SEG11 main::@1
|
||||
b1:
|
||||
//SEG12 [4] *((const byte*) SCREEN#0 + (byte) main::i#2) ← (const byte) STAR#0+(byte) 1 [ main::i#2 ] -- cowo1_staridx_xby=coby2
|
||||
lda #STAR+$1
|
||||
sta SCREEN,x
|
||||
//SEG13 [5] (byte) main::i#1 ← ++ (byte) main::i#2 [ main::i#1 ] -- xby=_inc_xby
|
||||
inx
|
||||
//SEG14 [6] if((byte) main::i#1!=(byte) 80) goto main::@1 [ main::i#1 ] -- xby_neq_coby1_then_la1
|
||||
cpx #$50
|
||||
bne b1
|
||||
//SEG15 main::@return
|
||||
//SEG16 [7] return [ ]
|
||||
rts
|
||||
}
|
||||
|
20
src/main/java/dk/camelot64/kickc/test/ref/constantmin.sym
Normal file
20
src/main/java/dk/camelot64/kickc/test/ref/constantmin.sym
Normal file
@ -0,0 +1,20 @@
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) BGCOL
|
||||
(const byte*) BGCOL#0 = (const byte*) VIC#0+(byte) 16*(byte) 2+(byte) 1
|
||||
(byte) RED
|
||||
(const byte) RED#0 = (byte) 2
|
||||
(byte*) SCREEN
|
||||
(const byte*) SCREEN#0 = (word) 1024
|
||||
(byte) STAR
|
||||
(const byte) STAR#0 = (byte) 81
|
||||
(byte*) VIC
|
||||
(const byte*) VIC#0 = (word) 53248
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@return
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 16.5
|
||||
(byte) main::i#2 reg byte x 16.5
|
||||
|
||||
reg byte x [ main::i#2 main::i#1 ]
|
Loading…
x
Reference in New Issue
Block a user