1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-08-07 22:25:13 +00:00
Files
kickc/src/test/ref/parse-negated-struct-ref.log

358 lines
9.7 KiB
Plaintext

Setting inferred volatile on symbol affected by address-of (struct A*) main::a ← &(struct A) aa
Created struct value member variable (byte) aa_b
Converted struct value to member variables (struct A) aa
Adding struct value member variable copy (byte) aa_b ← (byte) 1
Rewriting struct pointer member access *((struct A*) main::a).b
Warning! Adding boolean cast to non-boolean sub-expression *((byte*~) main::$2)
Identified constant variable (struct A*) main::a
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte) aa_b#0 ← (byte) 1
(struct A) aa#0 ← struct-unwound {(byte) aa_b#0}
to:@1
(void()) main()
main: scope:[main] from @1
(byte*~) main::$2 ← (byte*)(const struct A*) main::a + (const byte) OFFSET_STRUCT_A_B
(bool~) main::$3 ← (number) 0 != *((byte*~) main::$2)
(bool~) main::$0 ← ! (bool~) main::$3
(bool~) main::$1 ← ! (bool~) main::$0
if((bool~) main::$1) goto main::@1
to:main::@2
main::@1: scope:[main] from main main::@2
asm { jmp!a+ !a: }
to:main::@return
main::@2: scope:[main] from main
*((const byte*) main::SCREEN) ← (byte) 'a'
to:main::@1
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
(byte) A::b
(const byte) OFFSET_STRUCT_A_B = (byte) 0
(struct A) aa
(struct A) aa#0
(byte) aa_b
(byte) aa_b#0
(void()) main()
(bool~) main::$0
(bool~) main::$1
(byte*~) main::$2
(bool~) main::$3
(label) main::@1
(label) main::@2
(label) main::@return
(const byte*) main::SCREEN = (byte*)(number) $400
(const struct A*) main::a = &(struct A) aa
Adding number conversion cast (unumber) 0 in (bool~) main::$3 ← (number) 0 != *((byte*~) main::$2)
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [4] (bool~) main::$0 ← (byte) 0 == *((byte*~) main::$2) from [3] (bool~) main::$3 ← (byte) 0 != *((byte*~) main::$2)
Inversing boolean not [5] (bool~) main::$1 ← (byte) 0 != *((byte*~) main::$2) from [4] (bool~) main::$0 ← (byte) 0 == *((byte*~) main::$2)
Successful SSA optimization Pass2UnaryNotSimplification
Simple Condition (bool~) main::$1 [6] if((byte) 0!=*((byte*~) main::$2)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Rewriting struct address-of to first member &(struct A) aa
Successful SSA optimization PassNStructAddressOfRewriting
Constant right-side identified [2] (byte*~) main::$2 ← (byte*)(const struct A*) main::a + (const byte) OFFSET_STRUCT_A_B
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) main::$2 = (byte*)main::a+OFFSET_STRUCT_A_B
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero (byte*)main::a in
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (struct A) aa#0 and assignment [1] (struct A) aa#0 ← struct-unwound {(byte) aa_b#0}
Eliminating unused constant (const byte) OFFSET_STRUCT_A_B
Successful SSA optimization PassNEliminateUnusedVars
Constant inlined main::$2 = (byte*)(const struct A*) main::a
Successful SSA optimization Pass2ConstantInlining
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 @1
Adding NOP phi() at start of @end
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
[0] (byte) aa_b#0 ← (byte) 1
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] if((byte) 0!=*((byte*)(const struct A*) main::a)) goto main::@1
to:main::@2
main::@2: scope:[main] from main
[5] *((const byte*) main::SCREEN) ← (byte) 'a'
to:main::@1
main::@1: scope:[main] from main main::@2
asm { jmp!a+ !a: }
to:main::@return
main::@return: scope:[main] from main::@1
[7] return
to:@return
VARIABLE REGISTER WEIGHTS
(byte) A::b
(struct A) aa
(byte) aa_b
(byte) aa_b#0 20.0
(void()) main()
Initial phi equivalence classes
Complete equivalence classes
[ aa_b#0 ]
Allocated zp[1]:2 [ aa_b#0 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Test parsing a negated struct reference - which causes problems with the ASMREL labels !a++
// https://gitlab.com/camelot/kickc/issues/266
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.label aa_b = 2
// @begin
__bbegin:
// [0] (byte) aa_b#0 ← (byte) 1 -- vbuz1=vbuc1
lda #1
sta.z aa_b
// [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: {
.label SCREEN = $400
.label a = aa_b
// [4] if((byte) 0!=*((byte*)(const struct A*) main::a)) goto main::@1 -- vbuc1_neq__deref_pbuc2_then_la1
lda #0
cmp.z a
bne __b1
jmp __b2
// main::@2
__b2:
// [5] *((const byte*) main::SCREEN) ← (byte) 'a' -- _deref_pbuc1=vbuc2
lda #'a'
sta SCREEN
jmp __b1
// main::@1
__b1:
// asm { jmp!a+ !a: }
// ASMREL labels
jmp !a+
!a:
jmp __breturn
// main::@return
__breturn:
// [7] return
rts
}
// File Data
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] (byte) aa_b#0 ← (byte) 1 [ ] ( [ ] ) always clobbers reg byte a
Statement [4] if((byte) 0!=*((byte*)(const struct A*) main::a)) goto main::@1 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [5] *((const byte*) main::SCREEN) ← (byte) 'a' [ ] ( main:2 [ ] ) always clobbers reg byte a
Potential registers zp[1]:2 [ aa_b#0 ] : zp[1]:2 ,
REGISTER UPLIFT SCOPES
Uplift Scope [] 20: zp[1]:2 [ aa_b#0 ]
Uplift Scope [A]
Uplift Scope [main]
Uplifting [] best 48 combination zp[1]:2 [ aa_b#0 ]
Uplifting [A] best 48 combination
Uplifting [main] best 48 combination
Attempting to uplift remaining variables inzp[1]:2 [ aa_b#0 ]
Uplifting [] best 48 combination zp[1]:2 [ aa_b#0 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Test parsing a negated struct reference - which causes problems with the ASMREL labels !a++
// https://gitlab.com/camelot/kickc/issues/266
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.label aa_b = 2
// @begin
__bbegin:
// [0] (byte) aa_b#0 ← (byte) 1 -- vbuz1=vbuc1
lda #1
sta.z aa_b
// [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: {
.label SCREEN = $400
.label a = aa_b
// [4] if((byte) 0!=*((byte*)(const struct A*) main::a)) goto main::@1 -- vbuc1_neq__deref_pbuc2_then_la1
lda #0
cmp.z a
bne __b1
jmp __b2
// main::@2
__b2:
// [5] *((const byte*) main::SCREEN) ← (byte) 'a' -- _deref_pbuc1=vbuc2
lda #'a'
sta SCREEN
jmp __b1
// main::@1
__b1:
// asm { jmp!a+ !a: }
// ASMREL labels
jmp !a+
!a:
jmp __breturn
// main::@return
__breturn:
// [7] return
rts
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b2
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from___bbegin:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1:
Removing instruction __bend:
Removing instruction __b2:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Skipping double jump to !a+ in bne __b1
Succesful ASM optimization Pass5DoubleJumpElimination
Adding RTS to root block
Succesful ASM optimization Pass5AddMainRts
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte) A::b
(struct A) aa
(byte) aa_b
(byte) aa_b#0 aa_b zp[1]:2 20.0
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(const byte*) main::SCREEN = (byte*) 1024
(const struct A*) main::a = (struct A*)&(byte) aa_b#0
zp[1]:2 [ aa_b#0 ]
FINAL ASSEMBLER
Score: 39
// File Comments
// Test parsing a negated struct reference - which causes problems with the ASMREL labels !a++
// https://gitlab.com/camelot/kickc/issues/266
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.label aa_b = 2
// @begin
__bbegin:
// aa = { 1 }
// [0] (byte) aa_b#0 ← (byte) 1 -- vbuz1=vbuc1
lda #1
sta.z aa_b
// [1] phi from @begin to @1 [phi:@begin->@1]
// @1
// [2] call main
jsr main
rts
// [3] phi from @1 to @end [phi:@1->@end]
// @end
// main
main: {
.label SCREEN = $400
.label a = aa_b
// if(!a->b)
// [4] if((byte) 0!=*((byte*)(const struct A*) main::a)) goto main::@1 -- vbuc1_neq__deref_pbuc2_then_la1
lda #0
cmp.z a
bne !a+
// main::@2
// *SCREEN = 'a'
// [5] *((const byte*) main::SCREEN) ← (byte) 'a' -- _deref_pbuc1=vbuc2
lda #'a'
sta SCREEN
// main::@1
// asm
// asm { jmp!a+ !a: }
// ASMREL labels
jmp !a+
!a:
// main::@return
// }
// [7] return
rts
}
// File Data