2019-06-06 22:14:42 +00:00
|
|
|
Created struct value member variable (byte) point_x
|
|
|
|
Created struct value member variable (byte) point_y
|
|
|
|
Converted struct value to member variables (struct Point) point
|
|
|
|
Adding struct value member variable default initializer (byte) point_x ← (byte) 0
|
|
|
|
Adding struct value member variable default initializer (byte) point_y ← (byte) 0
|
|
|
|
Replacing struct member reference (struct Point) point.x with member variable reference (byte) point_x
|
|
|
|
Replacing struct member reference (struct Point) point.y with member variable reference (byte) point_y
|
|
|
|
Replacing struct member reference (struct Point) point.x with member variable reference (byte) point_x
|
|
|
|
Replacing struct member reference (struct Point) point.y with member variable reference (byte) point_y
|
2019-05-30 20:29:04 +00:00
|
|
|
Adding pointer type conversion cast (byte*) main::SCREEN in (byte*) main::SCREEN ← (number) $400
|
|
|
|
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
|
|
@begin: scope:[] from
|
2019-06-06 22:14:42 +00:00
|
|
|
(byte) point_x#0 ← (byte) 0
|
|
|
|
(byte) point_y#0 ← (byte) 0
|
2019-05-30 20:29:04 +00:00
|
|
|
to:@1
|
|
|
|
main: scope:[main] from @1
|
2019-06-06 22:14:42 +00:00
|
|
|
(byte) point_x#1 ← (number) 2
|
|
|
|
(byte) point_y#1 ← (number) 3
|
2019-05-30 20:29:04 +00:00
|
|
|
(byte*) main::SCREEN#0 ← ((byte*)) (number) $400
|
2019-06-06 22:14:42 +00:00
|
|
|
*((byte*) main::SCREEN#0 + (number) 0) ← (byte) point_x#1
|
|
|
|
*((byte*) main::SCREEN#0 + (number) 1) ← (byte) point_y#1
|
2019-05-30 20:29:04 +00:00
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main
|
2019-06-06 22:14:42 +00:00
|
|
|
(byte) point_y#4 ← phi( main/(byte) point_y#1 )
|
|
|
|
(byte) point_x#4 ← phi( main/(byte) point_x#1 )
|
|
|
|
(byte) point_x#2 ← (byte) point_x#4
|
|
|
|
(byte) point_y#2 ← (byte) point_y#4
|
2019-05-30 20:29:04 +00:00
|
|
|
return
|
|
|
|
to:@return
|
|
|
|
@1: scope:[] from @begin
|
2019-06-06 22:14:42 +00:00
|
|
|
(byte) point_y#6 ← phi( @begin/(byte) point_y#0 )
|
|
|
|
(byte) point_x#6 ← phi( @begin/(byte) point_x#0 )
|
2019-05-30 20:29:04 +00:00
|
|
|
call main
|
|
|
|
to:@2
|
|
|
|
@2: scope:[] from @1
|
2019-06-06 22:14:42 +00:00
|
|
|
(byte) point_y#5 ← phi( @1/(byte) point_y#2 )
|
|
|
|
(byte) point_x#5 ← phi( @1/(byte) point_x#2 )
|
|
|
|
(byte) point_x#3 ← (byte) point_x#5
|
|
|
|
(byte) point_y#3 ← (byte) point_y#5
|
2019-05-30 20:29:04 +00:00
|
|
|
to:@end
|
|
|
|
@end: scope:[] from @2
|
|
|
|
|
|
|
|
SYMBOL TABLE SSA
|
|
|
|
(label) @1
|
|
|
|
(label) @2
|
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
|
|
|
(byte) Point::x
|
|
|
|
(byte) Point::y
|
|
|
|
(void()) main()
|
|
|
|
(label) main::@return
|
|
|
|
(byte*) main::SCREEN
|
|
|
|
(byte*) main::SCREEN#0
|
|
|
|
(struct Point) point
|
2019-06-06 22:14:42 +00:00
|
|
|
(byte) point_x
|
|
|
|
(byte) point_x#0
|
|
|
|
(byte) point_x#1
|
|
|
|
(byte) point_x#2
|
|
|
|
(byte) point_x#3
|
|
|
|
(byte) point_x#4
|
|
|
|
(byte) point_x#5
|
|
|
|
(byte) point_x#6
|
|
|
|
(byte) point_y
|
|
|
|
(byte) point_y#0
|
|
|
|
(byte) point_y#1
|
|
|
|
(byte) point_y#2
|
|
|
|
(byte) point_y#3
|
|
|
|
(byte) point_y#4
|
|
|
|
(byte) point_y#5
|
|
|
|
(byte) point_y#6
|
2019-05-30 20:29:04 +00:00
|
|
|
|
2019-06-06 22:14:42 +00:00
|
|
|
Adding number conversion cast (unumber) 2 in (byte) point_x#1 ← (number) 2
|
|
|
|
Adding number conversion cast (unumber) 3 in (byte) point_y#1 ← (number) 3
|
|
|
|
Adding number conversion cast (unumber) 0 in *((byte*) main::SCREEN#0 + (number) 0) ← (byte) point_x#1
|
|
|
|
Adding number conversion cast (unumber) 1 in *((byte*) main::SCREEN#0 + (number) 1) ← (byte) point_y#1
|
2019-05-30 20:29:04 +00:00
|
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
2019-06-06 22:14:42 +00:00
|
|
|
Inlining cast (byte) point_x#1 ← (unumber)(number) 2
|
|
|
|
Inlining cast (byte) point_y#1 ← (unumber)(number) 3
|
2019-05-30 20:29:04 +00:00
|
|
|
Inlining cast (byte*) main::SCREEN#0 ← (byte*)(number) $400
|
|
|
|
Successful SSA optimization Pass2InlineCast
|
|
|
|
Simplifying constant integer cast 2
|
|
|
|
Simplifying constant integer cast 3
|
|
|
|
Simplifying constant pointer cast (byte*) 1024
|
|
|
|
Simplifying constant integer cast 0
|
|
|
|
Simplifying constant integer cast 1
|
|
|
|
Successful SSA optimization PassNCastSimplification
|
|
|
|
Finalized unsigned number type (byte) 2
|
|
|
|
Finalized unsigned number type (byte) 3
|
|
|
|
Finalized unsigned number type (byte) 0
|
|
|
|
Finalized unsigned number type (byte) 1
|
|
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
2019-06-06 22:14:42 +00:00
|
|
|
Alias (byte) point_x#1 = (byte) point_x#4 (byte) point_x#2
|
|
|
|
Alias (byte) point_y#1 = (byte) point_y#4 (byte) point_y#2
|
|
|
|
Alias (byte) point_x#0 = (byte) point_x#6
|
|
|
|
Alias (byte) point_y#0 = (byte) point_y#6
|
|
|
|
Alias (byte) point_x#3 = (byte) point_x#5
|
|
|
|
Alias (byte) point_y#3 = (byte) point_y#5
|
2019-05-30 20:29:04 +00:00
|
|
|
Successful SSA optimization Pass2AliasElimination
|
2019-06-06 22:14:42 +00:00
|
|
|
Identical Phi Values (byte) point_x#3 (byte) point_x#1
|
|
|
|
Identical Phi Values (byte) point_y#3 (byte) point_y#1
|
2019-05-30 20:29:04 +00:00
|
|
|
Successful SSA optimization Pass2IdenticalPhiElimination
|
2019-06-06 22:14:42 +00:00
|
|
|
Constant (const byte) point_x#0 = 0
|
|
|
|
Constant (const byte) point_y#0 = 0
|
|
|
|
Constant (const byte) point_x#1 = 2
|
|
|
|
Constant (const byte) point_y#1 = 3
|
2019-05-30 20:29:04 +00:00
|
|
|
Constant (const byte*) main::SCREEN#0 = (byte*) 1024
|
|
|
|
Successful SSA optimization Pass2ConstantIdentification
|
2019-06-06 22:14:42 +00:00
|
|
|
Simplifying expression containing zero main::SCREEN#0 in [5] *((const byte*) main::SCREEN#0 + (byte) 0) ← (const byte) point_x#1
|
2019-05-30 20:29:04 +00:00
|
|
|
Successful SSA optimization PassNSimplifyExpressionWithZero
|
2019-06-06 22:14:42 +00:00
|
|
|
Eliminating unused constant (const byte) point_x#0
|
|
|
|
Eliminating unused constant (const byte) point_y#0
|
|
|
|
Successful SSA optimization PassNEliminateUnusedVars
|
2019-05-30 20:29:04 +00:00
|
|
|
Consolidated array index constant in *(main::SCREEN#0+1)
|
|
|
|
Successful SSA optimization Pass2ConstantAdditionElimination
|
2019-06-06 22:14:42 +00:00
|
|
|
Adding NOP phi() at start of @begin
|
2019-05-30 20:29:04 +00:00
|
|
|
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
|
2019-06-06 22:14:42 +00:00
|
|
|
Adding NOP phi() at start of @begin
|
2019-05-30 20:29:04 +00:00
|
|
|
Adding NOP phi() at start of @1
|
|
|
|
Adding NOP phi() at start of @end
|
|
|
|
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
|
|
|
@begin: scope:[] from
|
2019-06-06 22:14:42 +00:00
|
|
|
[0] phi()
|
2019-05-30 20:29:04 +00:00
|
|
|
to:@1
|
|
|
|
@1: scope:[] from @begin
|
|
|
|
[1] phi()
|
|
|
|
[2] call main
|
|
|
|
to:@end
|
|
|
|
@end: scope:[] from @1
|
|
|
|
[3] phi()
|
|
|
|
main: scope:[main] from @1
|
2019-06-06 22:14:42 +00:00
|
|
|
[4] *((const byte*) main::SCREEN#0) ← (const byte) point_x#1
|
|
|
|
[5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) point_y#1
|
2019-05-30 20:29:04 +00:00
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main
|
2019-06-06 22:14:42 +00:00
|
|
|
[6] return
|
2019-05-30 20:29:04 +00:00
|
|
|
to:@return
|
|
|
|
|
|
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
|
|
(byte) Point::x
|
|
|
|
(byte) Point::y
|
|
|
|
(void()) main()
|
|
|
|
(byte*) main::SCREEN
|
|
|
|
(struct Point) point
|
2019-06-06 22:14:42 +00:00
|
|
|
(byte) point_x
|
|
|
|
(byte) point_y
|
2019-05-30 20:29:04 +00:00
|
|
|
|
|
|
|
Initial phi equivalence classes
|
|
|
|
Complete equivalence classes
|
|
|
|
|
|
|
|
INITIAL ASM
|
|
|
|
//SEG0 File Comments
|
|
|
|
// Minimal struct - declaration, instantiation and usage
|
|
|
|
//SEG1 Basic Upstart
|
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(bbegin)
|
|
|
|
.pc = $80d "Program"
|
|
|
|
//SEG2 Global Constants & labels
|
2019-06-06 22:14:42 +00:00
|
|
|
.const point_x = 2
|
|
|
|
.const point_y = 3
|
2019-05-30 20:29:04 +00:00
|
|
|
//SEG3 @begin
|
|
|
|
bbegin:
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
2019-05-30 20:29:04 +00:00
|
|
|
b1_from_bbegin:
|
|
|
|
jmp b1
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG5 @1
|
2019-05-30 20:29:04 +00:00
|
|
|
b1:
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG6 [2] call main
|
2019-05-30 20:29:04 +00:00
|
|
|
jsr main
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
|
2019-05-30 20:29:04 +00:00
|
|
|
bend_from_b1:
|
|
|
|
jmp bend
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG8 @end
|
2019-05-30 20:29:04 +00:00
|
|
|
bend:
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG9 main
|
2019-05-30 20:29:04 +00:00
|
|
|
main: {
|
|
|
|
.label SCREEN = $400
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG10 [4] *((const byte*) main::SCREEN#0) ← (const byte) point_x#1 -- _deref_pbuc1=vbuc2
|
|
|
|
lda #point_x
|
2019-05-30 20:29:04 +00:00
|
|
|
sta SCREEN
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG11 [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) point_y#1 -- _deref_pbuc1=vbuc2
|
|
|
|
lda #point_y
|
2019-05-30 20:29:04 +00:00
|
|
|
sta SCREEN+1
|
|
|
|
jmp breturn
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG12 main::@return
|
2019-05-30 20:29:04 +00:00
|
|
|
breturn:
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG13 [6] return
|
2019-05-30 20:29:04 +00:00
|
|
|
rts
|
|
|
|
}
|
|
|
|
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
2019-06-06 22:14:42 +00:00
|
|
|
Statement [4] *((const byte*) main::SCREEN#0) ← (const byte) point_x#1 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
|
|
|
Statement [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) point_y#1 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
2019-05-30 20:29:04 +00:00
|
|
|
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
|
|
Uplift Scope [Point]
|
|
|
|
Uplift Scope [main]
|
2019-06-06 22:14:42 +00:00
|
|
|
Uplift Scope []
|
2019-05-30 20:29:04 +00:00
|
|
|
|
2019-06-06 22:14:42 +00:00
|
|
|
Uplifting [Point] best 33 combination
|
|
|
|
Uplifting [main] best 33 combination
|
|
|
|
Uplifting [] best 33 combination
|
2019-05-30 20:29:04 +00:00
|
|
|
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
|
|
//SEG0 File Comments
|
|
|
|
// Minimal struct - declaration, instantiation and usage
|
|
|
|
//SEG1 Basic Upstart
|
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(bbegin)
|
|
|
|
.pc = $80d "Program"
|
|
|
|
//SEG2 Global Constants & labels
|
2019-06-06 22:14:42 +00:00
|
|
|
.const point_x = 2
|
|
|
|
.const point_y = 3
|
2019-05-30 20:29:04 +00:00
|
|
|
//SEG3 @begin
|
|
|
|
bbegin:
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
2019-05-30 20:29:04 +00:00
|
|
|
b1_from_bbegin:
|
|
|
|
jmp b1
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG5 @1
|
2019-05-30 20:29:04 +00:00
|
|
|
b1:
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG6 [2] call main
|
2019-05-30 20:29:04 +00:00
|
|
|
jsr main
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
|
2019-05-30 20:29:04 +00:00
|
|
|
bend_from_b1:
|
|
|
|
jmp bend
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG8 @end
|
2019-05-30 20:29:04 +00:00
|
|
|
bend:
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG9 main
|
2019-05-30 20:29:04 +00:00
|
|
|
main: {
|
|
|
|
.label SCREEN = $400
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG10 [4] *((const byte*) main::SCREEN#0) ← (const byte) point_x#1 -- _deref_pbuc1=vbuc2
|
|
|
|
lda #point_x
|
2019-05-30 20:29:04 +00:00
|
|
|
sta SCREEN
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG11 [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) point_y#1 -- _deref_pbuc1=vbuc2
|
|
|
|
lda #point_y
|
2019-05-30 20:29:04 +00:00
|
|
|
sta SCREEN+1
|
|
|
|
jmp breturn
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG12 main::@return
|
2019-05-30 20:29:04 +00:00
|
|
|
breturn:
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG13 [6] return
|
2019-05-30 20:29:04 +00:00
|
|
|
rts
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
|
|
Removing instruction jmp b1
|
|
|
|
Removing instruction jmp bend
|
|
|
|
Removing instruction jmp breturn
|
|
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
|
|
Removing instruction b1_from_bbegin:
|
2019-06-06 22:14:42 +00:00
|
|
|
Removing instruction b1:
|
2019-05-30 20:29:04 +00:00
|
|
|
Removing instruction bend_from_b1:
|
|
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
|
|
|
Removing instruction bend:
|
|
|
|
Removing instruction breturn:
|
|
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
2019-06-06 22:14:42 +00:00
|
|
|
Updating BasicUpstart to call main directly
|
|
|
|
Removing instruction jsr main
|
|
|
|
Succesful ASM optimization Pass5SkipBegin
|
|
|
|
Removing instruction bbegin:
|
|
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
2019-05-30 20:29:04 +00:00
|
|
|
|
|
|
|
FINAL SYMBOL TABLE
|
|
|
|
(label) @1
|
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
|
|
|
(byte) Point::x
|
|
|
|
(byte) Point::y
|
|
|
|
(void()) main()
|
|
|
|
(label) main::@return
|
|
|
|
(byte*) main::SCREEN
|
|
|
|
(const byte*) main::SCREEN#0 SCREEN = (byte*) 1024
|
|
|
|
(struct Point) point
|
2019-06-06 22:14:42 +00:00
|
|
|
(byte) point_x
|
|
|
|
(const byte) point_x#1 point_x = (byte) 2
|
|
|
|
(byte) point_y
|
|
|
|
(const byte) point_y#1 point_y = (byte) 3
|
2019-05-30 20:29:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
2019-06-06 22:14:42 +00:00
|
|
|
Score: 18
|
2019-05-30 20:29:04 +00:00
|
|
|
|
|
|
|
//SEG0 File Comments
|
|
|
|
// Minimal struct - declaration, instantiation and usage
|
|
|
|
//SEG1 Basic Upstart
|
|
|
|
.pc = $801 "Basic"
|
2019-06-06 22:14:42 +00:00
|
|
|
:BasicUpstart(main)
|
2019-05-30 20:29:04 +00:00
|
|
|
.pc = $80d "Program"
|
|
|
|
//SEG2 Global Constants & labels
|
2019-06-06 22:14:42 +00:00
|
|
|
.const point_x = 2
|
|
|
|
.const point_y = 3
|
2019-05-30 20:29:04 +00:00
|
|
|
//SEG3 @begin
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
|
|
|
//SEG5 @1
|
|
|
|
//SEG6 [2] call main
|
|
|
|
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
|
|
|
|
//SEG8 @end
|
|
|
|
//SEG9 main
|
2019-05-30 20:29:04 +00:00
|
|
|
main: {
|
|
|
|
.label SCREEN = $400
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG10 [4] *((const byte*) main::SCREEN#0) ← (const byte) point_x#1 -- _deref_pbuc1=vbuc2
|
|
|
|
lda #point_x
|
2019-05-30 20:29:04 +00:00
|
|
|
sta SCREEN
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG11 [5] *((const byte*) main::SCREEN#0+(byte) 1) ← (const byte) point_y#1 -- _deref_pbuc1=vbuc2
|
|
|
|
lda #point_y
|
2019-05-30 20:29:04 +00:00
|
|
|
sta SCREEN+1
|
2019-06-06 22:14:42 +00:00
|
|
|
//SEG12 main::@return
|
|
|
|
//SEG13 [6] return
|
2019-05-30 20:29:04 +00:00
|
|
|
rts
|
|
|
|
}
|
|
|
|
|