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

Now removing any unused procedures in pass 1. Closed #96

This commit is contained in:
jespergravgaard 2017-11-28 00:39:15 +01:00
parent b81ae706af
commit 663b885196
51 changed files with 912 additions and 14 deletions

View File

@ -86,14 +86,12 @@ public class Compiler {
log.append("INITIAL CONTROL FLOW GRAPH");
log.append(program.getGraph().toString(program));
Pass1EliminateEmptyBlocks pass1EliminateEmptyBlocks = new Pass1EliminateEmptyBlocks(program);
boolean blockEliminated = pass1EliminateEmptyBlocks.eliminate();
if (blockEliminated) {
log.append("CONTROL FLOW GRAPH");
log.append(program.getGraph().toString(program));
}
new Pass1EliminateUncalledProcedures(program).eliminate();
new Pass1EliminateEmptyBlocks(program).eliminate();
log.append("CONTROL FLOW GRAPH");
log.append(program.getGraph().toString(program));
(new Pass1ModifiedVarsAnalysis(program)).findModifiedVars();
new Pass1ModifiedVarsAnalysis(program).findModifiedVars();
log.append("PROCEDURE MODIFY VARIABLE ANALYSIS");
log.append(program.getProcedureModifiedVars().toString(program));

View File

@ -118,12 +118,7 @@ public class ControlFlowGraph {
predecessorBlocks.add(other);
}
}
Collections.sort(predecessorBlocks, new Comparator<ControlFlowBlock>() {
@Override
public int compare(ControlFlowBlock o1, ControlFlowBlock o2) {
return o1.getLabel().getFullName().compareTo(o2.getLabel().getFullName());
}
});
Collections.sort(predecessorBlocks, Comparator.comparing(o -> o.getLabel().getFullName()));
return predecessorBlocks;
}

View File

@ -21,7 +21,6 @@ public class VariableReferenceInfos {
/** Variables defined in each statement. */
private Map<Integer, Collection<VariableRef>> stmtDefined;
public VariableReferenceInfos(
Map<LabelRef, Collection<VariableRef>> blockReferenced,
Map<LabelRef, Collection<VariableRef>> blockUsed,

View File

@ -61,6 +61,7 @@ public class Pass1AddTypePromotions {
if(assignment.getOperator()==null) {
// No operator - add cast directly!
assignment.setOperator(Operator.getCastUnary(lValueType));
getProgram().getLog().append("Promoting "+rValueType+" to "+lValueType+" in "+assignment);
} else {
throw new RuntimeException("Tmp-var promotions not implemented yet "+assignment);
}

View File

@ -0,0 +1,53 @@
package dk.camelot64.kickc.passes;
import dk.camelot64.kickc.model.*;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
/** Eliminate uncalled methods */
public class Pass1EliminateUncalledProcedures {
private Program program;
public Pass1EliminateUncalledProcedures(Program program) {
this.program = program;
}
public void eliminate() {
Set<ProcedureRef> calledProcedures = new LinkedHashSet<>();
for (ControlFlowBlock block : program.getGraph().getAllBlocks()) {
for (Statement statement : block.getStatements()) {
if(statement instanceof StatementCall) {
StatementCall call = (StatementCall) statement;
ProcedureRef procedureRef = call.getProcedure();
calledProcedures.add(procedureRef);
}
}
}
Set<ProcedureRef> unusedProcedures = new LinkedHashSet<>();
Collection<Procedure> allProcedures = program.getScope().getAllProcedures(true);
for (Procedure procedure : allProcedures) {
if(!calledProcedures.contains(procedure.getRef())) {
// The procedure is not used - mark for removal!
unusedProcedures.add(procedure.getRef());
}
}
for (ProcedureRef unusedProcedure : unusedProcedures) {
program.getLog().append("Removing unused procedure "+unusedProcedure);
Procedure procedure = program.getScope().getProcedure(unusedProcedure);
List<ControlFlowBlock> procedureBlocks = program.getGraph().getScopeBlocks(unusedProcedure);
for (ControlFlowBlock procedureBlock : procedureBlocks) {
program.getGraph().remove(procedureBlock.getLabel());
}
procedure.getScope().remove(procedure);
}
}
}

View File

@ -24,6 +24,10 @@ public class TestPrograms extends TestCase {
helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/");
}
public void testUnusedMethod() throws IOException, URISyntaxException {
compileAndCompare("unused-method");
}
public void testLocalString() throws IOException, URISyntaxException {
compileAndCompare("local-string");
}

View File

@ -68,6 +68,7 @@ SYMBOLS
(byte) main::k
(byte) main::l
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -707,6 +707,22 @@ SYMBOLS
(byte[]) plot_yhi
(byte[]) plot_ylo
Promoting word to byte* in COLS ← ((byte*)) 55296
Promoting word to byte* in BGCOL ← ((byte*)) 53280
Promoting word to byte* in FGCOL ← ((byte*)) 53281
Promoting word to byte* in SCROLL ← ((byte*)) 53270
Promoting word to byte* in D018 ← ((byte*)) 53272
Promoting word to byte* in D011 ← ((byte*)) 53265
Promoting word to byte* in D016 ← ((byte*)) 53270
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
Promoting word/signed word to byte* in BITMAP ← ((byte*)) 8192
Promoting word/signed word to byte[] in plot_xlo ← ((byte*)) 4096
Promoting word/signed word to byte[] in plot_xhi ← ((byte*)) 4352
Promoting word/signed word to byte[] in plot_ylo ← ((byte*)) 4608
Promoting word/signed word to byte[] in plot_yhi ← ((byte*)) 4864
Promoting word/signed word to byte[] in plot_bit ← ((byte*)) 5120
Promoting byte/signed byte/word/signed word to byte* in plot::plotter_x ← ((byte*)) 0
Promoting byte/signed byte/word/signed word to byte* in init_plot_tables::yoffs ← ((byte*)) 0
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) COLS ← ((byte*)) (word) 55296

View File

@ -331,6 +331,22 @@ SYMBOLS
(byte[]) plots_x
(byte[]) plots_y
Promoting word to byte* in D011 ← ((byte*)) 53265
Promoting word to byte* in RASTER ← ((byte*)) 53266
Promoting word to byte* in D016 ← ((byte*)) 53270
Promoting word to byte* in D018 ← ((byte*)) 53272
Promoting word to byte* in BGCOL ← ((byte*)) 53280
Promoting word to byte* in FGCOL ← ((byte*)) 53281
Promoting word to byte* in COLS ← ((byte*)) 55296
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
Promoting word/signed word to byte* in BITMAP ← ((byte*)) 8192
Promoting word/signed word to byte[] in plot_xlo ← ((byte*)) 4096
Promoting word/signed word to byte[] in plot_xhi ← ((byte*)) 4352
Promoting word/signed word to byte[] in plot_ylo ← ((byte*)) 4608
Promoting word/signed word to byte[] in plot_yhi ← ((byte*)) 4864
Promoting word/signed word to byte[] in plot_bit ← ((byte*)) 5120
Promoting byte/signed byte/word/signed word to byte* in plot::plotter_x ← ((byte*)) 0
Promoting byte/signed byte/word/signed word to byte* in init_plot_tables::yoffs ← ((byte*)) 0
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) D011 ← ((byte*)) (word) 53265

View File

@ -104,6 +104,7 @@ SYMBOLS
(byte) main::y1
(byte) main::yd
Promoting word/signed word to byte[1000] in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte) STAR ← (byte/signed byte/word/signed word) 81

