mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-23 08:32:39 +00:00
Changed default to byte*
This commit is contained in:
parent
65419720c2
commit
df4294414a
@ -15,7 +15,7 @@ void main() {
|
||||
|
||||
byte* heap_head = 0xc000;
|
||||
|
||||
void* malloc() {
|
||||
byte* malloc() {
|
||||
heap_head++;
|
||||
return heap_head;
|
||||
}
|
||||
|
@ -5,27 +5,40 @@
|
||||
.label SCREEN = $400
|
||||
.label heap_head = 2
|
||||
main: {
|
||||
.label buf1 = 4
|
||||
.label buf2 = 6
|
||||
lda #<$c000
|
||||
sta heap_head
|
||||
lda #>$c000
|
||||
sta heap_head+1
|
||||
jsr malloc
|
||||
lda malloc.return_2
|
||||
sta malloc.return
|
||||
lda malloc.return_2+1
|
||||
sta malloc.return+1
|
||||
jsr malloc
|
||||
lda #'a'
|
||||
ldy #0
|
||||
sta (heap_head),y
|
||||
sta (buf1),y
|
||||
lda #'b'
|
||||
sta (heap_head),y
|
||||
lda (heap_head),y
|
||||
sta (buf2),y
|
||||
lda (buf1),y
|
||||
sta SCREEN
|
||||
lda (heap_head),y
|
||||
lda (buf2),y
|
||||
sta SCREEN+1
|
||||
rts
|
||||
}
|
||||
malloc: {
|
||||
.label return = 4
|
||||
.label return_1 = 6
|
||||
.label return_2 = 6
|
||||
inc heap_head
|
||||
bne !+
|
||||
inc heap_head+1
|
||||
!:
|
||||
lda heap_head
|
||||
sta return_2
|
||||
lda heap_head+1
|
||||
sta return_2+1
|
||||
rts
|
||||
}
|
||||
|
@ -10,24 +10,28 @@
|
||||
main: scope:[main] from @1
|
||||
[4] phi()
|
||||
[5] call malloc
|
||||
[6] (byte*) malloc::return#0 ← (byte*) malloc::return#2
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main
|
||||
[6] phi()
|
||||
[7] call malloc
|
||||
[7] (byte*) main::buf1#0 ← (byte*) malloc::return#0
|
||||
[8] call malloc
|
||||
[9] (byte*) malloc::return#1 ← (byte*) malloc::return#2
|
||||
to:main::@2
|
||||
main::@2: scope:[main] from main::@1
|
||||
[8] *((byte*)(void*)(byte*) heap_head#11) ← (byte) 'a'
|
||||
[9] *((byte*)(void*)(byte*) heap_head#11) ← (byte) 'b'
|
||||
[10] *((const byte*) SCREEN#0) ← *((byte*)(void*)(byte*) heap_head#11)
|
||||
[11] *((const byte*) SCREEN#0+(byte) 1) ← *((byte*)(void*)(byte*) heap_head#11)
|
||||
[10] (byte*) main::buf2#0 ← (byte*) malloc::return#1
|
||||
[11] *((byte*) main::buf1#0) ← (byte) 'a'
|
||||
[12] *((byte*) main::buf2#0) ← (byte) 'b'
|
||||
[13] *((const byte*) SCREEN#0) ← *((byte*) main::buf1#0)
|
||||
[14] *((const byte*) SCREEN#0+(byte) 1) ← *((byte*) main::buf2#0)
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@2
|
||||
[12] return
|
||||
to:@return
|
||||
malloc: scope:[malloc] from main main::@1
|
||||
[13] (byte*) heap_head#10 ← phi( main/(byte*) 49152 main::@1/(byte*) heap_head#11 )
|
||||
[14] (byte*) heap_head#11 ← ++ (byte*) heap_head#10
|
||||
to:malloc::@return
|
||||
malloc::@return: scope:[malloc] from malloc
|
||||
[15] return
|
||||
to:@return
|
||||
malloc: scope:[malloc] from main main::@1
|
||||
[16] (byte*) heap_head#10 ← phi( main/(byte*) 49152 main::@1/(byte*) heap_head#11 )
|
||||
[17] (byte*) heap_head#11 ← ++ (byte*) heap_head#10
|
||||
[18] (byte*) malloc::return#2 ← (byte*) heap_head#11
|
||||
to:malloc::@return
|
||||
malloc::@return: scope:[malloc] from malloc
|
||||
[19] return
|
||||
to:@return
|
||||
|
@ -1,8 +1,5 @@
|
||||
Adding pointer type conversion cast (byte*) SCREEN in (byte*) SCREEN ← (number) $400
|
||||
Adding pointer type conversion cast to void pointer (byte*) main::$0 in (byte*) main::buf1 ← (void*~) main::$0
|
||||
Adding pointer type conversion cast to void pointer (byte*) main::$1 in (byte*) main::buf2 ← (void*~) main::$1
|
||||
Adding pointer type conversion cast (byte*) heap_head in (byte*) heap_head ← (number) $c000
|
||||
Adding void pointer type conversion cast (void*) heap_head in (void*) malloc::return ← (byte*) heap_head
|
||||
Culled Empty Block (label) malloc::@1
|
||||
|
||||
CONTROL FLOW GRAPH SSA
|
||||
@ -12,24 +9,24 @@ CONTROL FLOW GRAPH SSA
|
||||
main: scope:[main] from @2
|
||||
(byte*) heap_head#13 ← phi( @2/(byte*) heap_head#14 )
|
||||
call malloc
|
||||
(void*) malloc::return#0 ← (void*) malloc::return#3
|
||||
(byte*) malloc::return#0 ← (byte*) malloc::return#3
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main
|
||||
(byte*) heap_head#7 ← phi( main/(byte*) heap_head#5 )
|
||||
(void*) malloc::return#4 ← phi( main/(void*) malloc::return#0 )
|
||||
(void*~) main::$0 ← (void*) malloc::return#4
|
||||
(byte*) malloc::return#4 ← phi( main/(byte*) malloc::return#0 )
|
||||
(byte*~) main::$0 ← (byte*) malloc::return#4
|
||||
(byte*) heap_head#0 ← (byte*) heap_head#7
|
||||
(byte*) main::buf1#0 ← ((byte*)) (void*~) main::$0
|
||||
(byte*) main::buf1#0 ← (byte*~) main::$0
|
||||
call malloc
|
||||
(void*) malloc::return#1 ← (void*) malloc::return#3
|
||||
(byte*) malloc::return#1 ← (byte*) malloc::return#3
|
||||
to:main::@2
|
||||
main::@2: scope:[main] from main::@1
|
||||
(byte*) main::buf1#1 ← phi( main::@1/(byte*) main::buf1#0 )
|
||||
(byte*) heap_head#8 ← phi( main::@1/(byte*) heap_head#5 )
|
||||
(void*) malloc::return#5 ← phi( main::@1/(void*) malloc::return#1 )
|
||||
(void*~) main::$1 ← (void*) malloc::return#5
|
||||
(byte*) malloc::return#5 ← phi( main::@1/(byte*) malloc::return#1 )
|
||||
(byte*~) main::$1 ← (byte*) malloc::return#5
|
||||
(byte*) heap_head#1 ← (byte*) heap_head#8
|
||||
(byte*) main::buf2#0 ← ((byte*)) (void*~) main::$1
|
||||
(byte*) main::buf2#0 ← (byte*~) main::$1
|
||||
*((byte*) main::buf1#1) ← (byte) 'a'
|
||||
*((byte*) main::buf2#0) ← (byte) 'b'
|
||||
*((byte*) SCREEN#0 + (number) 0) ← *((byte*) main::buf1#1)
|
||||
@ -46,12 +43,12 @@ main::@return: scope:[main] from main::@2
|
||||
malloc: scope:[malloc] from main main::@1
|
||||
(byte*) heap_head#10 ← phi( main/(byte*) heap_head#13 main::@1/(byte*) heap_head#0 )
|
||||
(byte*) heap_head#4 ← ++ (byte*) heap_head#10
|
||||
(void*) malloc::return#2 ← ((void*)) (byte*) heap_head#4
|
||||
(byte*) malloc::return#2 ← (byte*) heap_head#4
|
||||
to:malloc::@return
|
||||
malloc::@return: scope:[malloc] from malloc
|
||||
(byte*) heap_head#11 ← phi( malloc/(byte*) heap_head#4 )
|
||||
(void*) malloc::return#6 ← phi( malloc/(void*) malloc::return#2 )
|
||||
(void*) malloc::return#3 ← (void*) malloc::return#6
|
||||
(byte*) malloc::return#6 ← phi( malloc/(byte*) malloc::return#2 )
|
||||
(byte*) malloc::return#3 ← (byte*) malloc::return#6
|
||||
(byte*) heap_head#5 ← (byte*) heap_head#11
|
||||
return
|
||||
to:@return
|
||||
@ -90,8 +87,8 @@ SYMBOL TABLE SSA
|
||||
(byte*) heap_head#8
|
||||
(byte*) heap_head#9
|
||||
(void()) main()
|
||||
(void*~) main::$0
|
||||
(void*~) main::$1
|
||||
(byte*~) main::$0
|
||||
(byte*~) main::$1
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@return
|
||||
@ -100,25 +97,22 @@ SYMBOL TABLE SSA
|
||||
(byte*) main::buf1#1
|
||||
(byte*) main::buf2
|
||||
(byte*) main::buf2#0
|
||||
(void*()) malloc()
|
||||
(byte*()) malloc()
|
||||
(label) malloc::@return
|
||||
(void*) malloc::return
|
||||
(void*) malloc::return#0
|
||||
(void*) malloc::return#1
|
||||
(void*) malloc::return#2
|
||||
(void*) malloc::return#3
|
||||
(void*) malloc::return#4
|
||||
(void*) malloc::return#5
|
||||
(void*) malloc::return#6
|
||||
(byte*) malloc::return
|
||||
(byte*) malloc::return#0
|
||||
(byte*) malloc::return#1
|
||||
(byte*) malloc::return#2
|
||||
(byte*) malloc::return#3
|
||||
(byte*) malloc::return#4
|
||||
(byte*) malloc::return#5
|
||||
(byte*) malloc::return#6
|
||||
|
||||
Adding number conversion cast (unumber) 0 in *((byte*) SCREEN#0 + (number) 0) ← *((byte*) main::buf1#1)
|
||||
Adding number conversion cast (unumber) 1 in *((byte*) SCREEN#0 + (number) 1) ← *((byte*) main::buf2#0)
|
||||
Successful SSA optimization PassNAddNumberTypeConversions
|
||||
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
|
||||
Inlining cast (byte*) main::buf1#0 ← (byte*)(void*~) main::$0
|
||||
Inlining cast (byte*) main::buf2#0 ← (byte*)(void*~) main::$1
|
||||
Inlining cast (byte*) heap_head#3 ← (byte*)(number) $c000
|
||||
Inlining cast (void*) malloc::return#2 ← (void*)(byte*) heap_head#4
|
||||
Successful SSA optimization Pass2InlineCast
|
||||
Simplifying constant pointer cast (byte*) 1024
|
||||
Simplifying constant integer cast 0
|
||||
@ -128,12 +122,13 @@ Successful SSA optimization PassNCastSimplification
|
||||
Finalized unsigned number type (byte) 0
|
||||
Finalized unsigned number type (byte) 1
|
||||
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
||||
Alias (void*) malloc::return#0 = (void*) malloc::return#4
|
||||
Alias (byte*) malloc::return#0 = (byte*) malloc::return#4
|
||||
Alias (byte*) heap_head#0 = (byte*) heap_head#7
|
||||
Alias (void*) malloc::return#1 = (void*) malloc::return#5
|
||||
Alias (byte*) main::buf1#0 = (byte*) main::buf1#1
|
||||
Alias (byte*) main::buf1#0 = (byte*~) main::$0 (byte*) main::buf1#1
|
||||
Alias (byte*) malloc::return#1 = (byte*) malloc::return#5
|
||||
Alias (byte*) heap_head#1 = (byte*) heap_head#8 (byte*) heap_head#9 (byte*) heap_head#2
|
||||
Alias (void*) malloc::return#2 = (void*) malloc::return#6 (void*) malloc::return#3
|
||||
Alias (byte*) main::buf2#0 = (byte*~) main::$1
|
||||
Alias (byte*) malloc::return#2 = (byte*) malloc::return#6 (byte*) malloc::return#3
|
||||
Alias (byte*) heap_head#11 = (byte*) heap_head#4 (byte*) heap_head#5
|
||||
Alias (byte*) heap_head#14 = (byte*) heap_head#3
|
||||
Alias (byte*) heap_head#12 = (byte*) heap_head#6
|
||||
@ -148,17 +143,6 @@ Constant (const byte*) heap_head#14 = (byte*) 49152
|
||||
Successful SSA optimization Pass2ConstantIdentification
|
||||
Simplifying expression containing zero SCREEN#0 in [16] *((const byte*) SCREEN#0 + (byte) 0) ← *((byte*) main::buf1#0)
|
||||
Successful SSA optimization PassNSimplifyExpressionWithZero
|
||||
Inlining Noop Cast [3] (byte*) main::buf1#0 ← (byte*)(void*~) main::$0 keeping main::buf1#0
|
||||
Inlining Noop Cast [7] (byte*) main::buf2#0 ← (byte*)(void*~) main::$1 keeping main::buf2#0
|
||||
Successful SSA optimization Pass2NopCastInlining
|
||||
Inlining Noop Cast [15] (void*) malloc::return#2 ← (void*)(byte*) heap_head#11 keeping heap_head#11
|
||||
Successful SSA optimization Pass2NopCastInlining
|
||||
Inlining Noop Cast [1] (void*) malloc::return#0 ← (void*)(byte*) heap_head#11 keeping heap_head#11
|
||||
Inlining Noop Cast [5] (void*) malloc::return#1 ← (void*)(byte*) heap_head#11 keeping heap_head#11
|
||||
Successful SSA optimization Pass2NopCastInlining
|
||||
Inlining Noop Cast [2] (void*) main::buf1#0 ← (void*)(byte*) heap_head#11 keeping heap_head#11
|
||||
Inlining Noop Cast [6] (void*) main::buf2#0 ← (void*)(byte*) heap_head#11 keeping heap_head#11
|
||||
Successful SSA optimization Pass2NopCastInlining
|
||||
Inlining constant with var siblings (const byte*) heap_head#14
|
||||
Constant inlined heap_head#14 = (byte*) 49152
|
||||
Successful SSA optimization Pass2ConstantInlining
|
||||
@ -172,10 +156,10 @@ Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
CALL GRAPH
|
||||
Calls in [] to main:3
|
||||
Calls in [main] to malloc:7 malloc:9
|
||||
Calls in [main] to malloc:7 malloc:11
|
||||
|
||||
Created 1 initial phi equivalence classes
|
||||
Coalesced [8] heap_head#15 ← heap_head#11
|
||||
Coalesced [10] heap_head#15 ← heap_head#11
|
||||
Coalesced down to 1 phi equivalence classes
|
||||
Culled Empty Block (label) @1
|
||||
Culled Empty Block (label) @3
|
||||
@ -184,7 +168,6 @@ Adding NOP phi() at start of @begin
|
||||
Adding NOP phi() at start of @1
|
||||
Adding NOP phi() at start of @end
|
||||
Adding NOP phi() at start of main
|
||||
Adding NOP phi() at start of main::@1
|
||||
|
||||
FINAL CONTROL FLOW GRAPH
|
||||
@begin: scope:[] from
|
||||
@ -199,26 +182,30 @@ FINAL CONTROL FLOW GRAPH
|
||||
main: scope:[main] from @1
|
||||
[4] phi()
|
||||
[5] call malloc
|
||||
[6] (byte*) malloc::return#0 ← (byte*) malloc::return#2
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main
|
||||
[6] phi()
|
||||
[7] call malloc
|
||||
[7] (byte*) main::buf1#0 ← (byte*) malloc::return#0
|
||||
[8] call malloc
|
||||
[9] (byte*) malloc::return#1 ← (byte*) malloc::return#2
|
||||
to:main::@2
|
||||
main::@2: scope:[main] from main::@1
|
||||
[8] *((byte*)(void*)(byte*) heap_head#11) ← (byte) 'a'
|
||||
[9] *((byte*)(void*)(byte*) heap_head#11) ← (byte) 'b'
|
||||
[10] *((const byte*) SCREEN#0) ← *((byte*)(void*)(byte*) heap_head#11)
|
||||
[11] *((const byte*) SCREEN#0+(byte) 1) ← *((byte*)(void*)(byte*) heap_head#11)
|
||||
[10] (byte*) main::buf2#0 ← (byte*) malloc::return#1
|
||||
[11] *((byte*) main::buf1#0) ← (byte) 'a'
|
||||
[12] *((byte*) main::buf2#0) ← (byte) 'b'
|
||||
[13] *((const byte*) SCREEN#0) ← *((byte*) main::buf1#0)
|
||||
[14] *((const byte*) SCREEN#0+(byte) 1) ← *((byte*) main::buf2#0)
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@2
|
||||
[12] return
|
||||
[15] return
|
||||
to:@return
|
||||
malloc: scope:[malloc] from main main::@1
|
||||
[13] (byte*) heap_head#10 ← phi( main/(byte*) 49152 main::@1/(byte*) heap_head#11 )
|
||||
[14] (byte*) heap_head#11 ← ++ (byte*) heap_head#10
|
||||
[16] (byte*) heap_head#10 ← phi( main/(byte*) 49152 main::@1/(byte*) heap_head#11 )
|
||||
[17] (byte*) heap_head#11 ← ++ (byte*) heap_head#10
|
||||
[18] (byte*) malloc::return#2 ← (byte*) heap_head#11
|
||||
to:malloc::@return
|
||||
malloc::@return: scope:[malloc] from malloc
|
||||
[15] return
|
||||
[19] return
|
||||
to:@return
|
||||
|
||||
|
||||
@ -226,18 +213,38 @@ VARIABLE REGISTER WEIGHTS
|
||||
(byte*) SCREEN
|
||||
(byte*) heap_head
|
||||
(byte*) heap_head#10 4.0
|
||||
(byte*) heap_head#11 0.5
|
||||
(byte*) heap_head#11 1.0
|
||||
(void()) main()
|
||||
(byte*) main::buf1
|
||||
(byte*) main::buf1#0 1.0
|
||||
(byte*) main::buf2
|
||||
(void*()) malloc()
|
||||
(void*) malloc::return
|
||||
(byte*) main::buf2#0 1.5
|
||||
(byte*()) malloc()
|
||||
(byte*) malloc::return
|
||||
(byte*) malloc::return#0 4.0
|
||||
(byte*) malloc::return#1 4.0
|
||||
(byte*) malloc::return#2 1.5
|
||||
|
||||
Initial phi equivalence classes
|
||||
[ heap_head#10 heap_head#11 ]
|
||||
Added variable malloc::return#0 to zero page equivalence class [ malloc::return#0 ]
|
||||
Added variable main::buf1#0 to zero page equivalence class [ main::buf1#0 ]
|
||||
Added variable malloc::return#1 to zero page equivalence class [ malloc::return#1 ]
|
||||
Added variable main::buf2#0 to zero page equivalence class [ main::buf2#0 ]
|
||||
Added variable malloc::return#2 to zero page equivalence class [ malloc::return#2 ]
|
||||
Complete equivalence classes
|
||||
[ heap_head#10 heap_head#11 ]
|
||||
[ malloc::return#0 ]
|
||||
[ main::buf1#0 ]
|
||||
[ malloc::return#1 ]
|
||||
[ main::buf2#0 ]
|
||||
[ malloc::return#2 ]
|
||||
Allocated zp ZP_WORD:2 [ heap_head#10 heap_head#11 ]
|
||||
Allocated zp ZP_WORD:4 [ malloc::return#0 ]
|
||||
Allocated zp ZP_WORD:6 [ main::buf1#0 ]
|
||||
Allocated zp ZP_WORD:8 [ malloc::return#1 ]
|
||||
Allocated zp ZP_WORD:10 [ main::buf2#0 ]
|
||||
Allocated zp ZP_WORD:12 [ malloc::return#2 ]
|
||||
|
||||
INITIAL ASM
|
||||
//SEG0 File Comments
|
||||
@ -267,80 +274,122 @@ bend_from_b1:
|
||||
bend:
|
||||
//SEG10 main
|
||||
main: {
|
||||
.label buf1 = 6
|
||||
.label buf2 = $a
|
||||
//SEG11 [5] call malloc
|
||||
//SEG12 [13] phi from main to malloc [phi:main->malloc]
|
||||
//SEG12 [16] phi from main to malloc [phi:main->malloc]
|
||||
malloc_from_main:
|
||||
//SEG13 [13] phi (byte*) heap_head#10 = (byte*) 49152 [phi:main->malloc#0] -- pbuz1=pbuc1
|
||||
//SEG13 [16] phi (byte*) heap_head#10 = (byte*) 49152 [phi:main->malloc#0] -- pbuz1=pbuc1
|
||||
lda #<$c000
|
||||
sta heap_head
|
||||
lda #>$c000
|
||||
sta heap_head+1
|
||||
jsr malloc
|
||||
//SEG14 [6] phi from main to main::@1 [phi:main->main::@1]
|
||||
b1_from_main:
|
||||
//SEG14 [6] (byte*) malloc::return#0 ← (byte*) malloc::return#2 -- pbuz1=pbuz2
|
||||
lda malloc.return_2
|
||||
sta malloc.return
|
||||
lda malloc.return_2+1
|
||||
sta malloc.return+1
|
||||
jmp b1
|
||||
//SEG15 main::@1
|
||||
b1:
|
||||
//SEG16 [7] call malloc
|
||||
//SEG17 [13] phi from main::@1 to malloc [phi:main::@1->malloc]
|
||||
//SEG16 [7] (byte*) main::buf1#0 ← (byte*) malloc::return#0 -- pbuz1=pbuz2
|
||||
lda malloc.return
|
||||
sta buf1
|
||||
lda malloc.return+1
|
||||
sta buf1+1
|
||||
//SEG17 [8] call malloc
|
||||
//SEG18 [16] phi from main::@1 to malloc [phi:main::@1->malloc]
|
||||
malloc_from_b1:
|
||||
//SEG18 [13] phi (byte*) heap_head#10 = (byte*) heap_head#11 [phi:main::@1->malloc#0] -- register_copy
|
||||
//SEG19 [16] phi (byte*) heap_head#10 = (byte*) heap_head#11 [phi:main::@1->malloc#0] -- register_copy
|
||||
jsr malloc
|
||||
//SEG20 [9] (byte*) malloc::return#1 ← (byte*) malloc::return#2 -- pbuz1=pbuz2
|
||||
lda malloc.return_2
|
||||
sta malloc.return_1
|
||||
lda malloc.return_2+1
|
||||
sta malloc.return_1+1
|
||||
jmp b2
|
||||
//SEG19 main::@2
|
||||
//SEG21 main::@2
|
||||
b2:
|
||||
//SEG20 [8] *((byte*)(void*)(byte*) heap_head#11) ← (byte) 'a' -- _deref_pbuz1=vbuc1
|
||||
//SEG22 [10] (byte*) main::buf2#0 ← (byte*) malloc::return#1 -- pbuz1=pbuz2
|
||||
lda malloc.return_1
|
||||
sta buf2
|
||||
lda malloc.return_1+1
|
||||
sta buf2+1
|
||||
//SEG23 [11] *((byte*) main::buf1#0) ← (byte) 'a' -- _deref_pbuz1=vbuc1
|
||||
lda #'a'
|
||||
ldy #0
|
||||
sta (heap_head),y
|
||||
//SEG21 [9] *((byte*)(void*)(byte*) heap_head#11) ← (byte) 'b' -- _deref_pbuz1=vbuc1
|
||||
sta (buf1),y
|
||||
//SEG24 [12] *((byte*) main::buf2#0) ← (byte) 'b' -- _deref_pbuz1=vbuc1
|
||||
lda #'b'
|
||||
ldy #0
|
||||
sta (heap_head),y
|
||||
//SEG22 [10] *((const byte*) SCREEN#0) ← *((byte*)(void*)(byte*) heap_head#11) -- _deref_pbuc1=_deref_pbuz1
|
||||
sta (buf2),y
|
||||
//SEG25 [13] *((const byte*) SCREEN#0) ← *((byte*) main::buf1#0) -- _deref_pbuc1=_deref_pbuz1
|
||||
ldy #0
|
||||
lda (heap_head),y
|
||||
lda (buf1),y
|
||||
sta SCREEN
|
||||
//SEG23 [11] *((const byte*) SCREEN#0+(byte) 1) ← *((byte*)(void*)(byte*) heap_head#11) -- _deref_pbuc1=_deref_pbuz1
|
||||
//SEG26 [14] *((const byte*) SCREEN#0+(byte) 1) ← *((byte*) main::buf2#0) -- _deref_pbuc1=_deref_pbuz1
|
||||
ldy #0
|
||||
lda (heap_head),y
|
||||
lda (buf2),y
|
||||
sta SCREEN+1
|
||||
jmp breturn
|
||||
//SEG24 main::@return
|
||||
//SEG27 main::@return
|
||||
breturn:
|
||||
//SEG25 [12] return
|
||||
//SEG28 [15] return
|
||||
rts
|
||||
}
|
||||
//SEG26 malloc
|
||||
//SEG29 malloc
|
||||
malloc: {
|
||||
//SEG27 [14] (byte*) heap_head#11 ← ++ (byte*) heap_head#10 -- pbuz1=_inc_pbuz1
|
||||
.label return = 4
|
||||
.label return_1 = 8
|
||||
.label return_2 = $c
|
||||
//SEG30 [17] (byte*) heap_head#11 ← ++ (byte*) heap_head#10 -- pbuz1=_inc_pbuz1
|
||||
inc heap_head
|
||||
bne !+
|
||||
inc heap_head+1
|
||||
!:
|
||||
//SEG31 [18] (byte*) malloc::return#2 ← (byte*) heap_head#11 -- pbuz1=pbuz2
|
||||
lda heap_head
|
||||
sta return_2
|
||||
lda heap_head+1
|
||||
sta return_2+1
|
||||
jmp breturn
|
||||
//SEG28 malloc::@return
|
||||
//SEG32 malloc::@return
|
||||
breturn:
|
||||
//SEG29 [15] return
|
||||
//SEG33 [19] return
|
||||
rts
|
||||
}
|
||||
//SEG30 File Data
|
||||
//SEG34 File Data
|
||||
|
||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
||||
Statement [8] *((byte*)(void*)(byte*) heap_head#11) ← (byte) 'a' [ heap_head#11 ] ( main:2 [ heap_head#11 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [9] *((byte*)(void*)(byte*) heap_head#11) ← (byte) 'b' [ heap_head#11 ] ( main:2 [ heap_head#11 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [10] *((const byte*) SCREEN#0) ← *((byte*)(void*)(byte*) heap_head#11) [ heap_head#11 ] ( main:2 [ heap_head#11 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [11] *((const byte*) SCREEN#0+(byte) 1) ← *((byte*)(void*)(byte*) heap_head#11) [ ] ( main:2 [ ] ) always clobbers reg byte a reg byte y
|
||||
Statement [6] (byte*) malloc::return#0 ← (byte*) malloc::return#2 [ malloc::return#0 heap_head#11 ] ( main:2 [ malloc::return#0 heap_head#11 ] ) always clobbers reg byte a
|
||||
Statement [7] (byte*) main::buf1#0 ← (byte*) malloc::return#0 [ main::buf1#0 heap_head#11 ] ( main:2 [ main::buf1#0 heap_head#11 ] ) always clobbers reg byte a
|
||||
Statement [9] (byte*) malloc::return#1 ← (byte*) malloc::return#2 [ main::buf1#0 malloc::return#1 ] ( main:2 [ main::buf1#0 malloc::return#1 ] ) always clobbers reg byte a
|
||||
Statement [10] (byte*) main::buf2#0 ← (byte*) malloc::return#1 [ main::buf1#0 main::buf2#0 ] ( main:2 [ main::buf1#0 main::buf2#0 ] ) always clobbers reg byte a
|
||||
Statement [11] *((byte*) main::buf1#0) ← (byte) 'a' [ main::buf1#0 main::buf2#0 ] ( main:2 [ main::buf1#0 main::buf2#0 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [12] *((byte*) main::buf2#0) ← (byte) 'b' [ main::buf1#0 main::buf2#0 ] ( main:2 [ main::buf1#0 main::buf2#0 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [13] *((const byte*) SCREEN#0) ← *((byte*) main::buf1#0) [ main::buf2#0 ] ( main:2 [ main::buf2#0 ] ) always clobbers reg byte a reg byte y
|
||||
Statement [14] *((const byte*) SCREEN#0+(byte) 1) ← *((byte*) main::buf2#0) [ ] ( main:2 [ ] ) always clobbers reg byte a reg byte y
|
||||
Statement [18] (byte*) malloc::return#2 ← (byte*) heap_head#11 [ malloc::return#2 heap_head#11 ] ( main:2::malloc:5 [ malloc::return#2 heap_head#11 ] main:2::malloc:8 [ main::buf1#0 malloc::return#2 heap_head#11 ] ) always clobbers reg byte a
|
||||
Potential registers zp ZP_WORD:2 [ heap_head#10 heap_head#11 ] : zp ZP_WORD:2 ,
|
||||
Potential registers zp ZP_WORD:4 [ malloc::return#0 ] : zp ZP_WORD:4 ,
|
||||
Potential registers zp ZP_WORD:6 [ main::buf1#0 ] : zp ZP_WORD:6 ,
|
||||
Potential registers zp ZP_WORD:8 [ malloc::return#1 ] : zp ZP_WORD:8 ,
|
||||
Potential registers zp ZP_WORD:10 [ main::buf2#0 ] : zp ZP_WORD:10 ,
|
||||
Potential registers zp ZP_WORD:12 [ malloc::return#2 ] : zp ZP_WORD:12 ,
|
||||
|
||||
REGISTER UPLIFT SCOPES
|
||||
Uplift Scope [] 4.5: zp ZP_WORD:2 [ heap_head#10 heap_head#11 ]
|
||||
Uplift Scope [main]
|
||||
Uplift Scope [malloc]
|
||||
Uplift Scope [malloc] 4: zp ZP_WORD:4 [ malloc::return#0 ] 4: zp ZP_WORD:8 [ malloc::return#1 ] 1.5: zp ZP_WORD:12 [ malloc::return#2 ]
|
||||
Uplift Scope [] 5: zp ZP_WORD:2 [ heap_head#10 heap_head#11 ]
|
||||
Uplift Scope [main] 1.5: zp ZP_WORD:10 [ main::buf2#0 ] 1: zp ZP_WORD:6 [ main::buf1#0 ]
|
||||
|
||||
Uplifting [] best 112 combination zp ZP_WORD:2 [ heap_head#10 heap_head#11 ]
|
||||
Uplifting [main] best 112 combination
|
||||
Uplifting [malloc] best 112 combination
|
||||
Uplifting [malloc] best 172 combination zp ZP_WORD:4 [ malloc::return#0 ] zp ZP_WORD:8 [ malloc::return#1 ] zp ZP_WORD:12 [ malloc::return#2 ]
|
||||
Uplifting [] best 172 combination zp ZP_WORD:2 [ heap_head#10 heap_head#11 ]
|
||||
Uplifting [main] best 172 combination zp ZP_WORD:10 [ main::buf2#0 ] zp ZP_WORD:6 [ main::buf1#0 ]
|
||||
Coalescing zero page register with common assignment [ zp ZP_WORD:4 [ malloc::return#0 ] ] with [ zp ZP_WORD:6 [ main::buf1#0 ] ] - score: 1
|
||||
Coalescing zero page register with common assignment [ zp ZP_WORD:8 [ malloc::return#1 ] ] with [ zp ZP_WORD:10 [ main::buf2#0 ] ] - score: 1
|
||||
Coalescing zero page register with common assignment [ zp ZP_WORD:8 [ malloc::return#1 main::buf2#0 ] ] with [ zp ZP_WORD:12 [ malloc::return#2 ] ] - score: 1
|
||||
Allocated (was zp ZP_WORD:8) zp ZP_WORD:6 [ malloc::return#1 main::buf2#0 malloc::return#2 ]
|
||||
|
||||
ASSEMBLER BEFORE OPTIMIZATION
|
||||
//SEG0 File Comments
|
||||
@ -370,64 +419,80 @@ bend_from_b1:
|
||||
bend:
|
||||
//SEG10 main
|
||||
main: {
|
||||
.label buf1 = 4
|
||||
.label buf2 = 6
|
||||
//SEG11 [5] call malloc
|
||||
//SEG12 [13] phi from main to malloc [phi:main->malloc]
|
||||
//SEG12 [16] phi from main to malloc [phi:main->malloc]
|
||||
malloc_from_main:
|
||||
//SEG13 [13] phi (byte*) heap_head#10 = (byte*) 49152 [phi:main->malloc#0] -- pbuz1=pbuc1
|
||||
//SEG13 [16] phi (byte*) heap_head#10 = (byte*) 49152 [phi:main->malloc#0] -- pbuz1=pbuc1
|
||||
lda #<$c000
|
||||
sta heap_head
|
||||
lda #>$c000
|
||||
sta heap_head+1
|
||||
jsr malloc
|
||||
//SEG14 [6] phi from main to main::@1 [phi:main->main::@1]
|
||||
b1_from_main:
|
||||
//SEG14 [6] (byte*) malloc::return#0 ← (byte*) malloc::return#2 -- pbuz1=pbuz2
|
||||
lda malloc.return_2
|
||||
sta malloc.return
|
||||
lda malloc.return_2+1
|
||||
sta malloc.return+1
|
||||
jmp b1
|
||||
//SEG15 main::@1
|
||||
b1:
|
||||
//SEG16 [7] call malloc
|
||||
//SEG17 [13] phi from main::@1 to malloc [phi:main::@1->malloc]
|
||||
//SEG16 [7] (byte*) main::buf1#0 ← (byte*) malloc::return#0
|
||||
//SEG17 [8] call malloc
|
||||
//SEG18 [16] phi from main::@1 to malloc [phi:main::@1->malloc]
|
||||
malloc_from_b1:
|
||||
//SEG18 [13] phi (byte*) heap_head#10 = (byte*) heap_head#11 [phi:main::@1->malloc#0] -- register_copy
|
||||
//SEG19 [16] phi (byte*) heap_head#10 = (byte*) heap_head#11 [phi:main::@1->malloc#0] -- register_copy
|
||||
jsr malloc
|
||||
//SEG20 [9] (byte*) malloc::return#1 ← (byte*) malloc::return#2
|
||||
jmp b2
|
||||
//SEG19 main::@2
|
||||
//SEG21 main::@2
|
||||
b2:
|
||||
//SEG20 [8] *((byte*)(void*)(byte*) heap_head#11) ← (byte) 'a' -- _deref_pbuz1=vbuc1
|
||||
//SEG22 [10] (byte*) main::buf2#0 ← (byte*) malloc::return#1
|
||||
//SEG23 [11] *((byte*) main::buf1#0) ← (byte) 'a' -- _deref_pbuz1=vbuc1
|
||||
lda #'a'
|
||||
ldy #0
|
||||
sta (heap_head),y
|
||||
//SEG21 [9] *((byte*)(void*)(byte*) heap_head#11) ← (byte) 'b' -- _deref_pbuz1=vbuc1
|
||||
sta (buf1),y
|
||||
//SEG24 [12] *((byte*) main::buf2#0) ← (byte) 'b' -- _deref_pbuz1=vbuc1
|
||||
lda #'b'
|
||||
ldy #0
|
||||
sta (heap_head),y
|
||||
//SEG22 [10] *((const byte*) SCREEN#0) ← *((byte*)(void*)(byte*) heap_head#11) -- _deref_pbuc1=_deref_pbuz1
|
||||
sta (buf2),y
|
||||
//SEG25 [13] *((const byte*) SCREEN#0) ← *((byte*) main::buf1#0) -- _deref_pbuc1=_deref_pbuz1
|
||||
ldy #0
|
||||
lda (heap_head),y
|
||||
lda (buf1),y
|
||||
sta SCREEN
|
||||
//SEG23 [11] *((const byte*) SCREEN#0+(byte) 1) ← *((byte*)(void*)(byte*) heap_head#11) -- _deref_pbuc1=_deref_pbuz1
|
||||
//SEG26 [14] *((const byte*) SCREEN#0+(byte) 1) ← *((byte*) main::buf2#0) -- _deref_pbuc1=_deref_pbuz1
|
||||
ldy #0
|
||||
lda (heap_head),y
|
||||
lda (buf2),y
|
||||
sta SCREEN+1
|
||||
jmp breturn
|
||||
//SEG24 main::@return
|
||||
//SEG27 main::@return
|
||||
breturn:
|
||||
//SEG25 [12] return
|
||||
//SEG28 [15] return
|
||||
rts
|
||||
}
|
||||
//SEG26 malloc
|
||||
//SEG29 malloc
|
||||
malloc: {
|
||||
//SEG27 [14] (byte*) heap_head#11 ← ++ (byte*) heap_head#10 -- pbuz1=_inc_pbuz1
|
||||
.label return = 4
|
||||
.label return_1 = 6
|
||||
.label return_2 = 6
|
||||
//SEG30 [17] (byte*) heap_head#11 ← ++ (byte*) heap_head#10 -- pbuz1=_inc_pbuz1
|
||||
inc heap_head
|
||||
bne !+
|
||||
inc heap_head+1
|
||||
!:
|
||||
//SEG31 [18] (byte*) malloc::return#2 ← (byte*) heap_head#11 -- pbuz1=pbuz2
|
||||
lda heap_head
|
||||
sta return_2
|
||||
lda heap_head+1
|
||||
sta return_2+1
|
||||
jmp breturn
|
||||
//SEG28 malloc::@return
|
||||
//SEG32 malloc::@return
|
||||
breturn:
|
||||
//SEG29 [15] return
|
||||
//SEG33 [19] return
|
||||
rts
|
||||
}
|
||||
//SEG30 File Data
|
||||
//SEG34 File Data
|
||||
|
||||
ASSEMBLER OPTIMIZATIONS
|
||||
Removing instruction jmp b1
|
||||
@ -445,7 +510,6 @@ Removing instruction b1_from_bbegin:
|
||||
Removing instruction b1:
|
||||
Removing instruction main_from_b1:
|
||||
Removing instruction bend_from_b1:
|
||||
Removing instruction b1_from_main:
|
||||
Removing instruction malloc_from_b1:
|
||||
Succesful ASM optimization Pass5RedundantLabelElimination
|
||||
Removing instruction bend:
|
||||
@ -469,22 +533,29 @@ FINAL SYMBOL TABLE
|
||||
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
||||
(byte*) heap_head
|
||||
(byte*) heap_head#10 heap_head zp ZP_WORD:2 4.0
|
||||
(byte*) heap_head#11 heap_head zp ZP_WORD:2 0.5
|
||||
(byte*) heap_head#11 heap_head zp ZP_WORD:2 1.0
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@return
|
||||
(byte*) main::buf1
|
||||
(byte*) main::buf1#0 buf1 zp ZP_WORD:4 1.0
|
||||
(byte*) main::buf2
|
||||
(void*()) malloc()
|
||||
(byte*) main::buf2#0 buf2 zp ZP_WORD:6 1.5
|
||||
(byte*()) malloc()
|
||||
(label) malloc::@return
|
||||
(void*) malloc::return
|
||||
(byte*) malloc::return
|
||||
(byte*) malloc::return#0 return zp ZP_WORD:4 4.0
|
||||
(byte*) malloc::return#1 return#1 zp ZP_WORD:6 4.0
|
||||
(byte*) malloc::return#2 return#2 zp ZP_WORD:6 1.5
|
||||
|
||||
zp ZP_WORD:2 [ heap_head#10 heap_head#11 ]
|
||||
zp ZP_WORD:4 [ malloc::return#0 main::buf1#0 ]
|
||||
zp ZP_WORD:6 [ malloc::return#1 main::buf2#0 malloc::return#2 ]
|
||||
|
||||
|
||||
FINAL ASSEMBLER
|
||||
Score: 82
|
||||
Score: 106
|
||||
|
||||
//SEG0 File Comments
|
||||
// Test void pointer - issues when assigning returns from malloc()
|
||||
@ -504,48 +575,65 @@ Score: 82
|
||||
//SEG9 @end
|
||||
//SEG10 main
|
||||
main: {
|
||||
.label buf1 = 4
|
||||
.label buf2 = 6
|
||||
//SEG11 [5] call malloc
|
||||
//SEG12 [13] phi from main to malloc [phi:main->malloc]
|
||||
//SEG13 [13] phi (byte*) heap_head#10 = (byte*) 49152 [phi:main->malloc#0] -- pbuz1=pbuc1
|
||||
//SEG12 [16] phi from main to malloc [phi:main->malloc]
|
||||
//SEG13 [16] phi (byte*) heap_head#10 = (byte*) 49152 [phi:main->malloc#0] -- pbuz1=pbuc1
|
||||
lda #<$c000
|
||||
sta heap_head
|
||||
lda #>$c000
|
||||
sta heap_head+1
|
||||
jsr malloc
|
||||
//SEG14 [6] phi from main to main::@1 [phi:main->main::@1]
|
||||
//SEG14 [6] (byte*) malloc::return#0 ← (byte*) malloc::return#2 -- pbuz1=pbuz2
|
||||
lda malloc.return_2
|
||||
sta malloc.return
|
||||
lda malloc.return_2+1
|
||||
sta malloc.return+1
|
||||
//SEG15 main::@1
|
||||
//SEG16 [7] call malloc
|
||||
//SEG17 [13] phi from main::@1 to malloc [phi:main::@1->malloc]
|
||||
//SEG18 [13] phi (byte*) heap_head#10 = (byte*) heap_head#11 [phi:main::@1->malloc#0] -- register_copy
|
||||
//SEG16 [7] (byte*) main::buf1#0 ← (byte*) malloc::return#0
|
||||
//SEG17 [8] call malloc
|
||||
//SEG18 [16] phi from main::@1 to malloc [phi:main::@1->malloc]
|
||||
//SEG19 [16] phi (byte*) heap_head#10 = (byte*) heap_head#11 [phi:main::@1->malloc#0] -- register_copy
|
||||
jsr malloc
|
||||
//SEG19 main::@2
|
||||
//SEG20 [8] *((byte*)(void*)(byte*) heap_head#11) ← (byte) 'a' -- _deref_pbuz1=vbuc1
|
||||
//SEG20 [9] (byte*) malloc::return#1 ← (byte*) malloc::return#2
|
||||
//SEG21 main::@2
|
||||
//SEG22 [10] (byte*) main::buf2#0 ← (byte*) malloc::return#1
|
||||
//SEG23 [11] *((byte*) main::buf1#0) ← (byte) 'a' -- _deref_pbuz1=vbuc1
|
||||
lda #'a'
|
||||
ldy #0
|
||||
sta (heap_head),y
|
||||
//SEG21 [9] *((byte*)(void*)(byte*) heap_head#11) ← (byte) 'b' -- _deref_pbuz1=vbuc1
|
||||
sta (buf1),y
|
||||
//SEG24 [12] *((byte*) main::buf2#0) ← (byte) 'b' -- _deref_pbuz1=vbuc1
|
||||
lda #'b'
|
||||
sta (heap_head),y
|
||||
//SEG22 [10] *((const byte*) SCREEN#0) ← *((byte*)(void*)(byte*) heap_head#11) -- _deref_pbuc1=_deref_pbuz1
|
||||
lda (heap_head),y
|
||||
sta (buf2),y
|
||||
//SEG25 [13] *((const byte*) SCREEN#0) ← *((byte*) main::buf1#0) -- _deref_pbuc1=_deref_pbuz1
|
||||
lda (buf1),y
|
||||
sta SCREEN
|
||||
//SEG23 [11] *((const byte*) SCREEN#0+(byte) 1) ← *((byte*)(void*)(byte*) heap_head#11) -- _deref_pbuc1=_deref_pbuz1
|
||||
lda (heap_head),y
|
||||
//SEG26 [14] *((const byte*) SCREEN#0+(byte) 1) ← *((byte*) main::buf2#0) -- _deref_pbuc1=_deref_pbuz1
|
||||
lda (buf2),y
|
||||
sta SCREEN+1
|
||||
//SEG24 main::@return
|
||||
//SEG25 [12] return
|
||||
//SEG27 main::@return
|
||||
//SEG28 [15] return
|
||||
rts
|
||||
}
|
||||
//SEG26 malloc
|
||||
//SEG29 malloc
|
||||
malloc: {
|
||||
//SEG27 [14] (byte*) heap_head#11 ← ++ (byte*) heap_head#10 -- pbuz1=_inc_pbuz1
|
||||
.label return = 4
|
||||
.label return_1 = 6
|
||||
.label return_2 = 6
|
||||
//SEG30 [17] (byte*) heap_head#11 ← ++ (byte*) heap_head#10 -- pbuz1=_inc_pbuz1
|
||||
inc heap_head
|
||||
bne !+
|
||||
inc heap_head+1
|
||||
!:
|
||||
//SEG28 malloc::@return
|
||||
//SEG29 [15] return
|
||||
//SEG31 [18] (byte*) malloc::return#2 ← (byte*) heap_head#11 -- pbuz1=pbuz2
|
||||
lda heap_head
|
||||
sta return_2
|
||||
lda heap_head+1
|
||||
sta return_2+1
|
||||
//SEG32 malloc::@return
|
||||
//SEG33 [19] return
|
||||
rts
|
||||
}
|
||||
//SEG30 File Data
|
||||
//SEG34 File Data
|
||||
|
||||
|
@ -5,15 +5,22 @@
|
||||
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
|
||||
(byte*) heap_head
|
||||
(byte*) heap_head#10 heap_head zp ZP_WORD:2 4.0
|
||||
(byte*) heap_head#11 heap_head zp ZP_WORD:2 0.5
|
||||
(byte*) heap_head#11 heap_head zp ZP_WORD:2 1.0
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@return
|
||||
(byte*) main::buf1
|
||||
(byte*) main::buf1#0 buf1 zp ZP_WORD:4 1.0
|
||||
(byte*) main::buf2
|
||||
(void*()) malloc()
|
||||
(byte*) main::buf2#0 buf2 zp ZP_WORD:6 1.5
|
||||
(byte*()) malloc()
|
||||
(label) malloc::@return
|
||||
(void*) malloc::return
|
||||
(byte*) malloc::return
|
||||
(byte*) malloc::return#0 return zp ZP_WORD:4 4.0
|
||||
(byte*) malloc::return#1 return#1 zp ZP_WORD:6 4.0
|
||||
(byte*) malloc::return#2 return#2 zp ZP_WORD:6 1.5
|
||||
|
||||
zp ZP_WORD:2 [ heap_head#10 heap_head#11 ]
|
||||
zp ZP_WORD:4 [ malloc::return#0 main::buf1#0 ]
|
||||
zp ZP_WORD:6 [ malloc::return#1 main::buf2#0 malloc::return#2 ]
|
||||
|
Loading…
Reference in New Issue
Block a user