1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-01-11 04:29:53 +00:00

Using C declaration format for types in logs, errors, comments and more.

This commit is contained in:
jespergravgaard 2021-08-10 17:48:55 +02:00
parent ac9dbc88a8
commit 8a38c2a887
2482 changed files with 113330 additions and 112988 deletions

View File

@ -42,7 +42,7 @@ public class Initializers {
return new ConstantArrayFilled(typePointer.getElementType(), typePointer.getArraySpec().getArraySize());
}
} else {
throw new CompileError("Default initializer not implemented for type " + typeSpec.getType().getTypeName(), statementSource);
throw new CompileError("Default initializer not implemented for type " + typeSpec.getType().toCDecl(), statementSource);
}
}
@ -120,7 +120,7 @@ public class Initializers {
if(SymbolTypeConversion.assignmentTypeMatch(typeSpec.getType(), inferredType))
initValue = new CastValue(typeSpec.getType(), initValue);
else
throw new CompileError("Type mismatch (" + typeSpec.getType().getTypeName() + ") cannot be assigned from '" + initValue + "'.", source);
throw new CompileError("Type mismatch (" + typeSpec.getType().toCDecl() + ") cannot be assigned from '" + initValue + "'.", source);
}
}
}
@ -150,7 +150,7 @@ public class Initializers {
} else {
throw new CompileError(
"Struct initializer has wrong size (" + valueList.getList().size() + "), " +
"which does not match the number of members in " + structType.getTypeName() + " (" + structInitNeedSize + " members).\n" +
"which does not match the number of members in " + structType.toCDecl() + " (" + structInitNeedSize + " members).\n" +
" Struct initializer: " + valueList.toString(program),
source);

View File

@ -42,7 +42,7 @@ public class OperatorTypeId extends OperatorUnary {
* @return The constant variable
*/
public static ConstantRef getTypeIdConstantVar(ProgramScope programScope, SymbolType type) {
String typeConstName = "TYPEID_" + getTypeIdConstantName(type);
String typeConstName = getTypeIdConstantName(type);
Variable typeIdConstant = programScope.getLocalConstant(typeConstName);
if(typeIdConstant == null) {
// Constant not found - create it
@ -60,13 +60,7 @@ public class OperatorTypeId extends OperatorUnary {
* @return The name of the constant
*/
private static String getTypeIdConstantName(SymbolType type) {
if(type instanceof SymbolTypeProcedure) {
return "PROCEDURE";
} else if(type instanceof SymbolTypePointer) {
return "POINTER_" + getTypeIdConstantName(((SymbolTypePointer) type).getElementType());
} else {
return type.getTypeBaseName().toUpperCase(Locale.ENGLISH).replace(" ", "_");
}
return "TYPEID_" + type.getConstantFriendlyName();
}
/**

View File

@ -111,7 +111,7 @@ public class StatementCall extends StatementBase implements StatementLValue, Sta
first = false;
if(onlyTypes) {
final SymbolType symbolType = SymbolTypeInference.inferType(program.getScope(), parameter);
res.append(symbolType.getTypeName());
res.append(symbolType.toCDecl());
} else {
res.append(parameter.toString(program));
}

View File

@ -96,7 +96,7 @@ public class Label implements Symbol {
if(program == null) {
return getFullName();
} else {
return getType().getTypeName() + " " + getFullName();
return getType().toCDecl(getFullName());
}
}

View File

@ -224,6 +224,7 @@ public class Procedure extends Scope {
/**
* Get references to all constructors needed for this procedure
*
* @return The references
*/
public List<ProcedureRef> getConstructorRefs() {
@ -261,23 +262,23 @@ public class Procedure extends Scope {
if(interruptType != null) {
res.append("__interrupt(").append(interruptType).append(") ");
}
res.append(getReturnType().getTypeName()).append(" ").append(getFullName()).append("(");
boolean first = true;
if(parameterNames != null) {
for(Variable parameter : getParameters()) {
if(!first) res.append(" , ");
first = false;
if(onlyTypes) {
res.append(parameter.getType().getTypeName());
} else {
res.append(parameter.getType().getTypeName()+" "+parameter.toString(program));
if(onlyTypes) {
res.append(getType().toCDecl());
} else {
res.append(getReturnType().toCDecl()).append(" ").append(getFullName()).append("(");
boolean first = true;
if(parameterNames != null) {
for(Variable parameter : getParameters()) {
if(!first) res.append(" , ");
first = false;
res.append(parameter.toCDecl());
}
}
if(isVariableLengthParameterList()) {
res.append(", ...");
}
res.append(")");
}
if(isVariableLengthParameterList()) {
res.append(", ...");
}
res.append(")");
return res.toString();
}

View File

@ -186,7 +186,7 @@ public abstract class Scope implements Symbol, Serializable {
public Variable findVariable(String name) {
final Symbol symbol = findSymbol(name);
if(symbol!=null && !(symbol instanceof Variable))
if(symbol != null && !(symbol instanceof Variable))
throw new InternalError("Symbol is not a variable! " + symbol.toString());
return (Variable) symbol;
}
@ -286,7 +286,7 @@ public abstract class Scope implements Symbol, Serializable {
public Variable getLocalVar(String name) {
final Symbol symbol = getLocalSymbol(name);
if(symbol!=null && !(symbol instanceof Variable))
if(symbol != null && !(symbol instanceof Variable))
throw new InternalError("Symbol is not a variable! " + symbol.toString());
return (Variable) symbol;
}
@ -307,35 +307,35 @@ public abstract class Scope implements Symbol, Serializable {
public Label getLocalLabel(String name) {
final Symbol symbol = getLocalSymbol(name);
if(symbol!=null && !(symbol instanceof Label))
if(symbol != null && !(symbol instanceof Label))
throw new InternalError("Symbol is not a label! " + symbol.toString());
return (Label) getLocalSymbol(name);
}
public BlockScope getLocalBlockScope(String name) {
final Symbol symbol = getLocalSymbol(name);
if(symbol!=null && !(symbol instanceof BlockScope))
if(symbol != null && !(symbol instanceof BlockScope))
throw new InternalError("Symbol is not a block scope! " + symbol.toString());
return (BlockScope) symbol;
}
public StructDefinition getLocalStructDefinition(String name) {
final Symbol symbol = getLocalSymbol(name);
if(symbol!=null && !(symbol instanceof StructDefinition))
if(symbol != null && !(symbol instanceof StructDefinition))
throw new InternalError("Symbol is not a struct definition! " + symbol.toString());
return (StructDefinition) symbol;
}
public EnumDefinition getLocalEnumDefinition(String name) {
final Symbol symbol = getLocalSymbol(name);
if(symbol!=null && !(symbol instanceof EnumDefinition))
if(symbol != null && !(symbol instanceof EnumDefinition))
throw new InternalError("Symbol is not an enum definition! " + symbol.toString());
return (EnumDefinition) symbol;
}
public Scope getLocalScope(String name) {
final Symbol symbol = getLocalSymbol(name);
if(symbol!=null && !(symbol instanceof Scope))
if(symbol != null && !(symbol instanceof Scope))
throw new InternalError("Symbol is not a scope! " + symbol.toString());
return (Scope) symbol;
}
@ -350,47 +350,44 @@ public abstract class Scope implements Symbol, Serializable {
Symbol symbol = symbols.get(name);
if(symbol instanceof Scope) {
// Do not output struct definitions
if(symbol instanceof StructDefinition )
if(symbol instanceof StructDefinition)
continue;
if(!onlyVars || symbol instanceof Procedure || symbol instanceof BlockScope|| symbol instanceof ProgramScope)
if(!onlyVars || symbol instanceof Procedure || symbol instanceof BlockScope || symbol instanceof ProgramScope)
res.append(((Scope) symbol).toStringVars(program, onlyVars));
} else if(symbol instanceof Variable) {
Variable symVar = (Variable) symbol;
if(!onlyVars || symVar.isVariable()) {
// Output if not instructed to only output variables - or if it is a variable
res.append(symVar.typeString() + " " + symVar.toString());
if(symVar.isArray()) {
res.append("[");
if(symVar.getArraySize() != null) {
res.append(symVar.getArraySize().toString(program));
}
res.append("] ");
if(symVar.isKindLoadStore()) res.append("__loadstore ");
if(symVar.isKindConstant()) res.append("__constant ");
res.append(symVar.getType().toCDecl(symVar.getFullName()));
if(symVar.getInitValue() != null) {
res.append(" = " + symVar.getInitValue().toString(program));
}
boolean extra = false;
if(symVar.getAsmName() != null && !symVar.getName().equals(symVar.getAsmName())) {
if(!extra) { res.append(" //"); extra = true; }
res.append(" " + symVar.getAsmName());
}
if(symVar.isKindLoadStore()) {
res.append(" loadstore");
}
Registers.Register declRegister = symVar.getRegister();
if(declRegister != null) {
if(!extra) { res.append(" //"); extra = true; }
res.append(" !" + declRegister);
}
if(symVar.isVariable()) {
Registers.Register register = symVar.getAllocation();
if(register != null && !register.equals(declRegister)) {
if(!extra) { res.append(" //"); extra = true; }
res.append(" " + register);
}
if(registerWeights != null) {
Double weight = registerWeights.getWeight(symVar.getVariableRef());
if(weight != null) {
if(!extra) { res.append(" //"); extra = true; }
res.append(" " + weight);
}
}
}
if(symVar.getInitValue() != null) {
res.append(" = " + symVar.getInitValue().toString(program));
}
res.append("\n");
}
} else if(!onlyVars) {

View File

@ -557,21 +557,6 @@ public class Variable implements Symbol {
return toString();
}
/**
* Get a string describing the type of the variable
*
* @return The type as a string
*/
public String typeString() {
final StringBuilder print = new StringBuilder();
print
.append(isKindConstant() ? "constant " : "")
.append(getType().getTypeName())
.append(isKindIntermediate() ? "~" : "")
;
return print.toString();
}
public String toCDecl() {
StringBuilder cdecl = new StringBuilder();
cdecl.append(getType().toCDecl(getLocalName()));

View File

@ -103,22 +103,6 @@ public interface SymbolType extends Serializable {
return null;
}
/**
* Get the name of the type
*
* @return The type name
*/
default String getTypeName() {
return (isVolatile()?"volatile ":"") + (isNomodify()?"const ":"") + getTypeBaseName();
}
/**
* Get the type base name (without const/volatile)
*
* @return type base name
*/
String getTypeBaseName();
/**
* Get the size of the type (in bytes).
*
@ -136,14 +120,24 @@ public interface SymbolType extends Serializable {
return SDWORD.equals(type) || DWORD.equals(type) || SWORD.equals(type) || WORD.equals(type) || SBYTE.equals(type) || BYTE.equals(type) || NUMBER.equals(type) || UNUMBER.equals(type) || SNUMBER.equals(type);
}
default String toCDecl() {
return toCDecl("");
}
/**
* Get the C declaration formatted type.
*
* @return The C declaration string
* @param parentCDecl
*/
default public String toCDecl(String parentCDecl) {
default String toCDecl(String parentCDecl) {
return "";
}
/** Get a name that can be used as part of a constant (such as SIZEOF_, INDEXOF, ...)
*
* @return The name
*/
String getConstantFriendlyName();
}

View File

@ -21,11 +21,6 @@ public class SymbolTypeBlockScope implements SymbolType {
return false;
}
@Override
public String getTypeBaseName() {
return "BLOCK";
}
@Override
public int getSizeBytes() {
return -1;
@ -43,7 +38,11 @@ public class SymbolTypeBlockScope implements SymbolType {
@Override
public String toString() {
return getTypeName();
return "block";
}
@Override
public String getConstantFriendlyName() {
return "BLOCK";
}
}

View File

@ -2,6 +2,7 @@ package dk.camelot64.kickc.model.types;
import dk.camelot64.kickc.model.symbols.EnumDefinition;
import java.util.Locale;
import java.util.Objects;
/** An enum */
@ -44,9 +45,8 @@ public class SymbolTypeEnum implements SymbolType {
return isNomodify;
}
@Override
public String getTypeBaseName() {
return "enum " + this.enumName;
public String getEnumName() {
return enumName;
}
@Override
@ -60,7 +60,7 @@ public class SymbolTypeEnum implements SymbolType {
@Override
public String toString() {
return getTypeName();
return toCDecl();
}
@Override
@ -85,9 +85,14 @@ public class SymbolTypeEnum implements SymbolType {
cdecl.append("const ");
cdecl.append("enum ");
cdecl.append(this.enumName);
cdecl.append(" ");
if(parentCDecl.length()>0)
cdecl.append(" ");
cdecl.append(parentCDecl);
return cdecl.toString();
}
@Override
public String getConstantFriendlyName() {
return "ENUM_"+enumName.toUpperCase(Locale.ENGLISH);
}
}

View File

@ -3,4 +3,6 @@ package dk.camelot64.kickc.model.types;
/** Integer type marker interface. */
public interface SymbolTypeInteger extends SymbolType {
public String getTypeName();
}

View File

@ -1,5 +1,6 @@
package dk.camelot64.kickc.model.types;
import java.util.Locale;
import java.util.Objects;
/** Integer type that has not yet been fixed. This is used for constant expressions. The type is fixed when the constant meets a fixed type. */
@ -27,7 +28,7 @@ public class SymbolTypeIntegerAuto implements SymbolTypeInteger {
}
@Override
public String getTypeBaseName() {
public String getTypeName() {
return typeName;
}
@ -38,7 +39,7 @@ public class SymbolTypeIntegerAuto implements SymbolTypeInteger {
@Override
public String toString() {
return getTypeName();
return toCDecl();
}
@Override
@ -61,9 +62,16 @@ public class SymbolTypeIntegerAuto implements SymbolTypeInteger {
cdecl.append("volatile ");
if(isNomodify())
cdecl.append("const ");
cdecl.append(this.getTypeBaseName());
cdecl.append(" ");
cdecl.append(this.typeName);
if(parentCDecl.length()>0)
cdecl.append(" ");
cdecl.append(parentCDecl);
return cdecl.toString();
}
@Override
public String getConstantFriendlyName() {
return typeName.toUpperCase(Locale.ENGLISH).replace(" ", "_");
}
}

View File

@ -2,6 +2,7 @@ package dk.camelot64.kickc.model.types;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Locale;
import java.util.Objects;
/** Integer type with a fixed size (byte, signed byte, word, ...). */
@ -87,6 +88,11 @@ public class SymbolTypeIntegerFixed implements SymbolTypeInteger {
return isNomodify;
}
@Override
public String getTypeName() {
return typeBaseName;
}
/**
* Determines if a value can be represented by the type without loss of information
*
@ -97,11 +103,6 @@ public class SymbolTypeIntegerFixed implements SymbolTypeInteger {
return number >= getMinValue() && number <= getMaxValue();
}
@Override
public String getTypeBaseName() {
return typeBaseName;
}
public String getCTypeBaseName() {
return cTypeBaseName;
}
@ -129,7 +130,7 @@ public class SymbolTypeIntegerFixed implements SymbolTypeInteger {
@Override
public String toString() {
return getTypeName();
return toCDecl();
}
@Override
@ -146,6 +147,11 @@ public class SymbolTypeIntegerFixed implements SymbolTypeInteger {
return cdecl.toString();
}
@Override
public String getConstantFriendlyName() {
return cTypeBaseName.toUpperCase(Locale.ENGLISH).replace(" ", "_");
}
@Override
public boolean equals(Object o) {
if(this == o) return true;

View File

@ -1,15 +1,17 @@
package dk.camelot64.kickc.model.types;
import java.util.Locale;
/** Basic named (string, char, ...) Symbol Types */
public class SymbolTypeNamed implements SymbolType {
private String typeBaseName;
private String typeName;
private int sizeBytes;
private final boolean isVolatile;
private final boolean isNomodify;
SymbolTypeNamed(String typeBaseName, int sizeBytes, boolean isVolatile, boolean isNomodify) {
this.typeBaseName = typeBaseName;
SymbolTypeNamed(String typeName, int sizeBytes, boolean isVolatile, boolean isNomodify) {
this.typeName = typeName;
this.sizeBytes = sizeBytes;
this.isVolatile = isVolatile;
this.isNomodify = isNomodify;
@ -17,7 +19,7 @@ public class SymbolTypeNamed implements SymbolType {
@Override
public SymbolType getQualified(boolean isVolatile, boolean isNomodify) {
return new SymbolTypeNamed(this.typeBaseName, this.sizeBytes, isVolatile, isNomodify);
return new SymbolTypeNamed(this.typeName, this.sizeBytes, isVolatile, isNomodify);
}
@Override
@ -30,8 +32,8 @@ public class SymbolTypeNamed implements SymbolType {
return isNomodify;
}
public String getTypeBaseName() {
return typeBaseName;
public String getTypeName() {
return typeName;
}
@Override
@ -50,17 +52,17 @@ public class SymbolTypeNamed implements SymbolType {
SymbolTypeNamed that = (SymbolTypeNamed) o;
return typeBaseName != null ? typeBaseName.equals(that.typeBaseName) : that.typeBaseName == null;
return typeName != null ? typeName.equals(that.typeName) : that.typeName == null;
}
@Override
public int hashCode() {
return typeBaseName != null ? typeBaseName.hashCode() : 0;
return typeName != null ? typeName.hashCode() : 0;
}
@Override
public String toString() {
return getTypeName();
return toCDecl();
}
@Override
@ -70,11 +72,17 @@ public class SymbolTypeNamed implements SymbolType {
cdecl.append("volatile ");
if(isNomodify())
cdecl.append("const ");
cdecl.append(this.getTypeBaseName());
cdecl.append(this.typeName);
if(parentCDecl.length()>0)
cdecl.append(" ");
cdecl.append(parentCDecl);
return cdecl.toString();
}
@Override
public String getConstantFriendlyName() {
return typeName.toUpperCase(Locale.ENGLISH).replace(" ", "_");
}
}

View File

@ -56,21 +56,6 @@ public class SymbolTypePointer implements SymbolType {
return arraySpec;
}
@Override
public String getTypeName() {
String name = elementType.getTypeName() + "*";
if(isVolatile)
name += " volatile";
if(isNomodify)
name += " const";
return name;
}
@Override
public String getTypeBaseName() {
return elementType.getTypeName() + "*";
}
@Override
public int getSizeBytes() {
return SIZE_POINTER_BYTES;
@ -91,7 +76,7 @@ public class SymbolTypePointer implements SymbolType {
@Override
public String toString() {
return getTypeName();
return toCDecl();
}
@Override
@ -105,7 +90,8 @@ public class SymbolTypePointer implements SymbolType {
if(parentCDecl.contains("*"))
cdecl.append(")");
cdecl.append("[");
cdecl.append(getArraySpec().getArraySize().toString());
if(getArraySpec().getArraySize()!=null)
cdecl.append(getArraySpec().getArraySize().toString());
cdecl.append("]");
return this.getElementType().toCDecl(cdecl.toString());
} else {
@ -122,4 +108,10 @@ public class SymbolTypePointer implements SymbolType {
return this.getElementType().toCDecl(cdecl.toString());
}
}
@Override
public String getConstantFriendlyName() {
return "POINTER_"+elementType.getConstantFriendlyName();
}
}

View File

@ -47,25 +47,9 @@ public class SymbolTypeProcedure implements SymbolType {
this.paramTypes = paramTypes;
}
@Override
public String getTypeBaseName() {
final StringBuilder typeBaseName = new StringBuilder();
typeBaseName.append(returnType.getTypeBaseName());
typeBaseName.append("(");
boolean first = true;
for(SymbolType paramType : paramTypes) {
if(!first)
typeBaseName.append(",");
first = false;
typeBaseName.append(paramType.getTypeBaseName());
}
typeBaseName.append(")");
return typeBaseName.toString();
}
@Override
public String toString() {
return getTypeName();
return toCDecl();
}
@Override
@ -92,9 +76,14 @@ public class SymbolTypeProcedure implements SymbolType {
cdecl.append(")");
cdecl.append("(");
StringJoiner joiner = new StringJoiner(", ");
paramTypes.stream().forEach(symbolType -> joiner.add(symbolType.toCDecl("")));
paramTypes.stream().forEach(symbolType -> joiner.add(symbolType.toCDecl()));
cdecl.append(joiner);
cdecl.append(")");
return getReturnType().toCDecl(cdecl.toString());
}
@Override
public String getConstantFriendlyName() {
return "PROCEDURE";
}
}

View File

@ -21,11 +21,6 @@ public class SymbolTypeProgram implements SymbolType {
return false;
}
@Override
public String getTypeBaseName() {
return "PROGRAM";
}
@Override
public int getSizeBytes() {
return -1;
@ -43,7 +38,11 @@ public class SymbolTypeProgram implements SymbolType {
@Override
public String toString() {
return getTypeName();
return "program";
}
@Override
public String getConstantFriendlyName() {
return "PROGRAM";
}
}

View File

@ -7,6 +7,7 @@ import dk.camelot64.kickc.model.values.ConstantInteger;
import dk.camelot64.kickc.model.values.ConstantLiteral;
import dk.camelot64.kickc.model.values.ConstantValue;
import java.util.Locale;
import java.util.Objects;
/** A struct/union */
@ -61,15 +62,6 @@ public class SymbolTypeStruct implements SymbolType {
return isNomodify;
}
@Override
public String getTypeBaseName() {
if(isUnion) {
return "union " + this.structName;
} else {
return "struct " + this.structName;
}
}
public String getStructTypeName() {
return structName;
}
@ -144,7 +136,7 @@ public class SymbolTypeStruct implements SymbolType {
@Override
public String toString() {
return getTypeName();
return toCDecl();
}
@Override
@ -160,8 +152,18 @@ public class SymbolTypeStruct implements SymbolType {
cdecl.append("struct ");
}
cdecl.append(this.structName);
cdecl.append(" ");
if(parentCDecl.length()>0)
cdecl.append(" ");
cdecl.append(parentCDecl);
return cdecl.toString();
}
@Override
public String getConstantFriendlyName() {
if(isUnion) {
return "UNION_"+structName.toUpperCase(Locale.ENGLISH);
} else {
return "STRUCT_"+structName.toUpperCase(Locale.ENGLISH);
}
}
}

View File

@ -21,11 +21,6 @@ public class SymbolTypeTypeDefScope implements SymbolType {
return false;
}
@Override
public String getTypeBaseName() {
return "TYPEDEF";
}
@Override
public int getSizeBytes() {
return -1;
@ -43,7 +38,11 @@ public class SymbolTypeTypeDefScope implements SymbolType {
@Override
public String toString() {
return getTypeName();
return toCDecl();
}
@Override
public String getConstantFriendlyName() {
return "TYPEDEF";
}
}

View File

@ -38,7 +38,7 @@ public class CastValue implements RValue {
@Override
public String toString(Program program) {
return "("+ toType.toString()+")"+ value.toString(program);
return "("+ toType.toCDecl()+")"+ value.toString(program);
}
@Override

View File

@ -39,7 +39,7 @@ public class ConstantDouble implements ConstantLiteral<Double> {
if(program == null) {
return Double.toString(number);
} else {
return "(" + SymbolType.VOID.getTypeName() + ") " + Double.toString(number);
return "(" + SymbolType.VOID.toCDecl() + ") " + Double.toString(number);
}
}

View File

@ -52,7 +52,7 @@ public class ConstantPointer implements ConstantEnumerable<Long> {
@Override
public String toString(Program program) {
return "(" + getType().getTypeName() + ") " + Long.toString(location);
return "(" + getType().toCDecl() + ") " + Long.toString(location);
}
@Override

View File

@ -43,7 +43,7 @@ public class MemcpyValue implements RValue {
@Override
public String toString(Program program) {
return "memcpy("+source.toString(program)+", "+type.getTypeName()+", "+size.toString(program)+")";
return "memcpy("+source.toString(program)+", "+ type.toCDecl() +", "+size.toString(program)+")";
}

View File

@ -31,7 +31,7 @@ public class MemsetValue implements RValue {
@Override
public String toString(Program program) {
return "memset("+type.getTypeName()+", "+size.toString(program)+")";
return "memset("+ type.toCDecl() +", "+size.toString(program)+")";
}

View File

@ -35,7 +35,7 @@ public class StackIdxValue implements LValue {
@Override
public String toString(Program program) {
return "stackidx("+valueType.getTypeName()+","+stackOffset.toString(program)+")";
return "stackidx("+ valueType.toCDecl() +","+stackOffset.toString(program)+")";
}

View File

@ -19,6 +19,6 @@ public class StackPullValue implements RValue {
@Override
public String toString(Program program) {
return "stackpull(" + type.getTypeName()+ ")";
return "stackpull(" + type.toCDecl() + ")";
}
}

View File

@ -19,6 +19,6 @@ public class StackPushValue implements LValue {
@Override
public String toString(Program program) {
return "stackpush(" + type.getTypeName()+ ")";
return "stackpush(" + type.toCDecl() + ")";
}
}

View File

@ -26,7 +26,6 @@ import java.nio.file.Path;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collector;
import java.util.stream.Collectors;
/**
@ -1017,7 +1016,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
VariableBuilder varBuilder = new VariableBuilder(varName, getCurrentScope(), false, false, effectiveType, effectiveDirectives, currentDataSegment, program.getTargetPlatform().getVariableBuilderConfig());
Variable variable = varBuilder.build();
if(isStructMember && (initializer != null))
throw new CompileError("Initializer not supported inside structs " + effectiveType.getTypeName(), declSource);
throw new CompileError("Initializer not supported inside structs " + effectiveType.toCDecl(), declSource);
if(variable.isDeclarationOnly()) {
if(initializer != null) {
throw new CompileError("Initializer not allowed for extern variables " + varName, declSource);
@ -1108,7 +1107,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
StatementSource statementSource = new StatementSource(ctx);
SymbolType effectiveType = this.varDecl.getEffectiveType();
if(!(effectiveType instanceof SymbolTypePointer) || ((SymbolTypePointer) effectiveType).getArraySpec() == null) {
throw new CompileError("KickAsm initializers only supported for arrays " + varDecl.getEffectiveType().getTypeName(), statementSource);
throw new CompileError("KickAsm initializers only supported for arrays " + varDecl.getEffectiveType().toCDecl(), statementSource);
}
// Add KickAsm statement
KickAsm kasm = (KickAsm) this.visit(ctx.kasmContent());
@ -2662,7 +2661,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
StructDefinition structDefinition = structType.getStructDefinition(program.getScope());
final Variable member = structDefinition.getMember(structMemberRef.getMemberName());
if(member == null) {
throw new CompileError("Unknown struct member " + structMemberRef.getMemberName() + " in struct " + structType.getTypeName(), source);
throw new CompileError("Unknown struct member " + structMemberRef.getMemberName() + " in struct " + structType.toCDecl(), source);
}
final ConstantRef memberOffset = SizeOfConstants.getStructMemberOffsetConstant(program.getScope(), structDefinition, structMemberRef.getMemberName());
return new ConstantCastValue(new SymbolTypePointer(member.getType()), new ConstantBinary(new ConstantCastValue(new SymbolTypePointer(SymbolType.BYTE), structPointer), Operators.PLUS, memberOffset));
@ -2673,7 +2672,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
StructDefinition structDefinition = structType.getStructDefinition(program.getScope());
final Variable member = structDefinition.getMember(structMemberRef.getMemberName());
if(member == null) {
throw new CompileError("Unknown struct member " + structMemberRef.getMemberName() + " in struct " + structType.getTypeName(), source);
throw new CompileError("Unknown struct member " + structMemberRef.getMemberName() + " in struct " + structType.toCDecl(), source);
}
final ConstantRef memberOffset = SizeOfConstants.getStructMemberOffsetConstant(program.getScope(), structDefinition, structMemberRef.getMemberName());
return new ConstantCastValue(new SymbolTypePointer(member.getType()), new ConstantBinary(new ConstantCastValue(new SymbolTypePointer(SymbolType.BYTE), structPointer), Operators.PLUS, memberOffset));

View File

@ -52,7 +52,7 @@ public class Pass1StructTypeSizeFix extends Pass2SsaOptimization {
StructDefinition structDefinition = typeStruct.getStructDefinition(getScope());
int sizeBytes = typeStruct.calculateSizeBytes(structDefinition, getScope());
if(sizeBytes != typeStruct.getSizeBytes()) {
getLog().append("Fixing struct type SIZE_OF " + typeStruct.getTypeName() + " to " + sizeBytes);
getLog().append("Fixing struct type SIZE_OF " + typeStruct.toCDecl() + " to " + sizeBytes);
typeStruct.setSizeBytes(sizeBytes);
SizeOfConstants.fixSizeOfConstantVar(getScope(), typeStruct);
}
@ -74,7 +74,7 @@ public class Pass1StructTypeSizeFix extends Pass2SsaOptimization {
StructDefinition structDefinition = typeStruct.getStructDefinition(getScope());
int sizeBytes = typeStruct.calculateSizeBytes(structDefinition, getScope());
if(sizeBytes != typeStruct.getSizeBytes()) {
getLog().append("Fixing struct type size " + type.getTypeName() + " to " + sizeBytes);
getLog().append("Fixing struct type size " + type.toCDecl() + " to " + sizeBytes);
typeStruct.setSizeBytes(sizeBytes);
return true;
} else {

View File

@ -220,39 +220,15 @@ public class Pass4CodeGeneration {
*/
private void generateSignatureComments(AsmProgram asm, Procedure procedure) {
StringBuilder signature = new StringBuilder();
signature.append(" ");
generateSignatureVar(procedure.getLocalVar("return"), procedure, signature);
signature.append(procedure.getReturnType().toCDecl());
signature.append(" ").append(procedure.getLocalName()).append("(");
int i = 0;
for(Variable parameter : procedure.getParameters()) {
Variable param = parameter;
if(param.isKindPhiMaster()) {
List<Variable> versions = new ArrayList<>(procedure.getVersions(parameter));
if(versions.size() > 0)
param = versions.get(0);
else
// Parameter optimized away to a constant or unused
continue;
}
Registers.Register allocation = param.getAllocation();
if(i++ > 0) signature.append(", ");
signature.append(param.getType().getTypeBaseName()).append(" ");
if(allocation instanceof Registers.RegisterZpMem) {
Registers.RegisterZpMem registerZp = (Registers.RegisterZpMem) allocation;
signature.append("zp(").append(AsmFormat.getAsmNumber(registerZp.getZp())).append(")");
} else if(allocation instanceof Registers.RegisterMainMem) {
Registers.RegisterMainMem registerMainMem = (Registers.RegisterMainMem) allocation;
signature.append("mem(").append(registerMainMem.getAddress() == null ? "" : AsmFormat.getAsmNumber(registerMainMem.getAddress())).append(")");
} else if(allocation instanceof Registers.RegisterAByte) {
signature.append("register(A)");
} else if(allocation instanceof Registers.RegisterXByte) {
signature.append("register(X)");
} else if(allocation instanceof Registers.RegisterYByte) {
signature.append("register(Y)");
} else if(allocation instanceof Registers.RegisterZByte) {
signature.append("register(Z)");
}
signature.append(" ");
signature.append(parameter.getLocalName());
Variable param = generateSignatureVar(parameter, procedure, signature);
signature.append(param.getType().toCDecl(parameter.getLocalName()));
}
signature.append(")");
if(i > 0) {
@ -260,6 +236,49 @@ public class Pass4CodeGeneration {
}
}
/**
* Generate part of a comment that describes a returnvalue/parameter
* @param param The variable to describe
* @param scope The scope (procedure)
* @param signature The signature to append to
* @return The version of the variable chosen
*/
Variable generateSignatureVar(Variable param, Scope scope, StringBuilder signature) {
if(param==null) return param;
if(param.isKindPhiMaster()) {
List<Variable> versions = new ArrayList<>(scope.getVersions(param));
if(versions.size() > 0)
if(param.getLocalName().equals("return")) {
// Choose the last version for return values
param = versions.get(versions.size()-1);
} else {
// Choose the first version for parameters
param = versions.get(0);
}
else
// Parameter optimized away to a constant or unused
return param;
}
Registers.Register allocation = param.getAllocation();
if(allocation instanceof Registers.RegisterZpMem) {
Registers.RegisterZpMem registerZp = (Registers.RegisterZpMem) allocation;
signature.append("__zp(").append(AsmFormat.getAsmNumber(registerZp.getZp())).append(") ");
} else if(allocation instanceof Registers.RegisterMainMem) {
Registers.RegisterMainMem registerMainMem = (Registers.RegisterMainMem) allocation;
signature.append("__mem(").append(registerMainMem.getAddress() == null ? "" : AsmFormat.getAsmNumber(registerMainMem.getAddress())).append(") ");
} else if(allocation instanceof Registers.RegisterAByte) {
signature.append("__register(A) ");
} else if(allocation instanceof Registers.RegisterXByte) {
signature.append("__register(X) ");
} else if(allocation instanceof Registers.RegisterYByte) {
signature.append("__register(Y) ");
} else if(allocation instanceof Registers.RegisterZByte) {
signature.append("__register(Z) ");
}
return param;
}
/**
* Add comments to the assembler program
*

View File

@ -31,11 +31,11 @@ public class PassNAssertStructMembers extends Pass2SsaOptimization {
StructDefinition structDefinition = structType.getStructDefinition(getScope());
Variable member = structDefinition.getMember(structMemberRef.getMemberName());
if(member==null) {
throw new CompileError("Unknown struct member "+structMemberRef.getMemberName()+" in struct "+structType.getTypeName(), currentStmt);
throw new CompileError("Unknown struct member "+structMemberRef.getMemberName()+" in struct "+ structType.toCDecl(), currentStmt);
}
} else {
if(type instanceof SymbolTypePointer)
throw new CompileError("member '"+structMemberRef.getMemberName()+"' reference type '"+type.getTypeBaseName()+"' is a pointer; did you mean to use '->'?", currentStmt);
throw new CompileError("member '"+structMemberRef.getMemberName()+"' reference type '"+type.toCDecl()+"' is a pointer; did you mean to use '->'?", currentStmt);
else
throw new CompileError("member '"+structMemberRef.getMemberName()+"' reference operator '.'/'->' applied to a non-struct", currentStmt);
}

View File

@ -25,7 +25,7 @@ public class PassNAssertTypeDeref extends Pass2SsaAssertion {
RValue pointer = ((PointerDereference) programValue.get()).getPointer();
SymbolType pointertype = SymbolTypeInference.inferType(getProgram().getScope(), pointer);
if(!SymbolType.VAR.equals(pointertype) && !(pointertype instanceof SymbolTypePointer))
throw new CompileError("Dereferencing a non-pointer type "+pointertype.getTypeName(), currentStmt);
throw new CompileError("Dereferencing a non-pointer type "+ pointertype.toCDecl(), currentStmt);
}
});
}

View File

@ -48,8 +48,8 @@ public class PassNAssertTypeMatch extends Pass2SsaAssertion {
SymbolType rValueType = variable.getInitValue().getType(getScope());
if(SymbolTypeConversion.assignmentTypeMatch(lValueType, rValueType)) return;
// Types do not match
getLog().append("ERROR! Type mismatch (" + lValueType.getTypeName() + ") cannot be assigned from (" + rValueType.getTypeName() + "). In initialization of " + variable.toString(getProgram()));
throw new CompileError("Type mismatch (" + lValueType.getTypeName() + ") cannot be assigned from (" + rValueType.getTypeName() + "). In initialization of " + variable.toString(getProgram()));
getLog().append("ERROR! Type mismatch (" + lValueType.toCDecl() + ") cannot be assigned from (" + rValueType.toCDecl() + "). In initialization of " + variable.toString(getProgram()));
throw new CompileError("Type mismatch (" + lValueType.toCDecl() + ") cannot be assigned from (" + rValueType.toCDecl() + "). In initialization of " + variable.toString(getProgram()));
}
private void checkAssignment(StatementAssignment statement) {
@ -66,8 +66,8 @@ public class PassNAssertTypeMatch extends Pass2SsaAssertion {
SymbolType rValueType = SymbolTypeInference.inferType(getScope(), new AssignmentRValue(statement));
if(SymbolTypeConversion.assignmentTypeMatch(lValueType, rValueType)) return;
// Types do not match
getLog().append("ERROR! Type mismatch (" + lValueType.getTypeName() + ") cannot be assigned from (" + rValueType.getTypeName() + "). In " + statement.toString(getProgram(), false));
throw new CompileError("Type mismatch (" + lValueType.getTypeName() + ") cannot be assigned from (" + rValueType.getTypeName() + "). In " + statement.toString(getProgram(), false), statement.getSource());
getLog().append("ERROR! Type mismatch (" + lValueType.toCDecl() + ") cannot be assigned from (" + rValueType.toCDecl() + "). In " + statement.toString(getProgram(), false));
throw new CompileError("Type mismatch (" + lValueType.toCDecl() + ") cannot be assigned from (" + rValueType.toCDecl() + "). In " + statement.toString(getProgram(), false), statement.getSource());
}
}

View File

@ -115,7 +115,7 @@ public class PassNTypeInference extends Pass2SsaOptimization {
} else if(valueType instanceof SymbolTypeInteger && type instanceof SymbolTypeInteger) {
type = SymbolTypeConversion.convertedMathType((SymbolTypeInteger) valueType, (SymbolTypeInteger) type);
} else {
throw new CompileError("Phi value has type mismatch " + rValue.toString() + " not matching type " + type.getTypeName());
throw new CompileError("Phi value has type mismatch " + rValue.toString() + " not matching type " + type.toCDecl());
}
}
if(!SymbolType.VAR.equals(symbol.getType()) && !type.equals(symbol.getType())) {

View File

@ -36,6 +36,7 @@ public class SizeOfConstants {
/**
* Fix the size value of the constant variable if needed.
* Sizes for structs and other complex types is not known until late in Pass1, so they may need fixing.
*
* @param programScope The program scope (used for finding/adding the constant).
* @param type The type to get the variable for
*/
@ -59,10 +60,10 @@ public class SizeOfConstants {
*/
public static String getSizeofConstantName(SymbolType type) {
if(type instanceof SymbolTypePointer) {
// All pointers are the same size
return "SIZEOF_POINTER";
} else {
return "SIZEOF_" + type.getTypeBaseName().toUpperCase(Locale.ENGLISH).replace(" ", "_");
}
} else
return "SIZEOF_"+type.getConstantFriendlyName();
}
/**
@ -95,6 +96,6 @@ public class SizeOfConstants {
* @return The name of the constant
*/
private static String getStructMemberOffsetConstantName(StructDefinition structDefinition, String memberName) {
return "OFFSET_" + structDefinition.getType().getTypeBaseName().toUpperCase(Locale.ENGLISH).replace(" ", "_") + "_" + memberName.toUpperCase();
return "OFFSET_" + structDefinition.getType().getConstantFriendlyName()+ "_" + memberName.toUpperCase(Locale.ENGLISH);
}
}

View File

@ -1588,7 +1588,7 @@ public class TestProgramsFast extends TestPrograms {
@Test
public void testFunctionAsArray() throws IOException {
assertError("function-as-array.c", "Dereferencing a non-pointer type void(byte)");
assertError("function-as-array.c", "Dereferencing a non-pointer type void (char)");
}
//@Test
@ -2306,7 +2306,7 @@ public class TestProgramsFast extends TestPrograms {
@Test
public void testStructError7() throws IOException {
assertError("struct-err-7.c", "Type mismatch (signed word) cannot be assigned from '*main::per.qwe'");
assertError("struct-err-7.c", "Type mismatch (int) cannot be assigned from '*main::per.qwe'");
}
@Test

View File

@ -14,6 +14,25 @@ import java.util.Arrays;
/// https://cdecl.org
public class testTypeCDecl {
@Test
void testTypes() {
Assertions.assertEquals("char",SymbolType.BYTE.toCDecl());
Assertions.assertEquals("signed char",SymbolType.SBYTE.toCDecl());
Assertions.assertEquals("int",SymbolType.SWORD.toCDecl());
Assertions.assertEquals("unsigned int",SymbolType.WORD.toCDecl());
Assertions.assertEquals("long",SymbolType.SDWORD.toCDecl());
Assertions.assertEquals("unsigned long",SymbolType.DWORD.toCDecl());
Assertions.assertEquals("long",SymbolType.SDWORD.toCDecl());
Assertions.assertEquals("bool",SymbolType.BOOLEAN.toCDecl());
Assertions.assertEquals("number",SymbolType.NUMBER.toCDecl());
Assertions.assertEquals("snumber",SymbolType.SNUMBER.toCDecl());
Assertions.assertEquals("unumber",SymbolType.UNUMBER.toCDecl());
Assertions.assertEquals("volatile char", SymbolType.BYTE.getQualified(true, false).toCDecl());
Assertions.assertEquals("char *",new SymbolTypePointer(SymbolType.BYTE).toCDecl());
Assertions.assertEquals("int *",new SymbolTypePointer(SymbolType.SWORD).toCDecl());
Assertions.assertEquals("unsigned long **",new SymbolTypePointer(new SymbolTypePointer(SymbolType.DWORD)).toCDecl());
}
@Test
void testSimple() {
assertCDecl("char x", "x", SymbolType.BYTE);

View File

@ -1,4 +1,4 @@
Inlined call call __init
Inlined call call __init
CONTROL FLOW GRAPH SSA
@ -24,7 +24,7 @@ __start::__init1: scope:[__start] from __start
i = 3
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
call main
call main
to:__start::@2
__start::@2: scope:[__start] from __start::@1
to:__start::@return
@ -33,18 +33,18 @@ __start::@return: scope:[__start] from __start::@2
to:@return
SYMBOL TABLE SSA
constant byte* const SCREEN = (byte*)$400
__constant char * const SCREEN = (char *)$400
void __start()
byte i loadstore !zp[-1]:2
__loadstore char i // !zp[-1]:2
void main()
bool~ main::$0
bool main::$0
Adding number conversion cast (unumber) 7 in main::$0 = i < 7
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 7
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 7
Finalized unsigned number type (char) 7
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simple Condition main::$0 [1] if(i<7) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
@ -73,7 +73,7 @@ __start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
[2] phi()
[3] call main
[3] call main
to:__start::@return
__start::@return: scope:[__start] from __start::@1
[4] return
@ -97,7 +97,7 @@ main::@2: scope:[main] from main::@1
VARIABLE REGISTER WEIGHTS
void __start()
byte i loadstore !zp[-1]:2 84.49999999999999
__loadstore char i // !zp[-1]:2 84.49999999999999
void main()
Initial phi equivalence classes
@ -151,7 +151,7 @@ __start: {
jmp __b1
// __start::@1
__b1:
// [3] call main
// [3] call main
// [5] phi from __start::@1 to main [phi:__start::@1->main]
main_from___b1:
jsr main
@ -204,9 +204,9 @@ Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void __start()
byte i loadstore !zp[-1]:2 zp[1]:2 84.49999999999999
__loadstore char i // !zp[-1]:2 zp[1]:2 84.49999999999999
void main()
zp[1]:2 [ i ]
@ -240,7 +240,7 @@ __start: {
sta.z i
// [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
// __start::@1
// [3] call main
// [3] call main
// [5] phi from __start::@1 to main [phi:__start::@1->main]
jsr main
// __start::@return

View File

@ -1,6 +1,6 @@
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void __start()
byte i loadstore !zp[-1]:2 zp[1]:2 84.49999999999999
__loadstore char i // !zp[-1]:2 zp[1]:2 84.49999999999999
void main()
zp[1]:2 [ i ]

View File

@ -19,7 +19,7 @@ main::@return: scope:[main] from main::@1
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -28,18 +28,18 @@ __start::@return: scope:[__start] from __start::@1
to:@return
SYMBOL TABLE SSA
constant byte* const SCREEN = (byte*)$400
__constant char * const SCREEN = (char *)$400
void __start()
void main()
bool~ main::$0
byte main::i loadstore !zp[-1]:2
bool main::$0
__loadstore char main::i // !zp[-1]:2
Adding number conversion cast (unumber) 7 in main::$0 = main::i < 7
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 7
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 7
Finalized unsigned number type (char) 7
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simple Condition main::$0 [2] if(main::i<7) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
@ -73,7 +73,7 @@ main::@2: scope:[main] from main::@1
VARIABLE REGISTER WEIGHTS
void main()
byte main::i loadstore !zp[-1]:2 14.25
__loadstore char main::i // !zp[-1]:2 14.25
Initial phi equivalence classes
Added variable main::i to live range equivalence class [ main::i ]
@ -148,9 +148,9 @@ Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void main()
byte main::i loadstore !zp[-1]:2 zp[1]:2 14.25
__loadstore char main::i // !zp[-1]:2 zp[1]:2 14.25
zp[1]:2 [ main::i ]

View File

@ -1,5 +1,5 @@
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void main()
byte main::i loadstore !zp[-1]:2 zp[1]:2 14.25
__loadstore char main::i // !zp[-1]:2 zp[1]:2 14.25
zp[1]:2 [ main::i ]

View File

@ -1,4 +1,4 @@
Inlined call call __init
Inlined call call __init
CONTROL FLOW GRAPH SSA
@ -24,7 +24,7 @@ __start::__init1: scope:[__start] from __start
i = 3
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
call main
call main
to:__start::@2
__start::@2: scope:[__start] from __start::@1
to:__start::@return
@ -33,18 +33,18 @@ __start::@return: scope:[__start] from __start::@2
to:@return
SYMBOL TABLE SSA
constant byte* const SCREEN = (byte*)$400
__constant char * const SCREEN = (char *)$400
void __start()
byte i loadstore !mem[-1]:8192
__loadstore char i // !mem[-1]:8192
void main()
bool~ main::$0
bool main::$0
Adding number conversion cast (unumber) 7 in main::$0 = i < 7
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 7
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 7
Finalized unsigned number type (char) 7
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simple Condition main::$0 [1] if(i<7) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
@ -73,7 +73,7 @@ __start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
[2] phi()
[3] call main
[3] call main
to:__start::@return
__start::@return: scope:[__start] from __start::@1
[4] return
@ -97,7 +97,7 @@ main::@2: scope:[main] from main::@1
VARIABLE REGISTER WEIGHTS
void __start()
byte i loadstore !mem[-1]:8192 84.49999999999999
__loadstore char i // !mem[-1]:8192 84.49999999999999
void main()
Initial phi equivalence classes
@ -151,7 +151,7 @@ __start: {
jmp __b1
// __start::@1
__b1:
// [3] call main
// [3] call main
// [5] phi from __start::@1 to main [phi:__start::@1->main]
main_from___b1:
jsr main
@ -204,9 +204,9 @@ Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void __start()
byte i loadstore !mem[-1]:8192 mem[1]:8192 84.49999999999999
__loadstore char i // !mem[-1]:8192 mem[1]:8192 84.49999999999999
void main()
mem[1]:8192 [ i ]
@ -240,7 +240,7 @@ __start: {
sta i
// [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
// __start::@1
// [3] call main
// [3] call main
// [5] phi from __start::@1 to main [phi:__start::@1->main]
jsr main
// __start::@return

View File

@ -1,6 +1,6 @@
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void __start()
byte i loadstore !mem[-1]:8192 mem[1]:8192 84.49999999999999
__loadstore char i // !mem[-1]:8192 mem[1]:8192 84.49999999999999
void main()
mem[1]:8192 [ i ]

View File

@ -19,7 +19,7 @@ main::@return: scope:[main] from main::@1
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -28,18 +28,18 @@ __start::@return: scope:[__start] from __start::@1
to:@return
SYMBOL TABLE SSA
constant byte* const SCREEN = (byte*)$400
__constant char * const SCREEN = (char *)$400
void __start()
void main()
bool~ main::$0
byte main::i loadstore !mem[-1]:8192
bool main::$0
__loadstore char main::i // !mem[-1]:8192
Adding number conversion cast (unumber) 7 in main::$0 = main::i < 7
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 7
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 7
Finalized unsigned number type (char) 7
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simple Condition main::$0 [2] if(main::i<7) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
@ -73,7 +73,7 @@ main::@2: scope:[main] from main::@1
VARIABLE REGISTER WEIGHTS
void main()
byte main::i loadstore !mem[-1]:8192 14.25
__loadstore char main::i // !mem[-1]:8192 14.25
Initial phi equivalence classes
Added variable main::i to live range equivalence class [ main::i ]
@ -148,9 +148,9 @@ Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void main()
byte main::i loadstore !mem[-1]:8192 mem[1]:8192 14.25
__loadstore char main::i // !mem[-1]:8192 mem[1]:8192 14.25
mem[1]:8192 [ main::i ]

View File

@ -1,5 +1,5 @@
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void main()
byte main::i loadstore !mem[-1]:8192 mem[1]:8192 14.25
__loadstore char main::i // !mem[-1]:8192 mem[1]:8192 14.25
mem[1]:8192 [ main::i ]

View File

@ -1,4 +1,4 @@
Inlined call call __init
Inlined call call __init
CONTROL FLOW GRAPH SSA
@ -11,10 +11,10 @@ main::@1: scope:[main] from main main::@2
if(main::$0) goto main::@2
to:main::@return
main::@2: scope:[main] from main::@1
main::$1 = main::i * SIZEOF_WORD
main::$1 = main::i * SIZEOF_UNSIGNED_INT
SCREEN[main::$1] = main::ch
main::i = ++ main::i
main::$2 = main::i * SIZEOF_WORD
main::$2 = main::i * SIZEOF_UNSIGNED_INT
SCREEN[main::$2] = main::ch
main::i = ++ main::i
to:main::@1
@ -28,7 +28,7 @@ __start: scope:[__start] from
__start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
call main
call main
to:__start::@2
__start::@2: scope:[__start] from __start::@1
to:__start::@return
@ -37,22 +37,22 @@ __start::@return: scope:[__start] from __start::@2
to:@return
SYMBOL TABLE SSA
constant word* SCREEN = (byte*)$400
constant byte SIZEOF_WORD = 2
__constant unsigned int *SCREEN = (char *)$400
__constant char SIZEOF_UNSIGNED_INT = 2
void __start()
void main()
bool~ main::$0
byte~ main::$1
byte~ main::$2
constant const word main::ch = $102
byte main::i loadstore !zp[-1]:2
bool main::$0
char main::$1
char main::$2
__constant const unsigned int main::ch = $102
__loadstore char main::i // !zp[-1]:2
Adding number conversion cast (unumber) 8 in main::$0 = main::i < 8
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 8
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 8
Finalized unsigned number type (char) 8
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simple Condition main::$0 [2] if(main::i<8) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
@ -63,10 +63,10 @@ Removing unused procedure block __start::@1
Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Rewriting multiplication to use shift [2] main::$1 = main::i * SIZEOF_WORD
Rewriting multiplication to use shift [5] main::$2 = main::i * SIZEOF_WORD
Rewriting multiplication to use shift [2] main::$1 = main::i * SIZEOF_UNSIGNED_INT
Rewriting multiplication to use shift [5] main::$2 = main::i * SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2MultiplyToShiftRewriting
Eliminating unused constant SIZEOF_WORD
Eliminating unused constant SIZEOF_UNSIGNED_INT
Successful SSA optimization PassNEliminateUnusedVars
CALL GRAPH
@ -97,9 +97,9 @@ main::@2: scope:[main] from main::@1
VARIABLE REGISTER WEIGHTS
void main()
byte~ main::$1 22.0
byte~ main::$2 22.0
byte main::i loadstore !zp[-1]:2 9.875
char main::$1 // 22.0
char main::$2 // 22.0
__loadstore char main::i // !zp[-1]:2 9.875
Initial phi equivalence classes
Added variable main::i to live range equivalence class [ main::i ]
@ -202,12 +202,12 @@ Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant word* SCREEN = (byte*) 1024
__constant unsigned int *SCREEN = (char *) 1024
void main()
byte~ main::$1 reg byte a 22.0
byte~ main::$2 reg byte a 22.0
constant const word main::ch = $102
byte main::i loadstore !zp[-1]:2 zp[1]:2 9.875
char main::$1 // reg byte a 22.0
char main::$2 // reg byte a 22.0
__constant const unsigned int main::ch = $102
__loadstore char main::i // !zp[-1]:2 zp[1]:2 9.875
zp[1]:2 [ main::i ]
reg byte a [ main::$1 ]

View File

@ -1,9 +1,9 @@
constant word* SCREEN = (byte*) 1024
__constant unsigned int *SCREEN = (char *) 1024
void main()
byte~ main::$1 reg byte a 22.0
byte~ main::$2 reg byte a 22.0
constant const word main::ch = $102
byte main::i loadstore !zp[-1]:2 zp[1]:2 9.875
char main::$1 // reg byte a 22.0
char main::$2 // reg byte a 22.0
__constant const unsigned int main::ch = $102
__loadstore char main::i // !zp[-1]:2 zp[1]:2 9.875
zp[1]:2 [ main::i ]
reg byte a [ main::$1 ]

View File

@ -34,7 +34,7 @@ main: {
// }
rts
}
// print(byte zp(2) ch)
// void print(__zp(2) volatile char ch)
print: {
.label ch = 2
// asm

View File

@ -8,7 +8,7 @@ __start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
[2] phi()
[3] call main
[3] call main
to:__start::@return
__start::@return: scope:[__start] from __start::@1
[4] return
@ -17,21 +17,21 @@ __start::@return: scope:[__start] from __start::@1
void main()
main: scope:[main] from __start::@1
[5] print::ch = 'c'
[6] call print
[6] call print
to:main::@1
main::@1: scope:[main] from main
[7] print::ch = 'm'
[8] call print
[8] call print
to:main::@2
main::@2: scope:[main] from main::@1
[9] print::ch = 'l'
[10] call print
[10] call print
to:main::@return
main::@return: scope:[main] from main::@2
[11] return
to:@return
void print(volatile byte print::ch)
void print(volatile char ch)
print: scope:[print] from main main::@1 main::@2
asm { ldxidx ldach staSCREEN,x incidx }
to:print::@return

View File

@ -1,20 +1,20 @@
Setting inferred volatile on symbol affected by address-of: print::ch in asm { ldxidx ldach staSCREEN,x incidx }
Inlined call call __init
Inlined call call __init
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start::@1
print::ch = 'c'
call print
call print
to:main::@1
main::@1: scope:[main] from main
print::ch = 'm'
call print
call print
to:main::@2
main::@2: scope:[main] from main::@1
print::ch = 'l'
call print
call print
to:main::@3
main::@3: scope:[main] from main::@2
to:main::@return
@ -22,7 +22,7 @@ main::@return: scope:[main] from main::@3
return
to:@return
void print(volatile byte print::ch)
void print(volatile char ch)
print: scope:[print] from main main::@1 main::@2
asm { ldxidx ldach staSCREEN,x incidx }
to:print::@return
@ -37,7 +37,7 @@ __start::__init1: scope:[__start] from __start
idx = 0
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
call main
call main
to:__start::@2
__start::@2: scope:[__start] from __start::@1
to:__start::@return
@ -46,14 +46,14 @@ __start::@return: scope:[__start] from __start::@2
to:@return
SYMBOL TABLE SSA
constant byte* const SCREEN = (byte*)$400
__constant char * const SCREEN = (char *)$400
void __start()
volatile byte idx loadstore !zp[-1]:3
__loadstore volatile char idx // !zp[-1]:3
void main()
void print(volatile byte print::ch)
volatile byte print::ch loadstore
void print(volatile char ch)
__loadstore volatile char print::ch
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
@ -81,7 +81,7 @@ __start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
[2] phi()
[3] call main
[3] call main
to:__start::@return
__start::@return: scope:[__start] from __start::@1
[4] return
@ -90,21 +90,21 @@ __start::@return: scope:[__start] from __start::@1
void main()
main: scope:[main] from __start::@1
[5] print::ch = 'c'
[6] call print
[6] call print
to:main::@1
main::@1: scope:[main] from main
[7] print::ch = 'm'
[8] call print
[8] call print
to:main::@2
main::@2: scope:[main] from main::@1
[9] print::ch = 'l'
[10] call print
[10] call print
to:main::@return
main::@return: scope:[main] from main::@2
[11] return
to:@return
void print(volatile byte print::ch)
void print(volatile char ch)
print: scope:[print] from main main::@1 main::@2
asm { ldxidx ldach staSCREEN,x incidx }
to:print::@return
@ -115,10 +115,10 @@ print::@return: scope:[print] from print
VARIABLE REGISTER WEIGHTS
void __start()
volatile byte idx loadstore !zp[-1]:3 0.2222222222222222
__loadstore volatile char idx // !zp[-1]:3 0.2222222222222222
void main()
void print(volatile byte print::ch)
volatile byte print::ch loadstore 11.0
void print(volatile char ch)
__loadstore volatile char print::ch // 11.0
Initial phi equivalence classes
Added variable idx to live range equivalence class [ idx ]
@ -181,7 +181,7 @@ __start: {
jmp __b1
// __start::@1
__b1:
// [3] call main
// [3] call main
jsr main
jmp __breturn
// __start::@return
@ -194,7 +194,7 @@ main: {
// [5] print::ch = 'c' -- vbuz1=vbuc1
lda #'c'
sta.z print.ch
// [6] call print
// [6] call print
jsr print
jmp __b1
// main::@1
@ -202,7 +202,7 @@ main: {
// [7] print::ch = 'm' -- vbuz1=vbuc1
lda #'m'
sta.z print.ch
// [8] call print
// [8] call print
jsr print
jmp __b2
// main::@2
@ -210,7 +210,7 @@ main: {
// [9] print::ch = 'l' -- vbuz1=vbuc1
lda #'l'
sta.z print.ch
// [10] call print
// [10] call print
jsr print
jmp __breturn
// main::@return
@ -219,7 +219,7 @@ main: {
rts
}
// print
// print(byte zp(2) ch)
// void print(__zp(2) volatile char ch)
print: {
.label ch = 2
// asm { ldxidx ldach staSCREEN,x incidx }
@ -256,12 +256,12 @@ Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void __start()
volatile byte idx loadstore !zp[-1]:3 zp[1]:3 0.2222222222222222
__loadstore volatile char idx // !zp[-1]:3 zp[1]:3 0.2222222222222222
void main()
void print(volatile byte print::ch)
volatile byte print::ch loadstore zp[1]:2 11.0
void print(volatile char ch)
__loadstore volatile char print::ch // zp[1]:2 11.0
zp[1]:3 [ idx ]
zp[1]:2 [ print::ch ]
@ -295,7 +295,7 @@ __start: {
sta.z idx
// [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
// __start::@1
// [3] call main
// [3] call main
jsr main
// __start::@return
// [4] return
@ -307,21 +307,21 @@ main: {
// [5] print::ch = 'c' -- vbuz1=vbuc1
lda #'c'
sta.z print.ch
// [6] call print
// [6] call print
jsr print
// main::@1
// print('m')
// [7] print::ch = 'm' -- vbuz1=vbuc1
lda #'m'
sta.z print.ch
// [8] call print
// [8] call print
jsr print
// main::@2
// print('l')
// [9] print::ch = 'l' -- vbuz1=vbuc1
lda #'l'
sta.z print.ch
// [10] call print
// [10] call print
jsr print
// main::@return
// }
@ -329,7 +329,7 @@ main: {
rts
}
// print
// print(byte zp(2) ch)
// void print(__zp(2) volatile char ch)
print: {
.label ch = 2
// asm

View File

@ -1,9 +1,9 @@
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void __start()
volatile byte idx loadstore !zp[-1]:3 zp[1]:3 0.2222222222222222
__loadstore volatile char idx // !zp[-1]:3 zp[1]:3 0.2222222222222222
void main()
void print(volatile byte print::ch)
volatile byte print::ch loadstore zp[1]:2 11.0
void print(volatile char ch)
__loadstore volatile char print::ch // zp[1]:2 11.0
zp[1]:3 [ idx ]
zp[1]:2 [ print::ch ]

View File

@ -34,7 +34,7 @@ main: {
// }
rts
}
// print(byte zp(2) ch)
// void print(__zp(2) volatile char ch)
print: {
.label ch = 2
// asm

View File

@ -8,7 +8,7 @@ __start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
[2] phi()
[3] call main
[3] call main
to:__start::@return
__start::@return: scope:[__start] from __start::@1
[4] return
@ -17,21 +17,21 @@ __start::@return: scope:[__start] from __start::@1
void main()
main: scope:[main] from __start::@1
[5] print::ch = 'c'
[6] call print
[6] call print
to:main::@1
main::@1: scope:[main] from main
[7] print::ch = 'm'
[8] call print
[8] call print
to:main::@2
main::@2: scope:[main] from main::@1
[9] print::ch = 'l'
[10] call print
[10] call print
to:main::@return
main::@return: scope:[main] from main::@2
[11] return
to:@return
void print(volatile byte print::ch)
void print(volatile char ch)
print: scope:[print] from main main::@1 main::@2
asm { ldxidx ldach staSCREEN,x incidx }
to:print::@return

View File

@ -1,20 +1,20 @@
Setting inferred volatile on symbol affected by address-of: print::ch in asm { ldxidx ldach staSCREEN,x incidx }
Inlined call call __init
Inlined call call __init
CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start::@1
print::ch = 'c'
call print
call print
to:main::@1
main::@1: scope:[main] from main
print::ch = 'm'
call print
call print
to:main::@2
main::@2: scope:[main] from main::@1
print::ch = 'l'
call print
call print
to:main::@3
main::@3: scope:[main] from main::@2
to:main::@return
@ -22,7 +22,7 @@ main::@return: scope:[main] from main::@3
return
to:@return
void print(volatile byte print::ch)
void print(volatile char ch)
print: scope:[print] from main main::@1 main::@2
asm { ldxidx ldach staSCREEN,x incidx }
to:print::@return
@ -37,7 +37,7 @@ __start::__init1: scope:[__start] from __start
idx = 0
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
call main
call main
to:__start::@2
__start::@2: scope:[__start] from __start::@1
to:__start::@return
@ -46,14 +46,14 @@ __start::@return: scope:[__start] from __start::@2
to:@return
SYMBOL TABLE SSA
constant byte* const SCREEN = (byte*)$400
__constant char * const SCREEN = (char *)$400
void __start()
volatile byte idx loadstore !mem[-1]:12288
__loadstore volatile char idx // !mem[-1]:12288
void main()
void print(volatile byte print::ch)
volatile byte print::ch loadstore
void print(volatile char ch)
__loadstore volatile char print::ch
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
@ -81,7 +81,7 @@ __start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
[2] phi()
[3] call main
[3] call main
to:__start::@return
__start::@return: scope:[__start] from __start::@1
[4] return
@ -90,21 +90,21 @@ __start::@return: scope:[__start] from __start::@1
void main()
main: scope:[main] from __start::@1
[5] print::ch = 'c'
[6] call print
[6] call print
to:main::@1
main::@1: scope:[main] from main
[7] print::ch = 'm'
[8] call print
[8] call print
to:main::@2
main::@2: scope:[main] from main::@1
[9] print::ch = 'l'
[10] call print
[10] call print
to:main::@return
main::@return: scope:[main] from main::@2
[11] return
to:@return
void print(volatile byte print::ch)
void print(volatile char ch)
print: scope:[print] from main main::@1 main::@2
asm { ldxidx ldach staSCREEN,x incidx }
to:print::@return
@ -115,10 +115,10 @@ print::@return: scope:[print] from print
VARIABLE REGISTER WEIGHTS
void __start()
volatile byte idx loadstore !mem[-1]:12288 0.2222222222222222
__loadstore volatile char idx // !mem[-1]:12288 0.2222222222222222
void main()
void print(volatile byte print::ch)
volatile byte print::ch loadstore 11.0
void print(volatile char ch)
__loadstore volatile char print::ch // 11.0
Initial phi equivalence classes
Added variable idx to live range equivalence class [ idx ]
@ -181,7 +181,7 @@ __start: {
jmp __b1
// __start::@1
__b1:
// [3] call main
// [3] call main
jsr main
jmp __breturn
// __start::@return
@ -194,7 +194,7 @@ main: {
// [5] print::ch = 'c' -- vbuz1=vbuc1
lda #'c'
sta.z print.ch
// [6] call print
// [6] call print
jsr print
jmp __b1
// main::@1
@ -202,7 +202,7 @@ main: {
// [7] print::ch = 'm' -- vbuz1=vbuc1
lda #'m'
sta.z print.ch
// [8] call print
// [8] call print
jsr print
jmp __b2
// main::@2
@ -210,7 +210,7 @@ main: {
// [9] print::ch = 'l' -- vbuz1=vbuc1
lda #'l'
sta.z print.ch
// [10] call print
// [10] call print
jsr print
jmp __breturn
// main::@return
@ -219,7 +219,7 @@ main: {
rts
}
// print
// print(byte zp(2) ch)
// void print(__zp(2) volatile char ch)
print: {
.label ch = 2
// asm { ldxidx ldach staSCREEN,x incidx }
@ -256,12 +256,12 @@ Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void __start()
volatile byte idx loadstore !mem[-1]:12288 mem[1]:12288 0.2222222222222222
__loadstore volatile char idx // !mem[-1]:12288 mem[1]:12288 0.2222222222222222
void main()
void print(volatile byte print::ch)
volatile byte print::ch loadstore zp[1]:2 11.0
void print(volatile char ch)
__loadstore volatile char print::ch // zp[1]:2 11.0
mem[1]:12288 [ idx ]
zp[1]:2 [ print::ch ]
@ -295,7 +295,7 @@ __start: {
sta idx
// [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
// __start::@1
// [3] call main
// [3] call main
jsr main
// __start::@return
// [4] return
@ -307,21 +307,21 @@ main: {
// [5] print::ch = 'c' -- vbuz1=vbuc1
lda #'c'
sta.z print.ch
// [6] call print
// [6] call print
jsr print
// main::@1
// print('m')
// [7] print::ch = 'm' -- vbuz1=vbuc1
lda #'m'
sta.z print.ch
// [8] call print
// [8] call print
jsr print
// main::@2
// print('l')
// [9] print::ch = 'l' -- vbuz1=vbuc1
lda #'l'
sta.z print.ch
// [10] call print
// [10] call print
jsr print
// main::@return
// }
@ -329,7 +329,7 @@ main: {
rts
}
// print
// print(byte zp(2) ch)
// void print(__zp(2) volatile char ch)
print: {
.label ch = 2
// asm

View File

@ -1,9 +1,9 @@
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void __start()
volatile byte idx loadstore !mem[-1]:12288 mem[1]:12288 0.2222222222222222
__loadstore volatile char idx // !mem[-1]:12288 mem[1]:12288 0.2222222222222222
void main()
void print(volatile byte print::ch)
volatile byte print::ch loadstore zp[1]:2 11.0
void print(volatile char ch)
__loadstore volatile char print::ch // zp[1]:2 11.0
mem[1]:12288 [ idx ]
zp[1]:2 [ print::ch ]

View File

@ -11,7 +11,7 @@ main::@return: scope:[main] from main
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -20,20 +20,20 @@ __start::@return: scope:[__start] from __start::@1
to:@return
SYMBOL TABLE SSA
constant byte* DATA[$3e8] = { fill( $3e8, 0) }
constant byte* const SCREEN = (byte*)$400
__constant char DATA[$3e8] = { fill( $3e8, 0) }
__constant char * const SCREEN = (char *)$400
void __start()
void main()
Adding number conversion cast (unumber) 0 in SCREEN[0] = DATA[0]
Adding number conversion cast (unumber) 0 in SCREEN[0] = DATA[(unumber)0]
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simplifying expression containing zero DATA in [0] SCREEN[0] = DATA[0]
Simplifying expression containing zero SCREEN in [0] SCREEN[0] = *DATA
@ -43,9 +43,9 @@ Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Finalized unsigned number type (word) $3e8
Finalized unsigned number type (word) $3e8
Finalized unsigned number type (word) $1000
Finalized unsigned number type (unsigned int) $3e8
Finalized unsigned number type (unsigned int) $3e8
Finalized unsigned number type (unsigned int) $1000
Successful SSA optimization PassNFinalizeNumberTypeConversions
CALL GRAPH
@ -118,8 +118,8 @@ Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte* DATA[$3e8] = { fill( $3e8, 0) }
constant byte* const SCREEN = (byte*) 1024
__constant char DATA[$3e8] = { fill( $3e8, 0) }
__constant char * const SCREEN = (char *) 1024
void main()

View File

@ -1,4 +1,4 @@
constant byte* DATA[$3e8] = { fill( $3e8, 0) }
constant byte* const SCREEN = (byte*) 1024
__constant char DATA[$3e8] = { fill( $3e8, 0) }
__constant char * const SCREEN = (char *) 1024
void main()

View File

@ -3,7 +3,7 @@ CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
main::$0 = 0 * SIZEOF_SIGNED_WORD
main::$0 = 0 * SIZEOF_INT
SCREEN[main::$0] = DATA[main::$0]
to:main::@return
main::@return: scope:[main] from main
@ -12,7 +12,7 @@ main::@return: scope:[main] from main
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -21,42 +21,42 @@ __start::@return: scope:[__start] from __start::@1
to:@return
SYMBOL TABLE SSA
constant signed word* DATA[$3e8] = { fill( $3e8, 0) }
constant signed word* const SCREEN = (signed word*)$400
constant byte SIZEOF_SIGNED_WORD = 2
__constant int DATA[$3e8] = { fill( $3e8, 0) }
__constant int * const SCREEN = (int *)$400
__constant char SIZEOF_INT = 2
void __start()
void main()
number~ main::$0
number main::$0
Adding number conversion cast (unumber) 0 in main::$0 = 0 * SIZEOF_SIGNED_WORD
Adding number conversion cast (unumber) main::$0 in main::$0 = (unumber)0 * SIZEOF_SIGNED_WORD
Adding number conversion cast (unumber) 0 in main::$0 = 0 * SIZEOF_INT
Adding number conversion cast (unumber) main::$0 in main::$0 = (unumber)0 * SIZEOF_INT
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (signed word*) 1024
Simplifying constant pointer cast (int *) 1024
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in main::$0 = 0 * SIZEOF_SIGNED_WORD
Constant right-side identified [0] main::$0 = 0 * SIZEOF_SIGNED_WORD
Inferred type updated to char in main::$0 = 0 * SIZEOF_INT
Constant right-side identified [0] main::$0 = 0 * SIZEOF_INT
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant main::$0 = 0*SIZEOF_SIGNED_WORD
Constant main::$0 = 0*SIZEOF_INT
Successful SSA optimization Pass2ConstantIdentification
Simplifying constant evaluating to zero 0*SIZEOF_SIGNED_WORD in
Simplifying constant evaluating to zero 0*SIZEOF_INT in
Successful SSA optimization PassNSimplifyConstantZero
Simplifying expression containing zero DATA in [1] SCREEN[main::$0] = DATA[main::$0]
Simplifying expression containing zero SCREEN in [1] SCREEN[main::$0] = *DATA
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused constant main::$0
Eliminating unused constant SIZEOF_SIGNED_WORD
Eliminating unused constant SIZEOF_INT
Successful SSA optimization PassNEliminateUnusedVars
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Finalized unsigned number type (word) $3e8
Finalized unsigned number type (word) $3e8
Finalized unsigned number type (word) $1000
Finalized unsigned number type (unsigned int) $3e8
Finalized unsigned number type (unsigned int) $3e8
Finalized unsigned number type (unsigned int) $1000
Successful SSA optimization PassNFinalizeNumberTypeConversions
CALL GRAPH
@ -131,8 +131,8 @@ Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant signed word* DATA[$3e8] = { fill( $3e8, 0) }
constant signed word* const SCREEN = (signed word*) 1024
__constant int DATA[$3e8] = { fill( $3e8, 0) }
__constant int * const SCREEN = (int *) 1024
void main()

View File

@ -1,4 +1,4 @@
constant signed word* DATA[$3e8] = { fill( $3e8, 0) }
constant signed word* const SCREEN = (signed word*) 1024
__constant int DATA[$3e8] = { fill( $3e8, 0) }
__constant int * const SCREEN = (int *) 1024
void main()

View File

@ -20,7 +20,7 @@ main::@return: scope:[main] from main::@1
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -31,19 +31,19 @@ __start::@return: scope:[__start] from __start::@1
SYMBOL TABLE SSA
void __start()
void main()
bool~ main::$1
constant byte* main::SCREEN = (byte*)$400
volatile byte main::b loadstore
constant byte* main::bp = &main::b
byte main::c
byte main::c#0
bool main::$1
__constant char *main::SCREEN = (char *)$400
__loadstore volatile char main::b
__constant char *main::bp = &main::b
char main::c
char main::c#0
Adding number conversion cast (unumber) 1 in main::c#0 = *main::bp + 1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simple Condition main::$1 [5] if(main::b!=rangelast(0,$a)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
@ -58,7 +58,7 @@ Adding number conversion cast (unumber) $b in [4] if(main::b!=$b) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $b
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $b
Finalized unsigned number type (char) $b
Successful SSA optimization PassNFinalizeNumberTypeConversions
CALL GRAPH
@ -84,9 +84,9 @@ main::@return: scope:[main] from main::@1
VARIABLE REGISTER WEIGHTS
void main()
volatile byte main::b loadstore 9.200000000000001
byte main::c
byte main::c#0 22.0
__loadstore volatile char main::b // 9.200000000000001
char main::c
char main::c#0 // 22.0
Initial phi equivalence classes
Added variable main::b to live range equivalence class [ main::b ]
@ -167,11 +167,11 @@ Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
void main()
constant byte* main::SCREEN = (byte*) 1024
volatile byte main::b loadstore zp[1]:2 9.200000000000001
constant byte* main::bp = &main::b
byte main::c
byte main::c#0 reg byte a 22.0
__constant char *main::SCREEN = (char *) 1024
__loadstore volatile char main::b // zp[1]:2 9.200000000000001
__constant char *main::bp = &main::b
char main::c
char main::c#0 // reg byte a 22.0
zp[1]:2 [ main::b ]
reg byte a [ main::c#0 ]

View File

@ -1,9 +1,9 @@
void main()
constant byte* main::SCREEN = (byte*) 1024
volatile byte main::b loadstore zp[1]:2 9.200000000000001
constant byte* main::bp = &main::b
byte main::c
byte main::c#0 reg byte a 22.0
__constant char *main::SCREEN = (char *) 1024
__loadstore volatile char main::b // zp[1]:2 9.200000000000001
__constant char *main::bp = &main::b
char main::c
char main::c#0 // reg byte a 22.0
zp[1]:2 [ main::b ]
reg byte a [ main::c#0 ]

View File

@ -53,7 +53,7 @@ main: {
// }
rts
}
// setByte(byte* zp(2) ptr, byte register(X) b)
// void setByte(__zp(2) char *ptr, __register(X) char b)
setByte: {
.label ptr = 2
// *ptr = b

View File

@ -4,15 +4,15 @@ main: scope:[main] from
[0] main::b1 = 0
[1] main::b2 = 0
[2] main::b3 = 0
[3] call setByte
[3] call setByte
to:main::@1
main::@1: scope:[main] from main
[4] phi()
[5] call setByte
[5] call setByte
to:main::@2
main::@2: scope:[main] from main::@1
[6] phi()
[7] call setByte
[7] call setByte
to:main::@3
main::@3: scope:[main] from main::@2
[8] *main::SCREEN = main::b1
@ -23,7 +23,7 @@ main::@return: scope:[main] from main::@3
[11] return
to:@return
void setByte(byte* setByte::ptr , byte setByte::b)
void setByte(char *ptr , char b)
setByte: scope:[setByte] from main main::@1 main::@2
[12] setByte::ptr#3 = phi( main/&main::b1, main::@1/&main::b2, main::@2/&main::b3 )
[12] setByte::b#3 = phi( main/'c', main::@1/'m', main::@2/'l' )

View File

@ -11,17 +11,17 @@ main: scope:[main] from __start
main::b3 = 0
setByte::ptr#0 = &main::b1
setByte::b#0 = 'c'
call setByte
call setByte
to:main::@1
main::@1: scope:[main] from main
setByte::ptr#1 = &main::b2
setByte::b#1 = 'm'
call setByte
call setByte
to:main::@2
main::@2: scope:[main] from main::@1
setByte::ptr#2 = &main::b3
setByte::b#2 = 'l'
call setByte
call setByte
to:main::@3
main::@3: scope:[main] from main::@2
main::SCREEN[0] = main::b1
@ -32,7 +32,7 @@ main::@return: scope:[main] from main::@3
return
to:@return
void setByte(byte* setByte::ptr , byte setByte::b)
void setByte(char *ptr , char b)
setByte: scope:[setByte] from main main::@1 main::@2
setByte::ptr#3 = phi( main/setByte::ptr#0, main::@1/setByte::ptr#1, main::@2/setByte::ptr#2 )
setByte::b#3 = phi( main/setByte::b#0, main::@1/setByte::b#1, main::@2/setByte::b#2 )
@ -44,7 +44,7 @@ setByte::@return: scope:[setByte] from setByte
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -55,34 +55,34 @@ __start::@return: scope:[__start] from __start::@1
SYMBOL TABLE SSA
void __start()
void main()
constant byte* main::SCREEN = (byte*)$400
volatile byte main::b1 loadstore
volatile byte main::b2 loadstore
volatile byte main::b3 loadstore
void setByte(byte* setByte::ptr , byte setByte::b)
byte setByte::b
byte setByte::b#0
byte setByte::b#1
byte setByte::b#2
byte setByte::b#3
byte* setByte::ptr
byte* setByte::ptr#0
byte* setByte::ptr#1
byte* setByte::ptr#2
byte* setByte::ptr#3
__constant char *main::SCREEN = (char *)$400
__loadstore volatile char main::b1
__loadstore volatile char main::b2
__loadstore volatile char main::b3
void setByte(char *ptr , char b)
char setByte::b
char setByte::b#0
char setByte::b#1
char setByte::b#2
char setByte::b#3
char *setByte::ptr
char *setByte::ptr#0
char *setByte::ptr#1
char *setByte::ptr#2
char *setByte::ptr#3
Adding number conversion cast (unumber) 0 in main::SCREEN[0] = main::b1
Adding number conversion cast (unumber) 1 in main::SCREEN[1] = main::b2
Adding number conversion cast (unumber) 2 in main::SCREEN[2] = main::b3
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant setByte::ptr#0 = &main::b1
Constant setByte::b#0 = 'c'
@ -131,15 +131,15 @@ main: scope:[main] from
[0] main::b1 = 0
[1] main::b2 = 0
[2] main::b3 = 0
[3] call setByte
[3] call setByte
to:main::@1
main::@1: scope:[main] from main
[4] phi()
[5] call setByte
[5] call setByte
to:main::@2
main::@2: scope:[main] from main::@1
[6] phi()
[7] call setByte
[7] call setByte
to:main::@3
main::@3: scope:[main] from main::@2
[8] *main::SCREEN = main::b1
@ -150,7 +150,7 @@ main::@return: scope:[main] from main::@3
[11] return
to:@return
void setByte(byte* setByte::ptr , byte setByte::b)
void setByte(char *ptr , char b)
setByte: scope:[setByte] from main main::@1 main::@2
[12] setByte::ptr#3 = phi( main/&main::b1, main::@1/&main::b2, main::@2/&main::b3 )
[12] setByte::b#3 = phi( main/'c', main::@1/'m', main::@2/'l' )
@ -163,14 +163,14 @@ setByte::@return: scope:[setByte] from setByte
VARIABLE REGISTER WEIGHTS
void main()
volatile byte main::b1 loadstore 0.36363636363636365
volatile byte main::b2 loadstore 0.36363636363636365
volatile byte main::b3 loadstore 0.36363636363636365
void setByte(byte* setByte::ptr , byte setByte::b)
byte setByte::b
byte setByte::b#3 11.0
byte* setByte::ptr
byte* setByte::ptr#3 11.0
__loadstore volatile char main::b1 // 0.36363636363636365
__loadstore volatile char main::b2 // 0.36363636363636365
__loadstore volatile char main::b3 // 0.36363636363636365
void setByte(char *ptr , char b)
char setByte::b
char setByte::b#3 // 11.0
char *setByte::ptr
char *setByte::ptr#3 // 11.0
Initial phi equivalence classes
[ setByte::b#3 ]
@ -251,7 +251,7 @@ main: {
// [2] main::b3 = 0 -- vbuz1=vbuc1
lda #0
sta.z b3
// [3] call setByte
// [3] call setByte
// [12] phi from main to setByte [phi:main->setByte]
setByte_from_main:
// [12] phi setByte::ptr#3 = &main::b1 [phi:main->setByte#0] -- pbuz1=pbuc1
@ -267,7 +267,7 @@ main: {
jmp __b1
// main::@1
__b1:
// [5] call setByte
// [5] call setByte
// [12] phi from main::@1 to setByte [phi:main::@1->setByte]
setByte_from___b1:
// [12] phi setByte::ptr#3 = &main::b2 [phi:main::@1->setByte#0] -- pbuz1=pbuc1
@ -283,7 +283,7 @@ main: {
jmp __b2
// main::@2
__b2:
// [7] call setByte
// [7] call setByte
// [12] phi from main::@2 to setByte [phi:main::@2->setByte]
setByte_from___b2:
// [12] phi setByte::ptr#3 = &main::b3 [phi:main::@2->setByte#0] -- pbuz1=pbuc1
@ -313,7 +313,7 @@ main: {
rts
}
// setByte
// setByte(byte* zp(2) ptr, byte register(X) b)
// void setByte(__zp(2) char *ptr, __register(X) char b)
setByte: {
.label ptr = 2
// [13] *setByte::ptr#3 = setByte::b#3 -- _deref_pbuz1=vbuxx
@ -353,15 +353,15 @@ Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
void main()
constant byte* main::SCREEN = (byte*) 1024
volatile byte main::b1 loadstore zp[1]:4 0.36363636363636365
volatile byte main::b2 loadstore zp[1]:5 0.36363636363636365
volatile byte main::b3 loadstore zp[1]:6 0.36363636363636365
void setByte(byte* setByte::ptr , byte setByte::b)
byte setByte::b
byte setByte::b#3 reg byte x 11.0
byte* setByte::ptr
byte* setByte::ptr#3 ptr zp[2]:2 11.0
__constant char *main::SCREEN = (char *) 1024
__loadstore volatile char main::b1 // zp[1]:4 0.36363636363636365
__loadstore volatile char main::b2 // zp[1]:5 0.36363636363636365
__loadstore volatile char main::b3 // zp[1]:6 0.36363636363636365
void setByte(char *ptr , char b)
char setByte::b
char setByte::b#3 // reg byte x 11.0
char *setByte::ptr
char *setByte::ptr#3 // ptr zp[2]:2 11.0
reg byte x [ setByte::b#3 ]
zp[2]:2 [ setByte::ptr#3 ]
@ -403,7 +403,7 @@ main: {
// [2] main::b3 = 0 -- vbuz1=vbuc1
sta.z b3
// setByte(&b1, 'c')
// [3] call setByte
// [3] call setByte
// [12] phi from main to setByte [phi:main->setByte]
// [12] phi setByte::ptr#3 = &main::b1 [phi:main->setByte#0] -- pbuz1=pbuc1
lda #<b1
@ -416,7 +416,7 @@ main: {
// [4] phi from main to main::@1 [phi:main->main::@1]
// main::@1
// setByte(&b2, 'm')
// [5] call setByte
// [5] call setByte
// [12] phi from main::@1 to setByte [phi:main::@1->setByte]
// [12] phi setByte::ptr#3 = &main::b2 [phi:main::@1->setByte#0] -- pbuz1=pbuc1
lda #<b2
@ -429,7 +429,7 @@ main: {
// [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
// main::@2
// setByte(&b3, 'l')
// [7] call setByte
// [7] call setByte
// [12] phi from main::@2 to setByte [phi:main::@2->setByte]
// [12] phi setByte::ptr#3 = &main::b3 [phi:main::@2->setByte#0] -- pbuz1=pbuc1
lda #<b3
@ -458,7 +458,7 @@ main: {
rts
}
// setByte
// setByte(byte* zp(2) ptr, byte register(X) b)
// void setByte(__zp(2) char *ptr, __register(X) char b)
setByte: {
.label ptr = 2
// *ptr = b

View File

@ -1,13 +1,13 @@
void main()
constant byte* main::SCREEN = (byte*) 1024
volatile byte main::b1 loadstore zp[1]:4 0.36363636363636365
volatile byte main::b2 loadstore zp[1]:5 0.36363636363636365
volatile byte main::b3 loadstore zp[1]:6 0.36363636363636365
void setByte(byte* setByte::ptr , byte setByte::b)
byte setByte::b
byte setByte::b#3 reg byte x 11.0
byte* setByte::ptr
byte* setByte::ptr#3 ptr zp[2]:2 11.0
__constant char *main::SCREEN = (char *) 1024
__loadstore volatile char main::b1 // zp[1]:4 0.36363636363636365
__loadstore volatile char main::b2 // zp[1]:5 0.36363636363636365
__loadstore volatile char main::b3 // zp[1]:6 0.36363636363636365
void setByte(char *ptr , char b)
char setByte::b
char setByte::b#3 // reg byte x 11.0
char *setByte::ptr
char *setByte::ptr#3 // ptr zp[2]:2 11.0
reg byte x [ setByte::b#3 ]
zp[2]:2 [ setByte::ptr#3 ]

View File

@ -76,6 +76,7 @@ main: {
// }
rts
}
// void setv(char v)
setv: {
.const v = 4
// val = v
@ -84,6 +85,7 @@ setv: {
// }
rts
}
// void setp(char *p, char v)
setp: {
.const v = 5
// *p = v

View File

@ -8,7 +8,7 @@ __start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
[2] phi()
[3] call main
[3] call main
to:__start::@return
__start::@return: scope:[__start] from __start::@1
[4] return
@ -27,12 +27,12 @@ main: scope:[main] from __start::@1
[13] *main::ptr = 3
[14] *(main::SCREEN1+3) = val
[15] *(main::SCREEN2+3) = *main::ptr
[16] call setv
[16] call setv
to:main::@1
main::@1: scope:[main] from main
[17] *(main::SCREEN1+4) = val
[18] *(main::SCREEN2+4) = *main::ptr
[19] call setp
[19] call setp
to:main::@2
main::@2: scope:[main] from main::@1
[20] *(main::SCREEN1+5) = val
@ -42,7 +42,7 @@ main::@return: scope:[main] from main::@2
[22] return
to:@return
void setv(byte setv::v)
void setv(char v)
setv: scope:[setv] from main
[23] val = setv::v#0
to:setv::@return
@ -50,7 +50,7 @@ setv::@return: scope:[setv] from setv
[24] return
to:@return
void setp(byte* setp::p , byte setp::v)
void setp(char *p , char v)
setp: scope:[setp] from main::@1
[25] *main::ptr = setp::v#0
to:setp::@return

View File

@ -1,5 +1,5 @@
Setting inferred volatile on symbol affected by address-of main::ptr = &val
Inlined call call __init
Inlined call call __init
CONTROL FLOW GRAPH SSA
@ -22,7 +22,7 @@ main: scope:[main] from __start::@1
main::SCREEN2[main::idx#3] = *main::ptr
main::idx#4 = ++ main::idx#3
setv::v#0 = 4
call setv
call setv
to:main::@1
main::@1: scope:[main] from main
main::idx#7 = phi( main/main::idx#4 )
@ -31,7 +31,7 @@ main::@1: scope:[main] from main
main::idx#5 = ++ main::idx#7
setp::p#0 = main::ptr
setp::v#0 = 5
call setp
call setp
to:main::@2
main::@2: scope:[main] from main::@1
main::idx#8 = phi( main::@1/main::idx#5 )
@ -43,7 +43,7 @@ main::@return: scope:[main] from main::@2
return
to:@return
void setv(byte setv::v)
void setv(char v)
setv: scope:[setv] from main
setv::v#1 = phi( main/setv::v#0 )
val = setv::v#1
@ -52,7 +52,7 @@ setv::@return: scope:[setv] from setv
return
to:@return
void setp(byte* setp::p , byte setp::v)
void setp(char *p , char v)
setp: scope:[setp] from main::@1
setp::p#1 = phi( main::@1/setp::p#0 )
setp::v#1 = phi( main::@1/setp::v#0 )
@ -69,7 +69,7 @@ __start::__init1: scope:[__start] from __start
val = 0
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
call main
call main
to:__start::@2
__start::@2: scope:[__start] from __start::@1
to:__start::@return
@ -80,31 +80,31 @@ __start::@return: scope:[__start] from __start::@2
SYMBOL TABLE SSA
void __start()
void main()
constant byte* const main::SCREEN1 = (byte*)$400
constant byte* const main::SCREEN2 = main::SCREEN1+$28
byte main::idx
byte main::idx#0
byte main::idx#1
byte main::idx#2
byte main::idx#3
byte main::idx#4
byte main::idx#5
byte main::idx#6
byte main::idx#7
byte main::idx#8
constant byte* main::ptr = &val
void setp(byte* setp::p , byte setp::v)
byte* setp::p
byte* setp::p#0
byte* setp::p#1
byte setp::v
byte setp::v#0
byte setp::v#1
void setv(byte setv::v)
byte setv::v
byte setv::v#0
byte setv::v#1
volatile byte val loadstore
__constant char * const main::SCREEN1 = (char *)$400
__constant char * const main::SCREEN2 = main::SCREEN1+$28
char main::idx
char main::idx#0
char main::idx#1
char main::idx#2
char main::idx#3
char main::idx#4
char main::idx#5
char main::idx#6
char main::idx#7
char main::idx#8
__constant char *main::ptr = &val
void setp(char *p , char v)
char *setp::p
char *setp::p#0
char *setp::p#1
char setp::v
char setp::v#0
char setp::v#1
void setv(char v)
char setv::v
char setv::v#0
char setv::v#1
__loadstore volatile char val
Adding number conversion cast (unumber) $28 in
Adding number conversion cast (unumber) 1 in val = 1
@ -119,7 +119,7 @@ Inlining cast *main::ptr = (unumber)3
Inlining cast setv::v#0 = (unumber)4
Inlining cast setp::v#0 = (unumber)5
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast $28
Simplifying constant integer cast 1
Simplifying constant integer cast 2
@ -127,12 +127,12 @@ Simplifying constant integer cast 3
Simplifying constant integer cast 4
Simplifying constant integer cast 5
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) 4
Finalized unsigned number type (byte) 5
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) 4
Finalized unsigned number type (char) 5
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias main::idx#4 = main::idx#7
Alias main::idx#5 = main::idx#8
@ -236,7 +236,7 @@ __start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
[2] phi()
[3] call main
[3] call main
to:__start::@return
__start::@return: scope:[__start] from __start::@1
[4] return
@ -255,12 +255,12 @@ main: scope:[main] from __start::@1
[13] *main::ptr = 3
[14] *(main::SCREEN1+3) = val
[15] *(main::SCREEN2+3) = *main::ptr
[16] call setv
[16] call setv
to:main::@1
main::@1: scope:[main] from main
[17] *(main::SCREEN1+4) = val
[18] *(main::SCREEN2+4) = *main::ptr
[19] call setp
[19] call setp
to:main::@2
main::@2: scope:[main] from main::@1
[20] *(main::SCREEN1+5) = val
@ -270,7 +270,7 @@ main::@return: scope:[main] from main::@2
[22] return
to:@return
void setv(byte setv::v)
void setv(char v)
setv: scope:[setv] from main
[23] val = setv::v#0
to:setv::@return
@ -278,7 +278,7 @@ setv::@return: scope:[setv] from setv
[24] return
to:@return
void setp(byte* setp::p , byte setp::v)
void setp(char *p , char v)
setp: scope:[setp] from main::@1
[25] *main::ptr = setp::v#0
to:setp::@return
@ -290,13 +290,13 @@ setp::@return: scope:[setp] from setp
VARIABLE REGISTER WEIGHTS
void __start()
void main()
byte main::idx
void setp(byte* setp::p , byte setp::v)
byte* setp::p
byte setp::v
void setv(byte setv::v)
byte setv::v
volatile byte val loadstore 14.692307692307692
char main::idx
void setp(char *p , char v)
char *setp::p
char setp::v
void setv(char v)
char setv::v
__loadstore volatile char val // 14.692307692307692
Initial phi equivalence classes
Added variable val to live range equivalence class [ val ]
@ -367,7 +367,7 @@ __start: {
jmp __b1
// __start::@1
__b1:
// [3] call main
// [3] call main
jsr main
jmp __breturn
// __start::@return
@ -417,7 +417,7 @@ main: {
// [15] *(main::SCREEN2+3) = *main::ptr -- _deref_pbuc1=_deref_pbuc2
lda.z ptr
sta SCREEN2+3
// [16] call setv
// [16] call setv
// Set value directly in a call
jsr setv
jmp __b1
@ -429,7 +429,7 @@ main: {
// [18] *(main::SCREEN2+4) = *main::ptr -- _deref_pbuc1=_deref_pbuc2
lda.z ptr
sta SCREEN2+4
// [19] call setp
// [19] call setp
// Set value through pointer in a call
jsr setp
jmp __b2
@ -448,6 +448,7 @@ main: {
rts
}
// setv
// void setv(char v)
setv: {
.const v = 4
// [23] val = setv::v#0 -- vbuz1=vbuc1
@ -460,6 +461,7 @@ setv: {
rts
}
// setp
// void setp(char *p, char v)
setp: {
.const v = 5
// [25] *main::ptr = setp::v#0 -- _deref_pbuc1=vbuc2
@ -501,18 +503,18 @@ Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
void __start()
void main()
constant byte* const main::SCREEN1 = (byte*) 1024
constant byte* const main::SCREEN2 = main::SCREEN1+$28
byte main::idx
constant byte* main::ptr = &val
void setp(byte* setp::p , byte setp::v)
byte* setp::p
byte setp::v
constant byte setp::v#0 v = 5
void setv(byte setv::v)
byte setv::v
constant byte setv::v#0 v = 4
volatile byte val loadstore zp[1]:2 14.692307692307692
__constant char * const main::SCREEN1 = (char *) 1024
__constant char * const main::SCREEN2 = main::SCREEN1+$28
char main::idx
__constant char *main::ptr = &val
void setp(char *p , char v)
char *setp::p
char setp::v
__constant char setp::v#0 = 5 // v
void setv(char v)
char setv::v
__constant char setv::v#0 = 4 // v
__loadstore volatile char val // zp[1]:2 14.692307692307692
zp[1]:2 [ val ]
@ -543,7 +545,7 @@ __start: {
sta.z val
// [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
// __start::@1
// [3] call main
// [3] call main
jsr main
// __start::@return
// [4] return
@ -601,7 +603,7 @@ main: {
lda.z ptr
sta SCREEN2+3
// setv(4)
// [16] call setv
// [16] call setv
// Set value directly in a call
jsr setv
// main::@1
@ -614,7 +616,7 @@ main: {
lda.z ptr
sta SCREEN2+4
// setp(ptr, 5)
// [19] call setp
// [19] call setp
// Set value through pointer in a call
jsr setp
// main::@2
@ -632,6 +634,7 @@ main: {
rts
}
// setv
// void setv(char v)
setv: {
.const v = 4
// val = v
@ -644,6 +647,7 @@ setv: {
rts
}
// setp
// void setp(char *p, char v)
setp: {
.const v = 5
// *p = v

View File

@ -1,16 +1,16 @@
void __start()
void main()
constant byte* const main::SCREEN1 = (byte*) 1024
constant byte* const main::SCREEN2 = main::SCREEN1+$28
byte main::idx
constant byte* main::ptr = &val
void setp(byte* setp::p , byte setp::v)
byte* setp::p
byte setp::v
constant byte setp::v#0 v = 5
void setv(byte setv::v)
byte setv::v
constant byte setv::v#0 v = 4
volatile byte val loadstore zp[1]:2 14.692307692307692
__constant char * const main::SCREEN1 = (char *) 1024
__constant char * const main::SCREEN2 = main::SCREEN1+$28
char main::idx
__constant char *main::ptr = &val
void setp(char *p , char v)
char *setp::p
char setp::v
__constant char setp::v#0 = 5 // v
void setv(char v)
char setv::v
__constant char setv::v#0 = 4 // v
__loadstore volatile char val // zp[1]:2 14.692307692307692
zp[1]:2 [ val ]

View File

@ -7,7 +7,7 @@
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
.const SIZEOF_SIGNED_WORD = 2
.const SIZEOF_INT = 2
.label SCREEN = $400
.label idx = 3
.segment Code
@ -22,9 +22,9 @@ main: {
sta.z idx
jsr print
// print(&VALS[1])
lda #<VALS+1*SIZEOF_SIGNED_WORD
lda #<VALS+1*SIZEOF_INT
sta.z print.p
lda #>VALS+1*SIZEOF_SIGNED_WORD
lda #>VALS+1*SIZEOF_INT
sta.z print.p+1
jsr print
lda #2
@ -49,7 +49,7 @@ main: {
// }
rts
}
// print(signed word* zp(4) p)
// void print(__zp(4) int *p)
print: {
.label p = 4
// SCREEN[idx++] = *p

View File

@ -2,17 +2,17 @@
void main()
main: scope:[main] from
[0] phi()
[1] call print
[1] call print
to:main::@2
main::@2: scope:[main] from main
[2] phi()
[3] call print
[3] call print
to:main::@1
main::@1: scope:[main] from main::@2 main::@3
[4] main::i#2 = phi( main::@2/2, main::@3/main::i#1 )
[5] main::$5 = main::i#2 << 1
[6] print::p#2 = VALS + main::$5
[7] call print
[7] call print
to:main::@3
main::@3: scope:[main] from main::@1
[8] main::i#1 = ++ main::i#2
@ -22,9 +22,9 @@ main::@return: scope:[main] from main::@3
[10] return
to:@return
void print(signed word* print::p)
void print(int *p)
print: scope:[print] from main main::@1 main::@2
[11] print::p#3 = phi( main/VALS, main::@1/print::p#2, main::@2/VALS+1*SIZEOF_SIGNED_WORD )
[11] print::p#3 = phi( main/VALS, main::@1/print::p#2, main::@2/VALS+1*SIZEOF_INT )
[11] idx#13 = phi( main/0, main::@1/idx#14, main::@2/idx#14 )
[12] print::$0 = idx#13 << 1
[13] SCREEN[print::$0] = *print::p#3

View File

@ -1,5 +1,5 @@
Fixing constant pointer addition VALS+1
Inlined call call __init
Inlined call call __init
CONTROL FLOW GRAPH SSA
@ -7,13 +7,13 @@ void main()
main: scope:[main] from __start::@1
idx#17 = phi( __start::@1/idx#19 )
print::p#0 = VALS
call print
call print
to:main::@2
main::@2: scope:[main] from main
idx#9 = phi( main/idx#5 )
idx#0 = idx#9
print::p#1 = VALS+1*SIZEOF_SIGNED_WORD
call print
print::p#1 = VALS+1*SIZEOF_INT
call print
to:main::@3
main::@3: scope:[main] from main::@2
idx#10 = phi( main::@2/idx#5 )
@ -23,10 +23,10 @@ main::@3: scope:[main] from main::@2
main::@1: scope:[main] from main::@3 main::@4
idx#18 = phi( main::@3/idx#1, main::@4/idx#2 )
main::i#2 = phi( main::@3/main::i#0, main::@4/main::i#1 )
main::$5 = main::i#2 * SIZEOF_SIGNED_WORD
main::$5 = main::i#2 * SIZEOF_INT
main::$2 = & VALS[main::$5]
print::p#2 = main::$2
call print
call print
to:main::@4
main::@4: scope:[main] from main::@1
main::i#3 = phi( main::@1/main::i#2 )
@ -42,11 +42,11 @@ main::@return: scope:[main] from main::@4
return
to:@return
void print(signed word* print::p)
void print(int *p)
print: scope:[print] from main main::@1 main::@2
print::p#3 = phi( main/print::p#0, main::@1/print::p#2, main::@2/print::p#1 )
idx#13 = phi( main/idx#17, main::@1/idx#18, main::@2/idx#0 )
print::$0 = idx#13 * SIZEOF_SIGNED_WORD
print::$0 = idx#13 * SIZEOF_INT
SCREEN[print::$0] = *print::p#3
idx#4 = ++ idx#13
to:print::@return
@ -64,7 +64,7 @@ __start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
idx#19 = phi( __start::__init1/idx#6 )
call main
call main
to:__start::@2
__start::@2: scope:[__start] from __start::@1
idx#15 = phi( __start::@1/idx#3 )
@ -77,56 +77,56 @@ __start::@return: scope:[__start] from __start::@2
to:@return
SYMBOL TABLE SSA
constant signed word* const SCREEN = (signed word*)$400
constant byte SIZEOF_SIGNED_WORD = 2
constant signed word* VALS[] = { 1, 2, 3, 4 }
__constant int * const SCREEN = (int *)$400
__constant char SIZEOF_INT = 2
__constant int VALS[] = { 1, 2, 3, 4 }
void __start()
byte idx
byte idx#0
byte idx#1
byte idx#10
byte idx#11
byte idx#12
byte idx#13
byte idx#14
byte idx#15
byte idx#16
byte idx#17
byte idx#18
byte idx#19
byte idx#2
byte idx#3
byte idx#4
byte idx#5
byte idx#6
byte idx#7
byte idx#8
byte idx#9
char idx
char idx#0
char idx#1
char idx#10
char idx#11
char idx#12
char idx#13
char idx#14
char idx#15
char idx#16
char idx#17
char idx#18
char idx#19
char idx#2
char idx#3
char idx#4
char idx#5
char idx#6
char idx#7
char idx#8
char idx#9
void main()
signed word*~ main::$2
bool~ main::$4
byte~ main::$5
byte main::i
byte main::i#0
byte main::i#1
byte main::i#2
byte main::i#3
void print(signed word* print::p)
byte~ print::$0
signed word* print::p
signed word* print::p#0
signed word* print::p#1
signed word* print::p#2
signed word* print::p#3
int *main::$2
bool main::$4
char main::$5
char main::i
char main::i#0
char main::i#1
char main::i#2
char main::i#3
void print(int *p)
char print::$0
int *print::p
int *print::p#0
int *print::p#1
int *print::p#2
int *print::p#3
Adding number conversion cast (unumber) 1*SIZEOF_SIGNED_WORD in print::p#1 = VALS+1*SIZEOF_SIGNED_WORD
Adding number conversion cast (unumber) 1 in print::p#1 = VALS+(unumber)1*SIZEOF_SIGNED_WORD
Adding number conversion cast (unumber) 1*SIZEOF_INT in print::p#1 = VALS+1*SIZEOF_INT
Adding number conversion cast (unumber) 1 in print::p#1 = VALS+(unumber)1*SIZEOF_INT
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (signed word*) 1024
Simplifying constant integer cast (unumber)1*SIZEOF_SIGNED_WORD
Simplifying constant pointer cast (int *) 1024
Simplifying constant integer cast (unumber)1*SIZEOF_INT
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias idx#0 = idx#9
Alias idx#1 = idx#10
@ -150,7 +150,7 @@ Successful SSA optimization Pass2ConditionalJumpSimplification
Rewriting array member address-of to pointer addition [10] print::p#2 = VALS + main::$5
Successful SSA optimization PassNArrayElementAddressOfRewriting
Constant print::p#0 = VALS
Constant print::p#1 = VALS+1*SIZEOF_SIGNED_WORD
Constant print::p#1 = VALS+1*SIZEOF_INT
Constant main::i#0 = 2
Constant idx#19 = 0
Successful SSA optimization Pass2ConstantIdentification
@ -167,17 +167,17 @@ Adding number conversion cast (unumber) 4 in [7] if(main::i#1!=4) goto main::@1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast 4
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 4
Finalized unsigned number type (char) 4
Successful SSA optimization PassNFinalizeNumberTypeConversions
Rewriting multiplication to use shift [3] main::$5 = main::i#2 * SIZEOF_SIGNED_WORD
Rewriting multiplication to use shift [10] print::$0 = idx#13 * SIZEOF_SIGNED_WORD
Rewriting multiplication to use shift [3] main::$5 = main::i#2 * SIZEOF_INT
Rewriting multiplication to use shift [10] print::$0 = idx#13 * SIZEOF_INT
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings main::i#0
Inlining constant with var siblings print::p#0
Inlining constant with var siblings print::p#1
Inlining constant with var siblings idx#19
Constant inlined main::i#0 = 2
Constant inlined print::p#1 = VALS+1*SIZEOF_SIGNED_WORD
Constant inlined print::p#1 = VALS+1*SIZEOF_INT
Constant inlined print::p#0 = VALS
Constant inlined idx#19 = 0
Successful SSA optimization Pass2ConstantInlining
@ -204,17 +204,17 @@ FINAL CONTROL FLOW GRAPH
void main()
main: scope:[main] from
[0] phi()
[1] call print
[1] call print
to:main::@2
main::@2: scope:[main] from main
[2] phi()
[3] call print
[3] call print
to:main::@1
main::@1: scope:[main] from main::@2 main::@3
[4] main::i#2 = phi( main::@2/2, main::@3/main::i#1 )
[5] main::$5 = main::i#2 << 1
[6] print::p#2 = VALS + main::$5
[7] call print
[7] call print
to:main::@3
main::@3: scope:[main] from main::@1
[8] main::i#1 = ++ main::i#2
@ -224,9 +224,9 @@ main::@return: scope:[main] from main::@3
[10] return
to:@return
void print(signed word* print::p)
void print(int *p)
print: scope:[print] from main main::@1 main::@2
[11] print::p#3 = phi( main/VALS, main::@1/print::p#2, main::@2/VALS+1*SIZEOF_SIGNED_WORD )
[11] print::p#3 = phi( main/VALS, main::@1/print::p#2, main::@2/VALS+1*SIZEOF_INT )
[11] idx#13 = phi( main/0, main::@1/idx#14, main::@2/idx#14 )
[12] print::$0 = idx#13 << 1
[13] SCREEN[print::$0] = *print::p#3
@ -238,19 +238,19 @@ print::@return: scope:[print] from print
VARIABLE REGISTER WEIGHTS
byte idx
byte idx#13 71.66666666666666
byte idx#14 10.363636363636363
char idx
char idx#13 // 71.66666666666666
char idx#14 // 10.363636363636363
void main()
byte~ main::$5 22.0
byte main::i
byte main::i#1 16.5
byte main::i#2 8.25
void print(signed word* print::p)
byte~ print::$0 202.0
signed word* print::p
signed word* print::p#2 22.0
signed word* print::p#3 56.0
char main::$5 // 22.0
char main::i
char main::i#1 // 16.5
char main::i#2 // 8.25
void print(int *p)
char print::$0 // 202.0
int *print::p
int *print::p#2 // 22.0
int *print::p#3 // 56.0
Initial phi equivalence classes
[ main::i#2 main::i#1 ]
@ -314,14 +314,14 @@ ASSEMBLER BEFORE OPTIMIZATION
.segment Basic
:BasicUpstart(main)
// Global Constants & labels
.const SIZEOF_SIGNED_WORD = 2
.const SIZEOF_INT = 2
.label SCREEN = $400
.label idx = 3
.segment Code
// main
main: {
.label i = 2
// [1] call print
// [1] call print
// [11] phi from main to print [phi:main->print]
print_from_main:
// [11] phi print::p#3 = VALS [phi:main->print#0] -- pwsz1=pwsc1
@ -338,13 +338,13 @@ main: {
jmp __b2
// main::@2
__b2:
// [3] call print
// [3] call print
// [11] phi from main::@2 to print [phi:main::@2->print]
print_from___b2:
// [11] phi print::p#3 = VALS+1*SIZEOF_SIGNED_WORD [phi:main::@2->print#0] -- pwsz1=pwsc1
lda #<VALS+1*SIZEOF_SIGNED_WORD
// [11] phi print::p#3 = VALS+1*SIZEOF_INT [phi:main::@2->print#0] -- pwsz1=pwsc1
lda #<VALS+1*SIZEOF_INT
sta.z print.p
lda #>VALS+1*SIZEOF_SIGNED_WORD
lda #>VALS+1*SIZEOF_INT
sta.z print.p+1
// [11] phi idx#13 = idx#14 [phi:main::@2->print#1] -- register_copy
jsr print
@ -370,7 +370,7 @@ main: {
lda #>VALS
adc #0
sta.z print.p+1
// [7] call print
// [7] call print
// [11] phi from main::@1 to print [phi:main::@1->print]
print_from___b1:
// [11] phi print::p#3 = print::p#2 [phi:main::@1->print#0] -- register_copy
@ -392,7 +392,7 @@ main: {
rts
}
// print
// print(signed word* zp(4) p)
// void print(__zp(4) int *p)
print: {
.label p = 4
// [12] print::$0 = idx#13 << 1 -- vbuaa=vbuz1_rol_1
@ -442,22 +442,22 @@ Removing instruction jmp __b1
Succesful ASM optimization Pass5NextJumpElimination
FINAL SYMBOL TABLE
constant signed word* const SCREEN = (signed word*) 1024
constant byte SIZEOF_SIGNED_WORD = 2
constant signed word* VALS[] = { 1, 2, 3, 4 }
byte idx
byte idx#13 idx zp[1]:3 71.66666666666666
byte idx#14 idx zp[1]:3 10.363636363636363
__constant int * const SCREEN = (int *) 1024
__constant char SIZEOF_INT = 2
__constant int VALS[] = { 1, 2, 3, 4 }
char idx
char idx#13 // idx zp[1]:3 71.66666666666666
char idx#14 // idx zp[1]:3 10.363636363636363
void main()
byte~ main::$5 reg byte a 22.0
byte main::i
byte main::i#1 i zp[1]:2 16.5
byte main::i#2 i zp[1]:2 8.25
void print(signed word* print::p)
byte~ print::$0 reg byte a 202.0
signed word* print::p
signed word* print::p#2 p zp[2]:4 22.0
signed word* print::p#3 p zp[2]:4 56.0
char main::$5 // reg byte a 22.0
char main::i
char main::i#1 // i zp[1]:2 16.5
char main::i#2 // i zp[1]:2 8.25
void print(int *p)
char print::$0 // reg byte a 202.0
int *print::p
int *print::p#2 // p zp[2]:4 22.0
int *print::p#3 // p zp[2]:4 56.0
zp[1]:2 [ main::i#2 main::i#1 ]
zp[1]:3 [ idx#13 idx#14 ]
@ -481,7 +481,7 @@ Score: 457
.segment Basic
:BasicUpstart(main)
// Global Constants & labels
.const SIZEOF_SIGNED_WORD = 2
.const SIZEOF_INT = 2
.label SCREEN = $400
.label idx = 3
.segment Code
@ -489,7 +489,7 @@ Score: 457
main: {
.label i = 2
// print(VALS)
// [1] call print
// [1] call print
// [11] phi from main to print [phi:main->print]
// [11] phi print::p#3 = VALS [phi:main->print#0] -- pwsz1=pwsc1
lda #<VALS
@ -503,12 +503,12 @@ main: {
// [2] phi from main to main::@2 [phi:main->main::@2]
// main::@2
// print(&VALS[1])
// [3] call print
// [3] call print
// [11] phi from main::@2 to print [phi:main::@2->print]
// [11] phi print::p#3 = VALS+1*SIZEOF_SIGNED_WORD [phi:main::@2->print#0] -- pwsz1=pwsc1
lda #<VALS+1*SIZEOF_SIGNED_WORD
// [11] phi print::p#3 = VALS+1*SIZEOF_INT [phi:main::@2->print#0] -- pwsz1=pwsc1
lda #<VALS+1*SIZEOF_INT
sta.z print.p
lda #>VALS+1*SIZEOF_SIGNED_WORD
lda #>VALS+1*SIZEOF_INT
sta.z print.p+1
// [11] phi idx#13 = idx#14 [phi:main::@2->print#1] -- register_copy
jsr print
@ -532,7 +532,7 @@ main: {
lda #>VALS
adc #0
sta.z print.p+1
// [7] call print
// [7] call print
// [11] phi from main::@1 to print [phi:main::@1->print]
// [11] phi print::p#3 = print::p#2 [phi:main::@1->print#0] -- register_copy
// [11] phi idx#13 = idx#14 [phi:main::@1->print#1] -- register_copy
@ -551,7 +551,7 @@ main: {
rts
}
// print
// print(signed word* zp(4) p)
// void print(__zp(4) int *p)
print: {
.label p = 4
// SCREEN[idx++] = *p

View File

@ -1,19 +1,19 @@
constant signed word* const SCREEN = (signed word*) 1024
constant byte SIZEOF_SIGNED_WORD = 2
constant signed word* VALS[] = { 1, 2, 3, 4 }
byte idx
byte idx#13 idx zp[1]:3 71.66666666666666
byte idx#14 idx zp[1]:3 10.363636363636363
__constant int * const SCREEN = (int *) 1024
__constant char SIZEOF_INT = 2
__constant int VALS[] = { 1, 2, 3, 4 }
char idx
char idx#13 // idx zp[1]:3 71.66666666666666
char idx#14 // idx zp[1]:3 10.363636363636363
void main()
byte~ main::$5 reg byte a 22.0
byte main::i
byte main::i#1 i zp[1]:2 16.5
byte main::i#2 i zp[1]:2 8.25
void print(signed word* print::p)
byte~ print::$0 reg byte a 202.0
signed word* print::p
signed word* print::p#2 p zp[2]:4 22.0
signed word* print::p#3 p zp[2]:4 56.0
char main::$5 // reg byte a 22.0
char main::i
char main::i#1 // i zp[1]:2 16.5
char main::i#2 // i zp[1]:2 8.25
void print(int *p)
char print::$0 // reg byte a 202.0
int *print::p
int *print::p#2 // p zp[2]:4 22.0
int *print::p#3 // p zp[2]:4 56.0
zp[1]:2 [ main::i#2 main::i#1 ]
zp[1]:3 [ idx#13 idx#14 ]

View File

@ -11,7 +11,7 @@ main::@return: scope:[main] from main
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -20,22 +20,22 @@ __start::@return: scope:[__start] from __start::@1
to:@return
SYMBOL TABLE SSA
constant byte* DATA[$3e8] = { fill( $3e8, 0) }
constant byte* const SCREEN = (byte*)$400
__constant char DATA[$3e8] = { fill( $3e8, 0) }
__constant char * const SCREEN = (char *)$400
void __start()
void main()
constant const word var1 = $800
constant const word var2 = $900
__constant const unsigned int var1 = $800
__constant const unsigned int var2 = $900
Adding number conversion cast (unumber) 0 in SCREEN[0] = DATA[0]
Adding number conversion cast (unumber) 0 in SCREEN[0] = DATA[(unumber)0]
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simplifying expression containing zero DATA in [0] SCREEN[0] = DATA[0]
Simplifying expression containing zero SCREEN in [0] SCREEN[0] = *DATA
@ -45,8 +45,8 @@ Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Finalized unsigned number type (word) $3e8
Finalized unsigned number type (word) $3e8
Finalized unsigned number type (unsigned int) $3e8
Finalized unsigned number type (unsigned int) $3e8
Successful SSA optimization PassNFinalizeNumberTypeConversions
CALL GRAPH
@ -121,11 +121,11 @@ Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte* DATA[$3e8] = { fill( $3e8, 0) }
constant byte* const SCREEN = (byte*) 1024
__constant char DATA[$3e8] = { fill( $3e8, 0) }
__constant char * const SCREEN = (char *) 1024
void main()
constant const word var1 = $800
constant const word var2 = $900
__constant const unsigned int var1 = $800
__constant const unsigned int var2 = $900

View File

@ -1,6 +1,6 @@
constant byte* DATA[$3e8] = { fill( $3e8, 0) }
constant byte* const SCREEN = (byte*) 1024
__constant char DATA[$3e8] = { fill( $3e8, 0) }
__constant char * const SCREEN = (char *) 1024
void main()
constant const word var1 = $800
constant const word var2 = $900
__constant const unsigned int var1 = $800
__constant const unsigned int var2 = $900

View File

@ -12,6 +12,6 @@ main::@return: scope:[main] from main::@1
to:@return
main::@2: scope:[main] from main::@1
[4] main::$3 = main::c#2 << 1
[5] levelRowOff[main::$3] = (byte*) 12345
[5] levelRowOff[main::$3] = (char *) 12345
[6] main::c#1 = ++ main::c#2
to:main::@1

View File

@ -15,7 +15,7 @@ main::@1: scope:[main] from main main::@2
main::@2: scope:[main] from main::@1
main::c#3 = phi( main::@1/main::c#2 )
main::$3 = main::c#3 * SIZEOF_POINTER
levelRowOff[main::$3] = (byte*)$3039
levelRowOff[main::$3] = (char *)$3039
main::c#1 = ++ main::c#3
to:main::@1
main::@return: scope:[main] from main::@1
@ -24,7 +24,7 @@ main::@return: scope:[main] from main::@1
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -33,21 +33,21 @@ __start::@return: scope:[__start] from __start::@1
to:@return
SYMBOL TABLE SSA
constant byte SIZEOF_POINTER = 2
__constant char SIZEOF_POINTER = 2
void __start()
constant byte** levelRowOff[$1f] = { 1, 2, 3 }
__constant char *levelRowOff[$1f] = { 1, 2, 3 }
void main()
word~ main::$0
word~ main::$1
bool~ main::$2
byte~ main::$3
byte main::c
byte main::c#0
byte main::c#1
byte main::c#2
byte main::c#3
unsigned int main::$0
unsigned int main::$1
bool main::$2
char main::$3
char main::c
char main::c#0
char main::c#1
char main::c#2
char main::c#3
Simplifying constant pointer cast (byte*) 12345
Simplifying constant pointer cast (char *) 12345
Successful SSA optimization PassNCastSimplification
Alias main::c#2 = main::c#3
Successful SSA optimization Pass2AliasElimination
@ -73,7 +73,7 @@ Adding number conversion cast (unumber) $1f in
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $1f
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $1f
Finalized unsigned number type (char) $1f
Successful SSA optimization PassNFinalizeNumberTypeConversions
Rewriting multiplication to use shift [2] main::$3 = main::c#2 * SIZEOF_POINTER
Successful SSA optimization Pass2MultiplyToShiftRewriting
@ -82,10 +82,10 @@ Constant inlined main::$1 = $1f*SIZEOF_POINTER/SIZEOF_POINTER
Constant inlined main::c#0 = 0
Constant inlined main::$0 = $1f*SIZEOF_POINTER
Successful SSA optimization Pass2ConstantInlining
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) $1f
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) $1f
Successful SSA optimization PassNFinalizeNumberTypeConversions
Adding NOP phi() at start of main
CALL GRAPH
@ -110,17 +110,17 @@ main::@return: scope:[main] from main::@1
to:@return
main::@2: scope:[main] from main::@1
[4] main::$3 = main::c#2 << 1
[5] levelRowOff[main::$3] = (byte*) 12345
[5] levelRowOff[main::$3] = (char *) 12345
[6] main::c#1 = ++ main::c#2
to:main::@1
VARIABLE REGISTER WEIGHTS
void main()
byte~ main::$3 22.0
byte main::c
byte main::c#1 22.0
byte main::c#2 11.0
char main::$3 // 22.0
char main::c
char main::c#1 // 22.0
char main::c#2 // 11.0
Initial phi equivalence classes
[ main::c#2 main::c#1 ]
@ -133,9 +133,9 @@ Allocated zp[1]:3 [ main::$3 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] main::$3 = main::c#2 << 1 [ main::c#2 main::$3 ] ( [ main::c#2 main::$3 ] { } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::c#2 main::c#1 ]
Statement [5] levelRowOff[main::$3] = (byte*) 12345 [ main::c#2 ] ( [ main::c#2 ] { } ) always clobbers reg byte a
Statement [5] levelRowOff[main::$3] = (char *) 12345 [ main::c#2 ] ( [ main::c#2 ] { } ) always clobbers reg byte a
Statement [4] main::$3 = main::c#2 << 1 [ main::c#2 main::$3 ] ( [ main::c#2 main::$3 ] { } ) always clobbers reg byte a
Statement [5] levelRowOff[main::$3] = (byte*) 12345 [ main::c#2 ] ( [ main::c#2 ] { } ) always clobbers reg byte a
Statement [5] levelRowOff[main::$3] = (char *) 12345 [ main::c#2 ] ( [ main::c#2 ] { } ) always clobbers reg byte a
Potential registers zp[1]:2 [ main::c#2 main::c#1 ] : zp[1]:2 , reg byte x , reg byte y ,
Potential registers zp[1]:3 [ main::$3 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y ,
@ -184,7 +184,7 @@ main: {
// [4] main::$3 = main::c#2 << 1 -- vbuaa=vbuxx_rol_1
txa
asl
// [5] levelRowOff[main::$3] = (byte*) 12345 -- qbuc1_derefidx_vbuaa=pbuc2
// [5] levelRowOff[main::$3] = (char *) 12345 -- qbuc1_derefidx_vbuaa=pbuc2
tay
lda #<$3039
sta levelRowOff,y
@ -212,13 +212,13 @@ Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte SIZEOF_POINTER = 2
constant byte** levelRowOff[$1f] = { 1, 2, 3 }
__constant char SIZEOF_POINTER = 2
__constant char *levelRowOff[$1f] = { 1, 2, 3 }
void main()
byte~ main::$3 reg byte a 22.0
byte main::c
byte main::c#1 reg byte x 22.0
byte main::c#2 reg byte x 11.0
char main::$3 // reg byte a 22.0
char main::c
char main::c#1 // reg byte x 22.0
char main::c#2 // reg byte x 11.0
reg byte x [ main::c#2 main::c#1 ]
reg byte a [ main::$3 ]
@ -263,7 +263,7 @@ main: {
// [4] main::$3 = main::c#2 << 1 -- vbuaa=vbuxx_rol_1
txa
asl
// [5] levelRowOff[main::$3] = (byte*) 12345 -- qbuc1_derefidx_vbuaa=pbuc2
// [5] levelRowOff[main::$3] = (char *) 12345 -- qbuc1_derefidx_vbuaa=pbuc2
tay
lda #<$3039
sta levelRowOff,y

View File

@ -1,10 +1,10 @@
constant byte SIZEOF_POINTER = 2
constant byte** levelRowOff[$1f] = { 1, 2, 3 }
__constant char SIZEOF_POINTER = 2
__constant char *levelRowOff[$1f] = { 1, 2, 3 }
void main()
byte~ main::$3 reg byte a 22.0
byte main::c
byte main::c#1 reg byte x 22.0
byte main::c#2 reg byte x 11.0
char main::$3 // reg byte a 22.0
char main::c
char main::c#1 // reg byte x 22.0
char main::c#2 // reg byte x 11.0
reg byte x [ main::c#2 main::c#1 ]
reg byte a [ main::$3 ]

View File

@ -35,7 +35,7 @@ main: {
// }
rts
}
// getValue(word zp(2) index)
// __zp(4) unsigned int getValue(__zp(2) unsigned int index)
getValue: {
.label index = 2
.label return = 4

View File

@ -6,7 +6,7 @@ main: scope:[main] from
main::@1: scope:[main] from main main::@2
[1] main::idx#2 = phi( main/0, main::@2/main::idx#1 )
[2] getValue::index#0 = main::idx#2
[3] call getValue
[3] call getValue
[4] getValue::return#0 = getValue::return#1
to:main::@2
main::@2: scope:[main] from main::@1
@ -20,13 +20,13 @@ main::@return: scope:[main] from main::@2
[10] return
to:@return
word getValue(word getValue::index)
unsigned int getValue(unsigned int index)
getValue: scope:[getValue] from main::@1
[11] getValue::$0 = getValue::index#0 & $7f
[12] getValue::$3 = getValue::$0 << 1
[13] getValue::$1 = arr16[getValue::$3] & $ff
[14] getValue::$2 = getValue::$1 >> 1
[15] getValue::return#1 = (word)getValue::$2
[15] getValue::return#1 = (unsigned int)getValue::$2
to:getValue::@return
getValue::@return: scope:[getValue] from getValue
[16] return

View File

@ -8,14 +8,14 @@ main: scope:[main] from __start
main::@1: scope:[main] from main main::@2
main::idx#2 = phi( main/main::idx#0, main::@2/main::idx#1 )
getValue::index#0 = main::idx#2
call getValue
call getValue
getValue::return#0 = getValue::return#2
to:main::@2
main::@2: scope:[main] from main::@1
main::idx#3 = phi( main::@1/main::idx#2 )
getValue::return#3 = phi( main::@1/getValue::return#0 )
main::$0 = getValue::return#3
main::$2 = main::idx#3 * SIZEOF_WORD
main::$2 = main::idx#3 * SIZEOF_UNSIGNED_INT
main::SCREEN[main::$2] = main::$0
main::idx#1 = main::idx#3 + rangenext(0,$80)
main::$1 = main::idx#1 != rangelast(0,$80)
@ -25,14 +25,14 @@ main::@return: scope:[main] from main::@2
return
to:@return
word getValue(word getValue::index)
unsigned int getValue(unsigned int index)
getValue: scope:[getValue] from main::@1
getValue::index#1 = phi( main::@1/getValue::index#0 )
getValue::$0 = getValue::index#1 & $7f
getValue::$3 = getValue::$0 * SIZEOF_WORD
getValue::$3 = getValue::$0 * SIZEOF_UNSIGNED_INT
getValue::$1 = arr16[getValue::$3] & $ff
getValue::$2 = getValue::$1 >> 1
getValue::return#1 = (word)getValue::$2
getValue::return#1 = (unsigned int)getValue::$2
to:getValue::@return
getValue::@return: scope:[getValue] from getValue
getValue::return#4 = phi( getValue/getValue::return#1 )
@ -42,7 +42,7 @@ getValue::@return: scope:[getValue] from getValue
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -51,55 +51,55 @@ __start::@return: scope:[__start] from __start::@1
to:@return
SYMBOL TABLE SSA
constant byte SIZEOF_WORD = 2
__constant char SIZEOF_UNSIGNED_INT = 2
void __start()
constant word* arr16[$80] = { fill( $80, 0) }
word getValue(word getValue::index)
number~ getValue::$0
number~ getValue::$1
number~ getValue::$2
number~ getValue::$3
word getValue::index
word getValue::index#0
word getValue::index#1
word getValue::return
word getValue::return#0
word getValue::return#1
word getValue::return#2
word getValue::return#3
word getValue::return#4
__constant unsigned int arr16[$80] = { fill( $80, 0) }
unsigned int getValue(unsigned int index)
number getValue::$0
number getValue::$1
number getValue::$2
number getValue::$3
unsigned int getValue::index
unsigned int getValue::index#0
unsigned int getValue::index#1
unsigned int getValue::return
unsigned int getValue::return#0
unsigned int getValue::return#1
unsigned int getValue::return#2
unsigned int getValue::return#3
unsigned int getValue::return#4
void main()
word~ main::$0
bool~ main::$1
byte~ main::$2
constant word* main::SCREEN = (word*)$400
byte main::idx
byte main::idx#0
byte main::idx#1
byte main::idx#2
byte main::idx#3
unsigned int main::$0
bool main::$1
char main::$2
__constant unsigned int *main::SCREEN = (unsigned int *)$400
char main::idx
char main::idx#0
char main::idx#1
char main::idx#2
char main::idx#3
Adding number conversion cast (unumber) $7f in getValue::$0 = getValue::index#1 & $7f
Adding number conversion cast (unumber) getValue::$0 in getValue::$0 = getValue::index#1 & (unumber)$7f
Adding number conversion cast (unumber) getValue::$3 in getValue::$3 = getValue::$0 * SIZEOF_WORD
Adding number conversion cast (unumber) getValue::$3 in getValue::$3 = getValue::$0 * SIZEOF_UNSIGNED_INT
Adding number conversion cast (unumber) $ff in getValue::$1 = arr16[getValue::$3] & $ff
Adding number conversion cast (unumber) getValue::$1 in getValue::$1 = arr16[getValue::$3] & (unumber)$ff
Adding number conversion cast (unumber) 1 in getValue::$2 = getValue::$1 >> 1
Adding number conversion cast (unumber) getValue::$2 in getValue::$2 = getValue::$1 >> (unumber)1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (word*) 1024
Simplifying constant pointer cast (unsigned int *) 1024
Simplifying constant integer cast $7f
Simplifying constant integer cast $ff
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $7f
Finalized unsigned number type (byte) $ff
Finalized unsigned number type (byte) 1
Finalized unsigned number type (char) $7f
Finalized unsigned number type (char) $ff
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in getValue::$0 = getValue::index#1 & $7f
Inferred type updated to byte in getValue::$3 = getValue::$0 * SIZEOF_WORD
Inferred type updated to byte in getValue::$1 = arr16[getValue::$3] & $ff
Inferred type updated to byte in getValue::$2 = getValue::$1 >> 1
Inferred type updated to char in getValue::$0 = getValue::index#1 & $7f
Inferred type updated to char in getValue::$3 = getValue::$0 * SIZEOF_UNSIGNED_INT
Inferred type updated to char in getValue::$1 = arr16[getValue::$3] & $ff
Inferred type updated to char in getValue::$2 = getValue::$1 >> 1
Alias getValue::return#0 = getValue::return#3
Alias main::idx#2 = main::idx#3
Alias getValue::return#1 = getValue::return#4 getValue::return#2
@ -121,18 +121,18 @@ Adding number conversion cast (unumber) $81 in [8] if(main::idx#1!=$81) goto mai
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast $81
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $81
Finalized unsigned number type (char) $81
Successful SSA optimization PassNFinalizeNumberTypeConversions
Rewriting multiplication to use shift [5] main::$2 = main::idx#2 * SIZEOF_WORD
Rewriting multiplication to use shift [11] getValue::$3 = getValue::$0 * SIZEOF_WORD
Rewriting multiplication to use shift [5] main::$2 = main::idx#2 * SIZEOF_UNSIGNED_INT
Rewriting multiplication to use shift [11] getValue::$3 = getValue::$0 * SIZEOF_UNSIGNED_INT
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings main::idx#0
Constant inlined main::idx#0 = 0
Successful SSA optimization Pass2ConstantInlining
Eliminating unused constant SIZEOF_WORD
Eliminating unused constant SIZEOF_UNSIGNED_INT
Successful SSA optimization PassNEliminateUnusedVars
Finalized unsigned number type (byte) $80
Finalized unsigned number type (byte) $80
Finalized unsigned number type (char) $80
Finalized unsigned number type (char) $80
Successful SSA optimization PassNFinalizeNumberTypeConversions
Added new block during phi lifting main::@3(between main::@2 and main::@1)
Adding NOP phi() at start of main
@ -154,7 +154,7 @@ main: scope:[main] from
main::@1: scope:[main] from main main::@2
[1] main::idx#2 = phi( main/0, main::@2/main::idx#1 )
[2] getValue::index#0 = main::idx#2
[3] call getValue
[3] call getValue
[4] getValue::return#0 = getValue::return#1
to:main::@2
main::@2: scope:[main] from main::@1
@ -168,13 +168,13 @@ main::@return: scope:[main] from main::@2
[10] return
to:@return
word getValue(word getValue::index)
unsigned int getValue(unsigned int index)
getValue: scope:[getValue] from main::@1
[11] getValue::$0 = getValue::index#0 & $7f
[12] getValue::$3 = getValue::$0 << 1
[13] getValue::$1 = arr16[getValue::$3] & $ff
[14] getValue::$2 = getValue::$1 >> 1
[15] getValue::return#1 = (word)getValue::$2
[15] getValue::return#1 = (unsigned int)getValue::$2
to:getValue::@return
getValue::@return: scope:[getValue] from getValue
[16] return
@ -182,22 +182,22 @@ getValue::@return: scope:[getValue] from getValue
VARIABLE REGISTER WEIGHTS
word getValue(word getValue::index)
byte~ getValue::$0 202.0
byte~ getValue::$1 202.0
byte~ getValue::$2 101.0
byte~ getValue::$3 202.0
word getValue::index
word getValue::index#0 112.0
word getValue::return
word getValue::return#0 22.0
word getValue::return#1 37.33333333333333
unsigned int getValue(unsigned int index)
char getValue::$0 // 202.0
char getValue::$1 // 202.0
char getValue::$2 // 101.0
char getValue::$3 // 202.0
unsigned int getValue::index
unsigned int getValue::index#0 // 112.0
unsigned int getValue::return
unsigned int getValue::return#0 // 22.0
unsigned int getValue::return#1 // 37.33333333333333
void main()
word~ main::$0 11.0
byte~ main::$2 22.0
byte main::idx
byte main::idx#1 16.5
byte main::idx#2 6.285714285714286
unsigned int main::$0 // 11.0
char main::$2 // 22.0
char main::idx
char main::idx#1 // 16.5
char main::idx#2 // 6.285714285714286
Initial phi equivalence classes
[ main::idx#2 main::idx#1 ]
@ -242,7 +242,7 @@ Statement [11] getValue::$0 = getValue::index#0 & $7f [ getValue::$0 ] ( getValu
Statement [12] getValue::$3 = getValue::$0 << 1 [ getValue::$3 ] ( getValue:3 [ main::idx#2 getValue::$3 ] { { getValue::index#0 = main::idx#2 } { getValue::return#0 = getValue::return#1 } } ) always clobbers reg byte a
Statement [13] getValue::$1 = arr16[getValue::$3] & $ff [ getValue::$1 ] ( getValue:3 [ main::idx#2 getValue::$1 ] { { getValue::index#0 = main::idx#2 } { getValue::return#0 = getValue::return#1 } } ) always clobbers reg byte a
Statement [14] getValue::$2 = getValue::$1 >> 1 [ getValue::$2 ] ( getValue:3 [ main::idx#2 getValue::$2 ] { { getValue::index#0 = main::idx#2 } { getValue::return#0 = getValue::return#1 } } ) always clobbers reg byte a
Statement [15] getValue::return#1 = (word)getValue::$2 [ getValue::return#1 ] ( getValue:3 [ main::idx#2 getValue::return#1 ] { { getValue::index#0 = main::idx#2 } { getValue::return#0 = getValue::return#1 } } ) always clobbers reg byte a
Statement [15] getValue::return#1 = (unsigned int)getValue::$2 [ getValue::return#1 ] ( getValue:3 [ main::idx#2 getValue::return#1 ] { { getValue::index#0 = main::idx#2 } { getValue::return#0 = getValue::return#1 } } ) always clobbers reg byte a
Statement [2] getValue::index#0 = main::idx#2 [ main::idx#2 getValue::index#0 ] ( [ main::idx#2 getValue::index#0 ] { { getValue::index#0 = main::idx#2 } { getValue::return#0 = getValue::return#1 } } ) always clobbers reg byte a
Statement [4] getValue::return#0 = getValue::return#1 [ main::idx#2 getValue::return#0 ] ( [ main::idx#2 getValue::return#0 ] { { getValue::index#0 = main::idx#2 } { getValue::return#0 = getValue::return#1 } } ) always clobbers reg byte a
Statement [5] main::$0 = getValue::return#0 [ main::idx#2 main::$0 ] ( [ main::idx#2 main::$0 ] { } ) always clobbers reg byte a
@ -252,7 +252,7 @@ Statement [11] getValue::$0 = getValue::index#0 & $7f [ getValue::$0 ] ( getValu
Statement [12] getValue::$3 = getValue::$0 << 1 [ getValue::$3 ] ( getValue:3 [ main::idx#2 getValue::$3 ] { { getValue::index#0 = main::idx#2 } { getValue::return#0 = getValue::return#1 } } ) always clobbers reg byte a
Statement [13] getValue::$1 = arr16[getValue::$3] & $ff [ getValue::$1 ] ( getValue:3 [ main::idx#2 getValue::$1 ] { { getValue::index#0 = main::idx#2 } { getValue::return#0 = getValue::return#1 } } ) always clobbers reg byte a
Statement [14] getValue::$2 = getValue::$1 >> 1 [ getValue::$2 ] ( getValue:3 [ main::idx#2 getValue::$2 ] { { getValue::index#0 = main::idx#2 } { getValue::return#0 = getValue::return#1 } } ) always clobbers reg byte a
Statement [15] getValue::return#1 = (word)getValue::$2 [ getValue::return#1 ] ( getValue:3 [ main::idx#2 getValue::return#1 ] { { getValue::index#0 = main::idx#2 } { getValue::return#0 = getValue::return#1 } } ) always clobbers reg byte a
Statement [15] getValue::return#1 = (unsigned int)getValue::$2 [ getValue::return#1 ] ( getValue:3 [ main::idx#2 getValue::return#1 ] { { getValue::index#0 = main::idx#2 } { getValue::return#0 = getValue::return#1 } } ) always clobbers reg byte a
Potential registers zp[1]:2 [ main::idx#2 main::idx#1 ] : zp[1]:2 , reg byte x , reg byte y ,
Potential registers zp[2]:3 [ getValue::index#0 ] : zp[2]:3 ,
Potential registers zp[2]:5 [ getValue::return#0 ] : zp[2]:5 ,
@ -313,7 +313,7 @@ main: {
sta.z getValue.index
lda #0
sta.z getValue.index+1
// [3] call getValue
// [3] call getValue
jsr getValue
// [4] getValue::return#0 = getValue::return#1
jmp __b2
@ -341,7 +341,7 @@ main: {
rts
}
// getValue
// getValue(word zp(2) index)
// __zp(4) unsigned int getValue(__zp(2) unsigned int index)
getValue: {
.label index = 2
.label return = 4
@ -356,7 +356,7 @@ getValue: {
and arr16,y
// [14] getValue::$2 = getValue::$1 >> 1 -- vbuaa=vbuaa_ror_1
lsr
// [15] getValue::return#1 = (word)getValue::$2 -- vwuz1=_word_vbuaa
// [15] getValue::return#1 = (unsigned int)getValue::$2 -- vwuz1=_word_vbuaa
sta.z return
lda #0
sta.z return+1
@ -388,24 +388,24 @@ Removing instruction jmp __b1
Succesful ASM optimization Pass5NextJumpElimination
FINAL SYMBOL TABLE
constant word* arr16[$80] = { fill( $80, 0) }
word getValue(word getValue::index)
byte~ getValue::$0 reg byte a 202.0
byte~ getValue::$1 reg byte a 202.0
byte~ getValue::$2 reg byte a 101.0
byte~ getValue::$3 reg byte a 202.0
word getValue::index
word getValue::index#0 index zp[2]:2 112.0
word getValue::return
word getValue::return#0 return zp[2]:4 22.0
word getValue::return#1 return zp[2]:4 37.33333333333333
__constant unsigned int arr16[$80] = { fill( $80, 0) }
unsigned int getValue(unsigned int index)
char getValue::$0 // reg byte a 202.0
char getValue::$1 // reg byte a 202.0
char getValue::$2 // reg byte a 101.0
char getValue::$3 // reg byte a 202.0
unsigned int getValue::index
unsigned int getValue::index#0 // index zp[2]:2 112.0
unsigned int getValue::return
unsigned int getValue::return#0 // return zp[2]:4 22.0
unsigned int getValue::return#1 // return zp[2]:4 37.33333333333333
void main()
word~ main::$0 zp[2]:4 11.0
byte~ main::$2 reg byte a 22.0
constant word* main::SCREEN = (word*) 1024
byte main::idx
byte main::idx#1 reg byte x 16.5
byte main::idx#2 reg byte x 6.285714285714286
unsigned int main::$0 // zp[2]:4 11.0
char main::$2 // reg byte a 22.0
__constant unsigned int *main::SCREEN = (unsigned int *) 1024
char main::idx
char main::idx#1 // reg byte x 16.5
char main::idx#2 // reg byte x 6.285714285714286
reg byte x [ main::idx#2 main::idx#1 ]
zp[2]:2 [ getValue::index#0 ]
@ -451,7 +451,7 @@ main: {
sta.z getValue.index
lda #0
sta.z getValue.index+1
// [3] call getValue
// [3] call getValue
jsr getValue
// [4] getValue::return#0 = getValue::return#1
// main::@2
@ -478,7 +478,7 @@ main: {
rts
}
// getValue
// getValue(word zp(2) index)
// __zp(4) unsigned int getValue(__zp(2) unsigned int index)
getValue: {
.label index = 2
.label return = 4
@ -497,7 +497,7 @@ getValue: {
// [14] getValue::$2 = getValue::$1 >> 1 -- vbuaa=vbuaa_ror_1
lsr
// return (unsigned int)((arr16[index & 0x7f] & 0xff) >> 1);
// [15] getValue::return#1 = (word)getValue::$2 -- vwuz1=_word_vbuaa
// [15] getValue::return#1 = (unsigned int)getValue::$2 -- vwuz1=_word_vbuaa
sta.z return
lda #0
sta.z return+1

View File

@ -1,21 +1,21 @@
constant word* arr16[$80] = { fill( $80, 0) }
word getValue(word getValue::index)
byte~ getValue::$0 reg byte a 202.0
byte~ getValue::$1 reg byte a 202.0
byte~ getValue::$2 reg byte a 101.0
byte~ getValue::$3 reg byte a 202.0
word getValue::index
word getValue::index#0 index zp[2]:2 112.0
word getValue::return
word getValue::return#0 return zp[2]:4 22.0
word getValue::return#1 return zp[2]:4 37.33333333333333
__constant unsigned int arr16[$80] = { fill( $80, 0) }
unsigned int getValue(unsigned int index)
char getValue::$0 // reg byte a 202.0
char getValue::$1 // reg byte a 202.0
char getValue::$2 // reg byte a 101.0
char getValue::$3 // reg byte a 202.0
unsigned int getValue::index
unsigned int getValue::index#0 // index zp[2]:2 112.0
unsigned int getValue::return
unsigned int getValue::return#0 // return zp[2]:4 22.0
unsigned int getValue::return#1 // return zp[2]:4 37.33333333333333
void main()
word~ main::$0 zp[2]:4 11.0
byte~ main::$2 reg byte a 22.0
constant word* main::SCREEN = (word*) 1024
byte main::idx
byte main::idx#1 reg byte x 16.5
byte main::idx#2 reg byte x 6.285714285714286
unsigned int main::$0 // zp[2]:4 11.0
char main::$2 // reg byte a 22.0
__constant unsigned int *main::SCREEN = (unsigned int *) 1024
char main::idx
char main::idx#1 // reg byte x 16.5
char main::idx#2 // reg byte x 6.285714285714286
reg byte x [ main::idx#2 main::idx#1 ]
zp[2]:2 [ getValue::index#0 ]

View File

@ -18,7 +18,7 @@ main::@return: scope:[main] from main::@1
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -27,16 +27,16 @@ __start::@return: scope:[__start] from __start::@1
to:@return
SYMBOL TABLE SSA
constant const byte SZ = $f
__constant const char SZ = $f
void __start()
constant byte* items[SZ] = { fill( SZ, 0) }
__constant char items[SZ] = { fill( SZ, 0) }
void main()
bool~ main::$0
constant byte* main::cur_item = items
byte main::sub
byte main::sub#0
byte main::sub#1
byte main::sub#2
bool main::$0
__constant char *main::cur_item = items
char main::sub
char main::sub#0
char main::sub#1
char main::sub#2
Simple Condition main::$0 [5] if(main::sub#1!=rangelast(0,SZ)) goto main::@1
Successful SSA optimization Pass2ConditionalJumpSimplification
@ -55,7 +55,7 @@ Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast SZ+(unumber)1
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inlining constant with var siblings main::sub#0
Constant inlined main::sub#0 = 0
@ -90,9 +90,9 @@ main::@return: scope:[main] from main::@1
VARIABLE REGISTER WEIGHTS
void main()
byte main::sub
byte main::sub#1 16.5
byte main::sub#2 22.0
char main::sub
char main::sub#1 // 16.5
char main::sub#2 // 22.0
Initial phi equivalence classes
[ main::sub#2 main::sub#1 ]
@ -170,12 +170,12 @@ Removing instruction jmp __b1
Succesful ASM optimization Pass5NextJumpElimination
FINAL SYMBOL TABLE
constant const byte SZ = $f
constant byte* items[SZ] = { fill( SZ, 0) }
__constant const char SZ = $f
__constant char items[SZ] = { fill( SZ, 0) }
void main()
byte main::sub
byte main::sub#1 reg byte x 16.5
byte main::sub#2 reg byte x 22.0
char main::sub
char main::sub#1 // reg byte x 16.5
char main::sub#2 // reg byte x 22.0
reg byte x [ main::sub#2 main::sub#1 ]

View File

@ -1,8 +1,8 @@
constant const byte SZ = $f
constant byte* items[SZ] = { fill( SZ, 0) }
__constant const char SZ = $f
__constant char items[SZ] = { fill( SZ, 0) }
void main()
byte main::sub
byte main::sub#1 reg byte x 16.5
byte main::sub#2 reg byte x 22.0
char main::sub
char main::sub#1 // reg byte x 16.5
char main::sub#2 // reg byte x 22.0
reg byte x [ main::sub#2 main::sub#1 ]

View File

@ -36,7 +36,7 @@ main::@return: scope:[main] from main::@3
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -45,31 +45,31 @@ __start::@return: scope:[__start] from __start::@1
to:@return
SYMBOL TABLE SSA
constant const byte ITEM_COUNT = 3
constant const byte ITEM_SIZE = 5
__constant const char ITEM_COUNT = 3
__constant const char ITEM_SIZE = 5
void __start()
constant byte* items[ITEM_COUNT*ITEM_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
__constant char items[ITEM_COUNT*ITEM_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
void main()
number~ main::$0
number~ main::$1
bool~ main::$2
bool~ main::$3
byte* main::cur_item
byte* main::cur_item#0
byte* main::cur_item#1
byte* main::cur_item#2
byte* main::cur_item#3
byte* main::cur_item#4
byte main::item
byte main::item#0
byte main::item#1
byte main::item#2
byte main::item#3
byte main::item#4
byte main::sub
byte main::sub#0
byte main::sub#1
byte main::sub#2
number main::$0
number main::$1
bool main::$2
bool main::$3
char *main::cur_item
char *main::cur_item#0
char *main::cur_item#1
char *main::cur_item#2
char *main::cur_item#3
char *main::cur_item#4
char main::item
char main::item#0
char main::item#1
char main::item#2
char main::item#3
char main::item#4
char main::sub
char main::sub#0
char main::sub#1
char main::sub#2
Adding number conversion cast (unumber) $10 in main::$0 = main::item#2 * $10
Adding number conversion cast (unumber) main::$0 in main::$0 = main::item#2 * (unumber)$10
@ -81,12 +81,12 @@ Simplifying constant integer cast $10
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $10
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (char) $10
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in main::$0 = main::item#2 * $10
Inferred type updated to byte in main::$1 = main::$0 | main::sub#2
Inferred type updated to char in main::$0 = main::item#2 * $10
Inferred type updated to char in main::$1 = main::$0 | main::sub#2
Alias main::cur_item#2 = main::cur_item#3
Alias main::item#2 = main::item#3
Successful SSA optimization Pass2AliasElimination
@ -119,8 +119,8 @@ Simplifying constant integer cast 1
Simplifying constant integer cast ITEM_COUNT-1+(unumber)1
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Rewriting multiplication to use shift [2] main::$0 = main::item#4 * $10
Successful SSA optimization Pass2MultiplyToShiftRewriting
@ -175,17 +175,17 @@ main::@return: scope:[main] from main::@3
VARIABLE REGISTER WEIGHTS
void main()
byte~ main::$0 202.0
byte~ main::$1 202.0
byte* main::cur_item
byte* main::cur_item#1 7.333333333333333
byte* main::cur_item#4 17.571428571428573
byte main::item
byte main::item#1 16.5
byte main::item#4 15.375
byte main::sub
byte main::sub#1 151.5
byte main::sub#2 101.0
char main::$0 // 202.0
char main::$1 // 202.0
char *main::cur_item
char *main::cur_item#1 // 7.333333333333333
char *main::cur_item#4 // 17.571428571428573
char main::item
char main::item#1 // 16.5
char main::item#4 // 15.375
char main::sub
char main::sub#1 // 151.5
char main::sub#2 // 101.0
Initial phi equivalence classes
[ main::item#4 main::item#1 ]
@ -337,21 +337,21 @@ Removing instruction jmp __b2
Succesful ASM optimization Pass5NextJumpElimination
FINAL SYMBOL TABLE
constant const byte ITEM_COUNT = 3
constant const byte ITEM_SIZE = 5
constant byte* items[ITEM_COUNT*ITEM_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
__constant const char ITEM_COUNT = 3
__constant const char ITEM_SIZE = 5
__constant char items[ITEM_COUNT*ITEM_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
void main()
byte~ main::$0 reg byte a 202.0
byte~ main::$1 reg byte a 202.0
byte* main::cur_item
byte* main::cur_item#1 cur_item zp[2]:2 7.333333333333333
byte* main::cur_item#4 cur_item zp[2]:2 17.571428571428573
byte main::item
byte main::item#1 reg byte x 16.5
byte main::item#4 reg byte x 15.375
byte main::sub
byte main::sub#1 reg byte y 151.5
byte main::sub#2 reg byte y 101.0
char main::$0 // reg byte a 202.0
char main::$1 // reg byte a 202.0
char *main::cur_item
char *main::cur_item#1 // cur_item zp[2]:2 7.333333333333333
char *main::cur_item#4 // cur_item zp[2]:2 17.571428571428573
char main::item
char main::item#1 // reg byte x 16.5
char main::item#4 // reg byte x 15.375
char main::sub
char main::sub#1 // reg byte y 151.5
char main::sub#2 // reg byte y 101.0
reg byte x [ main::item#4 main::item#1 ]
zp[2]:2 [ main::cur_item#4 main::cur_item#1 ]

View File

@ -1,18 +1,18 @@
constant const byte ITEM_COUNT = 3
constant const byte ITEM_SIZE = 5
constant byte* items[ITEM_COUNT*ITEM_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
__constant const char ITEM_COUNT = 3
__constant const char ITEM_SIZE = 5
__constant char items[ITEM_COUNT*ITEM_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
void main()
byte~ main::$0 reg byte a 202.0
byte~ main::$1 reg byte a 202.0
byte* main::cur_item
byte* main::cur_item#1 cur_item zp[2]:2 7.333333333333333
byte* main::cur_item#4 cur_item zp[2]:2 17.571428571428573
byte main::item
byte main::item#1 reg byte x 16.5
byte main::item#4 reg byte x 15.375
byte main::sub
byte main::sub#1 reg byte y 151.5
byte main::sub#2 reg byte y 101.0
char main::$0 // reg byte a 202.0
char main::$1 // reg byte a 202.0
char *main::cur_item
char *main::cur_item#1 // cur_item zp[2]:2 7.333333333333333
char *main::cur_item#4 // cur_item zp[2]:2 17.571428571428573
char main::item
char main::item#1 // reg byte x 16.5
char main::item#4 // reg byte x 15.375
char main::sub
char main::sub#1 // reg byte y 151.5
char main::sub#2 // reg byte y 101.0
reg byte x [ main::item#4 main::item#1 ]
zp[2]:2 [ main::cur_item#4 main::cur_item#1 ]

View File

@ -1,4 +1,4 @@
Inlined call call __init
Inlined call call __init
CONTROL FLOW GRAPH SSA
@ -16,7 +16,7 @@ __start: scope:[__start] from
__start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
call main
call main
to:__start::@2
__start::@2: scope:[__start] from __start::@1
to:__start::@return
@ -25,8 +25,8 @@ __start::@return: scope:[__start] from __start::@2
to:@return
SYMBOL TABLE SSA
constant byte* SCREEN = (byte*)$400
constant byte* SINTAB[$100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
__constant char *SCREEN = (char *)$400
__constant char SINTAB[$100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
}}
void __start()
void main()
@ -34,12 +34,12 @@ void main()
Adding number conversion cast (unumber) 0 in SCREEN[0] = SINTAB[0]
Adding number conversion cast (unumber) 0 in SCREEN[0] = SINTAB[(unumber)0]
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simplifying expression containing zero SINTAB in [0] SCREEN[0] = SINTAB[0]
Simplifying expression containing zero SCREEN in [0] SCREEN[0] = *SINTAB
@ -51,7 +51,7 @@ Removing unused procedure block __start::@1
Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Finalized unsigned number type (word) $100
Finalized unsigned number type (unsigned int) $100
Successful SSA optimization PassNFinalizeNumberTypeConversions
CALL GRAPH
@ -124,8 +124,8 @@ Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte* SCREEN = (byte*) 1024
constant byte* SINTAB[$100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
__constant char *SCREEN = (char *) 1024
__constant char SINTAB[$100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
}}
void main()

View File

@ -1,5 +1,5 @@
constant byte* SCREEN = (byte*) 1024
constant byte* SINTAB[$100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
__constant char *SCREEN = (char *) 1024
__constant char SINTAB[$100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
}}
void main()

View File

@ -1,4 +1,4 @@
Inlined call call __init
Inlined call call __init
CONTROL FLOW GRAPH SSA
@ -16,7 +16,7 @@ __start: scope:[__start] from
__start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
call main
call main
to:__start::@2
__start::@2: scope:[__start] from __start::@1
to:__start::@return
@ -25,8 +25,8 @@ __start::@return: scope:[__start] from __start::@2
to:@return
SYMBOL TABLE SSA
constant byte* SCREEN = (byte*)$400
constant byte* SINTAB[$100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
__constant char *SCREEN = (char *)$400
__constant char SINTAB[$100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
}}
void __start()
void main()
@ -34,12 +34,12 @@ void main()
Adding number conversion cast (unumber) 0 in SCREEN[0] = SINTAB[0]
Adding number conversion cast (unumber) 0 in SCREEN[0] = SINTAB[(unumber)0]
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Simplifying expression containing zero SINTAB in [0] SCREEN[0] = SINTAB[0]
Simplifying expression containing zero SCREEN in [0] SCREEN[0] = *SINTAB
@ -51,8 +51,8 @@ Removing unused procedure block __start::@1
Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Finalized unsigned number type (word) $100
Finalized unsigned number type (word) $1000
Finalized unsigned number type (unsigned int) $100
Finalized unsigned number type (unsigned int) $1000
Successful SSA optimization PassNFinalizeNumberTypeConversions
CALL GRAPH
@ -127,8 +127,8 @@ Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte* SCREEN = (byte*) 1024
constant byte* SINTAB[$100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
__constant char *SCREEN = (char *) 1024
__constant char SINTAB[$100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
}}
void main()

View File

@ -1,5 +1,5 @@
constant byte* SCREEN = (byte*) 1024
constant byte* SINTAB[$100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
__constant char *SCREEN = (char *) 1024
__constant char SINTAB[$100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256)
}}
void main()

View File

@ -34,7 +34,7 @@ main::@return: scope:[main] from main::@4
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -43,36 +43,36 @@ __start::@return: scope:[__start] from __start::@1
to:@return
SYMBOL TABLE SSA
constant byte* const SCREEN = (byte*)$400
__constant char * const SCREEN = (char *)$400
void __start()
void main()
bool~ main::$0
bool~ main::$1
byte main::i
byte main::i#0
byte main::i#1
byte main::i#2
byte main::i#3
byte main::i1
byte main::i1#0
byte main::i1#1
byte main::i1#2
byte main::i1#3
constant byte* msg1[$10] = "camelot"
constant byte* msg2[$10] = { 'c', 'm', 'l' }
bool main::$0
bool main::$1
char main::i
char main::i#0
char main::i#1
char main::i#2
char main::i#3
char main::i1
char main::i1#0
char main::i1#1
char main::i1#2
char main::i1#3
__constant char msg1[$10] = "camelot"
__constant char msg2[$10] = { 'c', 'm', 'l' }
Adding number conversion cast (unumber) 0 in main::$0 = 0 != msg1[main::i#2]
Adding number conversion cast (unumber) 0 in main::$1 = 0 != msg2[main::i1#2]
Adding number conversion cast (unumber) $28 in (SCREEN+$28)[main::i1#3] = msg2[main::i1#3]
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast $28
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $28
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) $28
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias main::i#2 = main::i#3
Alias main::i1#2 = main::i1#3
@ -93,8 +93,8 @@ Inlining constant with var siblings main::i1#0
Constant inlined main::i#0 = 0
Constant inlined main::i1#0 = 0
Successful SSA optimization Pass2ConstantInlining
Finalized unsigned number type (byte) $10
Finalized unsigned number type (byte) $10
Finalized unsigned number type (char) $10
Finalized unsigned number type (char) $10
Successful SSA optimization PassNFinalizeNumberTypeConversions
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@3
@ -138,12 +138,12 @@ main::@2: scope:[main] from main::@1
VARIABLE REGISTER WEIGHTS
void main()
byte main::i
byte main::i#1 22.0
byte main::i#2 18.333333333333332
byte main::i1
byte main::i1#1 22.0
byte main::i1#2 18.333333333333332
char main::i
char main::i#1 // 22.0
char main::i#2 // 18.333333333333332
char main::i1
char main::i1#1 // 22.0
char main::i1#2 // 18.333333333333332
Initial phi equivalence classes
[ main::i#2 main::i#1 ]
@ -262,16 +262,16 @@ Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void main()
byte main::i
byte main::i#1 reg byte x 22.0
byte main::i#2 reg byte x 18.333333333333332
byte main::i1
byte main::i1#1 reg byte x 22.0
byte main::i1#2 reg byte x 18.333333333333332
constant byte* msg1[$10] = "camelot"
constant byte* msg2[$10] = { 'c', 'm', 'l' }
char main::i
char main::i#1 // reg byte x 22.0
char main::i#2 // reg byte x 18.333333333333332
char main::i1
char main::i1#1 // reg byte x 22.0
char main::i1#2 // reg byte x 18.333333333333332
__constant char msg1[$10] = "camelot"
__constant char msg2[$10] = { 'c', 'm', 'l' }
reg byte x [ main::i#2 main::i#1 ]
reg byte x [ main::i1#2 main::i1#1 ]

View File

@ -1,13 +1,13 @@
constant byte* const SCREEN = (byte*) 1024
__constant char * const SCREEN = (char *) 1024
void main()
byte main::i
byte main::i#1 reg byte x 22.0
byte main::i#2 reg byte x 18.333333333333332
byte main::i1
byte main::i1#1 reg byte x 22.0
byte main::i1#2 reg byte x 18.333333333333332
constant byte* msg1[$10] = "camelot"
constant byte* msg2[$10] = { 'c', 'm', 'l' }
char main::i
char main::i#1 // reg byte x 22.0
char main::i#2 // reg byte x 18.333333333333332
char main::i1
char main::i1#1 // reg byte x 22.0
char main::i1#2 // reg byte x 18.333333333333332
__constant char msg1[$10] = "camelot"
__constant char msg2[$10] = { 'c', 'm', 'l' }
reg byte x [ main::i#2 main::i#1 ]
reg byte x [ main::i1#2 main::i1#1 ]

View File

@ -1,4 +1,4 @@
Inlined call call __init
Inlined call call __init
CONTROL FLOW GRAPH SSA
@ -21,7 +21,7 @@ __start: scope:[__start] from
__start::__init1: scope:[__start] from __start
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
call main
call main
to:__start::@2
__start::@2: scope:[__start] from __start::@1
to:__start::@return
@ -30,14 +30,14 @@ __start::@return: scope:[__start] from __start::@2
to:@return
SYMBOL TABLE SSA
constant byte* SCREEN = (byte*)$400
__constant char *SCREEN = (char *)$400
void __start()
constant byte* b[3] = { fill( 3, 0) }
constant byte* c[] = { 'c', 'm', 'l' }
constant byte* d[] = "cml"z
__constant char b[3] = { fill( 3, 0) }
__constant char c[] = { 'c', 'm', 'l' }
__constant char d[] = "cml"z
void main()
byte*~ main::$0
byte*~ main::$1
char *main::$0
char *main::$1
Adding number conversion cast (unumber) 0 in b[0] = 'c'
Adding number conversion cast (unumber) 0 in *SCREEN = b[0]
@ -46,7 +46,7 @@ Adding number conversion cast (unumber) 1 in *main::$0 = c[1]
Adding number conversion cast (unumber) 2 in main::$1 = SCREEN + 2
Adding number conversion cast (unumber) 2 in *main::$1 = d[2]
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast 0
Simplifying constant integer cast 1
@ -54,12 +54,12 @@ Simplifying constant integer cast 1
Simplifying constant integer cast 2
Simplifying constant integer cast 2
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) 2
Finalized unsigned number type (byte) 2
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 2
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant right-side identified [2] main::$0 = SCREEN + 1
Constant right-side identified [4] main::$1 = SCREEN + 2
@ -83,8 +83,8 @@ Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(c+1)
Consolidated array index constant in *(d+2)
Successful SSA optimization Pass2ConstantAdditionElimination
Finalized unsigned number type (byte) 3
Finalized unsigned number type (byte) 3
Finalized unsigned number type (char) 3
Finalized unsigned number type (char) 3
Successful SSA optimization PassNFinalizeNumberTypeConversions
CALL GRAPH
@ -172,10 +172,10 @@ Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
constant byte* SCREEN = (byte*) 1024
constant byte* b[3] = { fill( 3, 0) }
constant byte* c[] = { 'c', 'm', 'l' }
constant byte* d[] = "cml"z
__constant char *SCREEN = (char *) 1024
__constant char b[3] = { fill( 3, 0) }
__constant char c[] = { 'c', 'm', 'l' }
__constant char d[] = "cml"z
void main()

View File

@ -1,6 +1,6 @@
constant byte* SCREEN = (byte*) 1024
constant byte* b[3] = { fill( 3, 0) }
constant byte* c[] = { 'c', 'm', 'l' }
constant byte* d[] = "cml"z
__constant char *SCREEN = (char *) 1024
__constant char b[3] = { fill( 3, 0) }
__constant char c[] = { 'c', 'm', 'l' }
__constant char d[] = "cml"z
void main()

View File

@ -2,7 +2,7 @@
void main()
main: scope:[main] from
asm { jmpqwe .byte0,25,51,76,102,128,153,179,204,230 qwe: lda#50 }
[1] *((byte*) 1024) = 'c'
[1] *((char *) 1024) = 'c'
to:main::@return
main::@return: scope:[main] from main
[2] return

View File

@ -4,7 +4,7 @@ CONTROL FLOW GRAPH SSA
void main()
main: scope:[main] from __start
asm { jmpqwe .byte0,25,51,76,102,128,153,179,204,230 qwe: lda#50 }
*((byte*)$400) = 'c'
*((char *)$400) = 'c'
to:main::@return
main::@return: scope:[main] from main
return
@ -12,7 +12,7 @@ main::@return: scope:[main] from main
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -24,7 +24,7 @@ SYMBOL TABLE SSA
void __start()
void main()
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Removing unused procedure __start
Removing unused procedure block __start
@ -41,7 +41,7 @@ FINAL CONTROL FLOW GRAPH
void main()
main: scope:[main] from
asm { jmpqwe .byte0,25,51,76,102,128,153,179,204,230 qwe: lda#50 }
[1] *((byte*) 1024) = 'c'
[1] *((char *) 1024) = 'c'
to:main::@return
main::@return: scope:[main] from main
[2] return
@ -55,7 +55,7 @@ Initial phi equivalence classes
Complete equivalence classes
REGISTER UPLIFT POTENTIAL REGISTERS
Statement asm { jmpqwe .byte0,25,51,76,102,128,153,179,204,230 qwe: lda#50 } always clobbers reg byte a
Statement [1] *((byte*) 1024) = 'c' [ ] ( [ ] { } ) always clobbers reg byte a
Statement [1] *((char *) 1024) = 'c' [ ] ( [ ] { } ) always clobbers reg byte a
REGISTER UPLIFT SCOPES
Uplift Scope [main]
@ -86,7 +86,7 @@ main: {
.byte 0, 25, 51, 76, 102, 128, 153, 179, 204, 230
qwe:
lda #$32
// [1] *((byte*) 1024) = 'c' -- _deref_pbuc1=vbuc2
// [1] *((char *) 1024) = 'c' -- _deref_pbuc1=vbuc2
lda #'c'
sta $400
jmp __breturn
@ -134,7 +134,7 @@ main: {
qwe:
lda #$32
// *((char*)0x0400) = 'c'
// [1] *((byte*) 1024) = 'c' -- _deref_pbuc1=vbuc2
// [1] *((char *) 1024) = 'c' -- _deref_pbuc1=vbuc2
lda #'c'
sta $400
// main::@return

View File

@ -25,6 +25,7 @@ main: {
// }
rts
}
// void bne(char jsr)
bne: {
// lda[1] = jsr
lda #main.jmp

View File

@ -2,7 +2,7 @@
void main()
main: scope:[main] from
[0] *lda = main::jmp
[1] call bne
[1] call bne
to:main::@1
main::@1: scope:[main] from main
asm { ldaa jmpa bnea a: }
@ -11,7 +11,7 @@ main::@return: scope:[main] from main::@1
[3] return
to:@return
void bne(byte bne::jsr)
void bne(char jsr)
bne: scope:[bne] from main
[4] *(lda+1) = main::jmp
to:bne::@return

View File

@ -5,7 +5,7 @@ void main()
main: scope:[main] from __start
*lda = main::jmp
bne::jsr#0 = main::jmp
call bne
call bne
to:main::@1
main::@1: scope:[main] from main
asm { ldaa jmpa bnea a: }
@ -14,7 +14,7 @@ main::@return: scope:[main] from main::@1
return
to:@return
void bne(byte bne::jsr)
void bne(char jsr)
bne: scope:[bne] from main
bne::jsr#1 = phi( main/bne::jsr#0 )
lda[1] = bne::jsr#1
@ -25,7 +25,7 @@ bne::@return: scope:[bne] from bne
void __start()
__start: scope:[__start] from
call main
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
@ -35,20 +35,20 @@ __start::@return: scope:[__start] from __start::@1
SYMBOL TABLE SSA
void __start()
void bne(byte bne::jsr)
byte bne::jsr
byte bne::jsr#0
byte bne::jsr#1
constant byte* const lda = (byte*)$400
void bne(char jsr)
char bne::jsr
char bne::jsr#0
char bne::jsr#1
__constant char * const lda = (char *)$400
void main()
constant byte main::jmp = 1
__constant char main::jmp = 1
Adding number conversion cast (unumber) 1 in lda[1] = bne::jsr#1
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (char *) 1024
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Finalized unsigned number type (char) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Identical Phi Values bne::jsr#1 bne::jsr#0
Successful SSA optimization Pass2IdenticalPhiElimination
@ -74,7 +74,7 @@ FINAL CONTROL FLOW GRAPH
void main()
main: scope:[main] from
[0] *lda = main::jmp
[1] call bne
[1] call bne
to:main::@1
main::@1: scope:[main] from main
asm { ldaa jmpa bnea a: }
@ -83,7 +83,7 @@ main::@return: scope:[main] from main::@1
[3] return
to:@return
void bne(byte bne::jsr)
void bne(char jsr)
bne: scope:[bne] from main
[4] *(lda+1) = main::jmp
to:bne::@return
@ -93,8 +93,8 @@ bne::@return: scope:[bne] from bne
VARIABLE REGISTER WEIGHTS
void bne(byte bne::jsr)
byte bne::jsr
void bne(char jsr)
char bne::jsr
void main()
Initial phi equivalence classes
@ -135,7 +135,7 @@ main: {
// [0] *lda = main::jmp -- _deref_pbuc1=vbuc2
lda #jmp
sta lda
// [1] call bne
// [1] call bne
jsr bne
jmp __b1
// main::@1
@ -153,6 +153,7 @@ main: {
rts
}
// bne
// void bne(char jsr)
bne: {
// [4] *(lda+1) = main::jmp -- _deref_pbuc1=vbuc2
lda #main.jmp
@ -180,11 +181,11 @@ Replacing jump to rts with rts in jmp a
Succesful ASM optimization Pass5DoubleJumpElimination
FINAL SYMBOL TABLE
void bne(byte bne::jsr)
byte bne::jsr
constant byte* const lda = (byte*) 1024
void bne(char jsr)
char bne::jsr
__constant char * const lda = (char *) 1024
void main()
constant byte main::jmp = 1
__constant char main::jmp = 1
@ -214,7 +215,7 @@ main: {
lda #jmp
sta lda
// bne(jmp)
// [1] call bne
// [1] call bne
jsr bne
// main::@1
// asm
@ -229,6 +230,7 @@ main: {
rts
}
// bne
// void bne(char jsr)
bne: {
// lda[1] = jsr
// [4] *(lda+1) = main::jmp -- _deref_pbuc1=vbuc2

View File

@ -1,6 +1,6 @@
void bne(byte bne::jsr)
byte bne::jsr
constant byte* const lda = (byte*) 1024
void bne(char jsr)
char bne::jsr
__constant char * const lda = (char *) 1024
void main()
constant byte main::jmp = 1
__constant char main::jmp = 1

Some files were not shown because too many files have changed in this diff Show More