View File

@ -102,6 +102,8 @@ SYMBOLS
(byte) main::y1
(byte) main::yd
Promoting word/signed word to byte[1000] in main::screen ← ((byte*)) 1024
Promoting byte to word in main::idx ← ((word)) main::$4
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1

View File

@ -53,6 +53,7 @@ SYMBOLS
(label) main::@return
(byte*) screen
Promoting word/signed word to byte* in screen ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) screen ← ((byte*)) (word/signed word) 1024

View File

@ -114,6 +114,7 @@ SYMBOLS
(word) w::w1
(word) w::w2
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -92,6 +92,9 @@ SYMBOLS
(byte) main::x
(byte) main::y
Promoting byte/signed byte/word/signed word to byte* in PROCPORT ← ((byte*)) 1
Promoting word to byte* in CHARGEN ← ((byte*)) 53248
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) PROCPORT ← ((byte*)) (byte/signed byte/word/signed word) 1
@ -149,6 +152,63 @@ main::@return: scope:[main] from main::@6
to:@end
@end: scope:[] from @1
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) PROCPORT ← ((byte*)) (byte/signed byte/word/signed word) 1
(byte*) CHARGEN ← ((byte*)) (word) 53248
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024
to:@1
main: scope:[main] from
asm { sei }
(byte*~) main::$0 ← (byte*) CHARGEN + (byte/signed byte/word/signed word) 8
(byte*) main::CHAR_A ← (byte*~) main::$0
*((byte*) PROCPORT) ← (byte/signed byte/word/signed word) 50
(byte*) main::sc ← (byte*) SCREEN
(byte) main::y ← (byte/signed byte/word/signed word) 0
to:main::@1
main::@1: scope:[main] from main main::@5
(byte~) main::$1 ← (byte*) main::CHAR_A *idx (byte) main::y
(byte) main::bits ← (byte~) main::$1
(byte) main::x ← (byte/signed byte/word/signed word) 0
to:main::@2
main::@2: scope:[main] from main::@1 main::@3
(byte) main::c ← (byte) '.'
(byte~) main::$2 ← (byte) main::bits & (byte/word/signed word) 128
(boolean~) main::$3 ← (byte~) main::$2 != (byte/signed byte/word/signed word) 0
(boolean~) main::$4 ← ! (boolean~) main::$3
if((boolean~) main::$4) goto main::@3
to:main::@4
main::@3: scope:[main] from main::@2 main::@4
*((byte*) main::sc) ← (byte) main::c
(byte*) main::sc ← ++ (byte*) main::sc
(byte~) main::$5 ← (byte) main::bits << (byte/signed byte/word/signed word) 1
(byte) main::bits ← (byte~) main::$5
(byte) main::x ← ++ (byte) main::x
(boolean~) main::$6 ← (byte) main::x != (byte/signed byte/word/signed word) 8
if((boolean~) main::$6) goto main::@2
to:main::@5
main::@4: scope:[main] from main::@2
(byte) main::c ← (byte) '*'
to:main::@3
main::@5: scope:[main] from main::@3
(byte*~) main::$7 ← (byte*) main::sc + (byte/signed byte/word/signed word) 32
(byte*) main::sc ← (byte*~) main::$7
(byte) main::y ← ++ (byte) main::y
(boolean~) main::$8 ← (byte) main::y != (byte/signed byte/word/signed word) 8
if((boolean~) main::$8) goto main::@1
to:main::@6
main::@6: scope:[main] from main::@5
*((byte*) PROCPORT) ← (byte/signed byte/word/signed word) 55
asm { cli }
to:main::@return
main::@return: scope:[main] from main::@6
return
to:@return
@1: scope:[] from @begin
call main
to:@end
@end: scope:[] from @1
PROCEDURE MODIFY VARIABLE ANALYSIS
CONTROL FLOW GRAPH WITH ASSIGNMENT CALL

