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

377 lines
11 KiB
Plaintext
Raw Normal View History

2019-05-30 20:29:04 +00:00
Culled Empty Block (label) main::@2
2018-08-22 22:24:32 +00:00
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
to:@1
(void()) main()
main: scope:[main] from @1
(byte*) main::b#0 ← (const nomodify byte*) main::BITMAP+(number) $1fff
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*) main::b#2 ← phi( main/(byte*) main::b#0 main::@1/(byte*) main::b#1 )
2019-05-30 20:29:04 +00:00
*((byte*) main::b#2) ← (number) $5a
(byte*) main::b#1 ← (byte*) main::b#2 + rangenext(main::BITMAP+$1fff,main::BITMAP)
(bool~) main::$0 ← (byte*) main::b#1 != rangelast(main::BITMAP+$1fff,main::BITMAP)
if((bool~) main::$0) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
return
to:@return
@1: scope:[] from @begin
call main
to:@2
@2: scope:[] from @1
to:@end
@end: scope:[] from @2
SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(void()) main()
(bool~) main::$0
(label) main::@1
(label) main::@return
(const nomodify byte*) main::BITMAP = (byte*)(number) $2000
(byte*) main::b
(byte*) main::b#0
(byte*) main::b#1
(byte*) main::b#2
Adding number conversion cast (unumber) $1fff in (byte*) main::b#0 ← (const nomodify byte*) main::BITMAP+(number) $1fff
2019-05-30 20:29:04 +00:00
Adding number conversion cast (unumber) $5a in *((byte*) main::b#2) ← (number) $5a
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((byte*) main::b#2) ← (unumber)(number) $5a
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 8192
Simplifying constant integer cast $1fff
Simplifying constant integer cast $5a
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (word) $1fff
Finalized unsigned number type (byte) $5a
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simple Condition (bool~) main::$0 [5] if((byte*) main::b#1!=rangelast(main::BITMAP+$1fff,main::BITMAP)) goto main::@1
2018-08-22 20:23:42 +00:00
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) main::b#0 = main::BITMAP+$1fff
2018-08-22 20:23:42 +00:00
Successful SSA optimization Pass2ConstantIdentification
2019-05-30 20:29:04 +00:00
Resolved ranged next value [3] main::b#1 ← -- main::b#2 to --
Resolved ranged comparison value [5] if(main::b#1!=rangelast(main::BITMAP+$1fff,main::BITMAP)) goto main::@1 to (byte*)(const nomodify byte*) main::BITMAP-(number) 1
Adding number conversion cast (unumber) 1 in if((byte*) main::b#1!=(byte*)(const nomodify byte*) main::BITMAP-(number) 1) goto main::@1
2019-05-30 20:29:04 +00:00
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast (const nomodify byte*) main::BITMAP-(unumber)(number) 1
2019-05-30 20:29:04 +00:00
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings (const byte*) main::b#0
Constant inlined main::b#0 = (const nomodify byte*) main::BITMAP+(word) $1fff
2018-08-22 20:23:42 +00:00
Successful SSA optimization Pass2ConstantInlining
Added new block during phi lifting main::@3(between main::@1 and main::@1)
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
Created 1 initial phi equivalence classes
2019-05-30 20:29:04 +00:00
Coalesced [11] main::b#3 ← main::b#1
Coalesced down to 1 phi equivalence classes
2019-05-30 20:29:04 +00:00
Culled Empty Block (label) @2
Culled Empty Block (label) main::@3
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
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::@1
[5] (byte*) main::b#2 ← phi( main/(const nomodify byte*) main::BITMAP+(word) $1fff main::@1/(byte*) main::b#1 )
2019-05-30 20:29:04 +00:00
[6] *((byte*) main::b#2) ← (byte) $5a
2018-11-11 20:51:36 +00:00
[7] (byte*) main::b#1 ← -- (byte*) main::b#2
[8] if((byte*) main::b#1!=(const nomodify byte*) main::BITMAP-(byte) 1) goto main::@1
to:main::@return
main::@return: scope:[main] from main::@1
2018-11-11 20:51:36 +00:00
[9] return
to:@return
VARIABLE REGISTER WEIGHTS
(void()) main()
(byte*) main::b
(byte*) main::b#1 151.5
(byte*) main::b#2 151.5
Initial phi equivalence classes
[ main::b#2 main::b#1 ]
Complete equivalence classes
[ main::b#2 main::b#1 ]
2019-10-12 09:40:36 +00:00
Allocated zp[2]:2 [ main::b#2 main::b#1 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
2019-02-17 23:12:29 +00:00
// Range-based for does not recognize symbolic constants.
// The following should work but gives a not-constant exception
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
// @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:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
.label BITMAP = $2000
.label b = 2
// [5] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [5] phi (byte*) main::b#2 = (const nomodify byte*) main::BITMAP+(word) $1fff [phi:main->main::@1#0] -- pbuz1=pbuc1
lda #<BITMAP+$1fff
sta.z b
lda #>BITMAP+$1fff
sta.z b+1
jmp __b1
// [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
__b1_from___b1:
// [5] phi (byte*) main::b#2 = (byte*) main::b#1 [phi:main::@1->main::@1#0] -- register_copy
jmp __b1
// main::@1
__b1:
// [6] *((byte*) main::b#2) ← (byte) $5a -- _deref_pbuz1=vbuc1
lda #$5a
ldy #0
sta (b),y
// [7] (byte*) main::b#1 ← -- (byte*) main::b#2 -- pbuz1=_dec_pbuz1
lda.z b
bne !+
dec.z b+1
!:
dec.z b
// [8] if((byte*) main::b#1!=(const nomodify byte*) main::BITMAP-(byte) 1) goto main::@1 -- pbuz1_neq_pbuc1_then_la1
lda.z b+1
cmp #>BITMAP-1
bne __b1_from___b1
lda.z b
cmp #<BITMAP-1
bne __b1_from___b1
jmp __breturn
// main::@return
__breturn:
// [9] return
rts
}
// File Data
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] *((byte*) main::b#2) ← (byte) $5a [ main::b#2 ] ( main:2 [ main::b#2 ] { } ) always clobbers reg byte a reg byte y
Statement [7] (byte*) main::b#1 ← -- (byte*) main::b#2 [ main::b#1 ] ( main:2 [ main::b#1 ] { } ) always clobbers reg byte a
Statement [8] if((byte*) main::b#1!=(const nomodify byte*) main::BITMAP-(byte) 1) goto main::@1 [ main::b#1 ] ( main:2 [ main::b#1 ] { } ) always clobbers reg byte a
2019-10-12 09:40:36 +00:00
Potential registers zp[2]:2 [ main::b#2 main::b#1 ] : zp[2]:2 ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 303: zp[2]:2 [ main::b#2 main::b#1 ]
Uplift Scope []
2019-10-12 09:40:36 +00:00
Uplifting [main] best 613 combination zp[2]:2 [ main::b#2 main::b#1 ]
Uplifting [] best 613 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
2019-02-17 23:12:29 +00:00
// Range-based for does not recognize symbolic constants.
// The following should work but gives a not-constant exception
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
// @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:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
.label BITMAP = $2000
.label b = 2
// [5] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [5] phi (byte*) main::b#2 = (const nomodify byte*) main::BITMAP+(word) $1fff [phi:main->main::@1#0] -- pbuz1=pbuc1
lda #<BITMAP+$1fff
sta.z b
lda #>BITMAP+$1fff
sta.z b+1
jmp __b1
// [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
__b1_from___b1:
// [5] phi (byte*) main::b#2 = (byte*) main::b#1 [phi:main::@1->main::@1#0] -- register_copy
jmp __b1
// main::@1
__b1:
// [6] *((byte*) main::b#2) ← (byte) $5a -- _deref_pbuz1=vbuc1
lda #$5a
ldy #0
sta (b),y
// [7] (byte*) main::b#1 ← -- (byte*) main::b#2 -- pbuz1=_dec_pbuz1
lda.z b
bne !+
dec.z b+1
!:
dec.z b
// [8] if((byte*) main::b#1!=(const nomodify byte*) main::BITMAP-(byte) 1) goto main::@1 -- pbuz1_neq_pbuc1_then_la1
lda.z b+1
cmp #>BITMAP-1
bne __b1_from___b1
lda.z b
cmp #<BITMAP-1
bne __b1_from___b1
jmp __breturn
// main::@return
__breturn:
// [9] return
rts
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __b1_from___b1 with __b1
Replacing label __b1_from___b1 with __b1
Removing instruction __b1_from___bbegin:
Removing instruction __b1:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b1_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction jmp __b1
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(void()) main()
(label) main::@1
(label) main::@return
(const nomodify byte*) main::BITMAP = (byte*) 8192
(byte*) main::b
(byte*) main::b#1 b zp[2]:2 151.5
(byte*) main::b#2 b zp[2]:2 151.5
2019-10-12 09:40:36 +00:00
zp[2]:2 [ main::b#2 main::b#1 ]
FINAL ASSEMBLER
Score: 511
// File Comments
2019-02-17 23:12:29 +00:00
// Range-based for does not recognize symbolic constants.
// The following should work but gives a not-constant exception
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
// @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
main: {
.label BITMAP = $2000
.label b = 2
// [5] phi from main to main::@1 [phi:main->main::@1]
// [5] phi (byte*) main::b#2 = (const nomodify byte*) main::BITMAP+(word) $1fff [phi:main->main::@1#0] -- pbuz1=pbuc1
lda #<BITMAP+$1fff
sta.z b
lda #>BITMAP+$1fff
sta.z b+1
// [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
// [5] phi (byte*) main::b#2 = (byte*) main::b#1 [phi:main::@1->main::@1#0] -- register_copy
// main::@1
__b1:
// *b = $5a
// [6] *((byte*) main::b#2) ← (byte) $5a -- _deref_pbuz1=vbuc1
lda #$5a
ldy #0
sta (b),y
// for(byte* b : BITMAP+$1fff..BITMAP)
// [7] (byte*) main::b#1 ← -- (byte*) main::b#2 -- pbuz1=_dec_pbuz1
lda.z b
bne !+
dec.z b+1
!:
dec.z b
// [8] if((byte*) main::b#1!=(const nomodify byte*) main::BITMAP-(byte) 1) goto main::@1 -- pbuz1_neq_pbuc1_then_la1
lda.z b+1
cmp #>BITMAP-1
bne __b1
lda.z b
cmp #<BITMAP-1
bne __b1
// main::@return
// }
// [9] return
rts
}
// File Data