From df62ca5c9f194355b580184b0e90b3a54ad43f4a Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sat, 12 Dec 2020 00:02:55 +0100 Subject: [PATCH] Merged improved integer type inference by @tfisher98. Closes !2, #594, #334, #199 --- src/test/ref/bitwise-not-1.asm | 13 ++++ src/test/ref/bitwise-not-1.cfg | 8 ++ src/test/ref/bitwise-not-1.log | 130 +++++++++++++++++++++++++++++++++ src/test/ref/bitwise-not-1.sym | 4 + 4 files changed, 155 insertions(+) create mode 100644 src/test/ref/bitwise-not-1.asm create mode 100644 src/test/ref/bitwise-not-1.cfg create mode 100644 src/test/ref/bitwise-not-1.log create mode 100644 src/test/ref/bitwise-not-1.sym diff --git a/src/test/ref/bitwise-not-1.asm b/src/test/ref/bitwise-not-1.asm new file mode 100644 index 000000000..1977c04a0 --- /dev/null +++ b/src/test/ref/bitwise-not-1.asm @@ -0,0 +1,13 @@ +// Test that bitwise NOT (~) is handled correctly +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +main: { + .const b = $10^$ff + .label screen = $400 + // *screen = b + lda #b + sta screen + // } + rts +} diff --git a/src/test/ref/bitwise-not-1.cfg b/src/test/ref/bitwise-not-1.cfg new file mode 100644 index 000000000..69029a34c --- /dev/null +++ b/src/test/ref/bitwise-not-1.cfg @@ -0,0 +1,8 @@ + +void main() +main: scope:[main] from + [0] *main::screen = main::b + to:main::@return +main::@return: scope:[main] from main + [1] return + to:@return diff --git a/src/test/ref/bitwise-not-1.log b/src/test/ref/bitwise-not-1.log new file mode 100644 index 000000000..95835ecc7 --- /dev/null +++ b/src/test/ref/bitwise-not-1.log @@ -0,0 +1,130 @@ + +CONTROL FLOW GRAPH SSA + +void main() +main: scope:[main] from __start + *main::screen = main::b + to:main::@return +main::@return: scope:[main] from main + return + to:@return + +void __start() +__start: scope:[__start] from + call main + to:__start::@1 +__start::@1: scope:[__start] from __start + to:__start::@return +__start::@return: scope:[__start] from __start::@1 + return + to:@return + +SYMBOL TABLE SSA +void __start() +void main() +const byte main::b = (byte)~$10 +const nomodify byte* main::screen = (byte*)$400 + +Simplifying constant pointer cast (byte*) 1024 +Successful SSA optimization PassNCastSimplification +Removing unused procedure __start +Removing unused procedure block __start +Removing unused procedure block __start::@1 +Removing unused procedure block __start::@return +Successful SSA optimization PassNEliminateEmptyStart +Finalized unsigned number type (byte) $10 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Simplifying constant integer cast ~$10 +Successful SSA optimization PassNCastSimplification +CALL GRAPH + +Created 0 initial phi equivalence classes +Coalesced down to 0 phi equivalence classes + +FINAL CONTROL FLOW GRAPH + +void main() +main: scope:[main] from + [0] *main::screen = main::b + to:main::@return +main::@return: scope:[main] from main + [1] return + to:@return + + +VARIABLE REGISTER WEIGHTS +void main() + +Initial phi equivalence classes +Complete equivalence classes +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [0] *main::screen = main::b [ ] ( [ ] { } ) always clobbers reg byte a + +REGISTER UPLIFT SCOPES +Uplift Scope [main] +Uplift Scope [] + +Uplifting [main] best 15 combination +Uplifting [] best 15 combination + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Test that bitwise NOT (~) is handled correctly + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + // main +main: { + .const b = $10^$ff + .label screen = $400 + // [0] *main::screen = main::b -- _deref_pbuc1=vbuc2 + lda #b + sta screen + jmp __breturn + // main::@return + __breturn: + // [1] return + rts +} + // File Data + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp __breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction __breturn: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +void main() +const byte main::b = ~$10 +const nomodify byte* main::screen = (byte*) 1024 + + + +FINAL ASSEMBLER +Score: 12 + + // File Comments +// Test that bitwise NOT (~) is handled correctly + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + // main +main: { + .const b = $10^$ff + .label screen = $400 + // *screen = b + // [0] *main::screen = main::b -- _deref_pbuc1=vbuc2 + lda #b + sta screen + // main::@return + // } + // [1] return + rts +} + // File Data + diff --git a/src/test/ref/bitwise-not-1.sym b/src/test/ref/bitwise-not-1.sym new file mode 100644 index 000000000..0697341a1 --- /dev/null +++ b/src/test/ref/bitwise-not-1.sym @@ -0,0 +1,4 @@ +void main() +const byte main::b = ~$10 +const nomodify byte* main::screen = (byte*) 1024 +