View File

@ -103,6 +103,8 @@ SYMBOLS
(byte) plot::x
(byte[]) plots
Promoting word/signed word to byte[] in plots ← ((byte*)) 4096
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte[]) plots ← ((byte*)) (word/signed word) 4096

View File

@ -52,6 +52,8 @@ SYMBOLS
(label) main::@return
(byte) main::i
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
Promoting word to byte* in VIC ← ((byte*)) 53248
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -43,6 +43,7 @@ SYMBOLS
(label) main::@return
(byte) main::i
Promoting word/signed word to byte[15] in fibs ← ((byte*)) 4352
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte[15]) fibs ← ((byte*)) (word/signed word) 4352

View File

@ -198,6 +198,10 @@ SYMBOLS
(label) prepare::@return
(byte) prepare::i
Promoting word/signed word to byte[1000] in SCREEN ← ((byte*)) 1024
Promoting word/signed word to byte[256] in buffer1 ← ((byte*)) 4096
Promoting word/signed word to byte[256] in buffer2 ← ((byte*)) 4352
Promoting word to byte* in RASTER ← ((byte*)) 53266
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte[1000]) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -47,6 +47,8 @@ SYMBOLS
(byte) main::i
(byte) main::j
Promoting word/signed word to byte* in SCREEN1 ← ((byte*)) 1024
Promoting word/signed word to byte* in SCREEN2 ← ((byte*)) 1280
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN1 ← ((byte*)) (word/signed word) 1024

View File

