1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-27 19:50:10 +00:00

Changed syntax slightly

This commit is contained in:
jespergravgaard 2019-08-10 08:21:58 +02:00
parent e53159699b
commit 5755616588
5 changed files with 137 additions and 150 deletions

View File

@ -6,11 +6,10 @@
void main() {
char i=0;
// Call functions one at a time
// Call SYSCALL functions one at a time
while(true) {
unsigned int fn = CALLS[i*2];
void()* f = (void()*)fn;
(*f)();
void()* fsyscall = FSYSCALLS[i*2];
(*fsyscall)();
if(++i==2) i=0;
}
}
@ -35,4 +34,4 @@ char[] SYSCALLS = {
JMP, <&fn2, >&fn2, NOP
};
const unsigned int* CALLS = (unsigned int*)(SYSCALLS+1);
const void()** FSYSCALLS = (void()**)(SYSCALLS+1);

View File

@ -10,32 +10,32 @@
.segmentdef Zeropage [min=$bf00, max=$bfff, fill]
.const JMP = $4c
.const NOP = $ea
.label CALLS = SYSCALLS+1
.label FSYSCALLS = SYSCALLS+1
.segment Code
main: {
.label fn = 3
.label fsyscall = 3
.label i = 2
b1:
lda #0
sta.z i
// Call functions one at a time
// Call SYSCALL functions one at a time
b2:
lda.z i
asl
asl
tay
lda CALLS,y
sta.z fn
lda CALLS+1,y
sta.z fn+1
jsr bi_fn
lda FSYSCALLS,y
sta.z fsyscall
lda FSYSCALLS+1,y
sta.z fsyscall+1
jsr bi_fsyscall
inc.z i
lda #2
cmp.z i
bne b2
jmp b1
bi_fn:
jmp (fn)
bi_fsyscall:
jmp (fsyscall)
}
fn2: {
.label BGCOL = $d021

View File

@ -15,9 +15,9 @@ main::@1: scope:[main] from main main::@2 main::@3
to:main::@2
main::@2: scope:[main] from main::@1
[6] (byte~) main::$0 ← (byte) main::i#3 << (byte) 1
[7] (byte~) main::$5 ← (byte~) main::$0 << (byte) 1
[8] (word) main::fn#0 ← *((const word*) CALLS#0 + (byte~) main::$5)
[9] call *((void()*)(word) main::fn#0)
[7] (byte~) main::$4 ← (byte~) main::$0 << (byte) 1
[8] (void()*) main::fsyscall#0 ← *((const void()**) FSYSCALLS#0 + (byte~) main::$4)
[9] call *((void()*) main::fsyscall#0)
[10] (byte) main::i#1 ← ++ (byte) main::i#3
[11] if((byte) main::i#1!=(byte) 2) goto main::@3
to:main::@1

View File

@ -1,6 +1,6 @@
Loading link script "xmega65.ld"
Resolved forward reference CALLS to (word*) CALLS
Fixing pointer array-indexing *((word*) CALLS + (number~) main::$0)
Resolved forward reference FSYSCALLS to (void()**) FSYSCALLS
Fixing pointer array-indexing *((void()**) FSYSCALLS + (number~) main::$0)
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@6
@ -22,15 +22,13 @@ main::@1: scope:[main] from main main::@2 main::@7
main::@2: scope:[main] from main::@1
(byte) main::i#3 ← phi( main::@1/(byte) main::i#4 )
(number~) main::$0 ← (byte) main::i#3 * (number) 2
(number~) main::$5 ← (number~) main::$0 * (const byte) SIZEOF_WORD
(word) main::fn#0 ← *((word*) CALLS#0 + (number~) main::$5)
(void()*~) main::$1 ← ((void()*)) (word) main::fn#0
(void()*) main::f#0 ← (void()*~) main::$1
call *((void()*) main::f#0)
(number~) main::$4 ← (number~) main::$0 * (const byte) SIZEOF_POINTER
(void()*) main::fsyscall#0 ← *((void()**) FSYSCALLS#0 + (number~) main::$4)
call *((void()*) main::fsyscall#0)
(byte) main::i#1 ← ++ (byte) main::i#3
(bool~) main::$3 ← (byte) main::i#1 == (number) 2
(bool~) main::$4 ← ! (bool~) main::$3
if((bool~) main::$4) goto main::@1
(bool~) main::$2 ← (byte) main::i#1 == (number) 2
(bool~) main::$3 ← ! (bool~) main::$2
if((bool~) main::$3) goto main::@1
to:main::@7
main::@7: scope:[main] from main::@2
(byte) main::i#2 ← (number) 0
@ -65,8 +63,8 @@ fn2::@return: scope:[fn2] from fn2
(byte~) $7 ← > (void()*~) $6
(byte[]) SYSCALLS#0 ← { (byte) JMP#0, (byte~) $1, (byte~) $3, (byte) NOP#0, (byte) JMP#0, (byte~) $5, (byte~) $7, (byte) NOP#0 }
(byte*~) $8 ← (byte[]) SYSCALLS#0 + (number) 1
(word*~) $9 ← ((word*)) (byte*~) $8
(word*) CALLS#0 ← (word*~) $9
(void()**~) $9 ← ((void()**)) (byte*~) $8
(void()**) FSYSCALLS#0 ← (void()**~) $9
call main
to:@4
@4: scope:[] from @3
@ -83,18 +81,18 @@ SYMBOL TABLE SSA
(void()*~) $6
(byte~) $7
(byte*~) $8
(word*~) $9
(void()**~) $9
(label) @3
(label) @4
(label) @begin
(label) @end
(word*) CALLS
(word*) CALLS#0
(void()**) FSYSCALLS
(void()**) FSYSCALLS#0
(byte) JMP
(byte) JMP#0
(byte) NOP
(byte) NOP#0
(const byte) SIZEOF_WORD = (byte) 2
(const byte) SIZEOF_POINTER = (byte) 2
(byte[]) SYSCALLS
(byte[]) SYSCALLS#0
(void()) fn1()
@ -107,18 +105,15 @@ SYMBOL TABLE SSA
(byte*) fn2::BGCOL#0
(void()) main()
(number~) main::$0
(void()*~) main::$1
(bool~) main::$2
(bool~) main::$3
(bool~) main::$4
(number~) main::$5
(number~) main::$4
(label) main::@1
(label) main::@2
(label) main::@7
(label) main::@return
(void()*) main::f
(void()*) main::f#0
(word) main::fn
(word) main::fn#0
(void()*) main::fsyscall
(void()*) main::fsyscall#0
(byte) main::i
(byte) main::i#0
(byte) main::i#1
@ -129,21 +124,20 @@ SYMBOL TABLE SSA
Adding number conversion cast (unumber) 0 in (byte) main::i#0 ← (number) 0
Adding number conversion cast (unumber) 2 in (number~) main::$0 ← (byte) main::i#3 * (number) 2
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (byte) main::i#3 * (unumber)(number) 2
Adding number conversion cast (unumber) main::$5 in (number~) main::$5 ← (unumber~) main::$0 * (const byte) SIZEOF_WORD
Adding number conversion cast (unumber) 2 in (bool~) main::$3 ← (byte) main::i#1 == (number) 2
Adding number conversion cast (unumber) main::$4 in (number~) main::$4 ← (unumber~) main::$0 * (const byte) SIZEOF_POINTER
Adding number conversion cast (unumber) 2 in (bool~) main::$2 ← (byte) main::i#1 == (number) 2
Adding number conversion cast (unumber) 0 in (byte) main::i#2 ← (number) 0
Adding number conversion cast (unumber) $4c in (byte) JMP#0 ← (number) $4c
Adding number conversion cast (unumber) $ea in (byte) NOP#0 ← (number) $ea
Adding number conversion cast (unumber) 1 in (byte*~) $8 ← (byte[]) SYSCALLS#0 + (number) 1
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) main::i#0 ← (unumber)(number) 0
Inlining cast (void()*~) main::$1 ← (void()*)(word) main::fn#0
Inlining cast (byte) main::i#2 ← (unumber)(number) 0
Inlining cast (byte*) fn1::BORDERCOL#0 ← (byte*)(number) $d020
Inlining cast (byte*) fn2::BGCOL#0 ← (byte*)(number) $d021
Inlining cast (byte) JMP#0 ← (unumber)(number) $4c
Inlining cast (byte) NOP#0 ← (unumber)(number) $ea
Inlining cast (word*~) $9 ← (word*)(byte*~) $8
Inlining cast (void()**~) $9 ← (void()**)(byte*~) $8
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast 0
Simplifying constant integer cast 2
@ -164,20 +158,19 @@ Finalized unsigned number type (byte) $ea
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$0 ← (byte) main::i#3 * (byte) 2
Inferred type updated to byte in (unumber~) main::$5 ← (byte~) main::$0 * (const byte) SIZEOF_WORD
Inversing boolean not [12] (bool~) main::$4 ← (byte) main::i#1 != (byte) 2 from [11] (bool~) main::$3 ← (byte) main::i#1 == (byte) 2
Inferred type updated to byte in (unumber~) main::$4 ← (byte~) main::$0 * (const byte) SIZEOF_POINTER
Inversing boolean not [10] (bool~) main::$3 ← (byte) main::i#1 != (byte) 2 from [9] (bool~) main::$2 ← (byte) main::i#1 == (byte) 2
Successful SSA optimization Pass2UnaryNotSimplification
Alias (byte) main::i#3 = (byte) main::i#4
Alias (void()*) main::f#0 = (void()*~) main::$1
Alias (word*) CALLS#0 = (word*~) $9
Alias (void()**) FSYSCALLS#0 = (void()**~) $9
Successful SSA optimization Pass2AliasElimination
Identified duplicate assignment right side [26] (void()*~) $2 ← & (void()) fn1()
Identified duplicate assignment right side [30] (void()*~) $6 ← & (void()) fn2()
Identified duplicate assignment right side [24] (void()*~) $2 ← & (void()) fn1()
Identified duplicate assignment right side [28] (void()*~) $6 ← & (void()) fn2()
Successful SSA optimization Pass2DuplicateRValueIdentification
Simple Condition (bool~) main::$4 [13] if((byte) main::i#1!=(byte) 2) goto main::@1
Simple Condition (bool~) main::$3 [11] if((byte) main::i#1!=(byte) 2) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant right-side identified [24] (void()*~) $0 ← & (void()) fn1()
Constant right-side identified [28] (void()*~) $4 ← & (void()) fn2()
Constant right-side identified [22] (void()*~) $0 ← & (void()) fn1()
Constant right-side identified [26] (void()*~) $4 ← & (void()) fn2()
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::i#0 = 0
Constant (const byte) main::i#2 = 0
@ -195,10 +188,10 @@ if() condition always true - replacing block destination [2] if(true) goto main:
Successful SSA optimization Pass2ConstantIfs
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Constant right-side identified [12] (byte~) $1 ← < (const void()*) $0
Constant right-side identified [13] (byte~) $3 ← > (const void()*) $2
Constant right-side identified [14] (byte~) $5 ← < (const void()*) $4
Constant right-side identified [15] (byte~) $7 ← > (const void()*) $6
Constant right-side identified [11] (byte~) $1 ← < (const void()*) $0
Constant right-side identified [12] (byte~) $3 ← > (const void()*) $2
Constant right-side identified [13] (byte~) $5 ← < (const void()*) $4
Constant right-side identified [14] (byte~) $7 ← > (const void()*) $6
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) $1 = <$0
Constant (const byte) $3 = >$2
@ -209,18 +202,16 @@ Identified constant from value list (byte[]) { (const byte) JMP#0, (const byte)
Successful SSA optimization Pass2ConstantInitializerValueLists
Constant (const byte[]) SYSCALLS#0 = { JMP#0, $1, $3, NOP#0, JMP#0, $5, $7, NOP#0 }
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [12] (byte*~) $8 ← (const byte[]) SYSCALLS#0 + (byte) 1
Constant right-side identified [11] (byte*~) $8 ← (const byte[]) SYSCALLS#0 + (byte) 1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) $8 = SYSCALLS#0+1
Successful SSA optimization Pass2ConstantIdentification
Constant value identified (word*)$8 in [13] (word*) CALLS#0 ← (word*)(const byte*) $8
Constant value identified (void()**)$8 in [12] (void()**) FSYSCALLS#0 ← (void()**)(const byte*) $8
Successful SSA optimization Pass2ConstantValues
Constant (const word*) CALLS#0 = (word*)$8
Constant (const void()**) FSYSCALLS#0 = (void()**)$8
Successful SSA optimization Pass2ConstantIdentification
Inlining Noop Cast [4] (void()*) main::f#0 ← (void()*)(word) main::fn#0 keeping main::fn#0
Successful SSA optimization Pass2NopCastInlining
Rewriting multiplication to use shift [1] (byte~) main::$0 ← (byte) main::i#3 * (byte) 2
Rewriting multiplication to use shift [2] (byte~) main::$5 ← (byte~) main::$0 * (const byte) SIZEOF_WORD
Rewriting multiplication to use shift [2] (byte~) main::$4 ← (byte~) main::$0 * (const byte) SIZEOF_POINTER
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings (const byte) main::i#0
Inlining constant with var siblings (const byte) main::i#2
@ -236,7 +227,7 @@ Constant inlined $1 = <&(void()) fn1()
Constant inlined $2 = &(void()) fn1()
Constant inlined $3 = >&(void()) fn1()
Successful SSA optimization Pass2ConstantInlining
Eliminating unused constant (const byte) SIZEOF_WORD
Eliminating unused constant (const byte) SIZEOF_POINTER
Successful SSA optimization PassNEliminateUnusedVars
Added new block during phi lifting main::@9(between main::@2 and main::@1)
Adding NOP phi() at start of @begin
@ -279,9 +270,9 @@ main::@1: scope:[main] from main main::@2 main::@3
to:main::@2
main::@2: scope:[main] from main::@1
[6] (byte~) main::$0 ← (byte) main::i#3 << (byte) 1
[7] (byte~) main::$5 ← (byte~) main::$0 << (byte) 1
[8] (word) main::fn#0 ← *((const word*) CALLS#0 + (byte~) main::$5)
[9] call *((void()*)(word) main::fn#0)
[7] (byte~) main::$4 ← (byte~) main::$0 << (byte) 1
[8] (void()*) main::fsyscall#0 ← *((const void()**) FSYSCALLS#0 + (byte~) main::$4)
[9] call *((void()*) main::fsyscall#0)
[10] (byte) main::i#1 ← ++ (byte) main::i#3
[11] if((byte) main::i#1!=(byte) 2) goto main::@3
to:main::@1
@ -303,7 +294,7 @@ fn1::@return: scope:[fn1] from fn1
VARIABLE REGISTER WEIGHTS
(word*) CALLS
(void()**) FSYSCALLS
(byte) JMP
(byte) NOP
(byte[]) SYSCALLS
@ -313,10 +304,9 @@ VARIABLE REGISTER WEIGHTS
(byte*) fn2::BGCOL
(void()) main()
(byte~) main::$0 202.0
(byte~) main::$5 202.0
(void()*) main::f
(word) main::fn
(word) main::fn#0 101.0
(byte~) main::$4 202.0
(void()*) main::fsyscall
(void()*) main::fsyscall#0 101.0
(byte) main::i
(byte) main::i#1 71.0
(byte) main::i#3 42.599999999999994
@ -324,17 +314,17 @@ VARIABLE REGISTER WEIGHTS
Initial phi equivalence classes
[ main::i#3 main::i#1 ]
Added variable main::$0 to zero page equivalence class [ main::$0 ]
Added variable main::$5 to zero page equivalence class [ main::$5 ]
Added variable main::fn#0 to zero page equivalence class [ main::fn#0 ]
Added variable main::$4 to zero page equivalence class [ main::$4 ]
Added variable main::fsyscall#0 to zero page equivalence class [ main::fsyscall#0 ]
Complete equivalence classes
[ main::i#3 main::i#1 ]
[ main::$0 ]
[ main::$5 ]
[ main::fn#0 ]
[ main::$4 ]
[ main::fsyscall#0 ]
Allocated zp ZP_BYTE:2 [ main::i#3 main::i#1 ]
Allocated zp ZP_BYTE:3 [ main::$0 ]
Allocated zp ZP_BYTE:4 [ main::$5 ]
Allocated zp ZP_WORD:5 [ main::fn#0 ]
Allocated zp ZP_BYTE:4 [ main::$4 ]
Allocated zp ZP_WORD:5 [ main::fsyscall#0 ]
INITIAL ASM
Target platform is custom
@ -353,7 +343,7 @@ Target platform is custom
// Global Constants & labels
.const JMP = $4c
.const NOP = $ea
.label CALLS = SYSCALLS+1
.label FSYSCALLS = SYSCALLS+1
// @begin
bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
@ -374,8 +364,8 @@ bend:
// main
main: {
.label _0 = 3
.label _5 = 4
.label fn = 5
.label _4 = 4
.label fsyscall = 5
.label i = 2
// [5] phi from main main::@2 to main::@1 [phi:main/main::@2->main::@1]
b1_from_main:
@ -384,7 +374,7 @@ main: {
lda #0
sta.z i
jmp b1
// Call functions one at a time
// Call SYSCALL functions one at a time
// main::@1
b1:
jmp b2
@ -394,18 +384,18 @@ main: {
lda.z i
asl
sta.z _0
// [7] (byte~) main::$5 ← (byte~) main::$0 << (byte) 1 -- vbuz1=vbuz2_rol_1
// [7] (byte~) main::$4 ← (byte~) main::$0 << (byte) 1 -- vbuz1=vbuz2_rol_1
lda.z _0
asl
sta.z _5
// [8] (word) main::fn#0 ← *((const word*) CALLS#0 + (byte~) main::$5) -- vwuz1=pwuc1_derefidx_vbuz2
ldy.z _5
lda CALLS,y
sta.z fn
lda CALLS+1,y
sta.z fn+1
// [9] call *((void()*)(word) main::fn#0)
jsr bi_fn
sta.z _4
// [8] (void()*) main::fsyscall#0 ← *((const void()**) FSYSCALLS#0 + (byte~) main::$4) -- pprz1=pptc1_derefidx_vbuz2
ldy.z _4
lda FSYSCALLS,y
sta.z fsyscall
lda FSYSCALLS+1,y
sta.z fsyscall+1
// [9] call *((void()*) main::fsyscall#0)
jsr bi_fsyscall
// [10] (byte) main::i#1 ← ++ (byte) main::i#3 -- vbuz1=_inc_vbuz1
inc.z i
// [11] if((byte) main::i#1!=(byte) 2) goto main::@3 -- vbuz1_neq_vbuc1_then_la1
@ -422,8 +412,8 @@ main: {
b1_from_b3:
// [5] phi (byte) main::i#3 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy
jmp b1
bi_fn:
jmp (fn)
bi_fsyscall:
jmp (fsyscall)
}
// fn2
fn2: {
@ -454,35 +444,35 @@ fn1: {
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] (byte~) main::$0 ← (byte) main::i#3 << (byte) 1 [ main::i#3 main::$0 ] ( main:2 [ main::i#3 main::$0 ] ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#3 main::i#1 ]
Statement [7] (byte~) main::$5 ← (byte~) main::$0 << (byte) 1 [ main::i#3 main::$5 ] ( main:2 [ main::i#3 main::$5 ] ) always clobbers reg byte a
Statement [8] (word) main::fn#0 ← *((const word*) CALLS#0 + (byte~) main::$5) [ main::i#3 main::fn#0 ] ( main:2 [ main::i#3 main::fn#0 ] ) always clobbers reg byte a
Statement [9] call *((void()*)(word) main::fn#0) [ main::i#3 ] ( main:2 [ main::i#3 ] ) always clobbers reg byte a reg byte x reg byte y
Statement [7] (byte~) main::$4 ← (byte~) main::$0 << (byte) 1 [ main::i#3 main::$4 ] ( main:2 [ main::i#3 main::$4 ] ) always clobbers reg byte a
Statement [8] (void()*) main::fsyscall#0 ← *((const void()**) FSYSCALLS#0 + (byte~) main::$4) [ main::i#3 main::fsyscall#0 ] ( main:2 [ main::i#3 main::fsyscall#0 ] ) always clobbers reg byte a
Statement [9] call *((void()*) main::fsyscall#0) [ main::i#3 ] ( main:2 [ main::i#3 ] ) always clobbers reg byte a reg byte x reg byte y
Removing always clobbered register reg byte x as potential for zp ZP_BYTE:2 [ main::i#3 main::i#1 ]
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:2 [ main::i#3 main::i#1 ]
Statement [11] if((byte) main::i#1!=(byte) 2) goto main::@3 [ main::i#1 ] ( main:2 [ main::i#1 ] ) always clobbers reg byte a
Statement [6] (byte~) main::$0 ← (byte) main::i#3 << (byte) 1 [ main::i#3 main::$0 ] ( main:2 [ main::i#3 main::$0 ] ) always clobbers reg byte a
Statement [7] (byte~) main::$5 ← (byte~) main::$0 << (byte) 1 [ main::i#3 main::$5 ] ( main:2 [ main::i#3 main::$5 ] ) always clobbers reg byte a
Statement [8] (word) main::fn#0 ← *((const word*) CALLS#0 + (byte~) main::$5) [ main::i#3 main::fn#0 ] ( main:2 [ main::i#3 main::fn#0 ] ) always clobbers reg byte a
Statement [9] call *((void()*)(word) main::fn#0) [ main::i#3 ] ( main:2 [ main::i#3 ] ) always clobbers reg byte a reg byte x reg byte y
Statement [7] (byte~) main::$4 ← (byte~) main::$0 << (byte) 1 [ main::i#3 main::$4 ] ( main:2 [ main::i#3 main::$4 ] ) always clobbers reg byte a
Statement [8] (void()*) main::fsyscall#0 ← *((const void()**) FSYSCALLS#0 + (byte~) main::$4) [ main::i#3 main::fsyscall#0 ] ( main:2 [ main::i#3 main::fsyscall#0 ] ) always clobbers reg byte a
Statement [9] call *((void()*) main::fsyscall#0) [ main::i#3 ] ( main:2 [ main::i#3 ] ) always clobbers reg byte a reg byte x reg byte y
Statement [11] if((byte) main::i#1!=(byte) 2) goto main::@3 [ main::i#1 ] ( main:2 [ main::i#1 ] ) always clobbers reg byte a
Potential registers zp ZP_BYTE:2 [ main::i#3 main::i#1 ] : zp ZP_BYTE:2 ,
Potential registers zp ZP_BYTE:3 [ main::$0 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_BYTE:4 [ main::$5 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_WORD:5 [ main::fn#0 ] : zp ZP_WORD:5 ,
Potential registers zp ZP_BYTE:4 [ main::$4 ] : zp ZP_BYTE:4 , reg byte a , reg byte x , reg byte y ,
Potential registers zp ZP_WORD:5 [ main::fsyscall#0 ] : zp ZP_WORD:5 ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 202: zp ZP_BYTE:3 [ main::$0 ] 202: zp ZP_BYTE:4 [ main::$5 ] 113.6: zp ZP_BYTE:2 [ main::i#3 main::i#1 ] 101: zp ZP_WORD:5 [ main::fn#0 ]
Uplift Scope [main] 202: zp ZP_BYTE:3 [ main::$0 ] 202: zp ZP_BYTE:4 [ main::$4 ] 113.6: zp ZP_BYTE:2 [ main::i#3 main::i#1 ] 101: zp ZP_WORD:5 [ main::fsyscall#0 ]
Uplift Scope [fn1]
Uplift Scope [fn2]
Uplift Scope []
Uplifting [main] best 6252 combination reg byte a [ main::$0 ] reg byte a [ main::$5 ] zp ZP_BYTE:2 [ main::i#3 main::i#1 ] zp ZP_WORD:5 [ main::fn#0 ]
Uplifting [main] best 6252 combination reg byte a [ main::$0 ] reg byte a [ main::$4 ] zp ZP_BYTE:2 [ main::i#3 main::i#1 ] zp ZP_WORD:5 [ main::fsyscall#0 ]
Uplifting [fn1] best 6252 combination
Uplifting [fn2] best 6252 combination
Uplifting [] best 6252 combination
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::i#3 main::i#1 ]
Uplifting [main] best 6252 combination zp ZP_BYTE:2 [ main::i#3 main::i#1 ]
Allocated (was zp ZP_WORD:5) zp ZP_WORD:3 [ main::fn#0 ]
Allocated (was zp ZP_WORD:5) zp ZP_WORD:3 [ main::fsyscall#0 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -500,7 +490,7 @@ ASSEMBLER BEFORE OPTIMIZATION
// Global Constants & labels
.const JMP = $4c
.const NOP = $ea
.label CALLS = SYSCALLS+1
.label FSYSCALLS = SYSCALLS+1
// @begin
bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
@ -520,7 +510,7 @@ bend:
.segment Code
// main
main: {
.label fn = 3
.label fsyscall = 3
.label i = 2
// [5] phi from main main::@2 to main::@1 [phi:main/main::@2->main::@1]
b1_from_main:
@ -529,7 +519,7 @@ main: {
lda #0
sta.z i
jmp b1
// Call functions one at a time
// Call SYSCALL functions one at a time
// main::@1
b1:
jmp b2
@ -538,16 +528,16 @@ main: {
// [6] (byte~) main::$0 ← (byte) main::i#3 << (byte) 1 -- vbuaa=vbuz1_rol_1
lda.z i
asl
// [7] (byte~) main::$5 ← (byte~) main::$0 << (byte) 1 -- vbuaa=vbuaa_rol_1
// [7] (byte~) main::$4 ← (byte~) main::$0 << (byte) 1 -- vbuaa=vbuaa_rol_1
asl
// [8] (word) main::fn#0 ← *((const word*) CALLS#0 + (byte~) main::$5) -- vwuz1=pwuc1_derefidx_vbuaa
// [8] (void()*) main::fsyscall#0 ← *((const void()**) FSYSCALLS#0 + (byte~) main::$4) -- pprz1=pptc1_derefidx_vbuaa
tay
lda CALLS,y
sta.z fn
lda CALLS+1,y
sta.z fn+1
// [9] call *((void()*)(word) main::fn#0)
jsr bi_fn
lda FSYSCALLS,y
sta.z fsyscall
lda FSYSCALLS+1,y
sta.z fsyscall+1
// [9] call *((void()*) main::fsyscall#0)
jsr bi_fsyscall
// [10] (byte) main::i#1 ← ++ (byte) main::i#3 -- vbuz1=_inc_vbuz1
inc.z i
// [11] if((byte) main::i#1!=(byte) 2) goto main::@3 -- vbuz1_neq_vbuc1_then_la1
@ -564,8 +554,8 @@ main: {
b1_from_b3:
// [5] phi (byte) main::i#3 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy
jmp b1
bi_fn:
jmp (fn)
bi_fsyscall:
jmp (fsyscall)
}
// fn2
fn2: {
@ -633,8 +623,8 @@ FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(word*) CALLS
(const word*) CALLS#0 CALLS = (word*)(const byte[]) SYSCALLS#0+(byte) 1
(void()**) FSYSCALLS
(const void()**) FSYSCALLS#0 FSYSCALLS = (void()**)(const byte[]) SYSCALLS#0+(byte) 1
(byte) JMP
(const byte) JMP#0 JMP = (byte) $4c
(byte) NOP
@ -651,21 +641,20 @@ FINAL SYMBOL TABLE
(const byte*) fn2::BGCOL#0 BGCOL = (byte*) 53281
(void()) main()
(byte~) main::$0 reg byte a 202.0
(byte~) main::$5 reg byte a 202.0
(byte~) main::$4 reg byte a 202.0
(label) main::@1
(label) main::@2
(label) main::@3
(void()*) main::f
(word) main::fn
(word) main::fn#0 fn zp ZP_WORD:3 101.0
(void()*) main::fsyscall
(void()*) main::fsyscall#0 fsyscall zp ZP_WORD:3 101.0
(byte) main::i
(byte) main::i#1 i zp ZP_BYTE:2 71.0
(byte) main::i#3 i zp ZP_BYTE:2 42.599999999999994
zp ZP_BYTE:2 [ main::i#3 main::i#1 ]
reg byte a [ main::$0 ]
reg byte a [ main::$5 ]
zp ZP_WORD:3 [ main::fn#0 ]
reg byte a [ main::$4 ]
zp ZP_WORD:3 [ main::fsyscall#0 ]
FINAL ASSEMBLER
@ -686,7 +675,7 @@ Score: 5574
// Global Constants & labels
.const JMP = $4c
.const NOP = $ea
.label CALLS = SYSCALLS+1
.label FSYSCALLS = SYSCALLS+1
// @begin
// [1] phi from @begin to @1 [phi:@begin->@1]
// @1
@ -697,14 +686,14 @@ Score: 5574
.segment Code
// main
main: {
.label fn = 3
.label fsyscall = 3
.label i = 2
// [5] phi from main main::@2 to main::@1 [phi:main/main::@2->main::@1]
b1:
// [5] phi (byte) main::i#3 = (byte) 0 [phi:main/main::@2->main::@1#0] -- vbuz1=vbuc1
lda #0
sta.z i
// Call functions one at a time
// Call SYSCALL functions one at a time
// main::@1
// main::@2
b2:
@ -712,18 +701,18 @@ main: {
// [6] (byte~) main::$0 ← (byte) main::i#3 << (byte) 1 -- vbuaa=vbuz1_rol_1
lda.z i
asl
// fn = CALLS[i*2]
// [7] (byte~) main::$5 ← (byte~) main::$0 << (byte) 1 -- vbuaa=vbuaa_rol_1
// fsyscall = FSYSCALLS[i*2]
// [7] (byte~) main::$4 ← (byte~) main::$0 << (byte) 1 -- vbuaa=vbuaa_rol_1
asl
// [8] (word) main::fn#0 ← *((const word*) CALLS#0 + (byte~) main::$5) -- vwuz1=pwuc1_derefidx_vbuaa
// [8] (void()*) main::fsyscall#0 ← *((const void()**) FSYSCALLS#0 + (byte~) main::$4) -- pprz1=pptc1_derefidx_vbuaa
tay
lda CALLS,y
sta.z fn
lda CALLS+1,y
sta.z fn+1
// (*f)()
// [9] call *((void()*)(word) main::fn#0)
jsr bi_fn
lda FSYSCALLS,y
sta.z fsyscall
lda FSYSCALLS+1,y
sta.z fsyscall+1
// (*fsyscall)()
// [9] call *((void()*) main::fsyscall#0)
jsr bi_fsyscall
// if(++i==2)
// [10] (byte) main::i#1 ← ++ (byte) main::i#3 -- vbuz1=_inc_vbuz1
inc.z i
@ -736,8 +725,8 @@ main: {
// main::@3
// [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
// [5] phi (byte) main::i#3 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy
bi_fn:
jmp (fn)
bi_fsyscall:
jmp (fsyscall)
}
// fn2
fn2: {

View File

@ -1,8 +1,8 @@
(label) @1
(label) @begin
(label) @end
(word*) CALLS
(const word*) CALLS#0 CALLS = (word*)(const byte[]) SYSCALLS#0+(byte) 1
(void()**) FSYSCALLS
(const void()**) FSYSCALLS#0 FSYSCALLS = (void()**)(const byte[]) SYSCALLS#0+(byte) 1
(byte) JMP
(const byte) JMP#0 JMP = (byte) $4c
(byte) NOP
@ -19,18 +19,17 @@
(const byte*) fn2::BGCOL#0 BGCOL = (byte*) 53281
(void()) main()
(byte~) main::$0 reg byte a 202.0
(byte~) main::$5 reg byte a 202.0
(byte~) main::$4 reg byte a 202.0
(label) main::@1
(label) main::@2
(label) main::@3
(void()*) main::f
(word) main::fn
(word) main::fn#0 fn zp ZP_WORD:3 101.0
(void()*) main::fsyscall
(void()*) main::fsyscall#0 fsyscall zp ZP_WORD:3 101.0
(byte) main::i
(byte) main::i#1 i zp ZP_BYTE:2 71.0
(byte) main::i#3 i zp ZP_BYTE:2 42.599999999999994
zp ZP_BYTE:2 [ main::i#3 main::i#1 ]
reg byte a [ main::$0 ]
reg byte a [ main::$5 ]
zp ZP_WORD:3 [ main::fn#0 ]
reg byte a [ main::$4 ]
zp ZP_WORD:3 [ main::fsyscall#0 ]