1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-16 21:07:56 +00:00
kickc/src/test/ref/forclassicmin.log

338 lines
8.9 KiB
Plaintext
Raw Normal View History

Identified constant variable (byte*) SCREEN
Culled Empty Block (label) main::@4
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
2017-08-17 22:28:39 +00:00
2018-08-22 22:24:32 +00:00
CONTROL FLOW GRAPH SSA
2017-08-17 22:28:39 +00:00
@begin: scope:[] from
to:@1
(void()) main()
2017-08-17 22:28:39 +00:00
main: scope:[main] from @1
(byte) main::i#0 ← (byte) 0
2017-08-17 22:28:39 +00:00
to:main::@1
main::@1: scope:[main] from main main::@2
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 )
(bool~) main::$0 ← (byte) main::i#2 != (number) $64
if((bool~) main::$0) goto main::@2
2017-08-17 22:28:39 +00:00
to:main::@return
main::@2: scope:[main] from main::@1
(byte) main::i#3 ← phi( main::@1/(byte) main::i#2 )
*((const byte*) SCREEN + (byte) main::i#3) ← (byte) main::i#3
(byte) main::i#1 ← ++ (byte) main::i#3
to:main::@1
2017-08-17 22:28:39 +00:00
main::@return: scope:[main] from main::@1
return
to:@return
@1: scope:[] from @begin
call main
2017-08-17 22:28:39 +00:00
to:@2
@2: scope:[] from @1
to:@end
@end: scope:[] from @2
2017-12-29 10:21:11 +00:00
SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(const byte*) SCREEN = (byte*)(number) $400
(void()) main()
2018-04-28 06:41:05 +00:00
(bool~) main::$0
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
Adding number conversion cast (unumber) $64 in (bool~) main::$0 ← (byte) main::i#2 != (number) $64
2019-05-30 20:29:04 +00:00
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $64
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $64
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) main::i#2 = (byte) main::i#3
2018-08-22 20:23:42 +00:00
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$0 [3] if((byte) main::i#2!=(byte) $64) goto main::@2
2018-08-22 20:23:42 +00:00
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::i#0 = 0
2018-08-22 20:23:42 +00:00
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte) main::i#0
2019-05-30 20:29:04 +00:00
Constant inlined main::i#0 = (byte) 0
2018-08-22 20:23:42 +00:00
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
2019-05-30 20:29:04 +00:00
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2
2017-08-17 22:28:39 +00:00
Created 1 initial phi equivalence classes
Coalesced [11] main::i#4 ← main::i#1
2017-08-17 22:28:39 +00:00
Coalesced down to 1 phi equivalence classes
2019-05-30 20:29:04 +00:00
Culled Empty Block (label) @2
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
2017-08-17 22:28:39 +00:00
2017-12-29 10:21:11 +00:00
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
2018-11-11 20:51:36 +00:00
[0] phi()
to:@1
@1: scope:[] from @begin
2018-11-11 20:51:36 +00:00
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
2018-11-11 20:51:36 +00:00
[3] phi()
(void()) main()
main: scope:[main] from @1
2018-11-11 20:51:36 +00:00
[4] phi()
to:main::@1
main::@1: scope:[main] from main main::@2
[5] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
[6] if((byte) main::i#2!=(byte) $64) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@1
[7] return
to:@return
main::@2: scope:[main] from main::@1
[8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) main::i#2
[9] (byte) main::i#1 ← ++ (byte) main::i#2
to:main::@1
2017-08-17 22:28:39 +00:00
VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::i
(byte) main::i#1 22.0
(byte) main::i#2 18.333333333333332
2017-08-17 22:28:39 +00:00
Initial phi equivalence classes
[ main::i#2 main::i#1 ]
2017-08-17 22:28:39 +00:00
Complete equivalence classes
[ main::i#2 main::i#1 ]
2019-10-12 09:40:36 +00:00
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
2017-12-29 10:21:11 +00:00
2017-08-17 22:28:39 +00:00
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
2019-02-17 23:12:29 +00:00
// Minimal classic for() loop
// Upstart
2017-11-04 18:53:55 +00:00
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
2017-11-04 18:53:55 +00:00
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
// @begin
__bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from___b1:
2017-08-17 22:28:39 +00:00
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
2017-08-17 22:28:39 +00:00
main: {
.label i = 2
// [5] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
2017-10-15 21:15:49 +00:00
lda #0
sta.z i
jmp __b1
// main::@1
__b1:
// [6] if((byte) main::i#2!=(byte) $64) goto main::@2 -- vbuz1_neq_vbuc1_then_la1
lda #$64
cmp.z i
bne __b2
jmp __breturn
// main::@return
__breturn:
// [7] return
2017-08-17 22:28:39 +00:00
rts
// main::@2
__b2:
// [8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuz1=vbuz1
ldy.z i
tya
sta SCREEN,y
// [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
inc.z i
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
__b1_from___b2:
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
jmp __b1
2017-08-17 22:28:39 +00:00
}
// File Data
2017-08-17 22:28:39 +00:00
REGISTER UPLIFT POTENTIAL REGISTERS
2019-10-12 09:40:36 +00:00
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y ,
2017-08-17 22:28:39 +00:00
REGISTER UPLIFT SCOPES
2019-10-12 09:40:36 +00:00
Uplift Scope [main] 40.33: zp[1]:2 [ main::i#2 main::i#1 ]
2017-08-17 22:28:39 +00:00
Uplift Scope []
Uplifting [main] best 263 combination reg byte x [ main::i#2 main::i#1 ]
Uplifting [] best 263 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
2019-02-17 23:12:29 +00:00
// Minimal classic for() loop
// Upstart
2017-11-04 18:53:55 +00:00
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
2017-11-04 18:53:55 +00:00
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
// @begin
__bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from___b1:
2017-08-17 22:28:39 +00:00
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
2017-08-17 22:28:39 +00:00
main: {
// [5] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
2017-10-15 21:15:49 +00:00
ldx #0
jmp __b1
// main::@1
__b1:
// [6] if((byte) main::i#2!=(byte) $64) goto main::@2 -- vbuxx_neq_vbuc1_then_la1
2017-08-17 22:28:39 +00:00
cpx #$64
bne __b2
jmp __breturn
// main::@return
__breturn:
// [7] return
2017-08-17 22:28:39 +00:00
rts
// main::@2
__b2:
// [8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx
txa
sta SCREEN,x
// [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
inx
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
__b1_from___b2:
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
jmp __b1
2017-08-17 22:28:39 +00:00
}
// File Data
2017-08-17 22:28:39 +00:00
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from___bbegin:
Removing instruction __b1:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
2017-08-17 22:28:39 +00:00
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __breturn:
Removing instruction __b1_from___b2:
2017-08-17 22:28:39 +00:00
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction __bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination
2017-08-17 22:28:39 +00:00
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte*) SCREEN = (byte*) 1024
2017-08-17 22:28:39 +00:00
(void()) main()
(label) main::@1
(label) main::@2
2017-08-17 22:28:39 +00:00
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte x 22.0
(byte) main::i#2 reg byte x 18.333333333333332
2017-08-17 22:28:39 +00:00
reg byte x [ main::i#2 main::i#1 ]
2017-08-17 22:28:39 +00:00
2017-12-29 10:21:11 +00:00
FINAL ASSEMBLER
Score: 191
2017-12-30 12:45:59 +00:00
// File Comments
2019-02-17 23:12:29 +00:00
// Minimal classic for() loop
// Upstart
2017-11-04 18:53:55 +00:00
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
// @begin
// [1] phi from @begin to @1 [phi:@begin->@1]
// @1
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
// [3] phi from @1 to @end [phi:@1->@end]
// @end
// main
2017-08-17 22:28:39 +00:00
main: {
// [5] phi from main to main::@1 [phi:main->main::@1]
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
2017-10-15 21:15:49 +00:00
ldx #0
// main::@1
__b1:
// for(byte i=0; i!=100; i++)
// [6] if((byte) main::i#2!=(byte) $64) goto main::@2 -- vbuxx_neq_vbuc1_then_la1
cpx #$64
bne __b2
// main::@return
// }
// [7] return
rts
// main::@2
__b2:
// SCREEN[i] = i
// [8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx
txa
sta SCREEN,x
// for(byte i=0; i!=100; i++)
// [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
inx
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
jmp __b1
2017-08-17 22:28:39 +00:00
}
// File Data
2017-08-17 22:28:39 +00:00