@ -208,6 +208,12 @@ SYMBOLS
(byte*) main::charset4
(byte) main::i
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
Promoting word/signed word to byte* in CHARSET ← ((byte*)) 8192
Promoting word to byte* in CHARGEN ← ((byte*)) 53248
Promoting byte/signed byte/word/signed word to byte* in PROCPORT ← ((byte*)) 1
Promoting word to byte* in D018 ← ((byte*)) 53272
Promoting word/signed word to byte* in CHARSET4 ← ((byte*)) 10240
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024
@ -330,6 +336,128 @@ main::@return: scope:[main] from main::@12
to:@end
@end: scope:[] from @1
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024
(byte*) CHARSET ← ((byte*)) (word/signed word) 8192
(byte*) CHARGEN ← ((byte*)) (word) 53248
(byte*) PROCPORT ← ((byte*)) (byte/signed byte/word/signed word) 1
(byte*) D018 ← ((byte*)) (word) 53272
(byte*) CHARSET4 ← ((byte*)) (word/signed word) 10240
(byte[]) bits_count ← { (byte/signed byte/word/signed word) 0, (byte/signed byte/word/signed word) 1, (byte/signed byte/word/signed word) 1, (byte/signed byte/word/signed word) 2, (byte/signed byte/word/signed word) 1, (byte/signed byte/word/signed word) 2, (byte/signed byte/word/signed word) 2, (byte/signed byte/word/signed word) 3, (byte/signed byte/word/signed word) 1, (byte/signed byte/word/signed word) 2, (byte/signed byte/word/signed word) 2, (byte/signed byte/word/signed word) 3, (byte/signed byte/word/signed word) 2, (byte/signed byte/word/signed word) 3, (byte/signed byte/word/signed word) 3, (byte/signed byte/word/signed word) 4 }
to:@1
main: scope:[main] from
asm { sei }
*((byte*) PROCPORT) ← (byte/signed byte/word/signed word) 50
(byte*) main::chargen ← (byte*) CHARGEN
(byte*) main::charset4 ← (byte*) CHARSET4
to:main::@1
main::@1: scope:[main] from main main::@5
(byte) main::bits_gen ← (byte/signed byte/word/signed word) 0
(byte*~) main::$0 ← (byte*) main::chargen + (byte/signed byte/word/signed word) 1
(byte*) main::chargen1 ← (byte*~) main::$0
(byte~) main::$1 ← *((byte*) main::chargen) & (byte/signed byte/word/signed word) 96
(byte~) main::$2 ← *((byte*) main::chargen1) & (byte/signed byte/word/signed word) 96
(byte~) main::$3 ← (byte~) main::$2 >> (byte/signed byte/word/signed word) 2
(byte~) main::$4 ← (byte~) main::$1 | (byte~) main::$3
(byte~) main::$5 ← (byte~) main::$4 >> (byte/signed byte/word/signed word) 1
(byte~) main::$6 ← (byte~) main::$5 >> (byte/signed byte/word/signed word) 2
(byte~) main::$7 ← (byte[]) bits_count *idx (byte~) main::$6
(byte) main::bits ← (byte~) main::$7
(boolean~) main::$8 ← (byte) main::bits >= (byte/signed byte/word/signed word) 2
(boolean~) main::$9 ← ! (boolean~) main::$8
if((boolean~) main::$9) goto main::@2
to:main::@7
main::@2: scope:[main] from main::@1 main::@7
(byte~) main::$11 ← (byte) main::bits_gen << (byte/signed byte/word/signed word) 1
(byte) main::bits_gen ← (byte~) main::$11
(byte~) main::$12 ← *((byte*) main::chargen) & (byte/signed byte/word/signed word) 24
(byte~) main::$13 ← *((byte*) main::chargen1) & (byte/signed byte/word/signed word) 24
(byte~) main::$14 ← (byte~) main::$13 >> (byte/signed byte/word/signed word) 2
(byte~) main::$15 ← (byte~) main::$12 | (byte~) main::$14
(byte~) main::$16 ← (byte~) main::$15 >> (byte/signed byte/word/signed word) 1
(byte~) main::$17 ← (byte[]) bits_count *idx (byte~) main::$16
(byte) main::bits ← (byte~) main::$17
(boolean~) main::$18 ← (byte) main::bits >= (byte/signed byte/word/signed word) 2
(boolean~) main::$19 ← ! (boolean~) main::$18
if((boolean~) main::$19) goto main::@3
to:main::@8
main::@7: scope:[main] from main::@1
(byte~) main::$10 ← (byte) main::bits_gen + (byte/signed byte/word/signed word) 1
(byte) main::bits_gen ← (byte~) main::$10
to:main::@2
main::@3: scope:[main] from main::@2 main::@8
(byte~) main::$21 ← (byte) main::bits_gen << (byte/signed byte/word/signed word) 1
(byte) main::bits_gen ← (byte~) main::$21
(byte~) main::$22 ← *((byte*) main::chargen) & (byte/signed byte/word/signed word) 6
(byte~) main::$23 ← (byte~) main::$22 << (byte/signed byte/word/signed word) 1
(byte~) main::$24 ← *((byte*) main::chargen1) & (byte/signed byte/word/signed word) 6
(byte~) main::$25 ← (byte~) main::$24 >> (byte/signed byte/word/signed word) 1
(byte~) main::$26 ← (byte~) main::$23 | (byte~) main::$25
(byte~) main::$27 ← (byte[]) bits_count *idx (byte~) main::$26
(byte) main::bits ← (byte~) main::$27
(boolean~) main::$28 ← (byte) main::bits >= (byte/signed byte/word/signed word) 2
(boolean~) main::$29 ← ! (boolean~) main::$28
if((boolean~) main::$29) goto main::@4
to:main::@9
main::@8: scope:[main] from main::@2
(byte~) main::$20 ← (byte) main::bits_gen + (byte/signed byte/word/signed word) 1
(byte) main::bits_gen ← (byte~) main::$20
to:main::@3
main::@4: scope:[main] from main::@3 main::@9
(byte~) main::$31 ← (byte) main::bits_gen << (byte/signed byte/word/signed word) 1
(byte) main::bits_gen ← (byte~) main::$31
(byte~) main::$32 ← *((byte*) main::chargen) & (byte/signed byte/word/signed word) 1
(byte~) main::$33 ← (byte~) main::$32 << (byte/signed byte/word/signed word) 2
(byte~) main::$34 ← *((byte*) main::chargen1) & (byte/signed byte/word/signed word) 1
(byte~) main::$35 ← (byte~) main::$33 | (byte~) main::$34
(byte~) main::$36 ← (byte[]) bits_count *idx (byte~) main::$35
(byte) main::bits ← (byte~) main::$36
(boolean~) main::$37 ← (byte) main::bits >= (byte/signed byte/word/signed word) 2
(boolean~) main::$38 ← ! (boolean~) main::$37
if((boolean~) main::$38) goto main::@5
to:main::@10
main::@9: scope:[main] from main::@3
(byte~) main::$30 ← (byte) main::bits_gen + (byte/signed byte/word/signed word) 1
(byte) main::bits_gen ← (byte~) main::$30
to:main::@4
main::@5: scope:[main] from main::@10 main::@4
(byte~) main::$40 ← (byte) main::bits_gen << (byte/signed byte/word/signed word) 1
(byte) main::bits_gen ← (byte~) main::$40
*((byte*) main::charset4) ← (byte) main::bits_gen
(byte*) main::charset4 ← ++ (byte*) main::charset4
(byte*~) main::$41 ← (byte*) main::chargen + (byte/signed byte/word/signed word) 2
(byte*) main::chargen ← (byte*~) main::$41
(byte*~) main::$42 ← (byte*) CHARGEN + (word/signed word) 2048
(boolean~) main::$43 ← (byte*) main::chargen < (byte*~) main::$42
if((boolean~) main::$43) goto main::@1
to:main::@11
main::@10: scope:[main] from main::@4
(byte~) main::$39 ← (byte) main::bits_gen + (byte/signed byte/word/signed word) 1
(byte) main::bits_gen ← (byte~) main::$39
to:main::@5
main::@11: scope:[main] from main::@5
*((byte*) PROCPORT) ← (byte/signed byte/word/signed word) 55
asm { cli }
(byte) main::i ← (byte/signed byte/word/signed word) 0
to:main::@6
main::@6: scope:[main] from main::@11 main::@6
*((byte*) SCREEN + (byte) main::i) ← (byte) main::i
(byte) main::i ← ++ (byte) main::i
(boolean~) main::$44 ← (byte) main::i != (byte/signed byte/word/signed word) 0
if((boolean~) main::$44) goto main::@6
to:main::@12
main::@12: scope:[main] from main::@6
*((byte*) D018) ← (byte/signed byte/word/signed word) 25
to:main::@return
main::@return: scope:[main] from main::@12
return
to:@return
@1: scope:[] from @begin
call main
to:@end
@end: scope:[] from @1
PROCEDURE MODIFY VARIABLE ANALYSIS
CONTROL FLOW GRAPH WITH ASSIGNMENT CALL

