1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-08 17:54:40 +00:00

Implemented sizeof() for structs - including values and arrays.

This commit is contained in:
jespergravgaard 2019-06-10 11:59:40 +02:00
parent 869ce161be
commit 54679cee8b
17 changed files with 1388 additions and 455 deletions

View File

@ -168,6 +168,7 @@ public class Compiler {
new Pass1AssertReturn(program).execute();
new Pass1AssertUsedVars(program).execute();
new PassNSizeOfSimplification(program).execute();
new Pass1UnwindStructValues(program).execute();
if(getLog().isVerbosePass1CreateSsa()) {
@ -260,7 +261,7 @@ public class Compiler {
optimizations.add(new PassNAddTypeConversionAssignment(program));
optimizations.add(new PassNTypeIdSimplification(program));
optimizations.add(new Pass2SizeOfSimplification(program));
optimizations.add(new PassNSizeOfSimplification(program));
optimizations.add(new PassNStatementIndices(program));
optimizations.add(new PassNVariableReferenceInfos(program));
optimizations.add(new Pass2UnaryNotSimplification(program));

View File

@ -22,9 +22,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
/**
* Simplifies sizeof() operators whenever the expression is constant
*/
public class Pass2SizeOfSimplification extends Pass2SsaOptimization {
public class PassNSizeOfSimplification extends Pass2SsaOptimization {
public Pass2SizeOfSimplification(Program program) {
public PassNSizeOfSimplification(Program program) {
super(program);
}

View File

@ -529,6 +529,16 @@ public class TestPrograms {
compileAndCompare("word-array-0");
}
@Test
public void testSizeofStruct() throws IOException, URISyntaxException {
compileAndCompare("sizeof-struct");
}
@Test
public void testSizeofArrays() throws IOException, URISyntaxException {
compileAndCompare("sizeof-arrays");
}
@Test
public void testSizeofExpression() throws IOException, URISyntaxException {
compileAndCompare("sizeof-expr");

View File

@ -0,0 +1,29 @@
// Tests the sizeof() operator on arrays
const byte* SCREEN = $400;
void main() {
byte idx = 0;
// Arrays
byte[3] ba;
SCREEN[idx++] = '0'+sizeof(ba)/sizeof(byte);
word[3] wa;
SCREEN[idx++] = '0'+sizeof(wa)/sizeof(word);
byte sz = 7;
byte[sz+2] bb;
SCREEN[idx++] = '0'+sizeof(bb)/sizeof(byte);
word[] wb = { 1, 2, 3, 4 };
SCREEN[idx++] = '0'+sizeof(wb)/sizeof(word);
byte[] sa = "camelot";
SCREEN[idx++] = '0'+sizeof(sa)/sizeof(byte);
byte[] sb = { 'a', 'b', 'c', 0};
SCREEN[idx++] = '0'+sizeof(sb)/sizeof(byte);
}

View File

@ -1,4 +1,4 @@
// Tests the sizeof() operator on epressions
// Tests the sizeof() operator on values/expressions
const byte* SCREEN = $400;
@ -11,15 +11,6 @@ void main() {
// Pointers
byte* bp = $1000;
word* wp = &w;
// Arrays
byte[3] ba;
word[3] wa;
byte sz = 15;
byte[sz+2] bb;
byte[] bc = { 1, 2, 3, 4 };
// Strings
byte[] sa = "camelot";
//byte[] sb = { 'a', 'b', 'c', 0};
SCREEN[idx++] = '0'+sizeof(0);
SCREEN[idx++] = '0'+sizeof(idx);
@ -31,12 +22,5 @@ void main() {
idx++;
SCREEN[idx++] = '0'+sizeof(bp);
SCREEN[idx++] = '0'+sizeof(wp);
idx++;
SCREEN[idx++] = '0'+sizeof(ba);
SCREEN[idx++] = '0'+sizeof(wa);
SCREEN[idx++] = '0'+sizeof(bb);
SCREEN[idx++] = '0'+sizeof(bc);
SCREEN[idx++] = '0'+sizeof(sa);
//SCREEN[idx++] = '0'+sizeof(sb);
}

View File

@ -0,0 +1,38 @@
// Tests the sizeof() operator on structs
struct Point {
byte x;
byte y;
};
struct Circle {
struct Point center;
byte radius;
};
const byte* SCREEN = $400;
void main() {
byte idx = 0;
// Struct Types
SCREEN[idx++] = '0'+sizeof(struct Point);
SCREEN[idx++] = '0'+sizeof(struct Circle);
idx++;
// Struct Values
struct Point p;
SCREEN[idx++] = '0'+sizeof(p);
struct Circle c;
SCREEN[idx++] = '0'+sizeof(c);
idx++;
// Struct Array
const byte NUM_POINTS = 4;
struct Point[NUM_POINTS] points;
SCREEN[idx++] = '0'+sizeof(points);
const byte NUM_CIRCLES = NUM_POINTS-1;
struct Point[NUM_CIRCLES] circles;
SCREEN[idx++] = '0'+sizeof(circles);
}

View File

@ -0,0 +1,23 @@
// Tests the sizeof() operator on arrays
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.const SIZEOF_BYTE = 1
.const SIZEOF_WORD = 2
.label SCREEN = $400
main: {
.const sz = 7
lda #'0'+3*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN
lda #'0'+3*SIZEOF_WORD/SIZEOF_WORD
sta SCREEN+1
lda #'0'+(sz+2)*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN+2
lda #'0'+4*SIZEOF_WORD/SIZEOF_WORD
sta SCREEN+3
lda #'0'+8*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN+4
lda #'0'+4*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN+5
rts
}

View File

@ -0,0 +1,20 @@
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] *((const byte*) SCREEN#0) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
[5] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD
[6] *((const byte*) SCREEN#0+(byte) 2) ← (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
[7] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD
[8] *((const byte*) SCREEN#0+(byte) 4) ← (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
[9] *((const byte*) SCREEN#0+(byte) 5) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
to:main::@return
main::@return: scope:[main] from main
[10] return
to:@return

View File

@ -0,0 +1,561 @@
Adding pointer type conversion cast (byte*) SCREEN in (byte*) SCREEN ← (number) $400
Identified constant variable (byte) main::sz
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte*) SCREEN#0 ← ((byte*)) (number) $400
to:@1
main: scope:[main] from @1
(byte) main::idx#0 ← (number) 0
(byte[3]) main::ba#0 ← { fill( 3, 0) }
(byte~) main::$0 ← sizeof (byte[3]) main::ba#0
(byte~) main::$1 ← (byte~) main::$0 / (const byte) SIZEOF_BYTE
(byte~) main::$2 ← (byte) '0' + (byte~) main::$1
*((byte*) SCREEN#0 + (byte) main::idx#0) ← (byte~) main::$2
(byte) main::idx#1 ← ++ (byte) main::idx#0
(word[3]) main::wa#0 ← { fill( 3, 0) }
(byte~) main::$3 ← sizeof (word[3]) main::wa#0
(byte~) main::$4 ← (byte~) main::$3 / (const byte) SIZEOF_WORD
(byte~) main::$5 ← (byte) '0' + (byte~) main::$4
*((byte*) SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$5
(byte) main::idx#2 ← ++ (byte) main::idx#1
(byte) main::sz#0 ← (number) 7
(number~) main::$6 ← (byte) main::sz#0 + (number) 2
(byte[main::$6]) main::bb#0 ← { fill( main::$6, 0) }
(byte~) main::$7 ← sizeof (byte[main::$6]) main::bb#0
(byte~) main::$8 ← (byte~) main::$7 / (const byte) SIZEOF_BYTE
(byte~) main::$9 ← (byte) '0' + (byte~) main::$8
*((byte*) SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$9
(byte) main::idx#3 ← ++ (byte) main::idx#2
(word[]) main::wb#0 ← { (number) 1, (number) 2, (number) 3, (number) 4 }
(byte~) main::$10 ← sizeof (word[]) main::wb#0
(byte~) main::$11 ← (byte~) main::$10 / (const byte) SIZEOF_WORD
(byte~) main::$12 ← (byte) '0' + (byte~) main::$11
*((byte*) SCREEN#0 + (byte) main::idx#3) ← (byte~) main::$12
(byte) main::idx#4 ← ++ (byte) main::idx#3
(byte[]) main::sa#0 ← (const string) main::$19
(byte~) main::$13 ← sizeof (byte[]) main::sa#0
(byte~) main::$14 ← (byte~) main::$13 / (const byte) SIZEOF_BYTE
(byte~) main::$15 ← (byte) '0' + (byte~) main::$14
*((byte*) SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$15
(byte) main::idx#5 ← ++ (byte) main::idx#4
(byte[]) main::sb#0 ← { (byte) 'a', (byte) 'b', (byte) 'c', (number) 0 }
(byte~) main::$16 ← sizeof (byte[]) main::sb#0
(byte~) main::$17 ← (byte~) main::$16 / (const byte) SIZEOF_BYTE
(byte~) main::$18 ← (byte) '0' + (byte~) main::$17
*((byte*) SCREEN#0 + (byte) main::idx#5) ← (byte~) main::$18
(byte) main::idx#6 ← ++ (byte) main::idx#5
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@1: scope:[] from @begin
call main
to:@2
@2: scope:[] from @1
to:@end
@end: scope:[] from @2
SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(const byte) SIZEOF_BYTE = (byte) 1
(const byte) SIZEOF_WORD = (byte) 2
(void()) main()
(byte~) main::$0
(byte~) main::$1
(byte~) main::$10
(byte~) main::$11
(byte~) main::$12
(byte~) main::$13
(byte~) main::$14
(byte~) main::$15
(byte~) main::$16
(byte~) main::$17
(byte~) main::$18
(const string) main::$19 = (string) "camelot@"
(byte~) main::$2
(byte~) main::$3
(byte~) main::$4
(byte~) main::$5
(number~) main::$6
(byte~) main::$7
(byte~) main::$8
(byte~) main::$9
(label) main::@return
(byte[3]) main::ba
(byte[3]) main::ba#0
(byte[main::$6]) main::bb
(byte[main::$6]) main::bb#0
(byte) main::idx
(byte) main::idx#0
(byte) main::idx#1
(byte) main::idx#2
(byte) main::idx#3
(byte) main::idx#4
(byte) main::idx#5
(byte) main::idx#6
(byte[]) main::sa
(byte[]) main::sa#0
(byte[]) main::sb
(byte[]) main::sb#0
(byte) main::sz
(byte) main::sz#0
(word[3]) main::wa
(word[3]) main::wa#0
(word[]) main::wb
(word[]) main::wb#0
Adding number conversion cast (unumber) 0 in (byte) main::idx#0 ← (number) 0
Adding number conversion cast (unumber) 7 in (byte) main::sz#0 ← (number) 7
Adding number conversion cast (unumber) 2 in (number~) main::$6 ← (byte) main::sz#0 + (number) 2
Adding number conversion cast (unumber) main::$6 in (number~) main::$6 ← (byte) main::sz#0 + (unumber)(number) 2
Successful SSA optimization PassNAddNumberTypeConversions
Adding number conversion cast (word) to elements in (word[]) main::wb#0 ← { (word)(number) 1, (word)(number) 2, (word)(number) 3, (word)(number) 4 }
Adding number conversion cast (byte) to elements in (byte[]) main::sb#0 ← { (byte) 'a', (byte) 'b', (byte) 'c', (byte)(number) 0 }
Successful SSA optimization PassNAddArrayNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte) main::idx#0 ← (unumber)(number) 0
Inlining cast (byte) main::sz#0 ← (unumber)(number) 7
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 7
Simplifying constant integer cast 2
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Simplifying constant integer cast 4
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 7
Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$6 ← (byte) main::sz#0 + (byte) 2
Constant right-side identified [2] (byte[3]) main::ba#0 ← { fill( 3, 0) }
Constant right-side identified [8] (word[3]) main::wa#0 ← { fill( 3, 0) }
Constant right-side identified [22] (word[]) main::wb#0 ← { (word) 1, (word) 2, (word) 3, (word) 4 }
Constant right-side identified [34] (byte[]) main::sb#0 ← { (byte) 'a', (byte) 'b', (byte) 'c', (byte) 0 }
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte) main::idx#0 = 0
Constant (const byte[3]) main::ba#0 = { fill( 3, 0) }
Constant (const word[3]) main::wa#0 = { fill( 3, 0) }
Constant (const byte) main::sz#0 = 7
Constant (const word[]) main::wb#0 = { 1, 2, 3, 4 }
Constant (const byte[]) main::sa#0 = main::$19
Constant (const byte[]) main::sb#0 = { 'a', 'b', 'c', 0 }
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero SCREEN#0 in [6] *((const byte*) SCREEN#0 + (const byte) main::idx#0) ← (byte~) main::$2
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (byte) main::idx#6 and assignment [31] (byte) main::idx#6 ← ++ (byte) main::idx#5
Successful SSA optimization PassNEliminateUnusedVars
Constant right-side identified [0] (byte~) main::$0 ← sizeof (const byte[3]) main::ba#0
Constant right-side identified [4] (byte) main::idx#1 ← ++ (const byte) main::idx#0
Constant right-side identified [5] (byte~) main::$3 ← sizeof (const word[3]) main::wa#0
Constant right-side identified [10] (byte~) main::$6 ← (const byte) main::sz#0 + (byte) 2
Constant right-side identified [17] (byte~) main::$10 ← sizeof (const word[]) main::wb#0
Constant right-side identified [22] (byte~) main::$13 ← sizeof (const byte[]) main::sa#0
Constant right-side identified [27] (byte~) main::$16 ← sizeof (const byte[]) main::sb#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::$0 = sizeof main::ba#0
Constant (const byte) main::idx#1 = ++main::idx#0
Constant (const byte) main::$3 = sizeof main::wa#0
Constant (const byte) main::$6 = main::sz#0+2
Constant (const byte) main::$10 = sizeof main::wb#0
Constant (const byte) main::$13 = sizeof main::sa#0
Constant (const byte) main::$16 = sizeof main::sb#0
Successful SSA optimization Pass2ConstantIdentification
Constant value identified { fill( main::$6, 0) } in [11] (byte[main::$6]) main::bb#0 ← { fill( main::$6, 0) }
Successful SSA optimization Pass2ConstantValues
Resolving array sizeof() sizeof (const byte[3]) main::ba#0
Resolving array sizeof() sizeof (const word[3]) main::wa#0
Resolving array sizeof() sizeof (const word[]) main::wb#0
Resolving string sizeof() sizeof (const byte[]) main::sa#0
Resolving array sizeof() sizeof (const byte[]) main::sb#0
Successful SSA optimization PassNSizeOfSimplification
Constant right-side identified [0] (byte~) main::$1 ← (const byte) main::$0 / (const byte) SIZEOF_BYTE
Constant right-side identified [3] (byte~) main::$4 ← (const byte) main::$3 / (const byte) SIZEOF_WORD
Constant right-side identified [6] (byte) main::idx#2 ← ++ (const byte) main::idx#1
Constant right-side identified [13] (byte~) main::$11 ← (const byte) main::$10 / (const byte) SIZEOF_WORD
Constant right-side identified [17] (byte~) main::$14 ← (const byte) main::$13 / (const byte) SIZEOF_BYTE
Constant right-side identified [21] (byte~) main::$17 ← (const byte) main::$16 / (const byte) SIZEOF_BYTE
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::$1 = main::$0/SIZEOF_BYTE
Constant (const byte) main::$4 = main::$3/SIZEOF_WORD
Constant (const byte) main::idx#2 = ++main::idx#1
Constant (const byte[main::$6]) main::bb#0 = { fill( main::$6, 0) }
Constant (const byte) main::$11 = main::$10/SIZEOF_WORD
Constant (const byte) main::$14 = main::$13/SIZEOF_BYTE
Constant (const byte) main::$17 = main::$16/SIZEOF_BYTE
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant (const byte[3]) main::ba#0
Eliminating unused constant (const word[3]) main::wa#0
Eliminating unused constant (const word[]) main::wb#0
Eliminating unused constant (const byte[]) main::sa#0
Eliminating unused constant (const byte[]) main::sb#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const string) main::$19
Successful SSA optimization PassNEliminateUnusedVars
Adding number conversion cast (unumber) 3 in
Adding number conversion cast (unumber) 3 in
Adding number conversion cast (unumber) 4 in
Adding number conversion cast (unumber) 8 in
Adding number conversion cast (unumber) 4 in
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 3
Simplifying constant integer cast 3
Simplifying constant integer cast 4
Simplifying constant integer cast 8
Simplifying constant integer cast 4
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) 8
Finalized unsigned number type (byte) 4
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [0] (byte~) main::$2 ← (byte) '0' + (const byte) main::$1
Constant right-side identified [2] (byte~) main::$5 ← (byte) '0' + (const byte) main::$4
Constant right-side identified [4] (byte~) main::$7 ← sizeof (const byte[main::$6]) main::bb#0
Constant right-side identified [8] (byte) main::idx#3 ← ++ (const byte) main::idx#2
Constant right-side identified [9] (byte~) main::$12 ← (byte) '0' + (const byte) main::$11
Constant right-side identified [12] (byte~) main::$15 ← (byte) '0' + (const byte) main::$14
Constant right-side identified [15] (byte~) main::$18 ← (byte) '0' + (const byte) main::$17
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::$2 = '0'+main::$1
Constant (const byte) main::$5 = '0'+main::$4
Constant (const byte) main::$7 = sizeof main::bb#0
Constant (const byte) main::idx#3 = ++main::idx#2
Constant (const byte) main::$12 = '0'+main::$11
Constant (const byte) main::$15 = '0'+main::$14
Constant (const byte) main::$18 = '0'+main::$17
Successful SSA optimization Pass2ConstantIdentification
Resolving array sizeof() sizeof (const byte[main::$6]) main::bb#0
Successful SSA optimization PassNSizeOfSimplification
Constant right-side identified [2] (byte~) main::$8 ← (const byte) main::$7 / (const byte) SIZEOF_BYTE
Constant right-side identified [6] (byte) main::idx#4 ← ++ (const byte) main::idx#3
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::$8 = main::$7/SIZEOF_BYTE
Constant (const byte) main::idx#4 = ++main::idx#3
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant (const byte[main::$6]) main::bb#0
Successful SSA optimization PassNEliminateUnusedVars
Constant right-side identified [2] (byte~) main::$9 ← (byte) '0' + (const byte) main::$8
Constant right-side identified [6] (byte) main::idx#5 ← ++ (const byte) main::idx#4
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::$9 = '0'+main::$8
Constant (const byte) main::idx#5 = ++main::idx#4
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings (const byte) main::idx#0
Inlining constant with different constant siblings (const byte) main::idx#1
Inlining constant with different constant siblings (const byte) main::idx#2
Inlining constant with different constant siblings (const byte) main::idx#3
Inlining constant with different constant siblings (const byte) main::idx#4
Inlining constant with different constant siblings (const byte) main::idx#5
Constant inlined main::$12 = (byte) '0'+(byte) 4*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD
Constant inlined main::$13 = (byte) 8*(const byte) SIZEOF_BYTE
Constant inlined main::$14 = (byte) 8*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
Constant inlined main::$15 = (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
Constant inlined main::$10 = (byte) 4*(const byte) SIZEOF_WORD
Constant inlined main::$11 = (byte) 4*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD
Constant inlined main::$16 = (byte) 4*(const byte) SIZEOF_BYTE
Constant inlined main::$17 = (byte) 4*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
Constant inlined main::$18 = (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
Constant inlined main::idx#0 = (byte) 0
Constant inlined main::idx#1 = ++(byte) 0
Constant inlined main::idx#2 = ++++(byte) 0
Constant inlined main::$1 = (byte) 3*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
Constant inlined main::idx#3 = ++++++(byte) 0
Constant inlined main::$2 = (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
Constant inlined main::idx#4 = ++++++++(byte) 0
Constant inlined main::idx#5 = ++++++++++(byte) 0
Constant inlined main::$0 = (byte) 3*(const byte) SIZEOF_BYTE
Constant inlined main::$5 = (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD
Constant inlined main::$6 = (const byte) main::sz#0+(byte) 2
Constant inlined main::$3 = (byte) 3*(const byte) SIZEOF_WORD
Constant inlined main::$4 = (byte) 3*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD
Constant inlined main::$9 = (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
Constant inlined main::$7 = (const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE
Constant inlined main::$8 = (const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(SCREEN#0+++0)
Consolidated array index constant in *(SCREEN#0+++++0)
Consolidated array index constant in *(SCREEN#0+++++++0)
Consolidated array index constant in *(SCREEN#0+++++++++0)
Consolidated array index constant in *(SCREEN#0+++++++++++0)
Successful SSA optimization Pass2ConstantAdditionElimination
Simplifying constant integer increment ++0
Simplifying constant integer increment ++0
Simplifying constant integer increment ++1
Simplifying constant integer increment ++2
Simplifying constant integer increment ++3
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer increment ++1
Simplifying constant integer increment ++2
Simplifying constant integer increment ++3
Simplifying constant integer increment ++4
Successful SSA optimization Pass2ConstantSimplification
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:2
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] *((const byte*) SCREEN#0) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
[5] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD
[6] *((const byte*) SCREEN#0+(byte) 2) ← (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
[7] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD
[8] *((const byte*) SCREEN#0+(byte) 4) ← (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
[9] *((const byte*) SCREEN#0+(byte) 5) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE
to:main::@return
main::@return: scope:[main] from main
[10] return
to:@return
VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(void()) main()
(byte[3]) main::ba
(byte[main::sz#0+2]) main::bb
(byte) main::idx
(byte[]) main::sa
(byte[]) main::sb
(byte) main::sz
(word[3]) main::wa
(word[]) main::wb
Initial phi equivalence classes
Complete equivalence classes
INITIAL ASM
//SEG0 File Comments
// Tests the sizeof() operator on arrays
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
.const SIZEOF_BYTE = 1
.const SIZEOF_WORD = 2
.label SCREEN = $400
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
.const sz = 7
//SEG10 [4] *((const byte*) SCREEN#0) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+3*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN
//SEG11 [5] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
lda #'0'+3*SIZEOF_WORD/SIZEOF_WORD
sta SCREEN+1
//SEG12 [6] *((const byte*) SCREEN#0+(byte) 2) ← (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+(sz+2)*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN+2
//SEG13 [7] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
lda #'0'+4*SIZEOF_WORD/SIZEOF_WORD
sta SCREEN+3
//SEG14 [8] *((const byte*) SCREEN#0+(byte) 4) ← (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+8*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN+4
//SEG15 [9] *((const byte*) SCREEN#0+(byte) 5) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+4*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN+5
jmp breturn
//SEG16 main::@return
breturn:
//SEG17 [10] return
rts
}
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) SCREEN#0) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [5] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [6] *((const byte*) SCREEN#0+(byte) 2) ← (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [8] *((const byte*) SCREEN#0+(byte) 4) ← (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [9] *((const byte*) SCREEN#0+(byte) 5) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
REGISTER UPLIFT SCOPES
Uplift Scope [main]
Uplift Scope []
Uplifting [main] best 57 combination
Uplifting [] best 57 combination
ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
// Tests the sizeof() operator on arrays
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
.const SIZEOF_BYTE = 1
.const SIZEOF_WORD = 2
.label SCREEN = $400
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
.const sz = 7
//SEG10 [4] *((const byte*) SCREEN#0) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+3*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN
//SEG11 [5] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
lda #'0'+3*SIZEOF_WORD/SIZEOF_WORD
sta SCREEN+1
//SEG12 [6] *((const byte*) SCREEN#0+(byte) 2) ← (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+(sz+2)*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN+2
//SEG13 [7] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
lda #'0'+4*SIZEOF_WORD/SIZEOF_WORD
sta SCREEN+3
//SEG14 [8] *((const byte*) SCREEN#0+(byte) 4) ← (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+8*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN+4
//SEG15 [9] *((const byte*) SCREEN#0+(byte) 5) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+4*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN+5
jmp breturn
//SEG16 main::@return
breturn:
//SEG17 [10] return
rts
}
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(const byte) SIZEOF_BYTE SIZEOF_BYTE = (byte) 1
(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2
(void()) main()
(label) main::@return
(byte[3]) main::ba
(byte[main::sz#0+2]) main::bb
(byte) main::idx
(byte[]) main::sa
(byte[]) main::sb
(byte) main::sz
(const byte) main::sz#0 sz = (byte) 7
(word[3]) main::wa
(word[]) main::wb
FINAL ASSEMBLER
Score: 42
//SEG0 File Comments
// Tests the sizeof() operator on arrays
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
.const SIZEOF_BYTE = 1
.const SIZEOF_WORD = 2
.label SCREEN = $400
//SEG3 @begin
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG5 @1
//SEG6 [2] call main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
.const sz = 7
//SEG10 [4] *((const byte*) SCREEN#0) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+3*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN
//SEG11 [5] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
lda #'0'+3*SIZEOF_WORD/SIZEOF_WORD
sta SCREEN+1
//SEG12 [6] *((const byte*) SCREEN#0+(byte) 2) ← (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+(sz+2)*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN+2
//SEG13 [7] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_WORD/(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
lda #'0'+4*SIZEOF_WORD/SIZEOF_WORD
sta SCREEN+3
//SEG14 [8] *((const byte*) SCREEN#0+(byte) 4) ← (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+8*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN+4
//SEG15 [9] *((const byte*) SCREEN#0+(byte) 5) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE/(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+4*SIZEOF_BYTE/SIZEOF_BYTE
sta SCREEN+5
//SEG16 main::@return
//SEG17 [10] return
rts
}

View File

@ -0,0 +1 @@
program

View File

@ -1,14 +1,13 @@
// Tests the sizeof() operator on epressions
// Tests the sizeof() operator on values/expressions
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.const SIZEOF_BYTE = 1
.const SIZEOF_NUMBER = $ff
.const SIZEOF_WORD = 2
.const SIZEOF_POINTER = 2
.label SCREEN = $400
.const SIZEOF_NUMBER = $ff
main: {
.const sz = $f
.label b = 2
.label w = 3
// Simple types
@ -16,29 +15,18 @@ main: {
sta b
sta w
sta w+1
//byte[] sb = { 'a', 'b', 'c', 0};
lda #'0'+SIZEOF_NUMBER
sta SCREEN
lda #'0'+SIZEOF_BYTE
sta SCREEN+1
sta SCREEN+2
sta SCREEN+3
lda #'0'+SIZEOF_NUMBER
sta SCREEN+3
sta SCREEN+5
lda #'0'+SIZEOF_WORD
sta SCREEN+6
lda #'0'+SIZEOF_POINTER
sta SCREEN+8
sta SCREEN+9
lda #'0'+3*SIZEOF_BYTE
sta SCREEN+$b
lda #'0'+3*SIZEOF_WORD
sta SCREEN+$c
lda #'0'+(sz+2)*SIZEOF_BYTE
sta SCREEN+$d
lda #'0'+4*SIZEOF_BYTE
sta SCREEN+$e
lda #'0'+8*SIZEOF_BYTE
sta SCREEN+$f
rts
}

View File

@ -13,17 +13,12 @@ main: scope:[main] from @1
[6] *((const byte*) SCREEN#0) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[7] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE
[8] *((const byte*) SCREEN#0+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE
[9] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_BYTE
[9] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[10] *((const byte*) SCREEN#0+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[11] *((const byte*) SCREEN#0+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD
[12] *((const byte*) SCREEN#0+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER
[13] *((const byte*) SCREEN#0+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER
[14] *((const byte*) SCREEN#0+(byte) $b) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE
[15] *((const byte*) SCREEN#0+(byte) $c) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD
[16] *((const byte*) SCREEN#0+(byte) $d) ← (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE
[17] *((const byte*) SCREEN#0+(byte) $e) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE
[18] *((const byte*) SCREEN#0+(byte) $f) ← (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE
to:main::@return
main::@return: scope:[main] from main
[19] return
[14] return
to:@return

View File

@ -1,7 +1,12 @@
Resolving sizeof() (byte~) main::$3 ← sizeof (byte) main::idx
Resolving sizeof() (byte~) main::$5 ← sizeof (byte) main::b
Resolving sizeof() (byte~) main::$8 ← sizeof (number~) main::$7
Resolving sizeof() (byte~) main::$12 ← sizeof (word) main::w
Resolving sizeof() (byte~) main::$14 ← sizeof (byte*) main::bp
Resolving sizeof() (byte~) main::$16 ← sizeof (word*) main::wp
Adding pointer type conversion cast (byte*) SCREEN in (byte*) SCREEN ← (number) $400
Adding pointer type conversion cast (byte*) main::bp in (byte*) main::bp ← (number) $1000
Identified constant variable (byte*) main::bp
Identified constant variable (byte) main::sz
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
@ -11,72 +16,40 @@ main: scope:[main] from @1
(byte) main::idx#0 ← (number) 0
(byte) main::b#0 ← (number) 0
(word) main::w#0 ← (number) 0
(byte*) main::bp#0 ← ((byte*)) (number) $1000
(word*~) main::$0 ← & (word) main::w#0
(word*) main::wp#0 ← (word*~) main::$0
(byte[3]) main::ba#0 ← { fill( 3, 0) }
(word[3]) main::wa#0 ← { fill( 3, 0) }
(byte) main::sz#0 ← (number) $f
(number~) main::$1 ← (byte) main::sz#0 + (number) 2
(byte[main::$1]) main::bb#0 ← { fill( main::$1, 0) }
(byte[]) main::bc#0 ← { (number) 1, (number) 2, (number) 3, (number) 4 }
(byte[]) main::sa#0 ← (const string) main::$29
(byte~) main::$2 ← sizeof (number) 0
(byte~) main::$3 ← (byte) '0' + (byte~) main::$2
*((byte*) SCREEN#0 + (byte) main::idx#0) ← (byte~) main::$3
(byte~) main::$1 ← sizeof (number) 0
(byte~) main::$2 ← (byte) '0' + (byte~) main::$1
*((byte*) SCREEN#0 + (byte) main::idx#0) ← (byte~) main::$2
(byte) main::idx#1 ← ++ (byte) main::idx#0
(byte~) main::$4 ← sizeof (byte) main::idx#1
(byte~) main::$5 ← (byte) '0' + (byte~) main::$4
*((byte*) SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$5
(byte~) main::$3 ← (const byte) SIZEOF_BYTE
(byte~) main::$4 ← (byte) '0' + (byte~) main::$3
*((byte*) SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$4
(byte) main::idx#2 ← ++ (byte) main::idx#1
(byte~) main::$6 ← sizeof (byte) main::b#0
(byte~) main::$7 ← (byte) '0' + (byte~) main::$6
*((byte*) SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$7
(byte~) main::$5 ← (const byte) SIZEOF_BYTE
(byte~) main::$6 ← (byte) '0' + (byte~) main::$5
*((byte*) SCREEN#0 + (byte) main::idx#2) ← (byte~) main::$6
(byte) main::idx#3 ← ++ (byte) main::idx#2
(number~) main::$8 ← (byte) main::b#0 * (number) 2
(byte~) main::$9 ← sizeof (number~) main::$8
(byte~) main::$10 ← (byte) '0' + (byte~) main::$9
*((byte*) SCREEN#0 + (byte) main::idx#3) ← (byte~) main::$10
(byte~) main::$8 ← (const byte) SIZEOF_NUMBER
(byte~) main::$9 ← (byte) '0' + (byte~) main::$8
*((byte*) SCREEN#0 + (byte) main::idx#3) ← (byte~) main::$9
(byte) main::idx#4 ← ++ (byte) main::idx#3
(byte) main::idx#5 ← ++ (byte) main::idx#4
(byte~) main::$11 ← sizeof (number) $43ff
(byte~) main::$12 ← (byte) '0' + (byte~) main::$11
*((byte*) SCREEN#0 + (byte) main::idx#5) ← (byte~) main::$12
(byte~) main::$10 ← sizeof (number) $43ff
(byte~) main::$11 ← (byte) '0' + (byte~) main::$10
*((byte*) SCREEN#0 + (byte) main::idx#5) ← (byte~) main::$11
(byte) main::idx#6 ← ++ (byte) main::idx#5
(byte~) main::$13 ← sizeof (word) main::w#0
(byte~) main::$14 ← (byte) '0' + (byte~) main::$13
*((byte*) SCREEN#0 + (byte) main::idx#6) ← (byte~) main::$14
(byte~) main::$12 ← (const byte) SIZEOF_WORD
(byte~) main::$13 ← (byte) '0' + (byte~) main::$12
*((byte*) SCREEN#0 + (byte) main::idx#6) ← (byte~) main::$13
(byte) main::idx#7 ← ++ (byte) main::idx#6
(byte) main::idx#8 ← ++ (byte) main::idx#7
(byte~) main::$15 ← sizeof (byte*) main::bp#0
(byte~) main::$16 ← (byte) '0' + (byte~) main::$15
*((byte*) SCREEN#0 + (byte) main::idx#8) ← (byte~) main::$16
(byte~) main::$14 ← (const byte) SIZEOF_POINTER
(byte~) main::$15 ← (byte) '0' + (byte~) main::$14
*((byte*) SCREEN#0 + (byte) main::idx#8) ← (byte~) main::$15
(byte) main::idx#9 ← ++ (byte) main::idx#8
(byte~) main::$17 ← sizeof (word*) main::wp#0
(byte~) main::$18 ← (byte) '0' + (byte~) main::$17
*((byte*) SCREEN#0 + (byte) main::idx#9) ← (byte~) main::$18
(byte~) main::$16 ← (const byte) SIZEOF_POINTER
(byte~) main::$17 ← (byte) '0' + (byte~) main::$16
*((byte*) SCREEN#0 + (byte) main::idx#9) ← (byte~) main::$17
(byte) main::idx#10 ← ++ (byte) main::idx#9
(byte) main::idx#11 ← ++ (byte) main::idx#10
(byte~) main::$19 ← sizeof (byte[3]) main::ba#0
(byte~) main::$20 ← (byte) '0' + (byte~) main::$19
*((byte*) SCREEN#0 + (byte) main::idx#11) ← (byte~) main::$20
(byte) main::idx#12 ← ++ (byte) main::idx#11
(byte~) main::$21 ← sizeof (word[3]) main::wa#0
(byte~) main::$22 ← (byte) '0' + (byte~) main::$21
*((byte*) SCREEN#0 + (byte) main::idx#12) ← (byte~) main::$22
(byte) main::idx#13 ← ++ (byte) main::idx#12
(byte~) main::$23 ← sizeof (byte[main::$1]) main::bb#0
(byte~) main::$24 ← (byte) '0' + (byte~) main::$23
*((byte*) SCREEN#0 + (byte) main::idx#13) ← (byte~) main::$24
(byte) main::idx#14 ← ++ (byte) main::idx#13
(byte~) main::$25 ← sizeof (byte[]) main::bc#0
(byte~) main::$26 ← (byte) '0' + (byte~) main::$25
*((byte*) SCREEN#0 + (byte) main::idx#14) ← (byte~) main::$26
(byte) main::idx#15 ← ++ (byte) main::idx#14
(byte~) main::$27 ← sizeof (byte[]) main::sa#0
(byte~) main::$28 ← (byte) '0' + (byte~) main::$27
*((byte*) SCREEN#0 + (byte) main::idx#15) ← (byte~) main::$28
(byte) main::idx#16 ← ++ (byte) main::idx#15
to:main::@return
main::@return: scope:[main] from main
return
@ -95,9 +68,12 @@ SYMBOL TABLE SSA
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(const byte) SIZEOF_BYTE = (byte) 1
(const byte) SIZEOF_NUMBER = (byte) $ff
(const byte) SIZEOF_POINTER = (byte) 2
(const byte) SIZEOF_WORD = (byte) 2
(void()) main()
(word*~) main::$0
(number~) main::$1
(byte~) main::$1
(byte~) main::$10
(byte~) main::$11
(byte~) main::$12
@ -106,47 +82,20 @@ SYMBOL TABLE SSA
(byte~) main::$15
(byte~) main::$16
(byte~) main::$17
(byte~) main::$18
(byte~) main::$19
(byte~) main::$2
(byte~) main::$20
(byte~) main::$21
(byte~) main::$22
(byte~) main::$23
(byte~) main::$24
(byte~) main::$25
(byte~) main::$26
(byte~) main::$27
(byte~) main::$28
(const string) main::$29 = (string) "camelot@"
(byte~) main::$3
(byte~) main::$4
(byte~) main::$5
(byte~) main::$6
(byte~) main::$7
(number~) main::$8
(byte~) main::$8
(byte~) main::$9
(label) main::@return
(byte) main::b
(byte) main::b#0
(byte[3]) main::ba
(byte[3]) main::ba#0
(byte[main::$1]) main::bb
(byte[main::$1]) main::bb#0
(byte[]) main::bc
(byte[]) main::bc#0
(byte*) main::bp
(byte*) main::bp#0
(byte) main::idx
(byte) main::idx#0
(byte) main::idx#1
(byte) main::idx#10
(byte) main::idx#11
(byte) main::idx#12
(byte) main::idx#13
(byte) main::idx#14
(byte) main::idx#15
(byte) main::idx#16
(byte) main::idx#2
(byte) main::idx#3
(byte) main::idx#4
@ -155,189 +104,80 @@ SYMBOL TABLE SSA
(byte) main::idx#7
(byte) main::idx#8
(byte) main::idx#9
(byte[]) main::sa
(byte[]) main::sa#0
(byte) main::sz
(byte) main::sz#0
(word) main::w
(word) main::w#0
(word[3]) main::wa
(word[3]) main::wa#0
(word*) main::wp
(word*) main::wp#0
Adding number conversion cast (unumber) 0 in (byte) main::idx#0 ← (number) 0
Adding number conversion cast (unumber) 0 in (byte) main::b#0 ← (number) 0
Adding number conversion cast (unumber) 0 in (word) main::w#0 ← (number) 0
Adding number conversion cast (unumber) $f in (byte) main::sz#0 ← (number) $f
Adding number conversion cast (unumber) 2 in (number~) main::$1 ← (byte) main::sz#0 + (number) 2
Adding number conversion cast (unumber) main::$1 in (number~) main::$1 ← (byte) main::sz#0 + (unumber)(number) 2
Adding number conversion cast (unumber) 2 in (number~) main::$8 ← (byte) main::b#0 * (number) 2
Adding number conversion cast (unumber) main::$8 in (number~) main::$8 ← (byte) main::b#0 * (unumber)(number) 2
Successful SSA optimization PassNAddNumberTypeConversions
Adding number conversion cast (byte) to elements in (byte[]) main::bc#0 ← { (byte)(number) 1, (byte)(number) 2, (byte)(number) 3, (byte)(number) 4 }
Successful SSA optimization PassNAddArrayNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte) main::idx#0 ← (unumber)(number) 0
Inlining cast (byte) main::b#0 ← (unumber)(number) 0
Inlining cast (word) main::w#0 ← (unumber)(number) 0
Inlining cast (byte*) main::bp#0 ← (byte*)(number) $1000
Inlining cast (byte) main::sz#0 ← (unumber)(number) $f
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant pointer cast (byte*) 4096
Simplifying constant integer cast $f
Simplifying constant integer cast 2
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 3
Simplifying constant integer cast 4
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $f
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$1 ← (byte) main::sz#0 + (byte) 2
Inferred type updated to byte in (unumber~) main::$8 ← (byte) main::b#0 * (byte) 2
Resolving sizeof() (byte~) main::$4 ← sizeof (byte) main::idx#1
Resolving sizeof() (byte~) main::$6 ← sizeof (byte) main::b#0
Resolving sizeof() (byte~) main::$9 ← sizeof (byte~) main::$8
Resolving sizeof() (byte~) main::$13 ← sizeof (word) main::w#0
Resolving sizeof() (byte~) main::$15 ← sizeof (byte*) main::bp#0
Resolving sizeof() (byte~) main::$17 ← sizeof (word*) main::wp#0
Successful SSA optimization Pass2SizeOfSimplification
Alias (word*) main::wp#0 = (word*~) main::$0
Successful SSA optimization Pass2AliasElimination
Constant right-side identified [5] (word*) main::wp#0 ← & (word) main::w#0
Constant right-side identified [7] (byte[3]) main::ba#0 ← { fill( 3, 0) }
Constant right-side identified [8] (word[3]) main::wa#0 ← { fill( 3, 0) }
Constant right-side identified [12] (byte[]) main::bc#0 ← { (byte) 1, (byte) 2, (byte) 3, (byte) 4 }
Constant right-side identified [14] (byte~) main::$2 ← sizeof (number) 0
Constant right-side identified [32] (byte~) main::$11 ← sizeof (number) $43ff
Constant right-side identified [4] (byte~) main::$1 ← sizeof (number) 0
Constant right-side identified [21] (byte~) main::$10 ← sizeof (number) $43ff
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte) main::idx#0 = 0
Constant (const byte*) main::bp#0 = (byte*) 4096
Constant (const word*) main::wp#0 = &main::w#0
Constant (const byte[3]) main::ba#0 = { fill( 3, 0) }
Constant (const word[3]) main::wa#0 = { fill( 3, 0) }
Constant (const byte) main::sz#0 = $f
Constant (const byte[]) main::bc#0 = { 1, 2, 3, 4 }
Constant (const byte[]) main::sa#0 = main::$29
Constant (const byte) main::$2 = sizeof 0
Constant (const byte) main::$4 = SIZEOF_BYTE
Constant (const byte) main::$6 = SIZEOF_BYTE
Constant (const byte) main::$9 = SIZEOF_BYTE
Constant (const byte) main::$11 = sizeof $43ff
Constant (const byte) main::$13 = SIZEOF_WORD
Constant (const byte) main::$15 = SIZEOF_POINTER
Constant (const byte) main::$17 = SIZEOF_POINTER
Constant (const byte) main::$1 = sizeof 0
Constant (const byte) main::$3 = SIZEOF_BYTE
Constant (const byte) main::$5 = SIZEOF_BYTE
Constant (const byte) main::$8 = SIZEOF_NUMBER
Constant (const byte) main::$10 = sizeof $43ff
Constant (const byte) main::$12 = SIZEOF_WORD
Constant (const byte) main::$14 = SIZEOF_POINTER
Constant (const byte) main::$16 = SIZEOF_POINTER
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero SCREEN#0 in [16] *((const byte*) SCREEN#0 + (const byte) main::idx#0) ← (byte~) main::$3
Simplifying expression containing zero SCREEN#0 in [6] *((const byte*) SCREEN#0 + (const byte) main::idx#0) ← (byte~) main::$2
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (byte~) main::$8 and assignment [13] (byte~) main::$8 ← (byte) main::b#0 * (byte) 2
Eliminating unused variable (byte) main::idx#16 and assignment [51] (byte) main::idx#16 ← ++ (byte) main::idx#15
Eliminating unused constant (const byte*) main::bp#0
Eliminating unused constant (const word*) main::wp#0
Eliminating unused variable (byte) main::idx#10 and assignment [27] (byte) main::idx#10 ← ++ (byte) main::idx#9
Successful SSA optimization PassNEliminateUnusedVars
Resolving sizeof() sizeof (number) 0
Resolving sizeof() sizeof (number) $43ff
Successful SSA optimization Pass2SizeOfSimplification
Constant right-side identified [2] (byte~) main::$1 ← (const byte) main::sz#0 + (byte) 2
Constant right-side identified [4] (byte~) main::$3 ← (byte) '0' + (const byte) main::$2
Constant right-side identified [6] (byte) main::idx#1 ← ++ (const byte) main::idx#0
Constant right-side identified [7] (byte~) main::$5 ← (byte) '0' + (const byte) main::$4
Constant right-side identified [10] (byte~) main::$7 ← (byte) '0' + (const byte) main::$6
Constant right-side identified [13] (byte~) main::$10 ← (byte) '0' + (const byte) main::$9
Constant right-side identified [17] (byte~) main::$12 ← (byte) '0' + (const byte) main::$11
Constant right-side identified [20] (byte~) main::$14 ← (byte) '0' + (const byte) main::$13
Constant right-side identified [24] (byte~) main::$16 ← (byte) '0' + (const byte) main::$15
Constant right-side identified [27] (byte~) main::$18 ← (byte) '0' + (const byte) main::$17
Constant right-side identified [31] (byte~) main::$19 ← sizeof (const byte[3]) main::ba#0
Constant right-side identified [35] (byte~) main::$21 ← sizeof (const word[3]) main::wa#0
Constant right-side identified [43] (byte~) main::$25 ← sizeof (const byte[]) main::bc#0
Constant right-side identified [47] (byte~) main::$27 ← sizeof (const byte[]) main::sa#0
Successful SSA optimization PassNSizeOfSimplification
Constant right-side identified [2] (byte~) main::$2 ← (byte) '0' + (const byte) main::$1
Constant right-side identified [4] (byte) main::idx#1 ← ++ (const byte) main::idx#0
Constant right-side identified [5] (byte~) main::$4 ← (byte) '0' + (const byte) main::$3
Constant right-side identified [8] (byte~) main::$6 ← (byte) '0' + (const byte) main::$5
Constant right-side identified [11] (byte~) main::$9 ← (byte) '0' + (const byte) main::$8
Constant right-side identified [15] (byte~) main::$11 ← (byte) '0' + (const byte) main::$10
Constant right-side identified [18] (byte~) main::$13 ← (byte) '0' + (const byte) main::$12
Constant right-side identified [22] (byte~) main::$15 ← (byte) '0' + (const byte) main::$14
Constant right-side identified [25] (byte~) main::$17 ← (byte) '0' + (const byte) main::$16
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::$1 = main::sz#0+2
Constant (const byte) main::$3 = '0'+main::$2
Constant (const byte) main::$2 = '0'+main::$1
Constant (const byte) main::idx#1 = ++main::idx#0
Constant (const byte) main::$5 = '0'+main::$4
Constant (const byte) main::$7 = '0'+main::$6
Constant (const byte) main::$10 = '0'+main::$9
Constant (const byte) main::$12 = '0'+main::$11
Constant (const byte) main::$14 = '0'+main::$13
Constant (const byte) main::$16 = '0'+main::$15
Constant (const byte) main::$18 = '0'+main::$17
Constant (const byte) main::$19 = sizeof main::ba#0
Constant (const byte) main::$21 = sizeof main::wa#0
Constant (const byte) main::$25 = sizeof main::bc#0
Constant (const byte) main::$27 = sizeof main::sa#0
Constant (const byte) main::$4 = '0'+main::$3
Constant (const byte) main::$6 = '0'+main::$5
Constant (const byte) main::$9 = '0'+main::$8
Constant (const byte) main::$11 = '0'+main::$10
Constant (const byte) main::$13 = '0'+main::$12
Constant (const byte) main::$15 = '0'+main::$14
Constant (const byte) main::$17 = '0'+main::$16
Successful SSA optimization Pass2ConstantIdentification
Constant value identified { fill( main::$1, 0) } in [3] (byte[main::$1]) main::bb#0 ← { fill( main::$1, 0) }
Successful SSA optimization Pass2ConstantValues
Resolving array sizeof() sizeof (const byte[3]) main::ba#0
Resolving array sizeof() sizeof (const word[3]) main::wa#0
Resolving array sizeof() sizeof (const byte[]) main::bc#0
Resolving string sizeof() sizeof (const byte[]) main::sa#0
Successful SSA optimization Pass2SizeOfSimplification
Constant right-side identified [5] (byte) main::idx#2 ← ++ (const byte) main::idx#1
Constant right-side identified [21] (byte~) main::$20 ← (byte) '0' + (const byte) main::$19
Constant right-side identified [24] (byte~) main::$22 ← (byte) '0' + (const byte) main::$21
Constant right-side identified [31] (byte~) main::$26 ← (byte) '0' + (const byte) main::$25
Constant right-side identified [34] (byte~) main::$28 ← (byte) '0' + (const byte) main::$27
Constant right-side identified [4] (byte) main::idx#2 ← ++ (const byte) main::idx#1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte[main::$1]) main::bb#0 = { fill( main::$1, 0) }
Constant (const byte) main::idx#2 = ++main::idx#1
Constant (const byte) main::$20 = '0'+main::$19
Constant (const byte) main::$22 = '0'+main::$21
Constant (const byte) main::$26 = '0'+main::$25
Constant (const byte) main::$28 = '0'+main::$27
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant (const byte[3]) main::ba#0
Eliminating unused constant (const word[3]) main::wa#0
Eliminating unused constant (const byte[]) main::bc#0
Eliminating unused constant (const byte[]) main::sa#0
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant (const string) main::$29
Successful SSA optimization PassNEliminateUnusedVars
Adding number conversion cast (unumber) 3 in
Adding number conversion cast (unumber) 3 in
Adding number conversion cast (unumber) 4 in
Adding number conversion cast (unumber) 8 in
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 3
Simplifying constant integer cast 3
Simplifying constant integer cast 4
Simplifying constant integer cast 8
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) 8
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [5] (byte) main::idx#3 ← ++ (const byte) main::idx#2
Constant right-side identified [23] (byte~) main::$23 ← sizeof (const byte[main::$1]) main::bb#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#3 = ++main::idx#2
Constant (const byte) main::$23 = sizeof main::bb#0
Successful SSA optimization Pass2ConstantIdentification
Resolving array sizeof() sizeof (const byte[main::$1]) main::bb#0
Successful SSA optimization Pass2SizeOfSimplification
Constant right-side identified [6] (byte) main::idx#4 ← ++ (const byte) main::idx#3
Constant right-side identified [22] (byte~) main::$24 ← (byte) '0' + (const byte) main::$23
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#4 = ++main::idx#3
Constant (const byte) main::$24 = '0'+main::$23
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant (const byte[main::$1]) main::bb#0
Successful SSA optimization PassNEliminateUnusedVars
Constant right-side identified [6] (byte) main::idx#5 ← ++ (const byte) main::idx#4
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#5 = ++main::idx#4
@ -358,30 +198,6 @@ Constant right-side identified [9] (byte) main::idx#9 ← ++ (const byte) main::
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#9 = ++main::idx#8
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [10] (byte) main::idx#10 ← ++ (const byte) main::idx#9
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#10 = ++main::idx#9
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [10] (byte) main::idx#11 ← ++ (const byte) main::idx#10
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#11 = ++main::idx#10
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [11] (byte) main::idx#12 ← ++ (const byte) main::idx#11
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#12 = ++main::idx#11
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [12] (byte) main::idx#13 ← ++ (const byte) main::idx#12
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#13 = ++main::idx#12
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [13] (byte) main::idx#14 ← ++ (const byte) main::idx#13
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#14 = ++main::idx#13
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [14] (byte) main::idx#15 ← ++ (const byte) main::idx#14
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#15 = ++main::idx#14
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings (const byte) main::idx#0
Inlining constant with different constant siblings (const byte) main::idx#1
Inlining constant with different constant siblings (const byte) main::idx#2
@ -392,55 +208,32 @@ Inlining constant with different constant siblings (const byte) main::idx#6
Inlining constant with different constant siblings (const byte) main::idx#7
Inlining constant with different constant siblings (const byte) main::idx#8
Inlining constant with different constant siblings (const byte) main::idx#9
Inlining constant with different constant siblings (const byte) main::idx#10
Inlining constant with different constant siblings (const byte) main::idx#11
Inlining constant with different constant siblings (const byte) main::idx#12
Inlining constant with different constant siblings (const byte) main::idx#13
Inlining constant with different constant siblings (const byte) main::idx#14
Inlining constant with different constant siblings (const byte) main::idx#15
Constant inlined main::idx#12 = ++++++++++++++++++++++++(byte) 0
Constant inlined main::idx#13 = ++++++++++++++++++++++++++(byte) 0
Constant inlined main::idx#14 = ++++++++++++++++++++++++++++(byte) 0
Constant inlined main::idx#15 = ++++++++++++++++++++++++++++++(byte) 0
Constant inlined main::$12 = (byte) '0'+(const byte) SIZEOF_NUMBER
Constant inlined main::$13 = (const byte) SIZEOF_WORD
Constant inlined main::$14 = (byte) '0'+(const byte) SIZEOF_WORD
Constant inlined main::$15 = (const byte) SIZEOF_POINTER
Constant inlined main::$10 = (byte) '0'+(const byte) SIZEOF_BYTE
Constant inlined main::$11 = (const byte) SIZEOF_NUMBER
Constant inlined main::$16 = (byte) '0'+(const byte) SIZEOF_POINTER
Constant inlined main::$17 = (const byte) SIZEOF_POINTER
Constant inlined main::$18 = (byte) '0'+(const byte) SIZEOF_POINTER
Constant inlined main::$19 = (byte) 3*(const byte) SIZEOF_BYTE
Constant inlined main::$23 = (const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE
Constant inlined main::$24 = (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE
Constant inlined main::$25 = (byte) 4*(const byte) SIZEOF_BYTE
Constant inlined main::$26 = (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE
Constant inlined main::$20 = (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE
Constant inlined main::$21 = (byte) 3*(const byte) SIZEOF_WORD
Constant inlined main::$22 = (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD
Constant inlined main::$12 = (const byte) SIZEOF_WORD
Constant inlined main::$13 = (byte) '0'+(const byte) SIZEOF_WORD
Constant inlined main::$14 = (const byte) SIZEOF_POINTER
Constant inlined main::$15 = (byte) '0'+(const byte) SIZEOF_POINTER
Constant inlined main::$10 = (const byte) SIZEOF_NUMBER
Constant inlined main::$11 = (byte) '0'+(const byte) SIZEOF_NUMBER
Constant inlined main::$16 = (const byte) SIZEOF_POINTER
Constant inlined main::$17 = (byte) '0'+(const byte) SIZEOF_POINTER
Constant inlined main::idx#0 = (byte) 0
Constant inlined main::idx#1 = ++(byte) 0
Constant inlined main::idx#2 = ++++(byte) 0
Constant inlined main::$1 = (const byte) main::sz#0+(byte) 2
Constant inlined main::$27 = (byte) 8*(const byte) SIZEOF_BYTE
Constant inlined main::$1 = (const byte) SIZEOF_NUMBER
Constant inlined main::idx#3 = ++++++(byte) 0
Constant inlined main::$2 = (const byte) SIZEOF_NUMBER
Constant inlined main::$28 = (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE
Constant inlined main::$2 = (byte) '0'+(const byte) SIZEOF_NUMBER
Constant inlined main::idx#4 = ++++++++(byte) 0
Constant inlined main::idx#5 = ++++++++++(byte) 0
Constant inlined main::idx#6 = ++++++++++++(byte) 0
Constant inlined main::$5 = (byte) '0'+(const byte) SIZEOF_BYTE
Constant inlined main::$5 = (const byte) SIZEOF_BYTE
Constant inlined main::idx#7 = ++++++++++++++(byte) 0
Constant inlined main::$6 = (const byte) SIZEOF_BYTE
Constant inlined main::$6 = (byte) '0'+(const byte) SIZEOF_BYTE
Constant inlined main::idx#8 = ++++++++++++++++(byte) 0
Constant inlined main::$3 = (byte) '0'+(const byte) SIZEOF_NUMBER
Constant inlined main::$3 = (const byte) SIZEOF_BYTE
Constant inlined main::idx#9 = ++++++++++++++++++(byte) 0
Constant inlined main::idx#10 = ++++++++++++++++++++(byte) 0
Constant inlined main::$4 = (const byte) SIZEOF_BYTE
Constant inlined main::idx#11 = ++++++++++++++++++++++(byte) 0
Constant inlined main::$9 = (const byte) SIZEOF_BYTE
Constant inlined main::$7 = (byte) '0'+(const byte) SIZEOF_BYTE
Constant inlined main::$4 = (byte) '0'+(const byte) SIZEOF_BYTE
Constant inlined main::$9 = (byte) '0'+(const byte) SIZEOF_NUMBER
Constant inlined main::$8 = (const byte) SIZEOF_NUMBER
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(SCREEN#0+++0)
Consolidated array index constant in *(SCREEN#0+++++0)
@ -449,11 +242,6 @@ Consolidated array index constant in *(SCREEN#0+++++++++++0)
Consolidated array index constant in *(SCREEN#0+++++++++++++0)
Consolidated array index constant in *(SCREEN#0+++++++++++++++++0)
Consolidated array index constant in *(SCREEN#0+++++++++++++++++++0)
Consolidated array index constant in *(SCREEN#0+++++++++++++++++++++++0)
Consolidated array index constant in *(SCREEN#0+++++++++++++++++++++++++0)
Consolidated array index constant in *(SCREEN#0+++++++++++++++++++++++++++0)
Consolidated array index constant in *(SCREEN#0+++++++++++++++++++++++++++++0)
Consolidated array index constant in *(SCREEN#0+++++++++++++++++++++++++++++++0)
Successful SSA optimization Pass2ConstantAdditionElimination
Simplifying constant integer increment ++0
Simplifying constant integer increment ++0
@ -462,27 +250,16 @@ Simplifying constant integer increment ++2
Simplifying constant integer increment ++3
Simplifying constant integer increment ++4
Simplifying constant integer increment ++5
Simplifying constant integer increment ++6
Simplifying constant integer increment ++7
Simplifying constant integer increment ++8
Simplifying constant integer increment ++9
Simplifying constant integer increment ++$a
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer increment ++1
Simplifying constant integer increment ++2
Simplifying constant integer increment ++4
Simplifying constant integer increment ++5
Simplifying constant integer increment ++6
Simplifying constant integer increment ++7
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer increment ++7
Simplifying constant integer increment ++8
Simplifying constant integer increment ++$a
Simplifying constant integer increment ++$b
Simplifying constant integer increment ++$b
Simplifying constant integer increment ++$c
Simplifying constant integer increment ++$d
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer increment ++$c
Simplifying constant integer increment ++$d
Simplifying constant integer increment ++$e
Successful SSA optimization Pass2ConstantSimplification
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
@ -514,19 +291,14 @@ main: scope:[main] from @1
[6] *((const byte*) SCREEN#0) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[7] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE
[8] *((const byte*) SCREEN#0+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE
[9] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_BYTE
[9] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[10] *((const byte*) SCREEN#0+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER
[11] *((const byte*) SCREEN#0+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD
[12] *((const byte*) SCREEN#0+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER
[13] *((const byte*) SCREEN#0+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER
[14] *((const byte*) SCREEN#0+(byte) $b) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE
[15] *((const byte*) SCREEN#0+(byte) $c) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD
[16] *((const byte*) SCREEN#0+(byte) $d) ← (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE
[17] *((const byte*) SCREEN#0+(byte) $e) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE
[18] *((const byte*) SCREEN#0+(byte) $f) ← (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE
to:main::@return
main::@return: scope:[main] from main
[19] return
[14] return
to:@return
@ -535,17 +307,9 @@ VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::b
(byte) main::b#0 20.0
(byte[3]) main::ba
(byte[main::sz#0+2]) main::bb
(byte[]) main::bc
(byte*) main::bp
(byte) main::idx
(byte[]) main::sa
(byte) main::sz
(word) main::w
(word) main::w#0 20.0
(word[3]) main::wa
(word*) main::wp
Initial phi equivalence classes
Complete equivalence classes
@ -556,17 +320,17 @@ Allocated zp ZP_WORD:3 [ main::w#0 ]
INITIAL ASM
//SEG0 File Comments
// Tests the sizeof() operator on epressions
// Tests the sizeof() operator on values/expressions
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
.const SIZEOF_BYTE = 1
.const SIZEOF_NUMBER = $ff
.const SIZEOF_WORD = 2
.const SIZEOF_POINTER = 2
.label SCREEN = $400
.const SIZEOF_NUMBER = $ff
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
@ -583,7 +347,6 @@ bend_from_b1:
bend:
//SEG9 main
main: {
.const sz = $f
.label b = 2
.label w = 3
//SEG10 [4] (byte) main::b#0 ← (byte) 0 -- vbuz1=vbuc1
@ -596,7 +359,6 @@ main: {
lda #0
sta w+1
//SEG12 [6] *((const byte*) SCREEN#0) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
//byte[] sb = { 'a', 'b', 'c', 0};
lda #'0'+SIZEOF_NUMBER
sta SCREEN
//SEG13 [7] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
@ -605,8 +367,8 @@ main: {
//SEG14 [8] *((const byte*) SCREEN#0+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_BYTE
sta SCREEN+2
//SEG15 [9] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_BYTE
//SEG15 [9] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
sta SCREEN+3
//SEG16 [10] *((const byte*) SCREEN#0+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
@ -620,25 +382,10 @@ main: {
//SEG19 [13] *((const byte*) SCREEN#0+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_POINTER
sta SCREEN+9
//SEG20 [14] *((const byte*) SCREEN#0+(byte) $b) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+3*SIZEOF_BYTE
sta SCREEN+$b
//SEG21 [15] *((const byte*) SCREEN#0+(byte) $c) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
lda #'0'+3*SIZEOF_WORD
sta SCREEN+$c
//SEG22 [16] *((const byte*) SCREEN#0+(byte) $d) ← (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+(sz+2)*SIZEOF_BYTE
sta SCREEN+$d
//SEG23 [17] *((const byte*) SCREEN#0+(byte) $e) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+4*SIZEOF_BYTE
sta SCREEN+$e
//SEG24 [18] *((const byte*) SCREEN#0+(byte) $f) ← (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+8*SIZEOF_BYTE
sta SCREEN+$f
jmp breturn
//SEG25 main::@return
//SEG20 main::@return
breturn:
//SEG26 [19] return
//SEG21 [14] return
rts
}
@ -648,16 +395,11 @@ Statement [5] (word) main::w#0 ← (byte) 0 [ ] ( main:2 [ ] ) always clobbers r
Statement [6] *((const byte*) SCREEN#0) ← (byte) '0'+(const byte) SIZEOF_NUMBER [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [8] *((const byte*) SCREEN#0+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [9] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [9] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [10] *((const byte*) SCREEN#0+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [11] *((const byte*) SCREEN#0+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [12] *((const byte*) SCREEN#0+(byte) 8) ← (byte) '0'+(const byte) SIZEOF_POINTER [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [13] *((const byte*) SCREEN#0+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [14] *((const byte*) SCREEN#0+(byte) $b) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [15] *((const byte*) SCREEN#0+(byte) $c) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [16] *((const byte*) SCREEN#0+(byte) $d) ← (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [17] *((const byte*) SCREEN#0+(byte) $e) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [18] *((const byte*) SCREEN#0+(byte) $f) ← (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE [ ] ( main:2 [ ] ) always clobbers reg byte a
Potential registers zp ZP_BYTE:2 [ main::b#0 ] : zp ZP_BYTE:2 ,
Potential registers zp ZP_WORD:3 [ main::w#0 ] : zp ZP_WORD:3 ,
@ -665,24 +407,24 @@ REGISTER UPLIFT SCOPES
Uplift Scope [main] 20: zp ZP_BYTE:2 [ main::b#0 ] 20: zp ZP_WORD:3 [ main::w#0 ]
Uplift Scope []
Uplifting [main] best 114 combination zp ZP_BYTE:2 [ main::b#0 ] zp ZP_WORD:3 [ main::w#0 ]
Uplifting [] best 114 combination
Uplifting [main] best 84 combination zp ZP_BYTE:2 [ main::b#0 ] zp ZP_WORD:3 [ main::w#0 ]
Uplifting [] best 84 combination
Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::b#0 ]
Uplifting [main] best 114 combination zp ZP_BYTE:2 [ main::b#0 ]
Uplifting [main] best 84 combination zp ZP_BYTE:2 [ main::b#0 ]
ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
// Tests the sizeof() operator on epressions
// Tests the sizeof() operator on values/expressions
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
.const SIZEOF_BYTE = 1
.const SIZEOF_NUMBER = $ff
.const SIZEOF_WORD = 2
.const SIZEOF_POINTER = 2
.label SCREEN = $400
.const SIZEOF_NUMBER = $ff
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
@ -699,7 +441,6 @@ bend_from_b1:
bend:
//SEG9 main
main: {
.const sz = $f
.label b = 2
.label w = 3
//SEG10 [4] (byte) main::b#0 ← (byte) 0 -- vbuz1=vbuc1
@ -712,7 +453,6 @@ main: {
lda #0
sta w+1
//SEG12 [6] *((const byte*) SCREEN#0) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
//byte[] sb = { 'a', 'b', 'c', 0};
lda #'0'+SIZEOF_NUMBER
sta SCREEN
//SEG13 [7] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
@ -721,8 +461,8 @@ main: {
//SEG14 [8] *((const byte*) SCREEN#0+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_BYTE
sta SCREEN+2
//SEG15 [9] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_BYTE
//SEG15 [9] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
sta SCREEN+3
//SEG16 [10] *((const byte*) SCREEN#0+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
@ -736,25 +476,10 @@ main: {
//SEG19 [13] *((const byte*) SCREEN#0+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_POINTER
sta SCREEN+9
//SEG20 [14] *((const byte*) SCREEN#0+(byte) $b) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+3*SIZEOF_BYTE
sta SCREEN+$b
//SEG21 [15] *((const byte*) SCREEN#0+(byte) $c) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
lda #'0'+3*SIZEOF_WORD
sta SCREEN+$c
//SEG22 [16] *((const byte*) SCREEN#0+(byte) $d) ← (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+(sz+2)*SIZEOF_BYTE
sta SCREEN+$d
//SEG23 [17] *((const byte*) SCREEN#0+(byte) $e) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+4*SIZEOF_BYTE
sta SCREEN+$e
//SEG24 [18] *((const byte*) SCREEN#0+(byte) $f) ← (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+8*SIZEOF_BYTE
sta SCREEN+$f
jmp breturn
//SEG25 main::@return
//SEG20 main::@return
breturn:
//SEG26 [19] return
//SEG21 [14] return
rts
}
@ -766,7 +491,7 @@ Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #0
Removing instruction lda #0
Removing instruction lda #'0'+SIZEOF_BYTE
Removing instruction lda #'0'+SIZEOF_BYTE
Removing instruction lda #'0'+SIZEOF_NUMBER
Removing instruction lda #'0'+SIZEOF_POINTER
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction b1_from_bbegin:
@ -796,38 +521,29 @@ FINAL SYMBOL TABLE
(label) main::@return
(byte) main::b
(byte) main::b#0 b zp ZP_BYTE:2 20.0
(byte[3]) main::ba
(byte[main::sz#0+2]) main::bb
(byte[]) main::bc
(byte*) main::bp
(byte) main::idx
(byte[]) main::sa
(byte) main::sz
(const byte) main::sz#0 sz = (byte) $f
(word) main::w
(word) main::w#0 w zp ZP_WORD:3 20.0
(word[3]) main::wa
(word*) main::wp
zp ZP_BYTE:2 [ main::b#0 ]
zp ZP_WORD:3 [ main::w#0 ]
FINAL ASSEMBLER
Score: 89
Score: 59
//SEG0 File Comments
// Tests the sizeof() operator on epressions
// Tests the sizeof() operator on values/expressions
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
.const SIZEOF_BYTE = 1
.const SIZEOF_NUMBER = $ff
.const SIZEOF_WORD = 2
.const SIZEOF_POINTER = 2
.label SCREEN = $400
.const SIZEOF_NUMBER = $ff
//SEG3 @begin
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG5 @1
@ -836,7 +552,6 @@ Score: 89
//SEG8 @end
//SEG9 main
main: {
.const sz = $f
.label b = 2
.label w = 3
//SEG10 [4] (byte) main::b#0 ← (byte) 0 -- vbuz1=vbuc1
@ -847,7 +562,6 @@ main: {
sta w
sta w+1
//SEG12 [6] *((const byte*) SCREEN#0) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
//byte[] sb = { 'a', 'b', 'c', 0};
lda #'0'+SIZEOF_NUMBER
sta SCREEN
//SEG13 [7] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
@ -855,10 +569,10 @@ main: {
sta SCREEN+1
//SEG14 [8] *((const byte*) SCREEN#0+(byte) 2) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
sta SCREEN+2
//SEG15 [9] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
//SEG15 [9] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
sta SCREEN+3
//SEG16 [10] *((const byte*) SCREEN#0+(byte) 5) ← (byte) '0'+(const byte) SIZEOF_NUMBER -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_NUMBER
sta SCREEN+5
//SEG17 [11] *((const byte*) SCREEN#0+(byte) 6) ← (byte) '0'+(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_WORD
@ -868,23 +582,8 @@ main: {
sta SCREEN+8
//SEG19 [13] *((const byte*) SCREEN#0+(byte) 9) ← (byte) '0'+(const byte) SIZEOF_POINTER -- _deref_pbuc1=vbuc2
sta SCREEN+9
//SEG20 [14] *((const byte*) SCREEN#0+(byte) $b) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+3*SIZEOF_BYTE
sta SCREEN+$b
//SEG21 [15] *((const byte*) SCREEN#0+(byte) $c) ← (byte) '0'+(byte) 3*(const byte) SIZEOF_WORD -- _deref_pbuc1=vbuc2
lda #'0'+3*SIZEOF_WORD
sta SCREEN+$c
//SEG22 [16] *((const byte*) SCREEN#0+(byte) $d) ← (byte) '0'+(const byte) main::sz#0+(byte) 2*(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+(sz+2)*SIZEOF_BYTE
sta SCREEN+$d
//SEG23 [17] *((const byte*) SCREEN#0+(byte) $e) ← (byte) '0'+(byte) 4*(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+4*SIZEOF_BYTE
sta SCREEN+$e
//SEG24 [18] *((const byte*) SCREEN#0+(byte) $f) ← (byte) '0'+(byte) 8*(const byte) SIZEOF_BYTE -- _deref_pbuc1=vbuc2
lda #'0'+8*SIZEOF_BYTE
sta SCREEN+$f
//SEG25 main::@return
//SEG26 [19] return
//SEG20 main::@return
//SEG21 [14] return
rts
}

View File

@ -0,0 +1,26 @@
// Tests the sizeof() operator on structs
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.const SIZEOF_STRUCT_POINT = 2
.const SIZEOF_STRUCT_CIRCLE = 3
.label SCREEN = $400
main: {
// Struct Array
.const NUM_POINTS = 4
.const NUM_CIRCLES = NUM_POINTS-1
// Struct Types
lda #'0'+SIZEOF_STRUCT_POINT
sta SCREEN
lda #'0'+SIZEOF_STRUCT_CIRCLE
sta SCREEN+1
lda #'0'+SIZEOF_STRUCT_POINT
sta SCREEN+3
lda #'0'+SIZEOF_STRUCT_CIRCLE
sta SCREEN+4
lda #'0'+NUM_POINTS*SIZEOF_STRUCT_POINT
sta SCREEN+6
lda #'0'+NUM_CIRCLES*SIZEOF_STRUCT_POINT
sta SCREEN+7
rts
}

View File

@ -0,0 +1,20 @@
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] *((const byte*) SCREEN#0) ← (byte) '0'+(const byte) SIZEOF_STRUCT_POINT
[5] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE
[6] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_STRUCT_POINT
[7] *((const byte*) SCREEN#0+(byte) 4) ← (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE
[8] *((const byte*) SCREEN#0+(byte) 6) ← (byte) '0'+(const byte) main::NUM_POINTS#0*(const byte) SIZEOF_STRUCT_POINT
[9] *((const byte*) SCREEN#0+(byte) 7) ← (byte) '0'+(const byte) main::NUM_CIRCLES#0*(const byte) SIZEOF_STRUCT_POINT
to:main::@return
main::@return: scope:[main] from main
[10] return
to:@return

View File

@ -0,0 +1,537 @@
Resolving sizeof() (byte~) main::$2 ← sizeof (struct Point) main::p
Resolving sizeof() (byte~) main::$4 ← sizeof (struct Circle) main::c
Created struct value member variable (byte) main::p_x
Created struct value member variable (byte) main::p_y
Converted struct value to member variables (struct Point) main::p
Created struct value member variable (struct Point) main::c_center
Created struct value member variable (byte) main::c_radius
Converted struct value to member variables (struct Circle) main::c
Adding struct value member variable default initializer (byte) main::p_x ← (byte) 0
Adding struct value member variable default initializer (byte) main::p_y ← (byte) 0
Adding struct value member variable default initializer (struct Point) main::c_center ← {}
Adding struct value member variable default initializer (byte) main::c_radius ← (byte) 0
Created struct value member variable (byte) main::c_center_x
Created struct value member variable (byte) main::c_center_y
Converted struct value to member variables (struct Point) main::c_center
Adding struct value member variable default initializer (byte) main::c_center_x ← (byte) 0
Adding struct value member variable default initializer (byte) main::c_center_y ← (byte) 0
Adding pointer type conversion cast (byte*) SCREEN in (byte*) SCREEN ← (number) $400
Identified constant variable (byte) main::p_x
Identified constant variable (byte) main::p_y
Identified constant variable (byte) main::c_radius
Identified constant variable (byte) main::c_center_x
Identified constant variable (byte) main::c_center_y
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte*) SCREEN#0 ← ((byte*)) (number) $400
to:@1
main: scope:[main] from @1
(byte) main::idx#0 ← (number) 0
(byte~) main::$0 ← (byte) '0' + (const byte) SIZEOF_STRUCT_POINT
*((byte*) SCREEN#0 + (byte) main::idx#0) ← (byte~) main::$0
(byte) main::idx#1 ← ++ (byte) main::idx#0
(byte~) main::$1 ← (byte) '0' + (const byte) SIZEOF_STRUCT_CIRCLE
*((byte*) SCREEN#0 + (byte) main::idx#1) ← (byte~) main::$1
(byte) main::idx#2 ← ++ (byte) main::idx#1
(byte) main::idx#3 ← ++ (byte) main::idx#2
(byte~) main::$2 ← (const byte) SIZEOF_STRUCT_POINT
(byte~) main::$3 ← (byte) '0' + (byte~) main::$2
*((byte*) SCREEN#0 + (byte) main::idx#3) ← (byte~) main::$3
(byte) main::idx#4 ← ++ (byte) main::idx#3
(byte~) main::$4 ← (const byte) SIZEOF_STRUCT_CIRCLE
(byte~) main::$5 ← (byte) '0' + (byte~) main::$4
*((byte*) SCREEN#0 + (byte) main::idx#4) ← (byte~) main::$5
(byte) main::idx#5 ← ++ (byte) main::idx#4
(byte) main::idx#6 ← ++ (byte) main::idx#5
(byte) main::NUM_POINTS#0 ← (number) 4
(struct Point[main::NUM_POINTS#0]) main::points#0 ← { fill( main::NUM_POINTS#0, 0) }
(byte~) main::$6 ← sizeof (struct Point[main::NUM_POINTS#0]) main::points#0
(byte~) main::$7 ← (byte) '0' + (byte~) main::$6
*((byte*) SCREEN#0 + (byte) main::idx#6) ← (byte~) main::$7
(byte) main::idx#7 ← ++ (byte) main::idx#6
(number~) main::$8 ← (byte) main::NUM_POINTS#0 - (number) 1
(byte) main::NUM_CIRCLES#0 ← (number~) main::$8
(struct Point[main::NUM_CIRCLES#0]) main::circles#0 ← { fill( main::NUM_CIRCLES#0, 0) }
(byte~) main::$9 ← sizeof (struct Point[main::NUM_CIRCLES#0]) main::circles#0
(byte~) main::$10 ← (byte) '0' + (byte~) main::$9
*((byte*) SCREEN#0 + (byte) main::idx#7) ← (byte~) main::$10
(byte) main::idx#8 ← ++ (byte) main::idx#7
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@1: scope:[] from @begin
call main
to:@2
@2: scope:[] from @1
to:@end
@end: scope:[] from @2
SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(struct Point) Circle::center
(byte) Circle::radius
(byte) Point::x
(byte) Point::y
(byte*) SCREEN
(byte*) SCREEN#0
(const byte) SIZEOF_STRUCT_CIRCLE = (byte) 3
(const byte) SIZEOF_STRUCT_POINT = (byte) 2
(void()) main()
(byte~) main::$0
(byte~) main::$1
(byte~) main::$10
(byte~) main::$2
(byte~) main::$3
(byte~) main::$4
(byte~) main::$5
(byte~) main::$6
(byte~) main::$7
(number~) main::$8
(byte~) main::$9
(label) main::@return
(byte) main::NUM_CIRCLES
(byte) main::NUM_CIRCLES#0
(byte) main::NUM_POINTS
(byte) main::NUM_POINTS#0
(struct Circle) main::c
(struct Point) main::c_center
(struct Point[main::NUM_CIRCLES#0]) main::circles
(struct Point[main::NUM_CIRCLES#0]) main::circles#0
(byte) main::idx
(byte) main::idx#0
(byte) main::idx#1
(byte) main::idx#2
(byte) main::idx#3
(byte) main::idx#4
(byte) main::idx#5
(byte) main::idx#6
(byte) main::idx#7
(byte) main::idx#8
(struct Point) main::p
(struct Point[main::NUM_POINTS#0]) main::points
(struct Point[main::NUM_POINTS#0]) main::points#0
Adding number conversion cast (unumber) 0 in (byte) main::idx#0 ← (number) 0
Adding number conversion cast (unumber) 4 in (byte) main::NUM_POINTS#0 ← (number) 4
Adding number conversion cast (unumber) 1 in (number~) main::$8 ← (byte) main::NUM_POINTS#0 - (number) 1
Adding number conversion cast (unumber) main::$8 in (number~) main::$8 ← (byte) main::NUM_POINTS#0 - (unumber)(number) 1
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte) main::idx#0 ← (unumber)(number) 0
Inlining cast (byte) main::NUM_POINTS#0 ← (unumber)(number) 4
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 4
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$8 ← (byte) main::NUM_POINTS#0 - (byte) 1
Alias (byte) main::NUM_CIRCLES#0 = (byte~) main::$8
Successful SSA optimization Pass2AliasElimination
Constant right-side identified [2] (byte~) main::$0 ← (byte) '0' + (const byte) SIZEOF_STRUCT_POINT
Constant right-side identified [5] (byte~) main::$1 ← (byte) '0' + (const byte) SIZEOF_STRUCT_CIRCLE
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte*) SCREEN#0 = (byte*) 1024
Constant (const byte) main::idx#0 = 0
Constant (const byte) main::$0 = '0'+SIZEOF_STRUCT_POINT
Constant (const byte) main::$1 = '0'+SIZEOF_STRUCT_CIRCLE
Constant (const byte) main::$2 = SIZEOF_STRUCT_POINT
Constant (const byte) main::$4 = SIZEOF_STRUCT_CIRCLE
Constant (const byte) main::NUM_POINTS#0 = 4
Successful SSA optimization Pass2ConstantIdentification
Constant value identified { fill( main::NUM_POINTS#0, 0) } in [19] (struct Point[main::NUM_POINTS#0]) main::points#0 ← { fill( main::NUM_POINTS#0, 0) }
Successful SSA optimization Pass2ConstantValues
Simplifying expression containing zero SCREEN#0 in [3] *((const byte*) SCREEN#0 + (const byte) main::idx#0) ← (const byte) main::$0
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (byte) main::idx#8 and assignment [22] (byte) main::idx#8 ← ++ (byte) main::idx#7
Successful SSA optimization PassNEliminateUnusedVars
Constant right-side identified [1] (byte) main::idx#1 ← ++ (const byte) main::idx#0
Constant right-side identified [5] (byte~) main::$3 ← (byte) '0' + (const byte) main::$2
Constant right-side identified [8] (byte~) main::$5 ← (byte) '0' + (const byte) main::$4
Constant right-side identified [17] (byte) main::NUM_CIRCLES#0 ← (const byte) main::NUM_POINTS#0 - (byte) 1
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#1 = ++main::idx#0
Constant (const byte) main::$3 = '0'+main::$2
Constant (const byte) main::$5 = '0'+main::$4
Constant (const struct Point[main::NUM_POINTS#0]) main::points#0 = { fill( main::NUM_POINTS#0, 0) }
Constant (const byte) main::NUM_CIRCLES#0 = main::NUM_POINTS#0-1
Successful SSA optimization Pass2ConstantIdentification
Constant value identified { fill( main::NUM_CIRCLES#0, 0) } in [18] (struct Point[main::NUM_CIRCLES#0]) main::circles#0 ← { fill( main::NUM_CIRCLES#0, 0) }
Successful SSA optimization Pass2ConstantValues
Constant right-side identified [2] (byte) main::idx#2 ← ++ (const byte) main::idx#1
Constant right-side identified [9] (byte~) main::$6 ← sizeof (const struct Point[main::NUM_POINTS#0]) main::points#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#2 = ++main::idx#1
Constant (const byte) main::$6 = sizeof main::points#0
Constant (const struct Point[main::NUM_CIRCLES#0]) main::circles#0 = { fill( main::NUM_CIRCLES#0, 0) }
Successful SSA optimization Pass2ConstantIdentification
Resolving array sizeof() sizeof (const struct Point[main::NUM_POINTS#0]) main::points#0
Successful SSA optimization PassNSizeOfSimplification
Constant right-side identified [2] (byte) main::idx#3 ← ++ (const byte) main::idx#2
Constant right-side identified [8] (byte~) main::$7 ← (byte) '0' + (const byte) main::$6
Constant right-side identified [11] (byte~) main::$9 ← sizeof (const struct Point[main::NUM_CIRCLES#0]) main::circles#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#3 = ++main::idx#2
Constant (const byte) main::$7 = '0'+main::$6
Constant (const byte) main::$9 = sizeof main::circles#0
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant (const struct Point[main::NUM_POINTS#0]) main::points#0
Successful SSA optimization PassNEliminateUnusedVars
Resolving array sizeof() sizeof (const struct Point[main::NUM_CIRCLES#0]) main::circles#0
Successful SSA optimization PassNSizeOfSimplification
Constant right-side identified [3] (byte) main::idx#4 ← ++ (const byte) main::idx#3
Constant right-side identified [9] (byte~) main::$10 ← (byte) '0' + (const byte) main::$9
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#4 = ++main::idx#3
Constant (const byte) main::$10 = '0'+main::$9
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant (const struct Point[main::NUM_CIRCLES#0]) main::circles#0
Successful SSA optimization PassNEliminateUnusedVars
Constant right-side identified [4] (byte) main::idx#5 ← ++ (const byte) main::idx#4
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#5 = ++main::idx#4
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [4] (byte) main::idx#6 ← ++ (const byte) main::idx#5
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#6 = ++main::idx#5
Successful SSA optimization Pass2ConstantIdentification
Constant right-side identified [5] (byte) main::idx#7 ← ++ (const byte) main::idx#6
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::idx#7 = ++main::idx#6
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with different constant siblings (const byte) main::idx#0
Inlining constant with different constant siblings (const byte) main::idx#1
Inlining constant with different constant siblings (const byte) main::idx#2
Inlining constant with different constant siblings (const byte) main::idx#3
Inlining constant with different constant siblings (const byte) main::idx#4
Inlining constant with different constant siblings (const byte) main::idx#5
Inlining constant with different constant siblings (const byte) main::idx#6
Inlining constant with different constant siblings (const byte) main::idx#7
Constant inlined main::$10 = (byte) '0'+(const byte) main::NUM_CIRCLES#0*(const byte) SIZEOF_STRUCT_POINT
Constant inlined main::idx#0 = (byte) 0
Constant inlined main::idx#1 = ++(byte) 0
Constant inlined main::idx#2 = ++++(byte) 0
Constant inlined main::$1 = (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE
Constant inlined main::idx#3 = ++++++(byte) 0
Constant inlined main::$2 = (const byte) SIZEOF_STRUCT_POINT
Constant inlined main::idx#4 = ++++++++(byte) 0
Constant inlined main::idx#5 = ++++++++++(byte) 0
Constant inlined main::$0 = (byte) '0'+(const byte) SIZEOF_STRUCT_POINT
Constant inlined main::idx#6 = ++++++++++++(byte) 0
Constant inlined main::$5 = (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE
Constant inlined main::idx#7 = ++++++++++++++(byte) 0
Constant inlined main::$6 = (const byte) main::NUM_POINTS#0*(const byte) SIZEOF_STRUCT_POINT
Constant inlined main::$3 = (byte) '0'+(const byte) SIZEOF_STRUCT_POINT
Constant inlined main::$4 = (const byte) SIZEOF_STRUCT_CIRCLE
Constant inlined main::$9 = (const byte) main::NUM_CIRCLES#0*(const byte) SIZEOF_STRUCT_POINT
Constant inlined main::$7 = (byte) '0'+(const byte) main::NUM_POINTS#0*(const byte) SIZEOF_STRUCT_POINT
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(SCREEN#0+++0)
Consolidated array index constant in *(SCREEN#0+++++++0)
Consolidated array index constant in *(SCREEN#0+++++++++0)
Consolidated array index constant in *(SCREEN#0+++++++++++++0)
Consolidated array index constant in *(SCREEN#0+++++++++++++++0)
Successful SSA optimization Pass2ConstantAdditionElimination
Simplifying constant integer increment ++0
Simplifying constant integer increment ++0
Simplifying constant integer increment ++1
Simplifying constant integer increment ++2
Simplifying constant integer increment ++3
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer increment ++2
Simplifying constant integer increment ++3
Simplifying constant integer increment ++4
Simplifying constant integer increment ++5
Successful SSA optimization Pass2ConstantSimplification
Simplifying constant integer increment ++5
Simplifying constant integer increment ++6
Successful SSA optimization Pass2ConstantSimplification
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:2
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
main: scope:[main] from @1
[4] *((const byte*) SCREEN#0) ← (byte) '0'+(const byte) SIZEOF_STRUCT_POINT
[5] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE
[6] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_STRUCT_POINT
[7] *((const byte*) SCREEN#0+(byte) 4) ← (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE
[8] *((const byte*) SCREEN#0+(byte) 6) ← (byte) '0'+(const byte) main::NUM_POINTS#0*(const byte) SIZEOF_STRUCT_POINT
[9] *((const byte*) SCREEN#0+(byte) 7) ← (byte) '0'+(const byte) main::NUM_CIRCLES#0*(const byte) SIZEOF_STRUCT_POINT
to:main::@return
main::@return: scope:[main] from main
[10] return
to:@return
VARIABLE REGISTER WEIGHTS
(struct Point) Circle::center
(byte) Circle::radius
(byte) Point::x
(byte) Point::y
(byte*) SCREEN
(void()) main()
(byte) main::NUM_CIRCLES
(byte) main::NUM_POINTS
(struct Circle) main::c
(struct Point) main::c_center
(struct Point[main::NUM_CIRCLES#0]) main::circles
(byte) main::idx
(struct Point) main::p
(struct Point[main::NUM_POINTS#0]) main::points
Initial phi equivalence classes
Complete equivalence classes
INITIAL ASM
//SEG0 File Comments
// Tests the sizeof() operator on structs
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
.const SIZEOF_STRUCT_POINT = 2
.const SIZEOF_STRUCT_CIRCLE = 3
.label SCREEN = $400
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
// Struct Array
.const NUM_POINTS = 4
.const NUM_CIRCLES = NUM_POINTS-1
//SEG10 [4] *((const byte*) SCREEN#0) ← (byte) '0'+(const byte) SIZEOF_STRUCT_POINT -- _deref_pbuc1=vbuc2
// Struct Types
lda #'0'+SIZEOF_STRUCT_POINT
sta SCREEN
//SEG11 [5] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_STRUCT_CIRCLE
sta SCREEN+1
//SEG12 [6] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_STRUCT_POINT -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_STRUCT_POINT
sta SCREEN+3
//SEG13 [7] *((const byte*) SCREEN#0+(byte) 4) ← (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_STRUCT_CIRCLE
sta SCREEN+4
//SEG14 [8] *((const byte*) SCREEN#0+(byte) 6) ← (byte) '0'+(const byte) main::NUM_POINTS#0*(const byte) SIZEOF_STRUCT_POINT -- _deref_pbuc1=vbuc2
lda #'0'+NUM_POINTS*SIZEOF_STRUCT_POINT
sta SCREEN+6
//SEG15 [9] *((const byte*) SCREEN#0+(byte) 7) ← (byte) '0'+(const byte) main::NUM_CIRCLES#0*(const byte) SIZEOF_STRUCT_POINT -- _deref_pbuc1=vbuc2
lda #'0'+NUM_CIRCLES*SIZEOF_STRUCT_POINT
sta SCREEN+7
jmp breturn
//SEG16 main::@return
breturn:
//SEG17 [10] return
rts
}
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] *((const byte*) SCREEN#0) ← (byte) '0'+(const byte) SIZEOF_STRUCT_POINT [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [5] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [6] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_STRUCT_POINT [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [7] *((const byte*) SCREEN#0+(byte) 4) ← (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [8] *((const byte*) SCREEN#0+(byte) 6) ← (byte) '0'+(const byte) main::NUM_POINTS#0*(const byte) SIZEOF_STRUCT_POINT [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [9] *((const byte*) SCREEN#0+(byte) 7) ← (byte) '0'+(const byte) main::NUM_CIRCLES#0*(const byte) SIZEOF_STRUCT_POINT [ ] ( main:2 [ ] ) always clobbers reg byte a
REGISTER UPLIFT SCOPES
Uplift Scope [Point]
Uplift Scope [Circle]
Uplift Scope [main]
Uplift Scope []
Uplifting [Point] best 57 combination
Uplifting [Circle] best 57 combination
Uplifting [main] best 57 combination
Uplifting [] best 57 combination
ASSEMBLER BEFORE OPTIMIZATION
//SEG0 File Comments
// Tests the sizeof() operator on structs
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(bbegin)
.pc = $80d "Program"
//SEG2 Global Constants & labels
.const SIZEOF_STRUCT_POINT = 2
.const SIZEOF_STRUCT_CIRCLE = 3
.label SCREEN = $400
//SEG3 @begin
bbegin:
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
b1_from_bbegin:
jmp b1
//SEG5 @1
b1:
//SEG6 [2] call main
jsr main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
bend_from_b1:
jmp bend
//SEG8 @end
bend:
//SEG9 main
main: {
// Struct Array
.const NUM_POINTS = 4
.const NUM_CIRCLES = NUM_POINTS-1
//SEG10 [4] *((const byte*) SCREEN#0) ← (byte) '0'+(const byte) SIZEOF_STRUCT_POINT -- _deref_pbuc1=vbuc2
// Struct Types
lda #'0'+SIZEOF_STRUCT_POINT
sta SCREEN
//SEG11 [5] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_STRUCT_CIRCLE
sta SCREEN+1
//SEG12 [6] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_STRUCT_POINT -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_STRUCT_POINT
sta SCREEN+3
//SEG13 [7] *((const byte*) SCREEN#0+(byte) 4) ← (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_STRUCT_CIRCLE
sta SCREEN+4
//SEG14 [8] *((const byte*) SCREEN#0+(byte) 6) ← (byte) '0'+(const byte) main::NUM_POINTS#0*(const byte) SIZEOF_STRUCT_POINT -- _deref_pbuc1=vbuc2
lda #'0'+NUM_POINTS*SIZEOF_STRUCT_POINT
sta SCREEN+6
//SEG15 [9] *((const byte*) SCREEN#0+(byte) 7) ← (byte) '0'+(const byte) main::NUM_CIRCLES#0*(const byte) SIZEOF_STRUCT_POINT -- _deref_pbuc1=vbuc2
lda #'0'+NUM_CIRCLES*SIZEOF_STRUCT_POINT
sta SCREEN+7
jmp breturn
//SEG16 main::@return
breturn:
//SEG17 [10] return
rts
}
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp b1
Removing instruction jmp bend
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction b1_from_bbegin:
Removing instruction b1:
Removing instruction bend_from_b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction bend:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(struct Point) Circle::center
(byte) Circle::radius
(byte) Point::x
(byte) Point::y
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (byte*) 1024
(const byte) SIZEOF_STRUCT_CIRCLE SIZEOF_STRUCT_CIRCLE = (byte) 3
(const byte) SIZEOF_STRUCT_POINT SIZEOF_STRUCT_POINT = (byte) 2
(void()) main()
(label) main::@return
(byte) main::NUM_CIRCLES
(const byte) main::NUM_CIRCLES#0 NUM_CIRCLES = (const byte) main::NUM_POINTS#0-(byte) 1
(byte) main::NUM_POINTS
(const byte) main::NUM_POINTS#0 NUM_POINTS = (byte) 4
(struct Circle) main::c
(struct Point) main::c_center
(struct Point[main::NUM_CIRCLES#0]) main::circles
(byte) main::idx
(struct Point) main::p
(struct Point[main::NUM_POINTS#0]) main::points
FINAL ASSEMBLER
Score: 42
//SEG0 File Comments
// Tests the sizeof() operator on structs
//SEG1 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG2 Global Constants & labels
.const SIZEOF_STRUCT_POINT = 2
.const SIZEOF_STRUCT_CIRCLE = 3
.label SCREEN = $400
//SEG3 @begin
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
//SEG5 @1
//SEG6 [2] call main
//SEG7 [3] phi from @1 to @end [phi:@1->@end]
//SEG8 @end
//SEG9 main
main: {
// Struct Array
.const NUM_POINTS = 4
.const NUM_CIRCLES = NUM_POINTS-1
//SEG10 [4] *((const byte*) SCREEN#0) ← (byte) '0'+(const byte) SIZEOF_STRUCT_POINT -- _deref_pbuc1=vbuc2
// Struct Types
lda #'0'+SIZEOF_STRUCT_POINT
sta SCREEN
//SEG11 [5] *((const byte*) SCREEN#0+(byte) 1) ← (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_STRUCT_CIRCLE
sta SCREEN+1
//SEG12 [6] *((const byte*) SCREEN#0+(byte) 3) ← (byte) '0'+(const byte) SIZEOF_STRUCT_POINT -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_STRUCT_POINT
sta SCREEN+3
//SEG13 [7] *((const byte*) SCREEN#0+(byte) 4) ← (byte) '0'+(const byte) SIZEOF_STRUCT_CIRCLE -- _deref_pbuc1=vbuc2
lda #'0'+SIZEOF_STRUCT_CIRCLE
sta SCREEN+4
//SEG14 [8] *((const byte*) SCREEN#0+(byte) 6) ← (byte) '0'+(const byte) main::NUM_POINTS#0*(const byte) SIZEOF_STRUCT_POINT -- _deref_pbuc1=vbuc2
lda #'0'+NUM_POINTS*SIZEOF_STRUCT_POINT
sta SCREEN+6
//SEG15 [9] *((const byte*) SCREEN#0+(byte) 7) ← (byte) '0'+(const byte) main::NUM_CIRCLES#0*(const byte) SIZEOF_STRUCT_POINT -- _deref_pbuc1=vbuc2
lda #'0'+NUM_CIRCLES*SIZEOF_STRUCT_POINT
sta SCREEN+7
//SEG16 main::@return
//SEG17 [10] return
rts
}

View File

@ -0,0 +1 @@
program