From 4a9a3d54f5ad33310c2dffca8902e31a2d74b81c Mon Sep 17 00:00:00 2001 From: Jesper Gravgaard Date: Mon, 31 Jul 2017 23:37:15 +0200 Subject: [PATCH] Fixed test data --- .../dk/camelot64/kickc/test/ref/fibmem.asm | 4 +- .../dk/camelot64/kickc/test/ref/fibmem.log | 54 ++-- .../dk/camelot64/kickc/test/ref/fibmem.sym | 2 +- .../camelot64/kickc/test/ref/flipper-rex2.asm | 2 + .../camelot64/kickc/test/ref/flipper-rex2.log | 70 +++-- .../camelot64/kickc/test/ref/flipper-rex2.sym | 2 +- .../dk/camelot64/kickc/test/ref/loopmin.asm | 2 +- .../dk/camelot64/kickc/test/ref/loopmin.log | 46 +-- .../dk/camelot64/kickc/test/ref/loopmin.sym | 2 +- .../dk/camelot64/kickc/test/ref/loopnest.asm | 6 +- .../dk/camelot64/kickc/test/ref/loopnest.log | 58 ++-- .../dk/camelot64/kickc/test/ref/loopnest.sym | 2 +- .../dk/camelot64/kickc/test/ref/loopnest2.asm | 6 +- .../dk/camelot64/kickc/test/ref/loopnest2.log | 62 ++--- .../dk/camelot64/kickc/test/ref/loopnest2.sym | 2 +- .../dk/camelot64/kickc/test/ref/loopsplit.asm | 4 +- .../dk/camelot64/kickc/test/ref/loopsplit.log | 58 ++-- .../dk/camelot64/kickc/test/ref/loopsplit.sym | 2 +- .../dk/camelot64/kickc/test/ref/minus.asm | 2 + .../dk/camelot64/kickc/test/ref/minus.log | 45 ++- .../dk/camelot64/kickc/test/ref/minus.sym | 2 +- .../dk/camelot64/kickc/test/ref/ptrtest.asm | 1 + .../dk/camelot64/kickc/test/ref/ptrtest.log | 39 ++- .../dk/camelot64/kickc/test/ref/ptrtest.sym | 2 +- .../dk/camelot64/kickc/test/ref/summin.asm | 1 + .../dk/camelot64/kickc/test/ref/summin.log | 48 +++- .../dk/camelot64/kickc/test/ref/summin.sym | 2 +- .../dk/camelot64/kickc/test/ref/useglobal.asm | 8 + .../dk/camelot64/kickc/test/ref/useglobal.cfg | 10 + .../dk/camelot64/kickc/test/ref/useglobal.log | 261 ++++++++++++++++++ .../dk/camelot64/kickc/test/ref/useglobal.sym | 6 + 31 files changed, 585 insertions(+), 226 deletions(-) create mode 100644 src/main/java/dk/camelot64/kickc/test/ref/useglobal.asm create mode 100644 src/main/java/dk/camelot64/kickc/test/ref/useglobal.cfg create mode 100644 src/main/java/dk/camelot64/kickc/test/ref/useglobal.log create mode 100644 src/main/java/dk/camelot64/kickc/test/ref/useglobal.sym diff --git a/src/main/java/dk/camelot64/kickc/test/ref/fibmem.asm b/src/main/java/dk/camelot64/kickc/test/ref/fibmem.asm index 69e3fe08b..3fb899493 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/fibmem.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/fibmem.asm @@ -13,8 +13,10 @@ B1: sta 3 ldx 2 lda 4353,x + sta 4 + lda 3 clc - adc 3 + adc 4 sta 3 lda 3 ldx 2 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/fibmem.log b/src/main/java/dk/camelot64/kickc/test/ref/fibmem.log index 0c78f6b82..5da422288 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/fibmem.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/fibmem.log @@ -443,13 +443,23 @@ zp byte:2 [ i#2 i#1 ] zp byte:3 [ $1 $4 ] zp byte:4 [ $3 ] -Re-allocated ZP register from zp byte:2 to zp byte:2 -Re-allocated ZP register from zp byte:3 to zp byte:3 -Re-allocated ZP register from zp byte:4 to zp byte:4 -Uplifting of variable (byte~) $3 to A +Uplifting max weight 33.0 live range equivalence class zp byte:3 [ $1 $4 ] +Error! Alive variable $1 register reg byte a clobbered by the ASM generated by statement [4] $3 ← 4353 *idx i#2 + ldx 2 + lda 4353,x + sta 4 + +Uplift to reg byte a resulted in clobber. +Error! Alive variable $1 register reg byte x clobbered by the ASM generated by statement [4] $3 ← 4353 *idx i#2 + ldx 2 + lda 4353,x + sta 4 + +Uplift to reg byte x resulted in clobber. +Uplift to reg byte y succesfull. REGISTER UPLIFTING (byte~) $1 zp byte:3 11.0 -(byte~) $3 reg byte a 22.0 +(byte~) $3 zp byte:4 22.0 (byte~) $4 zp byte:3 22.0 (byte[15]) fibs (byte) i @@ -481,12 +491,14 @@ B1: ldx 2 lda 4352,x sta 3 - // [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] // aby=cowo1_staridx_zpby1 + // [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] // zpby1=cowo1_staridx_zpby2 ldx 2 lda 4353,x - // [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] // zpby1=zpby1_plus_aby + sta 4 + // [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] // zpby1=zpby1_plus_zpby2 + lda 3 clc - adc 3 + adc 4 sta 3 // [6] *((word) 4354 + (byte) i#2) ← (byte~) $4 [ i#2 ] // cowo1_staridx_zpby1=zpby2 lda 3 @@ -524,12 +536,14 @@ B1: ldx 2 lda 4352,x sta 3 - // [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] // aby=cowo1_staridx_zpby1 + // [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] // zpby1=cowo1_staridx_zpby2 ldx 2 lda 4353,x - // [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] // zpby1=zpby1_plus_aby + sta 4 + // [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] // zpby1=zpby1_plus_zpby2 + lda 3 clc - adc 3 + adc 4 sta 3 // [6] *((word) 4354 + (byte) i#2) ← (byte~) $4 [ i#2 ] // cowo1_staridx_zpby1=zpby2 lda 3 @@ -564,12 +578,14 @@ B1: ldx 2 lda 4352,x sta 3 - // [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] // aby=cowo1_staridx_zpby1 + // [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] // zpby1=cowo1_staridx_zpby2 ldx 2 lda 4353,x - // [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] // zpby1=zpby1_plus_aby + sta 4 + // [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] // zpby1=zpby1_plus_zpby2 + lda 3 clc - adc 3 + adc 4 sta 3 // [6] *((word) 4354 + (byte) i#2) ← (byte~) $4 [ i#2 ] // cowo1_staridx_zpby1=zpby2 lda 3 @@ -585,7 +601,7 @@ BEND: FINAL SYMBOL TABLE (byte~) $1 zp byte:3 11.0 -(byte~) $3 reg byte a 22.0 +(byte~) $3 zp byte:4 22.0 (byte~) $4 zp byte:3 22.0 (label) @1 (label) @BEGIN @@ -618,12 +634,14 @@ B1: ldx 2 lda 4352,x sta 3 - // [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] // aby=cowo1_staridx_zpby1 + // [4] (byte~) $3 ← (word) 4353 *idx (byte) i#2 [ i#2 $1 $3 ] // zpby1=cowo1_staridx_zpby2 ldx 2 lda 4353,x - // [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] // zpby1=zpby1_plus_aby + sta 4 + // [5] (byte~) $4 ← (byte~) $1 + (byte~) $3 [ i#2 $4 ] // zpby1=zpby1_plus_zpby2 + lda 3 clc - adc 3 + adc 4 sta 3 // [6] *((word) 4354 + (byte) i#2) ← (byte~) $4 [ i#2 ] // cowo1_staridx_zpby1=zpby2 lda 3 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/fibmem.sym b/src/main/java/dk/camelot64/kickc/test/ref/fibmem.sym index 3d6dcb41e..efecb3bd3 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/fibmem.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/fibmem.sym @@ -1,5 +1,5 @@ (byte~) $1 zp byte:3 11.0 -(byte~) $3 reg byte a 22.0 +(byte~) $3 zp byte:4 22.0 (byte~) $4 zp byte:3 22.0 (label) @1 (label) @BEGIN diff --git a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.asm b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.asm index 9cd65edbd..ddb79a3a1 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.asm @@ -14,6 +14,8 @@ main__B3_from_B3: main__B3_from_B6: main__B3: lda 53266 + sta 14 + lda 14 cmp #254 bne main__B3_from_B3 main__B4: diff --git a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log index 5786e6134..9bb015fc7 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.log @@ -4148,23 +4148,25 @@ zp byte:16 [ plot::$3 ] zp byte:17 [ flip::$0 ] zp byte:18 [ flip::$4 ] -Re-allocated ZP register from zp byte:2 to zp byte:2 -Re-allocated ZP register from zp ptr byte:3 to zp ptr byte:3 -Re-allocated ZP register from zp byte:5 to zp byte:5 -Re-allocated ZP register from zp byte:6 to zp byte:6 -Re-allocated ZP register from zp byte:7 to zp byte:7 -Re-allocated ZP register from zp byte:8 to zp byte:8 -Re-allocated ZP register from zp byte:9 to zp byte:9 -Re-allocated ZP register from zp byte:10 to zp byte:10 -Re-allocated ZP register from zp byte:11 to zp byte:11 -Re-allocated ZP register from zp byte:12 to zp byte:12 -Re-allocated ZP register from zp byte:13 to zp byte:13 -Re-allocated ZP register from zp byte:14 to zp byte:14 -Re-allocated ZP register from zp byte:15 to zp byte:15 -Re-allocated ZP register from zp byte:16 to zp byte:16 -Re-allocated ZP register from zp byte:17 to zp byte:17 -Re-allocated ZP register from zp byte:18 to zp byte:18 -Uplifting of variable (byte~) main::$1 to A +Uplifting max weight 2252.25 live range equivalence class zp byte:7 [ plot::x#2 plot::x#1 ] +Error! Alive variable plot::x#2 register reg byte a clobbered by the ASM generated by statement [15] plot::$3 ← 4096 *idx plot::i#2 + ldx 6 + lda 4096,x + sta 16 + +Error! Alive variable plot::x#2 register reg byte a clobbered by the ASM generated by statement [16] *(plot::line#2 + plot::x#2) ← plot::$3 + tay + lda 16 + sta (3),y + +Uplift to reg byte a resulted in clobber. +Error! Alive variable plot::x#2 register reg byte x clobbered by the ASM generated by statement [15] plot::$3 ← 4096 *idx plot::i#2 + ldx 6 + lda 4096,x + sta 16 + +Uplift to reg byte x resulted in clobber. +Uplift to reg byte y succesfull. REGISTER UPLIFTING (byte*) RASTER (byte[1000]) SCREEN @@ -4192,7 +4194,7 @@ REGISTER UPLIFTING (byte) flip::srcIdx#2 zp byte:9 1034.6666666666667 (byte) flip::srcIdx#3 zp byte:9 202.0 (void()) main() -(byte~) main::$1 reg byte a 2002.0 +(byte~) main::$1 zp byte:14 2002.0 (byte~) main::$3 zp byte:15 2002.0 (byte) main::c (byte) main::c#1 zp byte:2 151.5 @@ -4267,9 +4269,11 @@ main__B3_from_B6: // (byte) main::c#2 = (byte) main::c#1 // register copy zp byte:2 jmp main__B3 main__B3: - // [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // aby=_star_cowo1 + // [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // zpby1=_star_cowo1 lda 53266 - // [4] if((byte~) main::$1!=(byte) 254) goto main::@3 [ main::c#2 ] // aby_neq_coby1_then_la1 + sta 14 + // [4] if((byte~) main::$1!=(byte) 254) goto main::@3 [ main::c#2 ] // zpby1_neq_coby1_then_la1 + lda 14 cmp #254 bne main__B3_from_B3 jmp main__B4 @@ -4515,9 +4519,11 @@ main__B3_from_B3: main__B3_from_B6: // (byte) main::c#2 = (byte) main::c#1 // register copy zp byte:2 main__B3: - // [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // aby=_star_cowo1 + // [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // zpby1=_star_cowo1 lda 53266 - // [4] if((byte~) main::$1!=(byte) 254) goto main::@3 [ main::c#2 ] // aby_neq_coby1_then_la1 + sta 14 + // [4] if((byte~) main::$1!=(byte) 254) goto main::@3 [ main::c#2 ] // zpby1_neq_coby1_then_la1 + lda 14 cmp #254 bne main__B3_from_B3 main__B4: @@ -4733,9 +4739,11 @@ main__B3_from_B3: main__B3_from_B6: // (byte) main::c#2 = (byte) main::c#1 // register copy zp byte:2 main__B3: - // [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // aby=_star_cowo1 + // [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // zpby1=_star_cowo1 lda 53266 - // [4] if((byte~) main::$1!=(byte) 254) goto main::@3 [ main::c#2 ] // aby_neq_coby1_then_la1 + sta 14 + // [4] if((byte~) main::$1!=(byte) 254) goto main::@3 [ main::c#2 ] // zpby1_neq_coby1_then_la1 + lda 14 cmp #254 bne main__B3_from_B3 main__B4: @@ -4938,9 +4946,11 @@ main__B3_from_B3: main__B3_from_B6: // (byte) main::c#2 = (byte) main::c#1 // register copy zp byte:2 main__B3: - // [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // aby=_star_cowo1 + // [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // zpby1=_star_cowo1 lda 53266 - // [4] if((byte~) main::$1!=(byte) 254) goto main::@3 [ main::c#2 ] // aby_neq_coby1_then_la1 + sta 14 + // [4] if((byte~) main::$1!=(byte) 254) goto main::@3 [ main::c#2 ] // zpby1_neq_coby1_then_la1 + lda 14 cmp #254 bne main__B3_from_B3 main__B4: @@ -5156,7 +5166,7 @@ FINAL SYMBOL TABLE (byte) flip::srcIdx#2 zp byte:9 1034.6666666666667 (byte) flip::srcIdx#3 zp byte:9 202.0 (void()) main() -(byte~) main::$1 reg byte a 2002.0 +(byte~) main::$1 zp byte:14 2002.0 (byte~) main::$3 zp byte:15 2002.0 (label) main::@10 (label) main::@11 @@ -5220,9 +5230,11 @@ main__B3_from_B3: main__B3_from_B6: // (byte) main::c#2 = (byte) main::c#1 // register copy zp byte:2 main__B3: - // [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // aby=_star_cowo1 + // [3] (byte~) main::$1 ← * (word) 53266 [ main::$1 main::c#2 ] // zpby1=_star_cowo1 lda 53266 - // [4] if((byte~) main::$1!=(byte) 254) goto main::@3 [ main::c#2 ] // aby_neq_coby1_then_la1 + sta 14 + // [4] if((byte~) main::$1!=(byte) 254) goto main::@3 [ main::c#2 ] // zpby1_neq_coby1_then_la1 + lda 14 cmp #254 bne main__B3_from_B3 main__B4: diff --git a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.sym b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.sym index 5a7d1cded..b8f2df9f1 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/flipper-rex2.sym @@ -31,7 +31,7 @@ (byte) flip::srcIdx#2 zp byte:9 1034.6666666666667 (byte) flip::srcIdx#3 zp byte:9 202.0 (void()) main() -(byte~) main::$1 reg byte a 2002.0 +(byte~) main::$1 zp byte:14 2002.0 (byte~) main::$3 zp byte:15 2002.0 (label) main::@10 (label) main::@11 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopmin.asm b/src/main/java/dk/camelot64/kickc/test/ref/loopmin.asm index 032a9f155..c02177b2f 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopmin.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopmin.asm @@ -21,6 +21,6 @@ B2: lda 3 clc adc 2 -B3_from_B2: sta 3 +B3_from_B2: jmp B3 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopmin.log b/src/main/java/dk/camelot64/kickc/test/ref/loopmin.log index 7b35bd6b7..0135d6992 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopmin.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopmin.log @@ -384,15 +384,27 @@ VARIABLE REGISTER WEIGHTS zp byte:2 [ i#2 i#1 ] zp byte:3 [ s#2 s#4 s#1 ] -Re-allocated ZP register from zp byte:2 to zp byte:2 -Re-allocated ZP register from zp byte:3 to zp byte:3 -Uplifting of variable (byte) s#1 to A +Uplifting max weight 49.5 live range equivalence class zp byte:3 [ s#2 s#4 s#1 ] +Error! Alive variable s#2 register reg byte a clobbered by the ASM generated by statement [1] if(i#2>5) goto @2 + lda 2 + cmp #5 + beq !+ + bcs B2 +!: + +Error! Alive variable s#4 register reg byte a clobbered by the ASM generated by statement [4] if(i#1>0) goto @1 + lda 2 + bne B1_from_B3 + +Uplift to reg byte a resulted in clobber. +Uplift to reg byte x succesfull. +Uplift to reg byte y succesfull. REGISTER UPLIFTING (byte) i (byte) i#1 zp byte:2 16.5 (byte) i#2 zp byte:2 11.0 (byte) s -(byte) s#1 reg byte a 22.0 +(byte) s#1 zp byte:3 22.0 (byte) s#2 zp byte:3 16.5 (byte) s#4 zp byte:3 11.0 @@ -432,13 +444,13 @@ B3: jmp BEND BEND: B2: - // [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] // aby=zpby1_plus_zpby2 + // [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] // zpby1=zpby1_plus_zpby2 lda 3 clc adc 2 -B3_from_B2: - // (byte) s#4 = (byte) s#1 // zpby1=aby sta 3 +B3_from_B2: + // (byte) s#4 = (byte) s#1 // register copy zp byte:3 jmp B3 Removing instruction jmp B1 @@ -475,13 +487,13 @@ B3: bne B1_from_B3 BEND: B2: - // [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] // aby=zpby1_plus_zpby2 + // [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] // zpby1=zpby1_plus_zpby2 lda 3 clc adc 2 -B3_from_B2: - // (byte) s#4 = (byte) s#1 // zpby1=aby sta 3 +B3_from_B2: + // (byte) s#4 = (byte) s#1 // register copy zp byte:3 jmp B3 Removing instruction jmp B1 @@ -515,13 +527,13 @@ B3: bne B1_from_B3 BEND: B2: - // [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] // aby=zpby1_plus_zpby2 + // [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] // zpby1=zpby1_plus_zpby2 lda 3 clc adc 2 -B3_from_B2: - // (byte) s#4 = (byte) s#1 // zpby1=aby sta 3 +B3_from_B2: + // (byte) s#4 = (byte) s#1 // register copy zp byte:3 jmp B3 FINAL SYMBOL TABLE @@ -534,7 +546,7 @@ FINAL SYMBOL TABLE (byte) i#1 zp byte:2 16.5 (byte) i#2 zp byte:2 11.0 (byte) s -(byte) s#1 reg byte a 22.0 +(byte) s#1 zp byte:3 22.0 (byte) s#2 zp byte:3 16.5 (byte) s#4 zp byte:3 11.0 @@ -570,12 +582,12 @@ B3: bne B1_from_B3 BEND: B2: - // [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] // aby=zpby1_plus_zpby2 + // [5] (byte) s#1 ← (byte) s#2 + (byte) i#2 [ i#2 s#1 ] // zpby1=zpby1_plus_zpby2 lda 3 clc adc 2 -B3_from_B2: - // (byte) s#4 = (byte) s#1 // zpby1=aby sta 3 +B3_from_B2: + // (byte) s#4 = (byte) s#1 // register copy zp byte:3 jmp B3 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopmin.sym b/src/main/java/dk/camelot64/kickc/test/ref/loopmin.sym index 5e5550c88..278cd587b 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopmin.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopmin.sym @@ -7,7 +7,7 @@ (byte) i#1 zp byte:2 16.5 (byte) i#2 zp byte:2 11.0 (byte) s -(byte) s#1 reg byte a 22.0 +(byte) s#1 zp byte:3 22.0 (byte) s#2 zp byte:3 16.5 (byte) s#4 zp byte:3 11.0 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopnest.asm b/src/main/java/dk/camelot64/kickc/test/ref/loopnest.asm index 93ce282b7..2d7dc2a63 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopnest.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopnest.asm @@ -18,16 +18,12 @@ nest: nest__B1_from_nest: lda #100 sta 3 - jmp nest__B1 nest__B1_from_B1: - sta 3 nest__B1: lda 3 sta 1024 + dec 3 lda 3 - sec - sbc #1 - cmp #0 bne nest__B1_from_B1 nest__Breturn: rts diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopnest.log b/src/main/java/dk/camelot64/kickc/test/ref/loopnest.log index 0a15a0511..c557addd7 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopnest.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopnest.log @@ -734,9 +734,10 @@ VARIABLE REGISTER WEIGHTS zp byte:2 [ main::i#2 main::i#1 ] zp byte:3 [ nest::j#2 nest::j#1 ] -Re-allocated ZP register from zp byte:2 to zp byte:2 -Re-allocated ZP register from zp byte:3 to zp byte:3 -Uplifting of variable (byte) nest::j#1 to A +Uplifting max weight 303.0 live range equivalence class zp byte:3 [ nest::j#2 nest::j#1 ] +Uplift to reg byte a succesfull. +Uplift to reg byte x succesfull. +Uplift to reg byte y succesfull. REGISTER UPLIFTING (byte*) SCREEN (void()) main() @@ -745,7 +746,7 @@ REGISTER UPLIFTING (byte) main::i#2 zp byte:2 3.142857142857143 (void()) nest() (byte) nest::j -(byte) nest::j#1 reg byte a 151.5 +(byte) nest::j#1 zp byte:3 151.5 (byte) nest::j#2 zp byte:3 151.5 zp byte:2 [ main::i#2 main::i#1 ] @@ -784,19 +785,16 @@ nest__B1_from_nest: sta 3 jmp nest__B1 nest__B1_from_B1: - // (byte) nest::j#2 = (byte) nest::j#1 // zpby1=aby - sta 3 + // (byte) nest::j#2 = (byte) nest::j#1 // register copy zp byte:3 jmp nest__B1 nest__B1: // [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] // _star_cowo1=zpby1 lda 3 sta 1024 - // [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] // aby=_dec_zpby1 + // [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] // zpby1=_dec_zpby1 + dec 3 + // [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] // zpby1_gt_0_then_la1 lda 3 - sec - sbc #1 - // [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] // aby_gt_0_then_la1 - cmp #0 bne nest__B1_from_B1 jmp nest__Breturn nest__Breturn: @@ -838,23 +836,21 @@ nest__B1_from_nest: sta 3 jmp nest__B1 nest__B1_from_B1: - // (byte) nest::j#2 = (byte) nest::j#1 // zpby1=aby - sta 3 + // (byte) nest::j#2 = (byte) nest::j#1 // register copy zp byte:3 nest__B1: // [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] // _star_cowo1=zpby1 lda 3 sta 1024 - // [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] // aby=_dec_zpby1 + // [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] // zpby1=_dec_zpby1 + dec 3 + // [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] // zpby1_gt_0_then_la1 lda 3 - sec - sbc #1 - // [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] // aby_gt_0_then_la1 - cmp #0 bne nest__B1_from_B1 nest__Breturn: rts Removing instruction jmp main__B1 +Removing instruction jmp nest__B1 Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER BBEGIN: @@ -882,20 +878,16 @@ nest__B1_from_nest: // (byte) nest::j#2 = (byte) 100 // zpby1=coby1 lda #100 sta 3 - jmp nest__B1 nest__B1_from_B1: - // (byte) nest::j#2 = (byte) nest::j#1 // zpby1=aby - sta 3 + // (byte) nest::j#2 = (byte) nest::j#1 // register copy zp byte:3 nest__B1: // [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] // _star_cowo1=zpby1 lda 3 sta 1024 - // [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] // aby=_dec_zpby1 + // [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] // zpby1=_dec_zpby1 + dec 3 + // [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] // zpby1_gt_0_then_la1 lda 3 - sec - sbc #1 - // [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] // aby_gt_0_then_la1 - cmp #0 bne nest__B1_from_B1 nest__Breturn: rts @@ -915,7 +907,7 @@ FINAL SYMBOL TABLE (label) nest::@1 (label) nest::@return (byte) nest::j -(byte) nest::j#1 reg byte a 151.5 +(byte) nest::j#1 zp byte:3 151.5 (byte) nest::j#2 zp byte:3 151.5 zp byte:2 [ main::i#2 main::i#1 ] @@ -947,20 +939,16 @@ nest__B1_from_nest: // (byte) nest::j#2 = (byte) 100 // zpby1=coby1 lda #100 sta 3 - jmp nest__B1 nest__B1_from_B1: - // (byte) nest::j#2 = (byte) nest::j#1 // zpby1=aby - sta 3 + // (byte) nest::j#2 = (byte) nest::j#1 // register copy zp byte:3 nest__B1: // [7] *((word) 1024) ← (byte) nest::j#2 [ main::i#2 nest::j#2 ] // _star_cowo1=zpby1 lda 3 sta 1024 - // [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] // aby=_dec_zpby1 + // [8] (byte) nest::j#1 ← -- (byte) nest::j#2 [ main::i#2 nest::j#1 ] // zpby1=_dec_zpby1 + dec 3 + // [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] // zpby1_gt_0_then_la1 lda 3 - sec - sbc #1 - // [9] if((byte) nest::j#1>(byte) 0) goto nest::@1 [ main::i#2 nest::j#1 ] // aby_gt_0_then_la1 - cmp #0 bne nest__B1_from_B1 nest__Breturn: rts diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopnest.sym b/src/main/java/dk/camelot64/kickc/test/ref/loopnest.sym index 800c8ec88..717de8585 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopnest.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopnest.sym @@ -12,7 +12,7 @@ (label) nest::@1 (label) nest::@return (byte) nest::j -(byte) nest::j#1 reg byte a 151.5 +(byte) nest::j#1 zp byte:3 151.5 (byte) nest::j#2 zp byte:3 151.5 zp byte:2 [ main::i#2 main::i#1 ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.asm b/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.asm index f995f6804..3dd0d9ec0 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.asm @@ -54,16 +54,12 @@ nest2__B1: nest2__B2_from_B1: lda #100 sta 7 - jmp nest2__B2 nest2__B2_from_B2: - sta 7 nest2__B2: lda 7 sta 1024 + dec 7 lda 7 - sec - sbc #1 - cmp #0 bne nest2__B2_from_B2 nest2__B3: dec 6 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.log b/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.log index 73f78a1c8..bc54c1364 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.log @@ -1849,13 +1849,10 @@ zp byte:5 [ nest1::j#2 nest1::j#1 ] zp byte:6 [ nest2::i#2 nest2::i#1 ] zp byte:7 [ nest2::j#2 nest2::j#1 ] -Re-allocated ZP register from zp byte:2 to zp byte:2 -Re-allocated ZP register from zp byte:3 to zp byte:3 -Re-allocated ZP register from zp byte:4 to zp byte:4 -Re-allocated ZP register from zp byte:5 to zp byte:5 -Re-allocated ZP register from zp byte:6 to zp byte:6 -Re-allocated ZP register from zp byte:7 to zp byte:7 -Uplifting of variable (byte) nest2::j#1 to A +Uplifting max weight 3000003.0 live range equivalence class zp byte:7 [ nest2::j#2 nest2::j#1 ] +Uplift to reg byte a succesfull. +Uplift to reg byte x succesfull. +Uplift to reg byte y succesfull. REGISTER UPLIFTING (byte*) SCREEN (void()) main() @@ -1877,7 +1874,7 @@ REGISTER UPLIFTING (byte) nest2::i#1 zp byte:6 150001.5 (byte) nest2::i#2 zp byte:6 40000.4 (byte) nest2::j -(byte) nest2::j#1 reg byte a 1500001.5 +(byte) nest2::j#1 zp byte:7 1500001.5 (byte) nest2::j#2 zp byte:7 1500001.5 zp byte:2 [ main::i#2 main::i#1 ] @@ -1982,19 +1979,16 @@ nest2__B2_from_B1: sta 7 jmp nest2__B2 nest2__B2_from_B2: - // (byte) nest2::j#2 = (byte) nest2::j#1 // zpby1=aby - sta 7 + // (byte) nest2::j#2 = (byte) nest2::j#1 // register copy zp byte:7 jmp nest2__B2 nest2__B2: // [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] // _star_cowo1=zpby1 lda 7 sta 1024 - // [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // aby=_dec_zpby1 + // [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1=_dec_zpby1 + dec 7 + // [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1_gt_0_then_la1 lda 7 - sec - sbc #1 - // [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // aby_gt_0_then_la1 - cmp #0 bne nest2__B2_from_B2 jmp nest2__B3 nest2__B3: @@ -2106,18 +2100,15 @@ nest2__B2_from_B1: sta 7 jmp nest2__B2 nest2__B2_from_B2: - // (byte) nest2::j#2 = (byte) nest2::j#1 // zpby1=aby - sta 7 + // (byte) nest2::j#2 = (byte) nest2::j#1 // register copy zp byte:7 nest2__B2: // [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] // _star_cowo1=zpby1 lda 7 sta 1024 - // [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // aby=_dec_zpby1 + // [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1=_dec_zpby1 + dec 7 + // [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1_gt_0_then_la1 lda 7 - sec - sbc #1 - // [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // aby_gt_0_then_la1 - cmp #0 bne nest2__B2_from_B2 nest2__B3: // [22] (byte) nest2::i#1 ← -- (byte) nest2::i#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] // zpby1=_dec_zpby1 @@ -2133,6 +2124,7 @@ Removing instruction jmp main__B2 Removing instruction jmp nest1__B1 Removing instruction jmp nest1__B2 Removing instruction jmp nest2__B1 +Removing instruction jmp nest2__B2 Succesful ASM optimization Pass5NextJumpElimination ASSEMBLER BBEGIN: @@ -2210,20 +2202,16 @@ nest2__B2_from_B1: // (byte) nest2::j#2 = (byte) 100 // zpby1=coby1 lda #100 sta 7 - jmp nest2__B2 nest2__B2_from_B2: - // (byte) nest2::j#2 = (byte) nest2::j#1 // zpby1=aby - sta 7 + // (byte) nest2::j#2 = (byte) nest2::j#1 // register copy zp byte:7 nest2__B2: // [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] // _star_cowo1=zpby1 lda 7 sta 1024 - // [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // aby=_dec_zpby1 + // [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1=_dec_zpby1 + dec 7 + // [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1_gt_0_then_la1 lda 7 - sec - sbc #1 - // [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // aby_gt_0_then_la1 - cmp #0 bne nest2__B2_from_B2 nest2__B3: // [22] (byte) nest2::i#1 ← -- (byte) nest2::i#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] // zpby1=_dec_zpby1 @@ -2271,7 +2259,7 @@ FINAL SYMBOL TABLE (byte) nest2::i#1 zp byte:6 150001.5 (byte) nest2::i#2 zp byte:6 40000.4 (byte) nest2::j -(byte) nest2::j#1 reg byte a 1500001.5 +(byte) nest2::j#1 zp byte:7 1500001.5 (byte) nest2::j#2 zp byte:7 1500001.5 zp byte:2 [ main::i#2 main::i#1 ] @@ -2357,20 +2345,16 @@ nest2__B2_from_B1: // (byte) nest2::j#2 = (byte) 100 // zpby1=coby1 lda #100 sta 7 - jmp nest2__B2 nest2__B2_from_B2: - // (byte) nest2::j#2 = (byte) nest2::j#1 // zpby1=aby - sta 7 + // (byte) nest2::j#2 = (byte) nest2::j#1 // register copy zp byte:7 nest2__B2: // [19] *((word) 1024) ← (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#2 nest2::i#2 ] // _star_cowo1=zpby1 lda 7 sta 1024 - // [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // aby=_dec_zpby1 + // [20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1=_dec_zpby1 + dec 7 + // [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // zpby1_gt_0_then_la1 lda 7 - sec - sbc #1 - // [21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::j#1 nest2::i#2 ] // aby_gt_0_then_la1 - cmp #0 bne nest2__B2_from_B2 nest2__B3: // [22] (byte) nest2::i#1 ← -- (byte) nest2::i#2 [ main::j#2 main::i#2 nest1::j#2 nest1::i#2 nest2::i#1 ] // zpby1=_dec_zpby1 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.sym b/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.sym index e12e5ec54..56df4f4ab 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopnest2.sym @@ -34,7 +34,7 @@ (byte) nest2::i#1 zp byte:6 150001.5 (byte) nest2::i#2 zp byte:6 40000.4 (byte) nest2::j -(byte) nest2::j#1 reg byte a 1500001.5 +(byte) nest2::j#1 zp byte:7 1500001.5 (byte) nest2::j#2 zp byte:7 1500001.5 zp byte:2 [ main::i#2 main::i#1 ] diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.asm b/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.asm index e5dd31e8e..a7a6bc7ad 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.asm @@ -6,8 +6,8 @@ main__B1_from_main: lda #0 sta 3 lda #100 -main__B1: sta 2 +main__B1: dec 2 lda 2 bne main__B2 @@ -22,10 +22,8 @@ main__B2: main__B5: dec 3 main__B1_from_B5: - lda 2 jmp main__B1 main__B4: inc 3 main__B1_from_B4: - lda 2 jmp main__B1 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.log b/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.log index 418485745..d128b20e5 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.log @@ -538,14 +538,26 @@ VARIABLE REGISTER WEIGHTS zp byte:2 [ main::i#2 main::i#1 ] zp byte:3 [ main::s#3 main::s#1 main::s#2 ] -Re-allocated ZP register from zp byte:2 to zp byte:2 -Re-allocated ZP register from zp byte:3 to zp byte:3 -Uplifting of variable (byte) main::i#2 to A +Uplifting max weight 55.0 live range equivalence class zp byte:3 [ main::s#3 main::s#1 main::s#2 ] +Error! Alive variable main::s#3 register reg byte a clobbered by the ASM generated by statement [3] if(main::i#1>0) goto main::@2 + lda 2 + bne main__B2 + +Error! Alive variable main::s#3 register reg byte a clobbered by the ASM generated by statement [5] if(main::i#1>50) goto main::@4 + lda 2 + cmp #50 + beq !+ + bcs main__B4 +!: + +Uplift to reg byte a resulted in clobber. +Uplift to reg byte x succesfull. +Uplift to reg byte y succesfull. REGISTER UPLIFTING (void()) main() (byte) main::i (byte) main::i#1 zp byte:2 11.0 -(byte) main::i#2 reg byte a 33.0 +(byte) main::i#2 zp byte:2 33.0 (byte) main::s (byte) main::s#1 zp byte:3 22.0 (byte) main::s#2 zp byte:3 22.0 @@ -564,12 +576,12 @@ main__B1_from_main: // (byte) main::s#3 = (byte) 0 // zpby1=coby1 lda #0 sta 3 - // (byte) main::i#2 = (byte) 100 // aby=coby1 + // (byte) main::i#2 = (byte) 100 // zpby1=coby1 lda #100 + sta 2 jmp main__B1 main__B1: - // [2] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 main::s#3 ] // zpby1=_dec_aby - sta 2 + // [2] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 main::s#3 ] // zpby1=_dec_zpby1 dec 2 // [3] if((byte) main::i#1>(byte) 0) goto main::@2 [ main::i#1 main::s#3 ] // zpby1_gt_0_then_la1 lda 2 @@ -590,16 +602,14 @@ main__B5: dec 3 main__B1_from_B5: // (byte) main::s#3 = (byte) main::s#2 // register copy zp byte:3 - // (byte) main::i#2 = (byte) main::i#1 // aby=zpby1 - lda 2 + // (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2 jmp main__B1 main__B4: // [7] (byte) main::s#1 ← ++ (byte) main::s#3 [ main::i#1 main::s#1 ] // zpby1=_inc_zpby1 inc 3 main__B1_from_B4: // (byte) main::s#3 = (byte) main::s#1 // register copy zp byte:3 - // (byte) main::i#2 = (byte) main::i#1 // aby=zpby1 - lda 2 + // (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2 jmp main__B1 Removing instruction jmp BEND @@ -616,11 +626,11 @@ main__B1_from_main: // (byte) main::s#3 = (byte) 0 // zpby1=coby1 lda #0 sta 3 - // (byte) main::i#2 = (byte) 100 // aby=coby1 + // (byte) main::i#2 = (byte) 100 // zpby1=coby1 lda #100 -main__B1: - // [2] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 main::s#3 ] // zpby1=_dec_aby sta 2 +main__B1: + // [2] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 main::s#3 ] // zpby1=_dec_zpby1 dec 2 // [3] if((byte) main::i#1>(byte) 0) goto main::@2 [ main::i#1 main::s#3 ] // zpby1_gt_0_then_la1 lda 2 @@ -639,16 +649,14 @@ main__B5: dec 3 main__B1_from_B5: // (byte) main::s#3 = (byte) main::s#2 // register copy zp byte:3 - // (byte) main::i#2 = (byte) main::i#1 // aby=zpby1 - lda 2 + // (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2 jmp main__B1 main__B4: // [7] (byte) main::s#1 ← ++ (byte) main::s#3 [ main::i#1 main::s#1 ] // zpby1=_inc_zpby1 inc 3 main__B1_from_B4: // (byte) main::s#3 = (byte) main::s#1 // register copy zp byte:3 - // (byte) main::i#2 = (byte) main::i#1 // aby=zpby1 - lda 2 + // (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2 jmp main__B1 FINAL SYMBOL TABLE @@ -662,7 +670,7 @@ FINAL SYMBOL TABLE (label) main::@return (byte) main::i (byte) main::i#1 zp byte:2 11.0 -(byte) main::i#2 reg byte a 33.0 +(byte) main::i#2 zp byte:2 33.0 (byte) main::s (byte) main::s#1 zp byte:3 22.0 (byte) main::s#2 zp byte:3 22.0 @@ -680,11 +688,11 @@ main__B1_from_main: // (byte) main::s#3 = (byte) 0 // zpby1=coby1 lda #0 sta 3 - // (byte) main::i#2 = (byte) 100 // aby=coby1 + // (byte) main::i#2 = (byte) 100 // zpby1=coby1 lda #100 -main__B1: - // [2] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 main::s#3 ] // zpby1=_dec_aby sta 2 +main__B1: + // [2] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 main::s#3 ] // zpby1=_dec_zpby1 dec 2 // [3] if((byte) main::i#1>(byte) 0) goto main::@2 [ main::i#1 main::s#3 ] // zpby1_gt_0_then_la1 lda 2 @@ -703,15 +711,13 @@ main__B5: dec 3 main__B1_from_B5: // (byte) main::s#3 = (byte) main::s#2 // register copy zp byte:3 - // (byte) main::i#2 = (byte) main::i#1 // aby=zpby1 - lda 2 + // (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2 jmp main__B1 main__B4: // [7] (byte) main::s#1 ← ++ (byte) main::s#3 [ main::i#1 main::s#1 ] // zpby1=_inc_zpby1 inc 3 main__B1_from_B4: // (byte) main::s#3 = (byte) main::s#1 // register copy zp byte:3 - // (byte) main::i#2 = (byte) main::i#1 // aby=zpby1 - lda 2 + // (byte) main::i#2 = (byte) main::i#1 // register copy zp byte:2 jmp main__B1 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.sym b/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.sym index 57f2fd34b..854b511f5 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/loopsplit.sym @@ -8,7 +8,7 @@ (label) main::@return (byte) main::i (byte) main::i#1 zp byte:2 11.0 -(byte) main::i#2 reg byte a 33.0 +(byte) main::i#2 zp byte:2 33.0 (byte) main::s (byte) main::s#1 zp byte:3 22.0 (byte) main::s#2 zp byte:3 22.0 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/minus.asm b/src/main/java/dk/camelot64/kickc/test/ref/minus.asm index 60bb7e35b..2602ddcc2 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/minus.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/minus.asm @@ -7,6 +7,8 @@ B1: lda 2 clc adc #4 + sta 3 + lda 3 ldx 2 sta 4352,x inc 2 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/minus.log b/src/main/java/dk/camelot64/kickc/test/ref/minus.log index 597fbc723..ff585045a 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/minus.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/minus.log @@ -311,11 +311,22 @@ VARIABLE REGISTER WEIGHTS zp byte:2 [ i#2 i#1 ] zp byte:3 [ $1 ] -Re-allocated ZP register from zp byte:2 to zp byte:2 -Re-allocated ZP register from zp byte:3 to zp byte:3 -Uplifting of variable (byte~) $1 to A +Uplifting max weight 31.166666666666664 live range equivalence class zp byte:2 [ i#2 i#1 ] +Error! Alive variable i#2 register reg byte a clobbered by the ASM generated by statement [1] $1 ← i#2 + 4 + clc + adc #4 + sta 3 + +Error! Alive variable i#2 register reg byte a clobbered by the ASM generated by statement [2] *(4352 + i#2) ← $1 + tax + lda 3 + sta 4352,x + +Uplift to reg byte a resulted in clobber. +Uplift to reg byte x succesfull. +Uplift to reg byte y succesfull. REGISTER UPLIFTING -(byte~) $1 reg byte a 22.0 +(byte~) $1 zp byte:3 22.0 (byte) i (byte) i#1 zp byte:2 16.5 (byte) i#2 zp byte:2 14.666666666666666 @@ -335,11 +346,13 @@ B1_from_B1: // (byte) i#2 = (byte) i#1 // register copy zp byte:2 jmp B1 B1: - // [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] // aby=zpby1_plus_coby1 + // [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] // zpby1=zpby2_plus_coby1 lda 2 clc adc #4 - // [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] // cowo1_staridx_zpby1=aby + sta 3 + // [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] // cowo1_staridx_zpby1=zpby2 + lda 3 ldx 2 sta 4352,x // [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] // zpby1=zpby1_plus_1 @@ -364,11 +377,13 @@ B1_from_BBEGIN: B1_from_B1: // (byte) i#2 = (byte) i#1 // register copy zp byte:2 B1: - // [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] // aby=zpby1_plus_coby1 + // [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] // zpby1=zpby2_plus_coby1 lda 2 clc adc #4 - // [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] // cowo1_staridx_zpby1=aby + sta 3 + // [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] // cowo1_staridx_zpby1=zpby2 + lda 3 ldx 2 sta 4352,x // [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] // zpby1=zpby1_plus_1 @@ -390,11 +405,13 @@ B1_from_BBEGIN: B1_from_B1: // (byte) i#2 = (byte) i#1 // register copy zp byte:2 B1: - // [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] // aby=zpby1_plus_coby1 + // [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] // zpby1=zpby2_plus_coby1 lda 2 clc adc #4 - // [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] // cowo1_staridx_zpby1=aby + sta 3 + // [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] // cowo1_staridx_zpby1=zpby2 + lda 3 ldx 2 sta 4352,x // [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] // zpby1=zpby1_plus_1 @@ -406,7 +423,7 @@ B1: BEND: FINAL SYMBOL TABLE -(byte~) $1 reg byte a 22.0 +(byte~) $1 zp byte:3 22.0 (label) @1 (label) @BEGIN (label) @END @@ -427,11 +444,13 @@ B1_from_BBEGIN: B1_from_B1: // (byte) i#2 = (byte) i#1 // register copy zp byte:2 B1: - // [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] // aby=zpby1_plus_coby1 + // [1] (byte~) $1 ← (byte) i#2 + (byte) 4 [ i#2 $1 ] // zpby1=zpby2_plus_coby1 lda 2 clc adc #4 - // [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] // cowo1_staridx_zpby1=aby + sta 3 + // [2] *((word) 4352 + (byte) i#2) ← (byte~) $1 [ i#2 ] // cowo1_staridx_zpby1=zpby2 + lda 3 ldx 2 sta 4352,x // [3] (byte) i#1 ← (byte) i#2 + (byte) 1 [ i#1 ] // zpby1=zpby1_plus_1 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/minus.sym b/src/main/java/dk/camelot64/kickc/test/ref/minus.sym index b9fec56c0..06669901d 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/minus.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/minus.sym @@ -1,4 +1,4 @@ -(byte~) $1 reg byte a 22.0 +(byte~) $1 zp byte:3 22.0 (label) @1 (label) @BEGIN (label) @END diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.asm b/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.asm index 2d2025703..ffa1922f9 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.asm @@ -63,6 +63,7 @@ rvaluevar__B1_from_B2: jmp rvaluevar__B1 rvalue: lda 1024 + sta 11 lda 1025 sta 12 rvalue__B1_from_rvalue: diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.log b/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.log index 2188d759e..5fcbee79e 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.log @@ -1890,16 +1890,22 @@ zp byte:10 [ rvaluevar::b#0 ] zp byte:11 [ rvalue::b#0 ] zp byte:12 [ rvalue::b#1 ] -Re-allocated ZP register from zp byte:2 to zp byte:2 -Re-allocated ZP register from zp ptr byte:3 to zp ptr byte:3 -Re-allocated ZP register from zp byte:5 to zp byte:5 -Re-allocated ZP register from zp ptr byte:6 to zp ptr byte:6 -Re-allocated ZP register from zp byte:8 to zp byte:8 -Re-allocated ZP register from zp byte:9 to zp byte:9 -Re-allocated ZP register from zp byte:10 to zp byte:10 -Re-allocated ZP register from zp byte:11 to zp byte:11 -Re-allocated ZP register from zp byte:12 to zp byte:12 -Uplifting of variable (byte) rvalue::b#0 to A +Uplifting max weight Infinity live range equivalence class zp byte:8 [ rvalue::i#2 rvalue::i#1 rvalue::b#2 ] +Error! Alive variable rvalue::i#2 register reg byte a clobbered by the ASM generated by statement [23] rvalue::b#2 ← 1024 *idx rvalue::i#2 + tax + lda 1024,x + +Uplift to reg byte a resulted in clobber. +Error! Alive variable rvalue::i#2 register reg byte x clobbered by the ASM generated by statement [23] rvalue::b#2 ← 1024 *idx rvalue::i#2 + lda 1024,x + tax + +Uplift to reg byte x resulted in clobber. +Error! Alive variable rvalue::i#2 register reg byte y clobbered by the ASM generated by statement [23] rvalue::b#2 ← 1024 *idx rvalue::i#2 + lda 1024,y + tay + +Uplift to reg byte y resulted in clobber. REGISTER UPLIFTING (void()) lvalue() (byte[1024]) lvalue::SCREEN @@ -1918,7 +1924,7 @@ REGISTER UPLIFTING (void()) rvalue() (byte[1024]) rvalue::SCREEN (byte) rvalue::b -(byte) rvalue::b#0 reg byte a Infinity +(byte) rvalue::b#0 zp byte:11 Infinity (byte) rvalue::b#1 zp byte:12 Infinity (byte) rvalue::b#2 zp byte:8 Infinity (byte) rvalue::i @@ -2041,8 +2047,9 @@ rvaluevar__B1_from_B2: // (byte) rvaluevar::i#2 = (byte) rvaluevar::i#1 // register copy zp byte:5 jmp rvaluevar__B1 rvalue: - // [18] (byte) rvalue::b#0 ← * (word) 1024 [ ] // aby=_star_cowo1 + // [18] (byte) rvalue::b#0 ← * (word) 1024 [ ] // zpby1=_star_cowo1 lda 1024 + sta 11 // [19] (byte) rvalue::b#1 ← * (word) 1025 [ ] // zpby1=_star_cowo1 lda 1025 sta 12 @@ -2195,8 +2202,9 @@ rvaluevar__B1_from_B2: // (byte) rvaluevar::i#2 = (byte) rvaluevar::i#1 // register copy zp byte:5 jmp rvaluevar__B1 rvalue: - // [18] (byte) rvalue::b#0 ← * (word) 1024 [ ] // aby=_star_cowo1 + // [18] (byte) rvalue::b#0 ← * (word) 1024 [ ] // zpby1=_star_cowo1 lda 1024 + sta 11 // [19] (byte) rvalue::b#1 ← * (word) 1025 [ ] // zpby1=_star_cowo1 lda 1025 sta 12 @@ -2283,7 +2291,7 @@ FINAL SYMBOL TABLE (label) rvalue::@return (byte[1024]) rvalue::SCREEN (byte) rvalue::b -(byte) rvalue::b#0 reg byte a Infinity +(byte) rvalue::b#0 zp byte:11 Infinity (byte) rvalue::b#1 zp byte:12 Infinity (byte) rvalue::b#2 zp byte:8 Infinity (byte) rvalue::i @@ -2386,8 +2394,9 @@ rvaluevar__B1_from_B2: // (byte) rvaluevar::i#2 = (byte) rvaluevar::i#1 // register copy zp byte:5 jmp rvaluevar__B1 rvalue: - // [18] (byte) rvalue::b#0 ← * (word) 1024 [ ] // aby=_star_cowo1 + // [18] (byte) rvalue::b#0 ← * (word) 1024 [ ] // zpby1=_star_cowo1 lda 1024 + sta 11 // [19] (byte) rvalue::b#1 ← * (word) 1025 [ ] // zpby1=_star_cowo1 lda 1025 sta 12 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.sym b/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.sym index c75e5afd9..c56a8cae9 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.sym @@ -30,7 +30,7 @@ (label) rvalue::@return (byte[1024]) rvalue::SCREEN (byte) rvalue::b -(byte) rvalue::b#0 reg byte a Infinity +(byte) rvalue::b#0 zp byte:11 Infinity (byte) rvalue::b#1 zp byte:12 Infinity (byte) rvalue::b#2 zp byte:8 Infinity (byte) rvalue::i diff --git a/src/main/java/dk/camelot64/kickc/test/ref/summin.asm b/src/main/java/dk/camelot64/kickc/test/ref/summin.asm index bbabf1193..079a13761 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/summin.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/summin.asm @@ -20,6 +20,7 @@ B3: lda 4 clc adc 5 + sta 4 BEND: sum: lda 2 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/summin.log b/src/main/java/dk/camelot64/kickc/test/ref/summin.log index 9a1465049..975c406e7 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/summin.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/summin.log @@ -390,18 +390,43 @@ zp byte:3 [ sum::b#2 ] zp byte:4 [ s1#0 s3#0 ] zp byte:5 [ s2#0 ] -Re-allocated ZP register from zp byte:2 to zp byte:2 -Re-allocated ZP register from zp byte:3 to zp byte:3 -Re-allocated ZP register from zp byte:4 to zp byte:4 -Re-allocated ZP register from zp byte:5 to zp byte:5 -Uplifting of variable (byte) s3#0 to A +Uplifting max weight Infinity live range equivalence class zp byte:4 [ s1#0 s3#0 ] +Error! Alive variable s1#0 register reg byte a clobbered by the ASM generated by statement [0] call sum param-assignment +sum_from_BBEGIN: + lda #2 + sta 3 + lda #1 + sta 2 + jsr sum + +Error! Alive variable s1#0 register reg byte a clobbered by the ASM generated by statement [2] call sum param-assignment +sum_from_B2: + lda #13 + sta 3 + lda #9 + sta 2 + jsr sum + +Error! Alive variable s1#0 register reg byte a clobbered by the ASM generated by statement [3] s2#0 ← sum::return#0 + lda 2 + sta 5 + +Error! Alive variable s1#0 register reg byte a clobbered by the ASM generated by statement [6] sum::return#0 ← sum::a#2 + sum::b#2 + lda 2 + clc + adc 3 + sta 2 + +Uplift to reg byte a resulted in clobber. +Uplift to reg byte x succesfull. +Uplift to reg byte y succesfull. REGISTER UPLIFTING (byte) s1 (byte) s1#0 zp byte:4 0.5714285714285714 (byte) s2 (byte) s2#0 zp byte:5 4.0 (byte) s3 -(byte) s3#0 reg byte a Infinity +(byte) s3#0 zp byte:4 Infinity (byte()) sum((byte) sum::a , (byte) sum::b) (byte) sum::a (byte) sum::a#2 zp byte:2 2.0 @@ -444,10 +469,11 @@ B3: // [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ] // zpby1=zpby2 lda 2 sta 5 - // [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] // aby=zpby1_plus_zpby2 + // [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] // zpby1=zpby1_plus_zpby2 lda 4 clc adc 5 + sta 4 jmp BEND BEND: sum: @@ -491,10 +517,11 @@ B3: // [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ] // zpby1=zpby2 lda 2 sta 5 - // [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] // aby=zpby1_plus_zpby2 + // [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] // zpby1=zpby1_plus_zpby2 lda 4 clc adc 5 + sta 4 BEND: sum: // [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] // zpby1=zpby1_plus_zpby2 @@ -515,7 +542,7 @@ FINAL SYMBOL TABLE (byte) s2 (byte) s2#0 zp byte:5 4.0 (byte) s3 -(byte) s3#0 reg byte a Infinity +(byte) s3#0 zp byte:4 Infinity (byte()) sum((byte) sum::a , (byte) sum::b) (label) sum::@return (byte) sum::a @@ -555,10 +582,11 @@ B3: // [3] (byte) s2#0 ← (byte) sum::return#0 [ s1#0 s2#0 ] // zpby1=zpby2 lda 2 sta 5 - // [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] // aby=zpby1_plus_zpby2 + // [4] (byte) s3#0 ← (byte) s1#0 + (byte) s2#0 [ ] // zpby1=zpby1_plus_zpby2 lda 4 clc adc 5 + sta 4 BEND: sum: // [6] (byte) sum::return#0 ← (byte) sum::a#2 + (byte) sum::b#2 [ sum::return#0 s1#0 ] // zpby1=zpby1_plus_zpby2 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/summin.sym b/src/main/java/dk/camelot64/kickc/test/ref/summin.sym index 47de49fc0..b10300081 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/summin.sym +++ b/src/main/java/dk/camelot64/kickc/test/ref/summin.sym @@ -7,7 +7,7 @@ (byte) s2 (byte) s2#0 zp byte:5 4.0 (byte) s3 -(byte) s3#0 reg byte a Infinity +(byte) s3#0 zp byte:4 Infinity (byte()) sum((byte) sum::a , (byte) sum::b) (label) sum::@return (byte) sum::a diff --git a/src/main/java/dk/camelot64/kickc/test/ref/useglobal.asm b/src/main/java/dk/camelot64/kickc/test/ref/useglobal.asm new file mode 100644 index 000000000..47f737e4a --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/test/ref/useglobal.asm @@ -0,0 +1,8 @@ +BBEGIN: + jsr main +BEND: +main: + lda #1 + sta 1024 +main__Breturn: + rts diff --git a/src/main/java/dk/camelot64/kickc/test/ref/useglobal.cfg b/src/main/java/dk/camelot64/kickc/test/ref/useglobal.cfg new file mode 100644 index 000000000..3e6cabbbc --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/test/ref/useglobal.cfg @@ -0,0 +1,10 @@ +@BEGIN: from + [0] call main param-assignment [ ] + to:@END +@END: from @BEGIN +main: from @BEGIN + [1] *((word) 1024) ← (byte) 1 [ ] + to:main::@return +main::@return: from main + [2] return [ ] + to:@RETURN diff --git a/src/main/java/dk/camelot64/kickc/test/ref/useglobal.log b/src/main/java/dk/camelot64/kickc/test/ref/useglobal.log new file mode 100644 index 000000000..bd6e4e040 --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/test/ref/useglobal.log @@ -0,0 +1,261 @@ +// Tests procedures using global variables (should not fail) +byte* SCREEN = $0400; +main(); +void main() { + *SCREEN = 1; +} +PROGRAM + (byte*) SCREEN ← (word) 1024 + (void~) $0 ← call main + proc (void()) main() + *((byte*) SCREEN) ← (byte) 1 +main::@return: + return + endproc // main() + +SYMBOLS +(void~) $0 +(byte*) SCREEN +(void()) main() +(label) main::@return + +INITIAL CONTROL FLOW GRAPH +@BEGIN: from + (byte*) SCREEN ← (word) 1024 + (void~) $0 ← call main + to:@1 +main: from + *((byte*) SCREEN) ← (byte) 1 + to:main::@return +main::@return: from main + return + to:@RETURN +@1: from @BEGIN + to:@END +@END: from @1 + +Removing empty block @1 +CONTROL FLOW GRAPH +@BEGIN: from + (byte*) SCREEN ← (word) 1024 + (void~) $0 ← call main + to:@END +main: from + *((byte*) SCREEN) ← (byte) 1 + to:main::@return +main::@return: from main + return + to:@RETURN +@END: from @BEGIN + +CONTROL FLOW GRAPH WITH ASSIGNMENT CALL +@BEGIN: from + (byte*) SCREEN ← (word) 1024 + call main param-assignment + to:@2 +@2: from @BEGIN + to:@END +main: from @BEGIN + *((byte*) SCREEN) ← (byte) 1 + to:main::@return +main::@return: from main + return + to:@RETURN +@END: from @2 + +Completing Phi functions... +CONTROL FLOW GRAPH SSA +@BEGIN: from + (byte*) SCREEN#0 ← (word) 1024 + call main param-assignment + to:@2 +@2: from @BEGIN + to:@END +main: from @BEGIN + (byte*) SCREEN#1 ← phi( @BEGIN/(byte*) SCREEN#0 ) + *((byte*) SCREEN#1) ← (byte) 1 + to:main::@return +main::@return: from main + return + to:@RETURN +@END: from @2 + +CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN +@BEGIN: from + (byte*) SCREEN#0 ← (word) 1024 + call main param-assignment + to:@2 +@2: from @BEGIN + to:@END +main: from @BEGIN + (byte*) SCREEN#1 ← phi( @BEGIN/(byte*) SCREEN#0 ) + *((byte*) SCREEN#1) ← (byte) 1 + to:main::@return +main::@return: from main + return + to:@RETURN +@END: from @2 + +Culled Empty Block (label) @2 +Succesful SSA optimization Pass2CullEmptyBlocks +CONTROL FLOW GRAPH +@BEGIN: from + (byte*) SCREEN#0 ← (word) 1024 + call main param-assignment + to:@END +main: from @BEGIN + (byte*) SCREEN#1 ← phi( @BEGIN/(byte*) SCREEN#0 ) + *((byte*) SCREEN#1) ← (byte) 1 + to:main::@return +main::@return: from main + return + to:@RETURN +@END: from @BEGIN + +Constant (byte*) SCREEN#0 (word) 1024 +Succesful SSA optimization Pass2ConstantPropagation +CONTROL FLOW GRAPH +@BEGIN: from + call main param-assignment + to:@END +main: from @BEGIN + (byte*) SCREEN#1 ← phi( @BEGIN/(word) 1024 ) + *((byte*) SCREEN#1) ← (byte) 1 + to:main::@return +main::@return: from main + return + to:@RETURN +@END: from @BEGIN + +Redundant Phi (byte*) SCREEN#1 (word) 1024 +Succesful SSA optimization Pass2RedundantPhiElimination +CONTROL FLOW GRAPH +@BEGIN: from + call main param-assignment + to:@END +main: from @BEGIN + *((word) 1024) ← (byte) 1 + to:main::@return +main::@return: from main + return + to:@RETURN +@END: from @BEGIN + +Block Sequence Planned @BEGIN @END main main::@return +Block Sequence Planned @BEGIN @END main main::@return +CONTROL FLOW GRAPH - PHI LIFTED +@BEGIN: from + call main param-assignment + to:@END +@END: from @BEGIN +main: from @BEGIN + *((word) 1024) ← (byte) 1 + to:main::@return +main::@return: from main + return + to:@RETURN + +Propagating live ranges... +CONTROL FLOW GRAPH - LIVE RANGES +@BEGIN: from + [0] call main param-assignment [ ] + to:@END +@END: from @BEGIN +main: from @BEGIN + [1] *((word) 1024) ← (byte) 1 [ ] + to:main::@return +main::@return: from main + [2] return [ ] + to:@RETURN + +Created 0 initial phi equivalence classes +Coalesced down to 0 phi equivalence classes +Block Sequence Planned @BEGIN @END main main::@return +Propagating live ranges... +CONTROL FLOW GRAPH - PHI MEM COALESCED +@BEGIN: from + [0] call main param-assignment [ ] + to:@END +@END: from @BEGIN +main: from @BEGIN + [1] *((word) 1024) ← (byte) 1 [ ] + to:main::@return +main::@return: from main + [2] return [ ] + to:@RETURN + +CALL GRAPH +Calls in [] to 0:main + +DOMINATORS +@BEGIN dominated by @BEGIN +@END dominated by @BEGIN @END +main dominated by @BEGIN main +main::@return dominated by @BEGIN main::@return main + +NATURAL LOOPS + +Found 0 loops in scope [] +Found 0 loops in scope [main] +NATURAL LOOPS WITH DEPTH + +Initial phi equivalence classes +Copy Coalesced equivalence classes +Complete equivalence classes + +VARIABLE REGISTER WEIGHTS +(byte*) SCREEN +(void()) main() + + +REGISTER UPLIFTING +(byte*) SCREEN +(void()) main() + + +INITIAL ASM +BBEGIN: + jsr main + jmp BEND +BEND: +main: + // [1] *((word) 1024) ← (byte) 1 [ ] // _star_cowo1=coby2 + lda #1 + sta 1024 + jmp main__Breturn +main__Breturn: + rts + +Removing instruction jmp BEND +Removing instruction jmp main__Breturn +Succesful ASM optimization Pass5NextJumpElimination +ASSEMBLER +BBEGIN: + jsr main +BEND: +main: + // [1] *((word) 1024) ← (byte) 1 [ ] // _star_cowo1=coby2 + lda #1 + sta 1024 +main__Breturn: + rts + +FINAL SYMBOL TABLE +(label) @BEGIN +(label) @END +(byte*) SCREEN +(void()) main() +(label) main::@return + + +FINAL CODE +BBEGIN: + jsr main +BEND: +main: + // [1] *((word) 1024) ← (byte) 1 [ ] // _star_cowo1=coby2 + lda #1 + sta 1024 +main__Breturn: + rts + diff --git a/src/main/java/dk/camelot64/kickc/test/ref/useglobal.sym b/src/main/java/dk/camelot64/kickc/test/ref/useglobal.sym new file mode 100644 index 000000000..46563cb31 --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/test/ref/useglobal.sym @@ -0,0 +1,6 @@ +(label) @BEGIN +(label) @END +(byte*) SCREEN +(void()) main() +(label) main::@return +