View File

@ -39,6 +39,7 @@ SYMBOLS
(label) main::@return
(byte) main::i
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -28,6 +28,7 @@ SYMBOLS
(label) main::@1
(label) main::@return
Promoting word to byte* in BGCOL ← ((byte*)) 53280
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) BGCOL ← ((byte*)) (word) 53280

View File

@ -39,6 +39,20 @@ main::@return: scope:[main] from main
to:@end
@end: scope:[] from @1
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from
asm { lda#'a'ldx#$ff!:sta$0400,xsta$0500,xsta$0600,xsta$0700,xdexbne!- }
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@1: scope:[] from @begin
call main
to:@end
@end: scope:[] from @1
PROCEDURE MODIFY VARIABLE ANALYSIS
CONTROL FLOW GRAPH WITH ASSIGNMENT CALL

View File

@ -46,6 +46,8 @@ SYMBOLS
(byte) main::i
(byte[]) main::txt
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
Promoting word/signed word to byte* in SCREEN2 ← ((byte*)) $0
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -49,6 +49,7 @@ SYMBOLS
(byte) main::i
(byte) main::j
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -53,6 +53,7 @@ SYMBOLS
(byte*) main::cursor
(byte) main::i
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -34,6 +34,7 @@ SYMBOLS
(byte[16]) main::buf
(byte) main::i
Promoting word/signed word to byte[16] in main::buf ← ((byte*)) 4352
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1

View File

@ -58,6 +58,7 @@ SYMBOLS
(byte[]) nums
(byte[]) str
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -43,6 +43,7 @@ SYMBOLS
(byte[]) main::msg
(byte*) main::screen
Promoting word/signed word to byte* in main::screen ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1

View File

@ -54,6 +54,7 @@ SYMBOLS
(label) nest::@return
(byte) nest::j
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -114,6 +114,7 @@ SYMBOLS
(byte) nest2::i
(byte) nest2::j
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -62,6 +62,7 @@ SYMBOLS
(byte~) main::$1
(label) main::@return
Promoting word/signed word to byte[256] in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte) cnt ← (byte/signed byte/word/signed word) 0

View File

@ -48,6 +48,7 @@ SYMBOLS
(void~) main::$1
(label) main::@return
Promoting word/signed word to byte[256] in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte) cnt ← (byte/signed byte/word/signed word) 0

View File

@ -73,6 +73,7 @@ SYMBOLS
(label) plot::@return
(byte) plot::x
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -69,6 +69,7 @@ SYMBOLS
(label) plot::@return
(byte) plot::x
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -118,6 +118,8 @@ SYMBOLS
(byte*) main::sc2
(byte*) main::screen
Promoting word/signed word to byte* in main::screen ← ((byte*)) 1024
Promoting word to byte* in main::BGCOL ← ((byte*)) 53280
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
@ -178,6 +180,66 @@ main::@return: scope:[main] from main::@4
to:@end
@end: scope:[] from @1
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from
(byte*) main::screen ← ((byte*)) (word/signed word) 1024
(byte*~) main::$0 ← (byte*) main::screen + (byte/signed byte/word/signed word) 80
(byte) main::a ← *((byte*~) main::$0)
(byte) main::i ← (byte/signed byte/word/signed word) 0
to:main::@1
main::@1: scope:[main] from main main::@1
(byte*~) main::$1 ← (byte*) main::screen + (byte/signed byte/word/signed word) 40
(byte*~) main::$2 ← (byte*~) main::$1 + (byte) main::i
*((byte*) main::screen + (byte) main::i) ← *((byte*~) main::$2)
(byte) main::i ← ++ (byte) main::i
(boolean~) main::$3 ← (byte) main::i != (byte/signed byte/word/signed word) 11
if((boolean~) main::$3) goto main::@1
to:main::@3
main::@3: scope:[main] from main::@1
(byte*~) main::$4 ← (byte*) main::screen + (byte/signed byte/word/signed word) 81
(byte*) main::sc2 ← (byte*~) main::$4
(byte*~) main::$5 ← (byte*) main::screen + (byte/signed byte/word/signed word) 121
*((byte*) main::sc2) ← *((byte*~) main::$5)
(byte*~) main::$6 ← (byte*) main::screen + (byte/signed byte/word/signed word) 82
(byte*~) main::$7 ← (byte*) main::screen + (byte/signed byte/word/signed word) 122
*((byte*~) main::$6) ← *((byte*~) main::$7)
(byte) main::j ← (byte/signed byte/word/signed word) 0
to:main::@2
main::@2: scope:[main] from main::@2 main::@3
(byte*~) main::$8 ← (byte*) main::screen + (byte/word/signed word) 160
(byte*~) main::$9 ← (byte*~) main::$8 + (byte) main::j
(byte*~) main::$10 ← (byte*) main::screen + (byte/word/signed word) 200
(byte*~) main::$11 ← (byte*~) main::$10 + (byte) main::j
*((byte*~) main::$9) ← *((byte*~) main::$11)
(byte) main::j ← ++ (byte) main::j
(boolean~) main::$12 ← (byte) main::j != (byte/signed byte/word/signed word) 11
if((boolean~) main::$12) goto main::@2
to:main::@4
main::@4: scope:[main] from main::@2
(byte*~) main::$13 ← ((byte*)) (word) 53280
*((byte*~) main::$13) ← ++ *((byte*~) main::$13)
(byte*~) main::$14 ← ((byte*)) (word) 53280
(byte*~) main::$15 ← ((byte*)) (word) 53280
(word~) main::$16 ← (word) 53248 + (byte/signed byte/word/signed word) 33
(byte*~) main::$17 ← ((byte*)) (word~) main::$16
*((byte*~) main::$17) ← -- *((byte*~) main::$17)
(word~) main::$18 ← (word) 53248 + (byte/signed byte/word/signed word) 33
(byte*~) main::$19 ← ((byte*)) (word~) main::$18
(word~) main::$20 ← (word) 53248 + (byte/signed byte/word/signed word) 33
(byte*~) main::$21 ← ((byte*)) (word~) main::$20
(byte*) main::BGCOL ← ((byte*)) (word) 53280
*((byte*) main::BGCOL) ← ++ *((byte*) main::BGCOL)
to:main::@return
main::@return: scope:[main] from main::@4
return
to:@return
@1: scope:[] from @begin
call main
to:@end
@end: scope:[] from @1
PROCEDURE MODIFY VARIABLE ANALYSIS
CONTROL FLOW GRAPH WITH ASSIGNMENT CALL

