mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-09-29 03:56:15 +00:00
369 lines
12 KiB
Plaintext
369 lines
12 KiB
Plaintext
|
|
CONTROL FLOW GRAPH SSA
|
|
@begin: scope:[] from
|
|
to:@1
|
|
|
|
(void()) main()
|
|
main: scope:[main] from @1
|
|
*((const nomodify byte*) main::SCREEN + (number) 0) ← (const byte) main::t_c1_center_x
|
|
*((const nomodify byte*) main::SCREEN + (number) 1) ← (const byte) main::t_c1_center_y
|
|
*((const nomodify byte*) main::SCREEN + (number) 2) ← (const byte) main::t_c1_radius
|
|
*((const nomodify byte*) main::SCREEN + (number) 3) ← (const byte) main::t_c2_center_x
|
|
*((const nomodify byte*) main::SCREEN + (number) 4) ← (const byte) main::t_c2_center_y
|
|
*((const nomodify byte*) main::SCREEN + (number) 5) ← (const byte) main::t_c2_radius
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
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
|
|
(struct Point) Circle::center
|
|
(byte) Circle::radius
|
|
(byte) Point::x
|
|
(byte) Point::y
|
|
(struct Circle) TwoCircles::c1
|
|
(struct Circle) TwoCircles::c2
|
|
(void()) main()
|
|
(label) main::@return
|
|
(const nomodify byte*) main::SCREEN = (byte*)(number) $400
|
|
(struct Circle) main::t_c1
|
|
(struct Point) main::t_c1_center
|
|
(const byte) main::t_c1_center_x = (byte) 1
|
|
(const byte) main::t_c1_center_y = (byte) 2
|
|
(const byte) main::t_c1_radius = (byte) 3
|
|
(struct Circle) main::t_c2
|
|
(struct Point) main::t_c2_center
|
|
(const byte) main::t_c2_center_x = (byte) 4
|
|
(const byte) main::t_c2_center_y = (byte) 5
|
|
(const byte) main::t_c2_radius = (byte) 6
|
|
|
|
Adding number conversion cast (unumber) 0 in *((const nomodify byte*) main::SCREEN + (number) 0) ← (const byte) main::t_c1_center_x
|
|
Adding number conversion cast (unumber) 1 in *((const nomodify byte*) main::SCREEN + (number) 1) ← (const byte) main::t_c1_center_y
|
|
Adding number conversion cast (unumber) 2 in *((const nomodify byte*) main::SCREEN + (number) 2) ← (const byte) main::t_c1_radius
|
|
Adding number conversion cast (unumber) 3 in *((const nomodify byte*) main::SCREEN + (number) 3) ← (const byte) main::t_c2_center_x
|
|
Adding number conversion cast (unumber) 4 in *((const nomodify byte*) main::SCREEN + (number) 4) ← (const byte) main::t_c2_center_y
|
|
Adding number conversion cast (unumber) 5 in *((const nomodify byte*) main::SCREEN + (number) 5) ← (const byte) main::t_c2_radius
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Simplifying constant pointer cast (byte*) 1024
|
|
Simplifying constant integer cast 0
|
|
Simplifying constant integer cast 1
|
|
Simplifying constant integer cast 2
|
|
Simplifying constant integer cast 3
|
|
Simplifying constant integer cast 4
|
|
Simplifying constant integer cast 5
|
|
Successful SSA optimization PassNCastSimplification
|
|
Finalized unsigned number type (byte) 0
|
|
Finalized unsigned number type (byte) 1
|
|
Finalized unsigned number type (byte) 2
|
|
Finalized unsigned number type (byte) 3
|
|
Finalized unsigned number type (byte) 4
|
|
Finalized unsigned number type (byte) 5
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
Simplifying expression containing zero main::SCREEN in [0] *((const nomodify byte*) main::SCREEN + (byte) 0) ← (const byte) main::t_c1_center_x
|
|
Successful SSA optimization PassNSimplifyExpressionWithZero
|
|
Consolidated array index constant in *(main::SCREEN+1)
|
|
Consolidated array index constant in *(main::SCREEN+2)
|
|
Consolidated array index constant in *(main::SCREEN+3)
|
|
Consolidated array index constant in *(main::SCREEN+4)
|
|
Consolidated array index constant in *(main::SCREEN+5)
|
|
Successful SSA optimization Pass2ConstantAdditionElimination
|
|
Adding NOP phi() at start of @begin
|
|
Adding NOP phi() at start of @1
|
|
Adding NOP phi() at start of @2
|
|
Adding NOP phi() at start of @end
|
|
CALL GRAPH
|
|
Calls in [] to main:2
|
|
|
|
Created 0 initial phi equivalence classes
|
|
Coalesced down to 0 phi equivalence classes
|
|
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
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
|
@begin: scope:[] from
|
|
[0] phi()
|
|
to:@1
|
|
@1: scope:[] from @begin
|
|
[1] phi()
|
|
[2] call main
|
|
to:@end
|
|
@end: scope:[] from @1
|
|
[3] phi()
|
|
|
|
(void()) main()
|
|
main: scope:[main] from @1
|
|
[4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::t_c1_center_x
|
|
[5] *((const nomodify byte*) main::SCREEN+(byte) 1) ← (const byte) main::t_c1_center_y
|
|
[6] *((const nomodify byte*) main::SCREEN+(byte) 2) ← (const byte) main::t_c1_radius
|
|
[7] *((const nomodify byte*) main::SCREEN+(byte) 3) ← (const byte) main::t_c2_center_x
|
|
[8] *((const nomodify byte*) main::SCREEN+(byte) 4) ← (const byte) main::t_c2_center_y
|
|
[9] *((const nomodify byte*) main::SCREEN+(byte) 5) ← (const byte) main::t_c2_radius
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
[10] return
|
|
to:@return
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
(struct Point) Circle::center
|
|
(byte) Circle::radius
|
|
(byte) Point::x
|
|
(byte) Point::y
|
|
(struct Circle) TwoCircles::c1
|
|
(struct Circle) TwoCircles::c2
|
|
(void()) main()
|
|
(struct Circle) main::t_c1
|
|
(struct Point) main::t_c1_center
|
|
(struct Circle) main::t_c2
|
|
(struct Point) main::t_c2_center
|
|
|
|
Initial phi equivalence classes
|
|
Complete equivalence classes
|
|
|
|
INITIAL ASM
|
|
Target platform is c64basic / MOS6502X
|
|
// File Comments
|
|
// Minimal struct - nesting structs 3 levels
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.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
|
|
jsr main
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
__bend_from___b1:
|
|
jmp __bend
|
|
// @end
|
|
__bend:
|
|
// main
|
|
main: {
|
|
.const t_c1_radius = 3
|
|
.const t_c2_radius = 6
|
|
.const t_c1_center_x = 1
|
|
.const t_c1_center_y = 2
|
|
.const t_c2_center_x = 4
|
|
.const t_c2_center_y = 5
|
|
.label SCREEN = $400
|
|
// [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::t_c1_center_x -- _deref_pbuc1=vbuc2
|
|
lda #t_c1_center_x
|
|
sta SCREEN
|
|
// [5] *((const nomodify byte*) main::SCREEN+(byte) 1) ← (const byte) main::t_c1_center_y -- _deref_pbuc1=vbuc2
|
|
lda #t_c1_center_y
|
|
sta SCREEN+1
|
|
// [6] *((const nomodify byte*) main::SCREEN+(byte) 2) ← (const byte) main::t_c1_radius -- _deref_pbuc1=vbuc2
|
|
lda #t_c1_radius
|
|
sta SCREEN+2
|
|
// [7] *((const nomodify byte*) main::SCREEN+(byte) 3) ← (const byte) main::t_c2_center_x -- _deref_pbuc1=vbuc2
|
|
lda #t_c2_center_x
|
|
sta SCREEN+3
|
|
// [8] *((const nomodify byte*) main::SCREEN+(byte) 4) ← (const byte) main::t_c2_center_y -- _deref_pbuc1=vbuc2
|
|
lda #t_c2_center_y
|
|
sta SCREEN+4
|
|
// [9] *((const nomodify byte*) main::SCREEN+(byte) 5) ← (const byte) main::t_c2_radius -- _deref_pbuc1=vbuc2
|
|
lda #t_c2_radius
|
|
sta SCREEN+5
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [10] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::t_c1_center_x [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [5] *((const nomodify byte*) main::SCREEN+(byte) 1) ← (const byte) main::t_c1_center_y [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [6] *((const nomodify byte*) main::SCREEN+(byte) 2) ← (const byte) main::t_c1_radius [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [7] *((const nomodify byte*) main::SCREEN+(byte) 3) ← (const byte) main::t_c2_center_x [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [8] *((const nomodify byte*) main::SCREEN+(byte) 4) ← (const byte) main::t_c2_center_y [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
Statement [9] *((const nomodify byte*) main::SCREEN+(byte) 5) ← (const byte) main::t_c2_radius [ ] ( main:2 [ ] { } ) always clobbers reg byte a
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [Point]
|
|
Uplift Scope [Circle]
|
|
Uplift Scope [TwoCircles]
|
|
Uplift Scope [main]
|
|
Uplift Scope []
|
|
|
|
Uplifting [Point] best 57 combination
|
|
Uplifting [Circle] best 57 combination
|
|
Uplifting [TwoCircles] best 57 combination
|
|
Uplifting [main] best 57 combination
|
|
Uplifting [] best 57 combination
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
// File Comments
|
|
// Minimal struct - nesting structs 3 levels
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.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
|
|
jsr main
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
__bend_from___b1:
|
|
jmp __bend
|
|
// @end
|
|
__bend:
|
|
// main
|
|
main: {
|
|
.const t_c1_radius = 3
|
|
.const t_c2_radius = 6
|
|
.const t_c1_center_x = 1
|
|
.const t_c1_center_y = 2
|
|
.const t_c2_center_x = 4
|
|
.const t_c2_center_y = 5
|
|
.label SCREEN = $400
|
|
// [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::t_c1_center_x -- _deref_pbuc1=vbuc2
|
|
lda #t_c1_center_x
|
|
sta SCREEN
|
|
// [5] *((const nomodify byte*) main::SCREEN+(byte) 1) ← (const byte) main::t_c1_center_y -- _deref_pbuc1=vbuc2
|
|
lda #t_c1_center_y
|
|
sta SCREEN+1
|
|
// [6] *((const nomodify byte*) main::SCREEN+(byte) 2) ← (const byte) main::t_c1_radius -- _deref_pbuc1=vbuc2
|
|
lda #t_c1_radius
|
|
sta SCREEN+2
|
|
// [7] *((const nomodify byte*) main::SCREEN+(byte) 3) ← (const byte) main::t_c2_center_x -- _deref_pbuc1=vbuc2
|
|
lda #t_c2_center_x
|
|
sta SCREEN+3
|
|
// [8] *((const nomodify byte*) main::SCREEN+(byte) 4) ← (const byte) main::t_c2_center_y -- _deref_pbuc1=vbuc2
|
|
lda #t_c2_center_y
|
|
sta SCREEN+4
|
|
// [9] *((const nomodify byte*) main::SCREEN+(byte) 5) ← (const byte) main::t_c2_radius -- _deref_pbuc1=vbuc2
|
|
lda #t_c2_radius
|
|
sta SCREEN+5
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [10] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
Removing instruction jmp __b1
|
|
Removing instruction jmp __bend
|
|
Removing instruction jmp __breturn
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
Removing instruction __b1_from___bbegin:
|
|
Removing instruction __b1:
|
|
Removing instruction __bend_from___b1:
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
|
Removing instruction __bbegin:
|
|
Removing instruction __bend:
|
|
Removing instruction __breturn:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
Removing instruction jsr main
|
|
Succesful ASM optimization Pass5SkipBegin
|
|
|
|
FINAL SYMBOL TABLE
|
|
(label) @1
|
|
(label) @begin
|
|
(label) @end
|
|
(struct Point) Circle::center
|
|
(byte) Circle::radius
|
|
(byte) Point::x
|
|
(byte) Point::y
|
|
(struct Circle) TwoCircles::c1
|
|
(struct Circle) TwoCircles::c2
|
|
(void()) main()
|
|
(label) main::@return
|
|
(const nomodify byte*) main::SCREEN = (byte*) 1024
|
|
(struct Circle) main::t_c1
|
|
(struct Point) main::t_c1_center
|
|
(const byte) main::t_c1_center_x = (byte) 1
|
|
(const byte) main::t_c1_center_y = (byte) 2
|
|
(const byte) main::t_c1_radius = (byte) 3
|
|
(struct Circle) main::t_c2
|
|
(struct Point) main::t_c2_center
|
|
(const byte) main::t_c2_center_x = (byte) 4
|
|
(const byte) main::t_c2_center_y = (byte) 5
|
|
(const byte) main::t_c2_radius = (byte) 6
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 42
|
|
|
|
// File Comments
|
|
// Minimal struct - nesting structs 3 levels
|
|
// 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
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
// @end
|
|
// main
|
|
main: {
|
|
.const t_c1_radius = 3
|
|
.const t_c2_radius = 6
|
|
.const t_c1_center_x = 1
|
|
.const t_c1_center_y = 2
|
|
.const t_c2_center_x = 4
|
|
.const t_c2_center_y = 5
|
|
.label SCREEN = $400
|
|
// SCREEN[0] = t.c1.center.x
|
|
// [4] *((const nomodify byte*) main::SCREEN) ← (const byte) main::t_c1_center_x -- _deref_pbuc1=vbuc2
|
|
lda #t_c1_center_x
|
|
sta SCREEN
|
|
// SCREEN[1] = t.c1.center.y
|
|
// [5] *((const nomodify byte*) main::SCREEN+(byte) 1) ← (const byte) main::t_c1_center_y -- _deref_pbuc1=vbuc2
|
|
lda #t_c1_center_y
|
|
sta SCREEN+1
|
|
// SCREEN[2] = t.c1.radius
|
|
// [6] *((const nomodify byte*) main::SCREEN+(byte) 2) ← (const byte) main::t_c1_radius -- _deref_pbuc1=vbuc2
|
|
lda #t_c1_radius
|
|
sta SCREEN+2
|
|
// SCREEN[3] = t.c2.center.x
|
|
// [7] *((const nomodify byte*) main::SCREEN+(byte) 3) ← (const byte) main::t_c2_center_x -- _deref_pbuc1=vbuc2
|
|
lda #t_c2_center_x
|
|
sta SCREEN+3
|
|
// SCREEN[4] = t.c2.center.y
|
|
// [8] *((const nomodify byte*) main::SCREEN+(byte) 4) ← (const byte) main::t_c2_center_y -- _deref_pbuc1=vbuc2
|
|
lda #t_c2_center_y
|
|
sta SCREEN+4
|
|
// SCREEN[5] = t.c2.radius
|
|
// [9] *((const nomodify byte*) main::SCREEN+(byte) 5) ← (const byte) main::t_c2_radius -- _deref_pbuc1=vbuc2
|
|
lda #t_c2_radius
|
|
sta SCREEN+5
|
|
// main::@return
|
|
// }
|
|
// [10] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|