mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-09-08 17:54:40 +00:00
298 lines
9.7 KiB
Plaintext
298 lines
9.7 KiB
Plaintext
Created struct value member variable (byte) main::p_x
|
|
Created struct value member variable (byte) main::p_y
|
|
Converted struct value to member variables (struct PointDef) main::p
|
|
Adding struct value list initializer (byte) main::p_x ← (number) 4
|
|
Adding struct value list initializer (byte) main::p_y ← (number) 7
|
|
Adding struct value member variable copy *((byte*) main::$0) ← (byte) main::p_x
|
|
Adding struct value member variable copy *((byte*) main::$1) ← (byte) main::p_y
|
|
Identified constant variable (struct PointDef*) main::SCREEN
|
|
Identified constant variable (byte) main::p_x
|
|
Identified constant variable (byte) main::p_y
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
@begin: scope:[] from
|
|
to:@1
|
|
main: scope:[main] from @1
|
|
(byte) main::p_x#0 ← (number) 4
|
|
(byte) main::p_y#0 ← (number) 7
|
|
(struct PointDef*) main::SCREEN#0 ← ((struct PointDef*)) (number) $400
|
|
(byte*) main::$0 ← (byte*)(struct PointDef*) main::SCREEN#0 + (const byte) OFFSET_STRUCT_POINTDEF_X
|
|
*((byte*) main::$0) ← (byte) main::p_x#0
|
|
(byte*) main::$1 ← (byte*)(struct PointDef*) main::SCREEN#0 + (const byte) OFFSET_STRUCT_POINTDEF_Y
|
|
*((byte*) main::$1) ← (byte) main::p_y#0
|
|
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
|
|
(const byte) OFFSET_STRUCT_POINTDEF_X = (byte) 0
|
|
(const byte) OFFSET_STRUCT_POINTDEF_Y = (byte) 1
|
|
(byte) PointDef::x
|
|
(byte) PointDef::y
|
|
(void()) main()
|
|
(byte*) main::$0
|
|
(byte*) main::$1
|
|
(label) main::@return
|
|
(struct PointDef*) main::SCREEN
|
|
(struct PointDef*) main::SCREEN#0
|
|
(byte) main::p_x
|
|
(byte) main::p_x#0
|
|
(byte) main::p_y
|
|
(byte) main::p_y#0
|
|
|
|
Adding number conversion cast (unumber) 4 in (byte) main::p_x#0 ← (number) 4
|
|
Adding number conversion cast (unumber) 7 in (byte) main::p_y#0 ← (number) 7
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Inlining cast (byte) main::p_x#0 ← (unumber)(number) 4
|
|
Inlining cast (byte) main::p_y#0 ← (unumber)(number) 7
|
|
Inlining cast (struct PointDef*) main::SCREEN#0 ← (struct PointDef*)(number) $400
|
|
Successful SSA optimization Pass2InlineCast
|
|
Simplifying constant integer cast 4
|
|
Simplifying constant integer cast 7
|
|
Simplifying constant pointer cast (struct PointDef*) 1024
|
|
Successful SSA optimization PassNCastSimplification
|
|
Finalized unsigned number type (byte) 4
|
|
Finalized unsigned number type (byte) 7
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
Constant (const byte) main::p_x#0 = 4
|
|
Constant (const byte) main::p_y#0 = 7
|
|
Constant (const struct PointDef*) main::SCREEN#0 = (struct PointDef*) 1024
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Constant value identified (byte*)main::SCREEN#0 in [3] (byte*) main::$0 ← (byte*)(const struct PointDef*) main::SCREEN#0 + (const byte) OFFSET_STRUCT_POINTDEF_X
|
|
Constant value identified (byte*)main::SCREEN#0 in [5] (byte*) main::$1 ← (byte*)(const struct PointDef*) main::SCREEN#0 + (const byte) OFFSET_STRUCT_POINTDEF_Y
|
|
Successful SSA optimization Pass2ConstantValues
|
|
Converting *(pointer+n) to pointer[n] [4] *((byte*) main::$0) ← (const byte) main::p_x#0 -- *((byte*)main::SCREEN#0 + OFFSET_STRUCT_POINTDEF_X)
|
|
Converting *(pointer+n) to pointer[n] [6] *((byte*) main::$1) ← (const byte) main::p_y#0 -- *((byte*)main::SCREEN#0 + OFFSET_STRUCT_POINTDEF_Y)
|
|
Successful SSA optimization Pass2InlineDerefIdx
|
|
Simplifying expression containing zero (byte*)main::SCREEN#0 in [3] (byte*) main::$0 ← (byte*)(const struct PointDef*) main::SCREEN#0 + (const byte) OFFSET_STRUCT_POINTDEF_X
|
|
Simplifying expression containing zero (byte*)main::SCREEN#0 in [4] *((byte*)(const struct PointDef*) main::SCREEN#0 + (const byte) OFFSET_STRUCT_POINTDEF_X) ← (const byte) main::p_x#0
|
|
Successful SSA optimization PassNSimplifyExpressionWithZero
|
|
Eliminating unused variable (byte*) main::$0 and assignment [0] (byte*) main::$0 ← (byte*)(const struct PointDef*) main::SCREEN#0
|
|
Eliminating unused variable (byte*) main::$1 and assignment [2] (byte*) main::$1 ← (byte*)(const struct PointDef*) main::SCREEN#0 + (const byte) OFFSET_STRUCT_POINTDEF_Y
|
|
Eliminating unused constant (const byte) OFFSET_STRUCT_POINTDEF_X
|
|
Successful SSA optimization PassNEliminateUnusedVars
|
|
Consolidated array index constant in *((byte*)main::SCREEN#0+OFFSET_STRUCT_POINTDEF_Y)
|
|
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()
|
|
main: scope:[main] from @1
|
|
[4] *((byte*)(const struct PointDef*) main::SCREEN#0) ← (const byte) main::p_x#0
|
|
[5] *((byte*)(const struct PointDef*) main::SCREEN#0+(const byte) OFFSET_STRUCT_POINTDEF_Y) ← (const byte) main::p_y#0
|
|
to:main::@return
|
|
main::@return: scope:[main] from main
|
|
[6] return
|
|
to:@return
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
(byte) PointDef::x
|
|
(byte) PointDef::y
|
|
(void()) main()
|
|
(struct PointDef*) main::SCREEN
|
|
(byte) main::p_x
|
|
(byte) main::p_y
|
|
|
|
Initial phi equivalence classes
|
|
Complete equivalence classes
|
|
|
|
INITIAL ASM
|
|
Target platform is c64basic / MOS6502X
|
|
// File Comments
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(bbegin)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.const OFFSET_STRUCT_POINTDEF_Y = 1
|
|
// @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 p_x = 4
|
|
.const p_y = 7
|
|
.label SCREEN = $400
|
|
// [4] *((byte*)(const struct PointDef*) main::SCREEN#0) ← (const byte) main::p_x#0 -- _deref_pbuc1=vbuc2
|
|
lda #p_x
|
|
sta SCREEN
|
|
// [5] *((byte*)(const struct PointDef*) main::SCREEN#0+(const byte) OFFSET_STRUCT_POINTDEF_Y) ← (const byte) main::p_y#0 -- _deref_pbuc1=vbuc2
|
|
lda #p_y
|
|
sta SCREEN+OFFSET_STRUCT_POINTDEF_Y
|
|
jmp breturn
|
|
// main::@return
|
|
breturn:
|
|
// [6] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [4] *((byte*)(const struct PointDef*) main::SCREEN#0) ← (const byte) main::p_x#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
|
Statement [5] *((byte*)(const struct PointDef*) main::SCREEN#0+(const byte) OFFSET_STRUCT_POINTDEF_Y) ← (const byte) main::p_y#0 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [PointDef]
|
|
Uplift Scope [main]
|
|
Uplift Scope []
|
|
|
|
Uplifting [PointDef] best 33 combination
|
|
Uplifting [main] best 33 combination
|
|
Uplifting [] best 33 combination
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
// File Comments
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(bbegin)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.const OFFSET_STRUCT_POINTDEF_Y = 1
|
|
// @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 p_x = 4
|
|
.const p_y = 7
|
|
.label SCREEN = $400
|
|
// [4] *((byte*)(const struct PointDef*) main::SCREEN#0) ← (const byte) main::p_x#0 -- _deref_pbuc1=vbuc2
|
|
lda #p_x
|
|
sta SCREEN
|
|
// [5] *((byte*)(const struct PointDef*) main::SCREEN#0+(const byte) OFFSET_STRUCT_POINTDEF_Y) ← (const byte) main::p_y#0 -- _deref_pbuc1=vbuc2
|
|
lda #p_y
|
|
sta SCREEN+OFFSET_STRUCT_POINTDEF_Y
|
|
jmp breturn
|
|
// main::@return
|
|
breturn:
|
|
// [6] 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 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
|
|
(const byte) OFFSET_STRUCT_POINTDEF_Y OFFSET_STRUCT_POINTDEF_Y = (byte) 1
|
|
(byte) PointDef::x
|
|
(byte) PointDef::y
|
|
(void()) main()
|
|
(label) main::@return
|
|
(struct PointDef*) main::SCREEN
|
|
(const struct PointDef*) main::SCREEN#0 SCREEN = (struct PointDef*) 1024
|
|
(byte) main::p_x
|
|
(const byte) main::p_x#0 p_x = (byte) 4
|
|
(byte) main::p_y
|
|
(const byte) main::p_y#0 p_y = (byte) 7
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 18
|
|
|
|
// File Comments
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.const OFFSET_STRUCT_POINTDEF_Y = 1
|
|
// @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 p_x = 4
|
|
.const p_y = 7
|
|
.label SCREEN = $400
|
|
// *SCREEN = p
|
|
// [4] *((byte*)(const struct PointDef*) main::SCREEN#0) ← (const byte) main::p_x#0 -- _deref_pbuc1=vbuc2
|
|
lda #p_x
|
|
sta SCREEN
|
|
// [5] *((byte*)(const struct PointDef*) main::SCREEN#0+(const byte) OFFSET_STRUCT_POINTDEF_Y) ← (const byte) main::p_y#0 -- _deref_pbuc1=vbuc2
|
|
lda #p_y
|
|
sta SCREEN+OFFSET_STRUCT_POINTDEF_Y
|
|
// main::@return
|
|
// }
|
|
// [6] return
|
|
rts
|
|
}
|
|
// File Data
|
|
|