View File

@ -203,6 +203,10 @@ SYMBOLS
(byte) rvaluevar::i
(byte*) rvaluevar::screen
Promoting word/signed word to byte[1024] in lvalue::SCREEN ← ((byte*)) 1024
Promoting word/signed word to byte[1024] in rvalue::SCREEN ← ((byte*)) 1024
Promoting word/signed word to byte* in lvaluevar::screen ← ((byte*)) 1024
Promoting word/signed word to byte* in rvaluevar::screen ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1

View File

@ -47,6 +47,7 @@ SYMBOLS
(byte) main::b
(byte) main::i
Promoting word/signed word to byte[1024] in main::SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1

View File

@ -56,6 +56,8 @@ SYMBOLS
(byte) main::i
(byte*) main::nxt
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
Promoting word to byte* in SCROLL ← ((byte*)) 53270
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -147,6 +147,10 @@ SYMBOLS
(byte*) main::nxt
(byte) main::scroll
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
Promoting word to byte* in RASTER ← ((byte*)) 53266
Promoting word to byte* in BGCOL ← ((byte*)) 53280
Promoting word to byte* in SCROLL ← ((byte*)) 53270
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -385,6 +385,13 @@ SYMBOLS
(label) scroll_soft::@1
(label) scroll_soft::@return
Promoting byte/signed byte/word/signed word to byte* in PROCPORT ← ((byte*)) 1
Promoting word to byte* in CHARGEN ← ((byte*)) 53248
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
Promoting word to byte* in RASTER ← ((byte*)) 53266
Promoting word to byte* in BGCOL ← ((byte*)) 53280
Promoting word to byte* in SCROLL ← ((byte*)) 53270
Promoting byte to word in scroll_bit::c ← ((word)) scroll_bit::$3
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) PROCPORT ← ((byte*)) (byte/signed byte/word/signed word) 1

View File

@ -47,6 +47,7 @@ SYMBOLS
(byte) main::j
(byte[]) main::screen
Promoting word/signed word to byte[] in main::screen ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1

View File

@ -0,0 +1,10 @@
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
jsr main
main: {
.const screen = $400
lda #1
sta screen+0
rts
}

View File

@ -0,0 +1,12 @@
@begin: scope:[] from
to:@2
@2: scope:[] from @begin
[0] call main param-assignment [ ] ( )
to:@end
@end: scope:[] from @2
main: scope:[main] from @2
[1] *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1 [ ] ( main:0 [ ] )
to:main::@return
main::@return: scope:[main] from main
[2] return [ ] ( main:0 [ ] )
to:@return

View File

