mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-08-09 04:25:12 +00:00
Refactored most casts to pointers to use the generic OperatorCastPtr.
This commit is contained in:
@@ -115,7 +115,7 @@ public class AsmFormat {
|
|||||||
} else {
|
} else {
|
||||||
return getAsmConstant(program, new ConstantBinary(new ConstantInteger((long)0xff), Operators.BOOL_AND, operand), outerPrecedence, codeScope);
|
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);
|
SymbolType operandType = SymbolTypeInference.inferType(program.getScope(), operand);
|
||||||
if(SymbolType.isWord(operandType) || SymbolType.isSWord(operandType) || SymbolType.isByte(operandType) || SymbolType.isSByte(operandType) || operandType instanceof SymbolTypePointer) {
|
if(SymbolType.isWord(operandType) || SymbolType.isSWord(operandType) || SymbolType.isByte(operandType) || SymbolType.isSByte(operandType) || operandType instanceof SymbolTypePointer) {
|
||||||
// No cast needed
|
// No cast needed
|
||||||
|
@@ -31,4 +31,7 @@ public class OperatorCastPtr extends OperatorUnary {
|
|||||||
return new SymbolTypePointer(elementType);
|
return new SymbolTypePointer(elementType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SymbolType getElementType() {
|
||||||
|
return elementType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -27,12 +27,6 @@ public class Operators {
|
|||||||
public static final OperatorUnary CAST_SDWORD = new OperatorCastSDWord(2);
|
public static final OperatorUnary CAST_SDWORD = new OperatorCastSDWord(2);
|
||||||
public static final OperatorUnary CAST_PTRBY = new OperatorCastPtrByte(2);
|
public static final OperatorUnary CAST_PTRBY = new OperatorCastPtrByte(2);
|
||||||
public static final OperatorUnary CAST_PTRSBY = new OperatorCastPtrSignedByte(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 OperatorUnary CAST_BOOL= new OperatorCastBool(2);
|
||||||
public static final OperatorBinary MULTIPLY = new OperatorMultiply(3);
|
public static final OperatorBinary MULTIPLY = new OperatorMultiply(3);
|
||||||
public static final OperatorBinary DIVIDE = new OperatorDivide(3);
|
public static final OperatorBinary DIVIDE = new OperatorDivide(3);
|
||||||
@@ -160,16 +154,6 @@ public class Operators {
|
|||||||
return CAST_PTRBY;
|
return CAST_PTRBY;
|
||||||
} else if(castType instanceof SymbolTypePointer && SymbolType.SBYTE.equals(((SymbolTypePointer) castType).getElementType())) {
|
} else if(castType instanceof SymbolTypePointer && SymbolType.SBYTE.equals(((SymbolTypePointer) castType).getElementType())) {
|
||||||
return CAST_PTRSBY;
|
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) {
|
} else if(castType instanceof SymbolTypePointer) {
|
||||||
return new OperatorCastPtr(CAST_BYTE.getPrecedence(), ((SymbolTypePointer) castType).getElementType());
|
return new OperatorCastPtr(CAST_BYTE.getPrecedence(), ((SymbolTypePointer) castType).getElementType());
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
package dk.camelot64.kickc.passes;
|
package dk.camelot64.kickc.passes;
|
||||||
|
|
||||||
import dk.camelot64.kickc.model.*;
|
import dk.camelot64.kickc.model.*;
|
||||||
|
import dk.camelot64.kickc.model.operators.OperatorCastPtr;
|
||||||
import dk.camelot64.kickc.model.operators.Operators;
|
import dk.camelot64.kickc.model.operators.Operators;
|
||||||
import dk.camelot64.kickc.model.values.*;
|
import dk.camelot64.kickc.model.values.*;
|
||||||
import dk.camelot64.kickc.model.statements.Statement;
|
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())) {
|
} else if(SymbolType.isWord(rValType) && Operators.CAST_PTRSBY.equals(assignment.getOperator())) {
|
||||||
isNopCast = true;
|
isNopCast = true;
|
||||||
toType = new SymbolTypePointer(SymbolType.SBYTE);
|
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;
|
isNopCast = true;
|
||||||
toType = new SymbolTypePointer(SymbolType.WORD);
|
OperatorCastPtr castOperator = (OperatorCastPtr) (assignment.getOperator());
|
||||||
} else if(SymbolType.isWord(rValType) && Operators.CAST_PTRSWO.equals(assignment.getOperator())) {
|
toType = new SymbolTypePointer(castOperator.getElementType());
|
||||||
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);
|
|
||||||
} else if(rValType instanceof SymbolTypePointer && Operators.CAST_WORD.equals(assignment.getOperator())) {
|
} else if(rValType instanceof SymbolTypePointer && Operators.CAST_WORD.equals(assignment.getOperator())) {
|
||||||
isNopCast = true;
|
isNopCast = true;
|
||||||
toType = SymbolType.WORD;
|
toType = SymbolType.WORD;
|
||||||
|
@@ -29,7 +29,7 @@ public class TestPrograms {
|
|||||||
|
|
||||||
String testPath;
|
String testPath;
|
||||||
|
|
||||||
public TestPrograms() throws IOException {
|
public TestPrograms() {
|
||||||
testPath = "src/test/java/dk/camelot64/kickc/test/kc";
|
testPath = "src/test/java/dk/camelot64/kickc/test/kc";
|
||||||
helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/");
|
helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/");
|
||||||
}
|
}
|
||||||
|
@@ -8,14 +8,14 @@
|
|||||||
@end: scope:[] from @1
|
@end: scope:[] from @1
|
||||||
[3] phi() [ ] ( )
|
[3] phi() [ ] ( )
|
||||||
main: scope:[main] from @1
|
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 [ ] )
|
[4] *(((bool*))(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 [ ] )
|
[5] *(((bool*))(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 [ ] )
|
[6] *(((bool*))(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 [ ] )
|
[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
|
to:main::@return
|
||||||
main::@return: scope:[main] from main main::@2
|
main::@return: scope:[main] from main main::@2
|
||||||
[8] return [ ] ( main:2 [ ] )
|
[8] return [ ] ( main:2 [ ] )
|
||||||
to:@return
|
to:@return
|
||||||
main::@2: scope:[main] from main
|
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
|
to:main::@return
|
||||||
|
@@ -25,12 +25,12 @@ SYMBOLS
|
|||||||
(label) main::@return
|
(label) main::@return
|
||||||
(bool*) main::bscreen
|
(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
|
INITIAL CONTROL FLOW GRAPH
|
||||||
@begin: scope:[] from
|
@begin: scope:[] from
|
||||||
to:@1
|
to:@1
|
||||||
main: scope:[main] from
|
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) 0) ← true
|
||||||
*((bool*) main::bscreen + (byte/signed byte/word/signed word/dword/signed dword) 1) ← false
|
*((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
|
(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
|
@begin: scope:[] from
|
||||||
to:@1
|
to:@1
|
||||||
main: scope:[main] from @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) 0) ← true
|
||||||
*((bool*) main::bscreen#0 + (byte/signed byte/word/signed word/dword/signed dword) 1) ← false
|
*((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
|
(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
|
Succesful SSA optimization Pass2AliasElimination
|
||||||
Rewriting ! if()-condition to reversed if() (bool~) main::$1 ← ! *((bool*) main::bscreen#1)
|
Rewriting ! if()-condition to reversed if() (bool~) main::$1 ← ! *((bool*) main::bscreen#1)
|
||||||
Succesful SSA optimization Pass2ConditionalAndOrRewriting
|
Succesful SSA optimization Pass2ConditionalAndOrRewriting
|
||||||
Constant (const bool*) main::bscreen#0 = ((boolean*))1024
|
Constant (const bool*) main::bscreen#0 = ((bool*))1024
|
||||||
Succesful SSA optimization Pass2ConstantIdentification
|
Succesful SSA optimization Pass2ConstantIdentification
|
||||||
Constant (const bool*) main::bscreen#1 = main::bscreen#0+2
|
Constant (const bool*) main::bscreen#1 = main::bscreen#0+2
|
||||||
Succesful SSA optimization Pass2ConstantIdentification
|
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#1
|
||||||
Inlining constant with different constant siblings (const bool*) main::bscreen#2
|
Inlining constant with different constant siblings (const bool*) main::bscreen#2
|
||||||
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#2 = ++((bool*))(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#0 = ((bool*))(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#1 = ((bool*))(word/signed word/dword/signed dword) 1024+(byte/signed byte/word/signed word/dword/signed dword) 2
|
||||||
Succesful SSA optimization Pass2ConstantInlining
|
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
|
||||||
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
|
@end: scope:[] from @1
|
||||||
[3] phi() [ ] ( )
|
[3] phi() [ ] ( )
|
||||||
main: scope:[main] from @1
|
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 [ ] )
|
[4] *(((bool*))(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 [ ] )
|
[5] *(((bool*))(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 [ ] )
|
[6] *(((bool*))(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 [ ] )
|
[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
|
to:main::@return
|
||||||
main::@return: scope:[main] from main main::@2
|
main::@return: scope:[main] from main main::@2
|
||||||
[8] return [ ] ( main:2 [ ] )
|
[8] return [ ] ( main:2 [ ] )
|
||||||
to:@return
|
to:@return
|
||||||
main::@2: scope:[main] from main
|
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
|
to:main::@return
|
||||||
|
|
||||||
DOMINATORS
|
DOMINATORS
|
||||||
@@ -216,16 +216,16 @@ bend_from_b1:
|
|||||||
bend:
|
bend:
|
||||||
//SEG8 main
|
//SEG8 main
|
||||||
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
|
lda #1
|
||||||
sta $400+0
|
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
|
lda #0
|
||||||
sta $400+1
|
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
|
lda #1
|
||||||
sta $400+2
|
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
|
lda $400+2
|
||||||
cmp #0
|
cmp #0
|
||||||
bne b2
|
bne b2
|
||||||
@@ -236,18 +236,18 @@ main: {
|
|||||||
rts
|
rts
|
||||||
//SEG15 main::@2
|
//SEG15 main::@2
|
||||||
b2:
|
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
|
lda #1
|
||||||
sta $400+2+1
|
sta $400+2+1
|
||||||
jmp breturn
|
jmp breturn
|
||||||
}
|
}
|
||||||
|
|
||||||
REGISTER UPLIFT POTENTIAL REGISTERS
|
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 [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] *(((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 [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] *(((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 [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(*(((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 [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] *(++((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 [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
|
REGISTER UPLIFT SCOPES
|
||||||
Uplift Scope [main]
|
Uplift Scope [main]
|
||||||
@@ -278,16 +278,16 @@ bend_from_b1:
|
|||||||
bend:
|
bend:
|
||||||
//SEG8 main
|
//SEG8 main
|
||||||
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
|
lda #1
|
||||||
sta $400+0
|
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
|
lda #0
|
||||||
sta $400+1
|
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
|
lda #1
|
||||||
sta $400+2
|
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
|
lda $400+2
|
||||||
cmp #0
|
cmp #0
|
||||||
bne b2
|
bne b2
|
||||||
@@ -298,7 +298,7 @@ main: {
|
|||||||
rts
|
rts
|
||||||
//SEG15 main::@2
|
//SEG15 main::@2
|
||||||
b2:
|
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
|
lda #1
|
||||||
sta $400+2+1
|
sta $400+2+1
|
||||||
jmp breturn
|
jmp breturn
|
||||||
@@ -347,16 +347,16 @@ Score: 43
|
|||||||
//SEG7 @end
|
//SEG7 @end
|
||||||
//SEG8 main
|
//SEG8 main
|
||||||
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
|
lda #1
|
||||||
sta $400+0
|
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
|
lda #0
|
||||||
sta $400+1
|
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
|
lda #1
|
||||||
sta $400+2
|
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
|
cmp #0
|
||||||
bne b2
|
bne b2
|
||||||
//SEG13 main::@return
|
//SEG13 main::@return
|
||||||
@@ -365,7 +365,7 @@ main: {
|
|||||||
rts
|
rts
|
||||||
//SEG15 main::@2
|
//SEG15 main::@2
|
||||||
b2:
|
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
|
lda #1
|
||||||
sta $400+2+1
|
sta $400+2+1
|
||||||
jmp breturn
|
jmp breturn
|
||||||
|
Reference in New Issue
Block a user