mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-06 00:33:42 +00:00
Collected all type inference in pass2 together.
This commit is contained in:
parent
fdbfa68c1c
commit
1df77d5ded
@ -231,9 +231,16 @@ public class Compiler {
|
||||
|
||||
private void pass2Optimize() {
|
||||
List<Pass2SsaOptimization> optimizations = new ArrayList<>();
|
||||
|
||||
optimizations.add(new Pass2FixInlineConstructorsNew(program));
|
||||
|
||||
optimizations.add(new PassNAddNumberTypeConversions(program));
|
||||
optimizations.add(new PassNAddArrayNumberTypeConversions(program));
|
||||
optimizations.add(new PassNTypeInference(program));
|
||||
optimizations.add(new PassNAddTypeConversionAssignment(program));
|
||||
optimizations.add(new Pass2InlineCast(program));
|
||||
optimizations.add(new PassNCastSimplification(program));
|
||||
|
||||
optimizations.add(new PassNTypeIdSimplification(program));
|
||||
optimizations.add(new Pass2SizeOfSimplification(program));
|
||||
optimizations.add(new Pass2CullEmptyBlocks(program));
|
||||
@ -243,6 +250,7 @@ public class Compiler {
|
||||
optimizations.add(new Pass2AliasElimination(program));
|
||||
optimizations.add(new Pass2SelfPhiElimination(program));
|
||||
optimizations.add(new Pass2IdenticalPhiElimination(program));
|
||||
optimizations.add(new Pass2DuplicateRValueIdentification(program));
|
||||
optimizations.add(new Pass2ConditionalJumpSimplification(program));
|
||||
optimizations.add(new Pass2ConditionalAndOrRewriting(program));
|
||||
optimizations.add(new Pass2ConstantRValueConsolidation(program));
|
||||
@ -253,19 +261,14 @@ public class Compiler {
|
||||
optimizations.add(new Pass2ConstantStringConsolidation(program));
|
||||
optimizations.add(new PassNStatementIndices(program));
|
||||
optimizations.add(new PassNVariableReferenceInfos(program));
|
||||
optimizations.add(new Pass2FixInlineConstructorsNew(program));
|
||||
optimizations.add(new PassNAddTypeConversionAssignment(program));
|
||||
optimizations.add(new Pass2RangeResolving(program));
|
||||
optimizations.add(new Pass2ComparisonOptimization(program));
|
||||
optimizations.add(new Pass2InlineCast(program));
|
||||
optimizations.add(new PassNCastSimplification(program));
|
||||
optimizations.add(new Pass2InlineDerefIdx(program));
|
||||
optimizations.add(new Pass2DeInlineWordDerefIdx(program));
|
||||
optimizations.add(new PassNSimplifyConstantZero(program));
|
||||
optimizations.add(new PassNSimplifyExpressionWithZero(program));
|
||||
optimizations.add(new PassNEliminateUnusedVars(program, true));
|
||||
optimizations.add(new Pass2EliminateUnusedBlocks(program));
|
||||
optimizations.add(new Pass2DuplicateRValueIdentification(program));
|
||||
pass2Execute(optimizations);
|
||||
}
|
||||
|
||||
|
@ -27,15 +27,15 @@ public class ProgramExpressionIterator {
|
||||
// Iterate all symbols
|
||||
ProgramValueHandler programValueHandler = (programValue, currentStmt, stmtIt, currentBlock) -> {
|
||||
if(programValue.get() instanceof ConstantBinary) {
|
||||
handler.execute(new ProgramExpressionBinary.ProgramExpressionBinaryConstant(programValue), null, null, null);
|
||||
handler.execute(new ProgramExpressionBinary.ProgramExpressionBinaryConstant(programValue), currentStmt, stmtIt, currentBlock);
|
||||
} else if(programValue.get() instanceof ConstantUnary) {
|
||||
handler.execute(new ProgramExpressionUnary.ProgramExpressionUnaryConstant(programValue), null, null, null);
|
||||
handler.execute(new ProgramExpressionUnary.ProgramExpressionUnaryConstant(programValue), currentStmt, stmtIt, currentBlock);
|
||||
} else if(programValue.get() instanceof PointerDereferenceIndexed) {
|
||||
handler.execute(new ProgramExpressionBinary.ProgramExpressionBinaryPointerDereferenceIndexed(programValue), null, null, null);
|
||||
handler.execute(new ProgramExpressionBinary.ProgramExpressionBinaryPointerDereferenceIndexed(programValue), currentStmt, stmtIt, currentBlock);
|
||||
} else if(programValue.get() instanceof ConstantCastValue) {
|
||||
handler.execute(new ProgramExpressionUnary.ProgramExpressionUnaryConstantCast(programValue), null, null, null);
|
||||
handler.execute(new ProgramExpressionUnary.ProgramExpressionUnaryConstantCast(programValue), currentStmt, stmtIt, currentBlock);
|
||||
} else if(programValue.get() instanceof CastValue) {
|
||||
handler.execute(new ProgramExpressionUnary.ProgramExpressionUnaryCast(programValue), null, null, null);
|
||||
handler.execute(new ProgramExpressionUnary.ProgramExpressionUnaryCast(programValue), currentStmt, stmtIt, currentBlock);
|
||||
}
|
||||
};
|
||||
ProgramValueIterator.execute(program.getScope(), programValueHandler);
|
||||
|
@ -77,7 +77,7 @@ public class Pass2FixInlineConstructorsNew extends Pass2SsaOptimization {
|
||||
// Convert list to a word constructor in a new tmp variable
|
||||
Scope currentScope = Pass2FixInlineConstructorsNew.this.getScope().getScope(currentBlock.getScope());
|
||||
VariableIntermediate tmpVar = currentScope.addVariableIntermediate();
|
||||
tmpVar.setTypeInferred(constructType);
|
||||
//tmpVar.setTypeInferred(constructType);
|
||||
// Move backward - to insert before the current statement
|
||||
stmtIt.previous();
|
||||
// Add assignment of the new tmpVar
|
||||
|
@ -336,11 +336,11 @@ init_screen: {
|
||||
bitmap_clear: {
|
||||
.label bitmap = 9
|
||||
.label y = 2
|
||||
.label _4 = 9
|
||||
.label _3 = 9
|
||||
lda bitmap_plot_xlo
|
||||
sta _4
|
||||
sta _3
|
||||
lda bitmap_plot_xhi
|
||||
sta _4+1
|
||||
sta _3+1
|
||||
lda #0
|
||||
sta y
|
||||
b1:
|
||||
|
@ -178,11 +178,11 @@ bitmap_plot: {
|
||||
.label plotter = 6
|
||||
.label plotter_1 = $10
|
||||
.label x = 4
|
||||
.label _4 = 6
|
||||
.label _3 = 6
|
||||
lda bitmap_plot_yhi,x
|
||||
sta _4+1
|
||||
sta _3+1
|
||||
lda bitmap_plot_ylo,x
|
||||
sta _4
|
||||
sta _3
|
||||
lda x
|
||||
and #<$fff8
|
||||
sta _1
|
||||
@ -729,11 +729,11 @@ divr16u: {
|
||||
bitmap_clear: {
|
||||
.label bitmap = 2
|
||||
.label y = $16
|
||||
.label _4 = 2
|
||||
.label _3 = 2
|
||||
lda bitmap_plot_ylo
|
||||
sta _4
|
||||
sta _3
|
||||
lda bitmap_plot_yhi
|
||||
sta _4+1
|
||||
sta _3+1
|
||||
lda #0
|
||||
sta y
|
||||
b1:
|
||||
|
@ -14,9 +14,9 @@ main: {
|
||||
// puta(byte register(A) ph, byte register(X) pl)
|
||||
puta: {
|
||||
.label screen = 2
|
||||
.label _2 = 2
|
||||
sta _2+1
|
||||
stx _2
|
||||
.label _1 = 2
|
||||
sta _1+1
|
||||
stx _1
|
||||
lda #'a'
|
||||
ldy #0
|
||||
sta (screen),y
|
||||
|
@ -8,15 +8,15 @@ main: {
|
||||
.label PTR = $9ffe
|
||||
.label SCREEN = $400
|
||||
.label ptr = 2
|
||||
.label _7 = 2
|
||||
.label _6 = 2
|
||||
lda #<STRING
|
||||
sta PTR
|
||||
lda #>STRING
|
||||
sta PTR+1
|
||||
lda PTR
|
||||
sta _7
|
||||
sta _6
|
||||
lda PTR+1
|
||||
sta _7+1
|
||||
sta _6+1
|
||||
ldy #0
|
||||
lda (ptr),y
|
||||
sta SCREEN
|
||||
|
@ -81,11 +81,11 @@ bitmap_plot: {
|
||||
.label x = 3
|
||||
.label plotter = 5
|
||||
.label plotter_1 = 7
|
||||
.label _4 = 5
|
||||
.label _3 = 5
|
||||
lda bitmap_plot_yhi,x
|
||||
sta _4+1
|
||||
sta _3+1
|
||||
lda bitmap_plot_ylo,x
|
||||
sta _4
|
||||
sta _3
|
||||
lda x
|
||||
and #<$fff8
|
||||
sta _1
|
||||
@ -428,11 +428,11 @@ screen_fill: {
|
||||
bitmap_clear: {
|
||||
.label bitmap = 3
|
||||
.label y = 2
|
||||
.label _4 = 3
|
||||
.label _3 = 3
|
||||
lda bitmap_plot_ylo
|
||||
sta _4
|
||||
sta _3
|
||||
lda bitmap_plot_yhi
|
||||
sta _4+1
|
||||
sta _3+1
|
||||
lda #0
|
||||
sta y
|
||||
b1:
|
||||
|
@ -7,27 +7,25 @@ main: {
|
||||
.label _0 = 2
|
||||
.label _2 = 2
|
||||
lda #<msg1
|
||||
sta first.msg
|
||||
sta first.return
|
||||
lda #>msg1
|
||||
sta first.msg+1
|
||||
sta first.return+1
|
||||
jsr first
|
||||
ldy #0
|
||||
lda (_0),y
|
||||
sta SCREEN
|
||||
lda #<msg2
|
||||
sta first.msg
|
||||
sta first.return
|
||||
lda #>msg2
|
||||
sta first.msg+1
|
||||
sta first.return+1
|
||||
jsr first
|
||||
ldy #0
|
||||
lda (_2),y
|
||||
sta SCREEN+1
|
||||
rts
|
||||
}
|
||||
// first(byte* zeropage(2) msg)
|
||||
first: {
|
||||
.label return = 2
|
||||
.label msg = 2
|
||||
rts
|
||||
}
|
||||
msg1: .text "hello world!@"
|
||||
|
Loading…
Reference in New Issue
Block a user