@ -0,0 +1,442 @@
void main() {
byte* screen = $0400;
screen[0] = 1;
}
byte sum(byte b1, byte b2) {
return b1+b2;
}
PROGRAM
proc (void()) main()
(byte*) main::screen ← (word/signed word) 1024
*((byte*) main::screen + (byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1
main::@return:
return
endproc // main()
proc (byte()) sum((byte) sum::b1 , (byte) sum::b2)
(byte~) sum::$0 ← (byte) sum::b1 + (byte) sum::b2
(byte) sum::return ← (byte~) sum::$0
goto sum::@return
sum::@return:
(byte) sum::return ← (byte) sum::return
return (byte) sum::return
endproc // sum()
call main
SYMBOLS
(void()) main()
(label) main::@return
(byte*) main::screen
(byte()) sum((byte) sum::b1 , (byte) sum::b2)
(byte~) sum::$0
(label) sum::@return
(byte) sum::b1
(byte) sum::b2
(byte) sum::return
Promoting word/signed word to byte* in main::screen ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1
main: scope:[main] from
(byte*) main::screen ← ((byte*)) (word/signed word) 1024
*((byte*) main::screen + (byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@1: scope:[] from @begin
to:@2
sum: scope:[sum] from
(byte~) sum::$0 ← (byte) sum::b1 + (byte) sum::b2
(byte) sum::return ← (byte~) sum::$0
to:sum::@return
sum::@return: scope:[sum] from sum sum::@1
(byte) sum::return ← (byte) sum::return
return (byte) sum::return
to:@return
sum::@1: scope:[sum] from
to:sum::@return
@2: scope:[] from @1
call main
to:@end
@end: scope:[] from @2
Removing unused procedure sum
Removing empty block @1
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@2
main: scope:[main] from
(byte*) main::screen ← ((byte*)) (word/signed word) 1024
*((byte*) main::screen + (byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@2: scope:[] from @begin
call main
to:@end
@end: scope:[] from @2
PROCEDURE MODIFY VARIABLE ANALYSIS
CONTROL FLOW GRAPH WITH ASSIGNMENT CALL
@begin: scope:[] from
to:@2
main: scope:[main] from @2
(byte*) main::screen ← ((byte*)) (word/signed word) 1024
*((byte*) main::screen + (byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@2: scope:[] from @begin
call main param-assignment
to:@3
@3: scope:[] from @2
to:@end
@end: scope:[] from @3
Completing Phi functions...
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
to:@2
main: scope:[main] from @2
(byte*) main::screen#0 ← ((byte*)) (word/signed word) 1024
*((byte*) main::screen#0 + (byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@2: scope:[] from @begin
call main param-assignment
to:@3
@3: scope:[] from @2
to:@end
@end: scope:[] from @3
CONTROL FLOW GRAPH WITH ASSIGNMENT CALL & RETURN
@begin: scope:[] from
to:@2
main: scope:[main] from @2
(byte*) main::screen#0 ← ((byte*)) (word/signed word) 1024
*((byte*) main::screen#0 + (byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@2: scope:[] from @begin
call main param-assignment
to:@3
@3: scope:[] from @2
to:@end
@end: scope:[] from @3
INITIAL SSA SYMBOL TABLE
(label) @2
(label) @3
(label) @begin
(label) @end
(void()) main()
(label) main::@return
(byte*) main::screen
(byte*) main::screen#0
Culled Empty Block (label) @3
Succesful SSA optimization Pass2CullEmptyBlocks
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@2
main: scope:[main] from @2
(byte*) main::screen#0 ← ((byte*)) (word/signed word) 1024
*((byte*) main::screen#0 + (byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@2: scope:[] from @begin
call main param-assignment
to:@end
@end: scope:[] from @2
Constant (const byte*) main::screen#0 = ((byte*))1024
Succesful SSA optimization Pass2ConstantIdentification
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@2
main: scope:[main] from @2
*((const byte*) main::screen#0 + (byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@2: scope:[] from @begin
call main param-assignment
to:@end
@end: scope:[] from @2
Consolidated assigned array index constant in assignment *(main::screen#0+0)
Succesful SSA optimization Pass2ConstantAdditionElimination
CONTROL FLOW GRAPH
@begin: scope:[] from
to:@2
main: scope:[main] from @2
*((const byte*) main::screen#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@2: scope:[] from @begin
call main param-assignment
to:@end
@end: scope:[] from @2
FINAL SYMBOL TABLE
(label) @2
(label) @begin
(label) @end
(void()) main()
(label) main::@return
(byte*) main::screen
(const byte*) main::screen#0 = ((byte*))(word/signed word) 1024
Block Sequence Planned @begin @2 @end main main::@return
Block Sequence Planned @begin @2 @end main main::@return
CONTROL FLOW GRAPH - PHI LIFTED
@begin: scope:[] from
to:@2
@2: scope:[] from @begin
call main param-assignment
to:@end
@end: scope:[] from @2
main: scope:[main] from @2
*((const byte*) main::screen#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1
to:main::@return
main::@return: scope:[main] from main
return
to:@return
CALL GRAPH
Calls in [] to main:0
Propagating live ranges...
CONTROL FLOW GRAPH - LIVE RANGES FOUND
@begin: scope:[] from
to:@2
@2: scope:[] from @begin
[0] call main param-assignment [ ]
to:@end
@end: scope:[] from @2
main: scope:[main] from @2
[1] *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1 [ ]
to:main::@return
main::@return: scope:[main] from main
[2] return [ ]
to:@return
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Block Sequence Planned @begin @2 @end main main::@return
Propagating live ranges...
CONTROL FLOW GRAPH - BEFORE EFFECTIVE LIVE RANGES
@begin: scope:[] from
to:@2
@2: scope:[] from @begin
[0] call main param-assignment [ ]
to:@end
@end: scope:[] from @2
main: scope:[main] from @2
[1] *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1 [ ]
to:main::@return
main::@return: scope:[main] from main
[2] return [ ]
to:@return
CONTROL FLOW GRAPH - PHI MEM COALESCED
@begin: scope:[] from
to:@2
@2: scope:[] from @begin
[0] call main param-assignment [ ] ( )
to:@end
@end: scope:[] from @2
main: scope:[main] from @2
[1] *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1 [ ] ( main:0 [ ] )
to:main::@return
main::@return: scope:[main] from main
[2] return [ ] ( main:0 [ ] )
to:@return
DOMINATORS
@begin dominated by @begin
@2 dominated by @2 @begin
@end dominated by @2 @begin @end
main dominated by @2 @begin main
main::@return dominated by main::@return @2 @begin main
NATURAL LOOPS
Found 0 loops in scope []
Found 0 loops in scope [main]
NATURAL LOOPS WITH DEPTH
VARIABLE REGISTER WEIGHTS
(void()) main()
(byte*) main::screen
Initial phi equivalence classes
Complete equivalence classes
INITIAL ASM
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
//SEG2 @begin
bbegin:
jmp b2
//SEG3 @2
b2:
//SEG4 [0] call main param-assignment [ ] ( )
jsr main
jmp bend
//SEG5 @end
bend:
//SEG6 main
main: {
.const screen = $400
//SEG7 [1] *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1 [ ] ( main:0 [ ] ) -- _deref_cowo1=coby2
lda #1
sta screen+0
jmp breturn
//SEG8 main::@return
breturn:
//SEG9 [2] return [ ] ( main:0 [ ] )
rts
}
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1 [ ] ( main:0 [ ] ) always clobbers reg byte a
REGISTER UPLIFT SCOPES
Uplift Scope [main]
Uplift Scope []
Uplifting [main] best 54 combination
Uplifting [] best 54 combination
Removing instruction jmp b2
Removing instruction jmp bend
Removing instruction jmp breturn
Succesful ASM optimization Pass5NextJumpElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
//SEG2 @begin
bbegin:
//SEG3 @2
b2:
//SEG4 [0] call main param-assignment [ ] ( )
jsr main
//SEG5 @end
bend:
//SEG6 main
main: {
.const screen = $400
//SEG7 [1] *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1 [ ] ( main:0 [ ] ) -- _deref_cowo1=coby2
lda #1
sta screen+0
//SEG8 main::@return
breturn:
//SEG9 [2] return [ ] ( main:0 [ ] )
rts
}
Removing instruction bbegin:
Succesful ASM optimization Pass5RedundantLabelElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
//SEG2 @begin
//SEG3 @2
b2:
//SEG4 [0] call main param-assignment [ ] ( )
jsr main
//SEG5 @end
bend:
//SEG6 main
main: {
.const screen = $400
//SEG7 [1] *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1 [ ] ( main:0 [ ] ) -- _deref_cowo1=coby2
lda #1
sta screen+0
//SEG8 main::@return
breturn:
//SEG9 [2] return [ ] ( main:0 [ ] )
rts
}
Removing instruction b2:
Removing instruction bend:
Removing instruction breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
ASSEMBLER
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
//SEG2 @begin
//SEG3 @2
//SEG4 [0] call main param-assignment [ ] ( )
jsr main
//SEG5 @end
//SEG6 main
main: {
.const screen = $400
//SEG7 [1] *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1 [ ] ( main:0 [ ] ) -- _deref_cowo1=coby2
lda #1
sta screen+0
//SEG8 main::@return
//SEG9 [2] return [ ] ( main:0 [ ] )
rts
}
FINAL SYMBOL TABLE
(label) @2
(label) @begin
(label) @end
(void()) main()
(label) main::@return
(byte*) main::screen
(const byte*) main::screen#0 screen = ((byte*))(word/signed word) 1024
FINAL CODE
//SEG0 Basic Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
//SEG1 Global Constants & labels
//SEG2 @begin
//SEG3 @2
//SEG4 [0] call main param-assignment [ ] ( )
jsr main
//SEG5 @end
//SEG6 main
main: {
.const screen = $400
//SEG7 [1] *((const byte*) main::screen#0+(byte/signed byte/word/signed word) 0) ← (byte/signed byte/word/signed word) 1 [ ] ( main:0 [ ] ) -- _deref_cowo1=coby2
lda #1
sta screen+0
//SEG8 main::@return
//SEG9 [2] return [ ] ( main:0 [ ] )
rts
}

View File

@ -0,0 +1,8 @@
(label) @2
(label) @begin
(label) @end
(void()) main()
(label) main::@return
(byte*) main::screen
(const byte*) main::screen#0 screen = ((byte*))(word/signed word) 1024

View File

@ -17,6 +17,7 @@ SYMBOLS
(void()) main()
(label) main::@return
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024
@ -32,6 +33,21 @@ main::@return: scope:[main] from main
to:@end
@end: scope:[] from @1
CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024
to:@1
main: scope:[main] from
*((byte*) SCREEN) ← (byte/signed byte/word/signed word) 1
to:main::@return
main::@return: scope:[main] from main
return
to:@return
@1: scope:[] from @begin
call main
to:@end
@end: scope:[] from @1
PROCEDURE MODIFY VARIABLE ANALYSIS
CONTROL FLOW GRAPH WITH ASSIGNMENT CALL

View File

@ -377,6 +377,8 @@ SYMBOLS
(byte) render::x
(byte) render::y
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
Promoting word to byte* in COLORS ← ((byte*)) 55296
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -89,6 +89,8 @@ SYMBOLS
(byte) sum2::c
(byte) sum2::return
Promoting word/signed word to byte* in SCREEN ← ((byte*)) 1024
Promoting word/signed word to byte* in SCREEN2 ← ((byte*)) $0
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -61,6 +61,7 @@ SYMBOLS
(byte*) main::zpptr
(byte*) main::zpptr2
Promoting word/signed word to byte* in main::zpptr ← ((byte*)) 4096
INITIAL CONTROL FLOW GRAPH
@begin: scope:[] from
to:@1

View File

@ -0,0 +1,8 @@
void main() {
byte* screen = $0400;
screen[0] = 1;
}
byte sum(byte b1, byte b2) {
return b1+b2;
}