mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-10-21 17:24:39 +00:00
295 lines
8.5 KiB
Plaintext
295 lines
8.5 KiB
Plaintext
Adding pointer type conversion cast (byte*) screen in (byte*) screen ← (number) $400
|
|
Identified constant variable (byte) call
|
|
Identified constant variable (byte*) screen
|
|
Culled Empty Block (label) main::@1
|
|
Culled Empty Block (label) @1
|
|
Culled Empty Block (label) proc::@1
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
@begin: scope:[] from
|
|
(byte) call#0 ← (number) 0
|
|
(byte*) screen#0 ← ((byte*)) (number) $400
|
|
to:@2
|
|
main: scope:[main] from @2
|
|
*((byte*) screen#0 + (number) 0) ← (byte) 'a'
|
|
(bool~) main::$0 ← (byte) call#0 != (number) 0
|
|
(bool~) main::$1 ← ! (bool~) main::$0
|
|
if((bool~) main::$1) goto main::@return
|
|
to:main::@2
|
|
main::@2: scope:[main] from main
|
|
call proc
|
|
to:main::@3
|
|
main::@3: scope:[main] from main::@2
|
|
to:main::@return
|
|
main::@return: scope:[main] from main main::@3
|
|
return
|
|
to:@return
|
|
proc: scope:[proc] from main::@2
|
|
*((byte*) screen#0 + (number) 1) ← (byte) 'a'
|
|
(bool~) proc::$0 ← *((byte*) screen#0 + (number) 1) != (number) 0
|
|
(bool~) proc::$1 ← ! (bool~) proc::$0
|
|
if((bool~) proc::$1) goto proc::@return
|
|
to:proc::@2
|
|
proc::@2: scope:[proc] from proc
|
|
*((byte*) screen#0 + (number) 2) ← (byte) 'a'
|
|
to:proc::@return
|
|
proc::@return: scope:[proc] from proc proc::@2
|
|
return
|
|
to:@return
|
|
@2: scope:[] from @begin
|
|
call main
|
|
to:@3
|
|
@3: scope:[] from @2
|
|
to:@end
|
|
@end: scope:[] from @3
|
|
|
|
SYMBOL TABLE SSA
|
|
(label) @2
|
|
(label) @3
|
|
(label) @begin
|
|
(label) @end
|
|
(byte) call
|
|
(byte) call#0
|
|
(void()) main()
|
|
(bool~) main::$0
|
|
(bool~) main::$1
|
|
(label) main::@2
|
|
(label) main::@3
|
|
(label) main::@return
|
|
(void()) proc()
|
|
(bool~) proc::$0
|
|
(bool~) proc::$1
|
|
(label) proc::@2
|
|
(label) proc::@return
|
|
(byte*) screen
|
|
(byte*) screen#0
|
|
|
|
Adding number conversion cast (unumber) 0 in (byte) call#0 ← (number) 0
|
|
Adding number conversion cast (unumber) 0 in *((byte*) screen#0 + (number) 0) ← (byte) 'a'
|
|
Adding number conversion cast (unumber) 0 in (bool~) main::$0 ← (byte) call#0 != (number) 0
|
|
Adding number conversion cast (unumber) 1 in *((byte*) screen#0 + (number) 1) ← (byte) 'a'
|
|
Adding number conversion cast (unumber) 0 in (bool~) proc::$0 ← *((byte*) screen#0 + (number) 1) != (number) 0
|
|
Adding number conversion cast (unumber) 1 in (bool~) proc::$0 ← *((byte*) screen#0 + (number) 1) != (unumber)(number) 0
|
|
Adding number conversion cast (unumber) 2 in *((byte*) screen#0 + (number) 2) ← (byte) 'a'
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Inlining cast (byte) call#0 ← (unumber)(number) 0
|
|
Inlining cast (byte*) screen#0 ← (byte*)(number) $400
|
|
Successful SSA optimization Pass2InlineCast
|
|
Simplifying constant integer cast 0
|
|
Simplifying constant pointer cast (byte*) 1024
|
|
Simplifying constant integer cast 0
|
|
Simplifying constant integer cast 0
|
|
Simplifying constant integer cast 1
|
|
Simplifying constant integer cast 1
|
|
Simplifying constant integer cast 0
|
|
Simplifying constant integer cast 2
|
|
Successful SSA optimization PassNCastSimplification
|
|
Finalized unsigned number type (byte) 0
|
|
Finalized unsigned number type (byte) 0
|
|
Finalized unsigned number type (byte) 0
|
|
Finalized unsigned number type (byte) 1
|
|
Finalized unsigned number type (byte) 1
|
|
Finalized unsigned number type (byte) 0
|
|
Finalized unsigned number type (byte) 2
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
Inversing boolean not [4] (bool~) main::$1 ← (byte) call#0 == (byte) 0 from [3] (bool~) main::$0 ← (byte) call#0 != (byte) 0
|
|
Inversing boolean not [10] (bool~) proc::$1 ← *((byte*) screen#0 + (byte) 1) == (byte) 0 from [9] (bool~) proc::$0 ← *((byte*) screen#0 + (byte) 1) != (byte) 0
|
|
Successful SSA optimization Pass2UnaryNotSimplification
|
|
Simple Condition (bool~) main::$1 [5] if((byte) call#0==(byte) 0) goto main::@return
|
|
Simple Condition (bool~) proc::$1 [11] if(*((byte*) screen#0 + (byte) 1)==(byte) 0) goto proc::@return
|
|
Successful SSA optimization Pass2ConditionalJumpSimplification
|
|
Constant (const byte) call#0 = 0
|
|
Constant (const byte*) screen#0 = (byte*) 1024
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
if() condition always true - replacing block destination [5] if((const byte) call#0==(byte) 0) goto main::@return
|
|
Successful SSA optimization Pass2ConstantIfs
|
|
Simplifying expression containing zero screen#0 in [2] *((const byte*) screen#0 + (byte) 0) ← (byte) 'a'
|
|
Successful SSA optimization PassNSimplifyExpressionWithZero
|
|
Eliminating unused constant (const byte) call#0
|
|
Successful SSA optimization PassNEliminateUnusedVars
|
|
Removing unused block main::@2
|
|
Removing unused block main::@3
|
|
Removing unused procedure proc
|
|
Removing unused procedure block proc
|
|
Removing unused procedure block proc::@2
|
|
Removing unused procedure block proc::@return
|
|
Successful SSA optimization Pass2EliminateUnusedBlocks
|
|
Adding NOP phi() at start of @begin
|
|
Adding NOP phi() at start of @2
|
|
Adding NOP phi() at start of @3
|
|
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) @3
|
|
Renumbering block @2 to @1
|
|
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()
|
|
main: scope:[main] from @1
|
|
[4] *((const byte*) screen#0) ← (byte) 'a'
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
[5] return
|
|
to:@return
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
(byte) call
|
|
(void()) main()
|
|
(byte*) screen
|
|
|
|
Initial phi equivalence classes
|
|
Complete equivalence classes
|
|
|
|
INITIAL ASM
|
|
//SEG0 File Comments
|
|
// Tests that a procedure that is never called, but requires static analysis is correctly eliminated
|
|
//SEG1 Basic Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(bbegin)
|
|
.pc = $80d "Program"
|
|
//SEG2 Global Constants & labels
|
|
.label screen = $400
|
|
//SEG3 @begin
|
|
bbegin:
|
|
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
|
b1_from_bbegin:
|
|
jmp b1
|
|
//SEG5 @1
|
|
b1:
|
|
//SEG6 [2] call main
|
|
jsr main
|
|
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
|
|
bend_from_b1:
|
|
jmp bend
|
|
//SEG8 @end
|
|
bend:
|
|
//SEG9 main
|
|
main: {
|
|
//SEG10 [4] *((const byte*) screen#0) ← (byte) 'a' -- _deref_pbuc1=vbuc2
|
|
lda #'a'
|
|
sta screen
|
|
jmp breturn
|
|
//SEG11 main::@return
|
|
breturn:
|
|
//SEG12 [5] return
|
|
rts
|
|
}
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [4] *((const byte*) screen#0) ← (byte) 'a' [ ] ( main:2 [ ] ) always clobbers reg byte a
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [main]
|
|
Uplift Scope []
|
|
|
|
Uplifting [main] best 27 combination
|
|
Uplifting [] best 27 combination
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
//SEG0 File Comments
|
|
// Tests that a procedure that is never called, but requires static analysis is correctly eliminated
|
|
//SEG1 Basic Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(bbegin)
|
|
.pc = $80d "Program"
|
|
//SEG2 Global Constants & labels
|
|
.label screen = $400
|
|
//SEG3 @begin
|
|
bbegin:
|
|
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
|
b1_from_bbegin:
|
|
jmp b1
|
|
//SEG5 @1
|
|
b1:
|
|
//SEG6 [2] call main
|
|
jsr main
|
|
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
|
|
bend_from_b1:
|
|
jmp bend
|
|
//SEG8 @end
|
|
bend:
|
|
//SEG9 main
|
|
main: {
|
|
//SEG10 [4] *((const byte*) screen#0) ← (byte) 'a' -- _deref_pbuc1=vbuc2
|
|
lda #'a'
|
|
sta screen
|
|
jmp breturn
|
|
//SEG11 main::@return
|
|
breturn:
|
|
//SEG12 [5] return
|
|
rts
|
|
}
|
|
|
|
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 bend:
|
|
Removing instruction breturn:
|
|
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
|
|
|
|
FINAL SYMBOL TABLE
|
|
(label) @1
|
|
(label) @begin
|
|
(label) @end
|
|
(byte) call
|
|
(void()) main()
|
|
(label) main::@return
|
|
(byte*) screen
|
|
(const byte*) screen#0 screen = (byte*) 1024
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 12
|
|
|
|
//SEG0 File Comments
|
|
// Tests that a procedure that is never called, but requires static analysis is correctly eliminated
|
|
//SEG1 Basic Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
//SEG2 Global Constants & labels
|
|
.label screen = $400
|
|
//SEG3 @begin
|
|
//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
|
|
main: {
|
|
//SEG10 [4] *((const byte*) screen#0) ← (byte) 'a' -- _deref_pbuc1=vbuc2
|
|
lda #'a'
|
|
sta screen
|
|
//SEG11 main::@return
|
|
//SEG12 [5] return
|
|
rts
|
|
}
|
|
|