From 129de6c3ec9fc1ab71a6c683aef1ac4f3f414b0e Mon Sep 17 00:00:00 2001 From: Jesper Gravgaard Date: Sat, 11 Aug 2018 11:30:19 +0200 Subject: [PATCH] Refactored most casts to pointers to use the generic OperatorCastPtr. --- .../camelot64/kickc/fragment/AsmFormat.java | 2 +- .../model/operators/OperatorCastPtr.java | 3 + .../model/operators/OperatorCastPtrBool.java | 30 --------- .../model/operators/OperatorCastPtrDWord.java | 30 --------- .../model/operators/OperatorCastPtrProc.java | 32 ---------- .../operators/OperatorCastPtrSignedDWord.java | 30 --------- .../operators/OperatorCastPtrSignedWord.java | 30 --------- .../model/operators/OperatorCastPtrWord.java | 30 --------- .../kickc/model/operators/Operators.java | 16 ----- .../kickc/passes/Pass2NopCastElimination.java | 15 ++--- .../dk/camelot64/kickc/test/TestPrograms.java | 2 +- .../camelot64/kickc/test/ref/bool-pointer.cfg | 10 +-- .../camelot64/kickc/test/ref/bool-pointer.log | 64 +++++++++---------- 13 files changed, 46 insertions(+), 248 deletions(-) delete mode 100644 src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrBool.java delete mode 100644 src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrDWord.java delete mode 100644 src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrProc.java delete mode 100644 src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrSignedDWord.java delete mode 100644 src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrSignedWord.java delete mode 100644 src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrWord.java diff --git a/src/main/java/dk/camelot64/kickc/fragment/AsmFormat.java b/src/main/java/dk/camelot64/kickc/fragment/AsmFormat.java index d9ab03b8d..2af353a29 100644 --- a/src/main/java/dk/camelot64/kickc/fragment/AsmFormat.java +++ b/src/main/java/dk/camelot64/kickc/fragment/AsmFormat.java @@ -115,7 +115,7 @@ public class AsmFormat { } else { return getAsmConstant(program, new ConstantBinary(new ConstantInteger((long)0xff), Operators.BOOL_AND, operand), outerPrecedence, codeScope); } - } else if(operator instanceof OperatorCastPtr || Operators.CAST_WORD.equals(operator) || Operators.CAST_SWORD.equals(operator) || Operators.CAST_PTRBY.equals(operator)|| Operators.CAST_PTRSBY.equals(operator)|| Operators.CAST_PTRWO.equals(operator)|| Operators.CAST_PTRSWO.equals(operator)|| Operators.CAST_PTRDWO.equals(operator)|| Operators.CAST_PTRSDWO.equals(operator)|| Operators.CAST_PTRBO.equals(operator)) { + } else if(operator instanceof OperatorCastPtr || Operators.CAST_WORD.equals(operator) || Operators.CAST_SWORD.equals(operator) || Operators.CAST_PTRBY.equals(operator)|| Operators.CAST_PTRSBY.equals(operator)) { SymbolType operandType = SymbolTypeInference.inferType(program.getScope(), operand); if(SymbolType.isWord(operandType) || SymbolType.isSWord(operandType) || SymbolType.isByte(operandType) || SymbolType.isSByte(operandType) || operandType instanceof SymbolTypePointer) { // No cast needed diff --git a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtr.java b/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtr.java index 86ed9d20c..089ef43f1 100644 --- a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtr.java +++ b/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtr.java @@ -31,4 +31,7 @@ public class OperatorCastPtr extends OperatorUnary { return new SymbolTypePointer(elementType); } + public SymbolType getElementType() { + return elementType; + } } diff --git a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrBool.java b/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrBool.java deleted file mode 100644 index 225cd62d2..000000000 --- a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrBool.java +++ /dev/null @@ -1,30 +0,0 @@ -package dk.camelot64.kickc.model.operators; - -import dk.camelot64.kickc.model.CompileError; -import dk.camelot64.kickc.model.types.SymbolType; -import dk.camelot64.kickc.model.types.SymbolTypePointer; -import dk.camelot64.kickc.model.types.SymbolTypeSimple; -import dk.camelot64.kickc.model.values.ConstantInteger; -import dk.camelot64.kickc.model.values.ConstantLiteral; -import dk.camelot64.kickc.model.values.ConstantPointer; - -/** Unary Cast to boolean pointer operator ( (boolean*) x ) */ -public class OperatorCastPtrBool extends OperatorUnary { - - public OperatorCastPtrBool(int precedence) { - super("((boolean*))", "_ptrbo_", precedence); - } - - @Override - public ConstantLiteral calculateLiteral(ConstantLiteral value) { - if(value instanceof ConstantInteger) { - return new ConstantPointer(((ConstantInteger) value).getInteger(), SymbolType.BOOLEAN); - } - throw new CompileError("Calculation not implemented " + getOperator() + " " + value ); - } - - @Override - public SymbolType inferType(SymbolTypeSimple operandType) { - return new SymbolTypePointer(SymbolType.BOOLEAN); - } -} diff --git a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrDWord.java b/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrDWord.java deleted file mode 100644 index cee46ce2f..000000000 --- a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrDWord.java +++ /dev/null @@ -1,30 +0,0 @@ -package dk.camelot64.kickc.model.operators; - -import dk.camelot64.kickc.model.CompileError; -import dk.camelot64.kickc.model.types.SymbolType; -import dk.camelot64.kickc.model.types.SymbolTypePointer; -import dk.camelot64.kickc.model.types.SymbolTypeSimple; -import dk.camelot64.kickc.model.values.ConstantInteger; -import dk.camelot64.kickc.model.values.ConstantLiteral; -import dk.camelot64.kickc.model.values.ConstantPointer; - -/** Unary Cast to double word pointer operator ( (word*) x ) */ -public class OperatorCastPtrDWord extends OperatorUnary { - - public OperatorCastPtrDWord(int precedence) { - super("((dword*))", "_ptrdwo_", precedence); - } - - @Override - public ConstantLiteral calculateLiteral(ConstantLiteral value) { - if(value instanceof ConstantInteger) { - return new ConstantPointer(((ConstantInteger) value).getInteger(), SymbolType.DWORD); - } - throw new CompileError("Calculation not implemented " + getOperator() + " " + value ); - } - - @Override - public SymbolType inferType(SymbolTypeSimple operandType) { - return new SymbolTypePointer(SymbolType.DWORD); - } -} diff --git a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrProc.java b/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrProc.java deleted file mode 100644 index 74a01155d..000000000 --- a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrProc.java +++ /dev/null @@ -1,32 +0,0 @@ -package dk.camelot64.kickc.model.operators; - -import dk.camelot64.kickc.model.CompileError; -import dk.camelot64.kickc.model.types.SymbolType; -import dk.camelot64.kickc.model.types.SymbolTypePointer; -import dk.camelot64.kickc.model.types.SymbolTypeProcedure; -import dk.camelot64.kickc.model.types.SymbolTypeSimple; -import dk.camelot64.kickc.model.values.ConstantInteger; -import dk.camelot64.kickc.model.values.ConstantLiteral; -import dk.camelot64.kickc.model.values.ConstantPointer; - -/** Unary Cast to procedure pointer operator ( (void()*) x ) */ -public class OperatorCastPtrProc extends OperatorUnary { - - public OperatorCastPtrProc(int precedence) { - super("((void()*))", "_ptrproc_", precedence); - } - - @Override - public ConstantLiteral calculateLiteral(ConstantLiteral value) { - if(value instanceof ConstantInteger) { - return new ConstantPointer(((ConstantInteger) value).getInteger(), new SymbolTypeProcedure(SymbolType.VOID)); - } - throw new CompileError("Calculation not implemented " + getOperator() + " " + value); - } - - @Override - public SymbolType inferType(SymbolTypeSimple operandType) { - return new SymbolTypePointer(new SymbolTypeProcedure(SymbolType.VOID)); - } - -} diff --git a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrSignedDWord.java b/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrSignedDWord.java deleted file mode 100644 index 984fbada1..000000000 --- a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrSignedDWord.java +++ /dev/null @@ -1,30 +0,0 @@ -package dk.camelot64.kickc.model.operators; - -import dk.camelot64.kickc.model.CompileError; -import dk.camelot64.kickc.model.types.SymbolType; -import dk.camelot64.kickc.model.types.SymbolTypePointer; -import dk.camelot64.kickc.model.types.SymbolTypeSimple; -import dk.camelot64.kickc.model.values.ConstantInteger; -import dk.camelot64.kickc.model.values.ConstantLiteral; -import dk.camelot64.kickc.model.values.ConstantPointer; - -/** Unary Cast to signed double word pointer operator ( (signed word*) x ) */ -public class OperatorCastPtrSignedDWord extends OperatorUnary { - - public OperatorCastPtrSignedDWord(int precedence) { - super("((signed dword*))", "_ptrsdwo_", precedence); - } - - @Override - public ConstantLiteral calculateLiteral(ConstantLiteral value) { - if(value instanceof ConstantInteger) { - return new ConstantPointer(((ConstantInteger) value).getInteger(), SymbolType.SDWORD); - } - throw new CompileError("Calculation not implemented " + getOperator() + " " + value ); - } - - @Override - public SymbolType inferType(SymbolTypeSimple operandType) { - return new SymbolTypePointer(SymbolType.SDWORD); - } -} diff --git a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrSignedWord.java b/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrSignedWord.java deleted file mode 100644 index a9dd470a2..000000000 --- a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrSignedWord.java +++ /dev/null @@ -1,30 +0,0 @@ -package dk.camelot64.kickc.model.operators; - -import dk.camelot64.kickc.model.CompileError; -import dk.camelot64.kickc.model.types.SymbolType; -import dk.camelot64.kickc.model.types.SymbolTypePointer; -import dk.camelot64.kickc.model.types.SymbolTypeSimple; -import dk.camelot64.kickc.model.values.ConstantInteger; -import dk.camelot64.kickc.model.values.ConstantLiteral; -import dk.camelot64.kickc.model.values.ConstantPointer; - -/** Unary Cast to signed word pointer operator ( (signed word*) x ) */ -public class OperatorCastPtrSignedWord extends OperatorUnary { - - public OperatorCastPtrSignedWord(int precedence) { - super("((signed word*))", "_ptrswo_", precedence); - } - - @Override - public ConstantLiteral calculateLiteral(ConstantLiteral value) { - if(value instanceof ConstantInteger) { - return new ConstantPointer(((ConstantInteger) value).getInteger(), SymbolType.SWORD); - } - throw new CompileError("Calculation not implemented " + getOperator() + " " + value ); - } - - @Override - public SymbolType inferType(SymbolTypeSimple operandType) { - return new SymbolTypePointer(SymbolType.SWORD); - } -} diff --git a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrWord.java b/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrWord.java deleted file mode 100644 index a00c233a4..000000000 --- a/src/main/java/dk/camelot64/kickc/model/operators/OperatorCastPtrWord.java +++ /dev/null @@ -1,30 +0,0 @@ -package dk.camelot64.kickc.model.operators; - -import dk.camelot64.kickc.model.CompileError; -import dk.camelot64.kickc.model.types.SymbolType; -import dk.camelot64.kickc.model.types.SymbolTypePointer; -import dk.camelot64.kickc.model.types.SymbolTypeSimple; -import dk.camelot64.kickc.model.values.ConstantInteger; -import dk.camelot64.kickc.model.values.ConstantLiteral; -import dk.camelot64.kickc.model.values.ConstantPointer; - -/** Unary Cast to word pointer operator ( (word*) x ) */ -public class OperatorCastPtrWord extends OperatorUnary { - - public OperatorCastPtrWord(int precedence) { - super("((word*))", "_ptrwo_", precedence); - } - - @Override - public ConstantLiteral calculateLiteral(ConstantLiteral value) { - if(value instanceof ConstantInteger) { - return new ConstantPointer(((ConstantInteger) value).getInteger(), SymbolType.WORD); - } - throw new CompileError("Calculation not implemented " + getOperator() + " " + value ); - } - - @Override - public SymbolType inferType(SymbolTypeSimple operandType) { - return new SymbolTypePointer(SymbolType.WORD); - } -} diff --git a/src/main/java/dk/camelot64/kickc/model/operators/Operators.java b/src/main/java/dk/camelot64/kickc/model/operators/Operators.java index 9a4970500..6c2644686 100644 --- a/src/main/java/dk/camelot64/kickc/model/operators/Operators.java +++ b/src/main/java/dk/camelot64/kickc/model/operators/Operators.java @@ -27,12 +27,6 @@ public class Operators { public static final OperatorUnary CAST_SDWORD = new OperatorCastSDWord(2); public static final OperatorUnary CAST_PTRBY = new OperatorCastPtrByte(2); public static final OperatorUnary CAST_PTRSBY = new OperatorCastPtrSignedByte(2); - public static final OperatorUnary CAST_PTRWO = new OperatorCastPtrWord(2); - public static final OperatorUnary CAST_PTRSWO = new OperatorCastPtrSignedWord(2); - public static final OperatorUnary CAST_PTRDWO = new OperatorCastPtrDWord(2); - public static final OperatorUnary CAST_PTRSDWO = new OperatorCastPtrSignedDWord(2); - public static final OperatorUnary CAST_PTRBO = new OperatorCastPtrBool(2); - public static final OperatorUnary CAST_PTRPROC = new OperatorCastPtrProc(2); public static final OperatorUnary CAST_BOOL= new OperatorCastBool(2); public static final OperatorBinary MULTIPLY = new OperatorMultiply(3); public static final OperatorBinary DIVIDE = new OperatorDivide(3); @@ -160,16 +154,6 @@ public class Operators { return CAST_PTRBY; } else if(castType instanceof SymbolTypePointer && SymbolType.SBYTE.equals(((SymbolTypePointer) castType).getElementType())) { return CAST_PTRSBY; - } else if(castType instanceof SymbolTypePointer && SymbolType.WORD.equals(((SymbolTypePointer) castType).getElementType())) { - return CAST_PTRWO; - } else if(castType instanceof SymbolTypePointer && SymbolType.SWORD.equals(((SymbolTypePointer) castType).getElementType())) { - return CAST_PTRSWO; - } else if(castType instanceof SymbolTypePointer && SymbolType.DWORD.equals(((SymbolTypePointer) castType).getElementType())) { - return CAST_PTRDWO; - } else if(castType instanceof SymbolTypePointer && SymbolType.SDWORD.equals(((SymbolTypePointer) castType).getElementType())) { - return CAST_PTRSDWO; - } else if(castType instanceof SymbolTypePointer && SymbolType.BOOLEAN.equals(((SymbolTypePointer) castType).getElementType())) { - return CAST_PTRBO; } else if(castType instanceof SymbolTypePointer) { return new OperatorCastPtr(CAST_BYTE.getPrecedence(), ((SymbolTypePointer) castType).getElementType()); } else { diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass2NopCastElimination.java b/src/main/java/dk/camelot64/kickc/passes/Pass2NopCastElimination.java index 36d5debeb..352d6a7ad 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass2NopCastElimination.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass2NopCastElimination.java @@ -1,6 +1,7 @@ package dk.camelot64.kickc.passes; import dk.camelot64.kickc.model.*; +import dk.camelot64.kickc.model.operators.OperatorCastPtr; import dk.camelot64.kickc.model.operators.Operators; import dk.camelot64.kickc.model.values.*; import dk.camelot64.kickc.model.statements.Statement; @@ -57,18 +58,10 @@ public class Pass2NopCastElimination extends Pass2SsaOptimization { } else if(SymbolType.isWord(rValType) && Operators.CAST_PTRSBY.equals(assignment.getOperator())) { isNopCast = true; toType = new SymbolTypePointer(SymbolType.SBYTE); - } else if(SymbolType.isWord(rValType) && Operators.CAST_PTRWO.equals(assignment.getOperator())) { + } else if(SymbolType.isWord(rValType) && assignment.getOperator() instanceof OperatorCastPtr) { isNopCast = true; - toType = new SymbolTypePointer(SymbolType.WORD); - } else if(SymbolType.isWord(rValType) && Operators.CAST_PTRSWO.equals(assignment.getOperator())) { - isNopCast = true; - toType = new SymbolTypePointer(SymbolType.SWORD); - } else if(SymbolType.isWord(rValType) && Operators.CAST_PTRDWO.equals(assignment.getOperator())) { - isNopCast = true; - toType = new SymbolTypePointer(SymbolType.DWORD); - } else if(SymbolType.isWord(rValType) && Operators.CAST_PTRSDWO.equals(assignment.getOperator())) { - isNopCast = true; - toType = new SymbolTypePointer(SymbolType.SDWORD); + OperatorCastPtr castOperator = (OperatorCastPtr) (assignment.getOperator()); + toType = new SymbolTypePointer(castOperator.getElementType()); } else if(rValType instanceof SymbolTypePointer && Operators.CAST_WORD.equals(assignment.getOperator())) { isNopCast = true; toType = SymbolType.WORD; diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index a986f544f..a8d6860a8 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -29,7 +29,7 @@ public class TestPrograms { String testPath; - public TestPrograms() throws IOException { + public TestPrograms() { testPath = "src/test/java/dk/camelot64/kickc/test/kc"; helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/"); } diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bool-pointer.cfg b/src/test/java/dk/camelot64/kickc/test/ref/bool-pointer.cfg index 39531d51d..8df18bce0 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bool-pointer.cfg +++ b/src/test/java/dk/camelot64/kickc/test/ref/bool-pointer.cfg @@ -8,14 +8,14 @@ @end: scope:[] from @1 [3] phi() [ ] ( ) main: scope:[main] from @1 - [4] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 0) ← true [ ] ( main:2 [ ] ) - [5] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false [ ] ( main:2 [ ] ) - [6] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) - [7] if(*(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 [ ] ( main:2 [ ] ) + [4] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 0) ← true [ ] ( main:2 [ ] ) + [5] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false [ ] ( main:2 [ ] ) + [6] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) + [7] if(*(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 [ ] ( main:2 [ ] ) to:main::@return main::@return: scope:[main] from main main::@2 [8] return [ ] ( main:2 [ ] ) to:@return main::@2: scope:[main] from main - [9] *(++((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) + [9] *(++((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) to:main::@return diff --git a/src/test/java/dk/camelot64/kickc/test/ref/bool-pointer.log b/src/test/java/dk/camelot64/kickc/test/ref/bool-pointer.log index 57818778c..69a04c46d 100644 --- a/src/test/java/dk/camelot64/kickc/test/ref/bool-pointer.log +++ b/src/test/java/dk/camelot64/kickc/test/ref/bool-pointer.log @@ -25,12 +25,12 @@ SYMBOLS (label) main::@return (bool*) main::bscreen -Promoting word/signed word/dword/signed dword to bool* in main::bscreen ← ((boolean*)) 1024 +Promoting word/signed word/dword/signed dword to bool* in main::bscreen ← ((bool*)) 1024 INITIAL CONTROL FLOW GRAPH @begin: scope:[] from to:@1 main: scope:[main] from - (bool*) main::bscreen ← ((boolean*)) (word/signed word/dword/signed dword) 1024 + (bool*) main::bscreen ← ((bool*)) (word/signed word/dword/signed dword) 1024 *((bool*) main::bscreen + (byte/signed byte/word/signed word/dword/signed dword) 0) ← true *((bool*) main::bscreen + (byte/signed byte/word/signed word/dword/signed dword) 1) ← false (bool*~) main::$0 ← (bool*) main::bscreen + (byte/signed byte/word/signed word/dword/signed dword) 2 @@ -61,7 +61,7 @@ CONTROL FLOW GRAPH SSA WITH ASSIGNMENT CALL & RETURN @begin: scope:[] from to:@1 main: scope:[main] from @1 - (bool*) main::bscreen#0 ← ((boolean*)) (word/signed word/dword/signed dword) 1024 + (bool*) main::bscreen#0 ← ((bool*)) (word/signed word/dword/signed dword) 1024 *((bool*) main::bscreen#0 + (byte/signed byte/word/signed word/dword/signed dword) 0) ← true *((bool*) main::bscreen#0 + (byte/signed byte/word/signed word/dword/signed dword) 1) ← false (bool*~) main::$0 ← (bool*) main::bscreen#0 + (byte/signed byte/word/signed word/dword/signed dword) 2 @@ -112,7 +112,7 @@ Alias (bool*) main::bscreen#1 = (bool*~) main::$0 (bool*) main::bscreen#3 Succesful SSA optimization Pass2AliasElimination Rewriting ! if()-condition to reversed if() (bool~) main::$1 ← ! *((bool*) main::bscreen#1) Succesful SSA optimization Pass2ConditionalAndOrRewriting -Constant (const bool*) main::bscreen#0 = ((boolean*))1024 +Constant (const bool*) main::bscreen#0 = ((bool*))1024 Succesful SSA optimization Pass2ConstantIdentification Constant (const bool*) main::bscreen#1 = main::bscreen#0+2 Succesful SSA optimization Pass2ConstantIdentification @@ -128,9 +128,9 @@ Inlining constant with different constant siblings (const bool*) main::bscreen#1 Inlining constant with different constant siblings (const bool*) main::bscreen#1 Inlining constant with different constant siblings (const bool*) main::bscreen#2 Inlining constant with different constant siblings (const bool*) main::bscreen#2 -Constant inlined main::bscreen#2 = ++((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2 -Constant inlined main::bscreen#0 = ((boolean*))(word/signed word/dword/signed dword) 1024 -Constant inlined main::bscreen#1 = ((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2 +Constant inlined main::bscreen#2 = ++((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2 +Constant inlined main::bscreen#0 = ((bool*))(word/signed word/dword/signed dword) 1024 +Constant inlined main::bscreen#1 = ((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2 Succesful SSA optimization Pass2ConstantInlining Block Sequence Planned @begin @1 @end main main::@return main::@2 Block Sequence Planned @begin @1 @end main main::@return main::@2 @@ -160,16 +160,16 @@ FINAL CONTROL FLOW GRAPH @end: scope:[] from @1 [3] phi() [ ] ( ) main: scope:[main] from @1 - [4] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 0) ← true [ ] ( main:2 [ ] ) - [5] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false [ ] ( main:2 [ ] ) - [6] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) - [7] if(*(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 [ ] ( main:2 [ ] ) + [4] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 0) ← true [ ] ( main:2 [ ] ) + [5] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false [ ] ( main:2 [ ] ) + [6] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) + [7] if(*(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 [ ] ( main:2 [ ] ) to:main::@return main::@return: scope:[main] from main main::@2 [8] return [ ] ( main:2 [ ] ) to:@return main::@2: scope:[main] from main - [9] *(++((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) + [9] *(++((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) to:main::@return DOMINATORS @@ -216,16 +216,16 @@ bend_from_b1: bend: //SEG8 main main: { - //SEG9 [4] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 0) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 + //SEG9 [4] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 0) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 lda #1 sta $400+0 - //SEG10 [5] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 + //SEG10 [5] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 lda #0 sta $400+1 - //SEG11 [6] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 + //SEG11 [6] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 lda #1 sta $400+2 - //SEG12 [7] if(*(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 [ ] ( main:2 [ ] ) -- _deref_pboc1_then_la1 + //SEG12 [7] if(*(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 [ ] ( main:2 [ ] ) -- _deref_pboc1_then_la1 lda $400+2 cmp #0 bne b2 @@ -236,18 +236,18 @@ main: { rts //SEG15 main::@2 b2: - //SEG16 [9] *(++((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 + //SEG16 [9] *(++((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 lda #1 sta $400+2+1 jmp breturn } REGISTER UPLIFT POTENTIAL REGISTERS -Statement [4] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 0) ← true [ ] ( main:2 [ ] ) always clobbers reg byte a -Statement [5] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false [ ] ( main:2 [ ] ) always clobbers reg byte a -Statement [6] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) always clobbers reg byte a -Statement [7] if(*(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 [ ] ( main:2 [ ] ) always clobbers reg byte a -Statement [9] *(++((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [4] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 0) ← true [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [5] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [6] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [7] if(*(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [9] *(++((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) always clobbers reg byte a REGISTER UPLIFT SCOPES Uplift Scope [main] @@ -278,16 +278,16 @@ bend_from_b1: bend: //SEG8 main main: { - //SEG9 [4] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 0) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 + //SEG9 [4] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 0) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 lda #1 sta $400+0 - //SEG10 [5] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 + //SEG10 [5] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 lda #0 sta $400+1 - //SEG11 [6] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 + //SEG11 [6] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 lda #1 sta $400+2 - //SEG12 [7] if(*(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 [ ] ( main:2 [ ] ) -- _deref_pboc1_then_la1 + //SEG12 [7] if(*(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 [ ] ( main:2 [ ] ) -- _deref_pboc1_then_la1 lda $400+2 cmp #0 bne b2 @@ -298,7 +298,7 @@ main: { rts //SEG15 main::@2 b2: - //SEG16 [9] *(++((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 + //SEG16 [9] *(++((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 lda #1 sta $400+2+1 jmp breturn @@ -347,16 +347,16 @@ Score: 43 //SEG7 @end //SEG8 main main: { - //SEG9 [4] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 0) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 + //SEG9 [4] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 0) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 lda #1 sta $400+0 - //SEG10 [5] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 + //SEG10 [5] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 1) ← false [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 lda #0 sta $400+1 - //SEG11 [6] *(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 + //SEG11 [6] *(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 lda #1 sta $400+2 - //SEG12 [7] if(*(((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 [ ] ( main:2 [ ] ) -- _deref_pboc1_then_la1 + //SEG12 [7] if(*(((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2)) goto main::@2 [ ] ( main:2 [ ] ) -- _deref_pboc1_then_la1 cmp #0 bne b2 //SEG13 main::@return @@ -365,7 +365,7 @@ main: { rts //SEG15 main::@2 b2: - //SEG16 [9] *(++((boolean*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 + //SEG16 [9] *(++((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2) ← true [ ] ( main:2 [ ] ) -- _deref_pboc1=vboc2 lda #1 sta $400+2+1 jmp breturn