1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-04-09 21:37:31 +00:00

Removed __notconst directive.

This commit is contained in:
jespergravgaard 2019-11-17 19:36:30 +01:00
parent 5d54b7c352
commit 4cd74cf0a0
37 changed files with 1511 additions and 3057 deletions

View File

@ -31,10 +31,6 @@ public interface Directive {
class Export implements Directive {
}
/** Variable declared __notconst */
class NotConst implements Directive {
}
/** Variable __ssa */
class FormSsa implements Directive {
}

View File

@ -116,8 +116,6 @@ public class DirectiveParserContext {
lValue.setDeclaredConst(true);
if(directiveType.equals(DirectiveType.ARRAY))
lValue.setDeclaredConst(true);
if(hasDirective(Directive.NotConst.class, sourceDirectives))
lValue.setDeclaredNotConst(true);
if(hasDirective(Directive.Volatile.class, sourceDirectives))
lValue.setDeclaredVolatile(true);
if(hasDirective(Directive.Export.class, sourceDirectives))

View File

@ -51,7 +51,7 @@ public class Variable implements Symbol {
/** The scope containing the variable. [ALL] */
private Scope scope;
/** The type of the variable. VAR means tha type is unknown, and has not been inferred yet. [ALL]*/
/** The type of the variable. VAR means the type is unknown, and has not been inferred yet. [ALL]*/
private SymbolType type;
/** true if the symbol type is inferred (not declared) [kind:INTERMEDIATE] TODO: Collapse with kind==INTERMEDIATE? */
@ -66,9 +66,6 @@ public class Variable implements Symbol {
/** Specifies that the variable is declared as const */
private boolean declaredConst;
/** Specifies that the variable is declared as __notconst */
private boolean declaredNotConst;
/** Specifies that the variable must always live in memory to be available for any multi-threaded accees (eg. in interrupts). [Only Variables]*/
private boolean declaredVolatile;
@ -166,7 +163,6 @@ public class Variable implements Symbol {
this.setDeclaredAsRegister(phiMaster.isDeclaredAsRegister());
this.setDeclaredNotRegister(phiMaster.isDeclaredAsNotRegister());
this.setDeclaredConst(phiMaster.isDeclaredConst());
this.setDeclaredNotConst(phiMaster.isDeclaredNotConst());
this.setDeclaredRegister(phiMaster.getDeclaredRegister());
this.setDeclaredVolatile(phiMaster.isDeclaredVolatile());
this.setDeclaredExport(phiMaster.isDeclaredExport());
@ -188,7 +184,6 @@ public class Variable implements Symbol {
this.setDeclaredAsRegister(original.isDeclaredAsRegister());
this.setDeclaredNotRegister(original.isDeclaredAsNotRegister());
this.setDeclaredConst(original.isDeclaredConst());
this.setDeclaredNotConst(original.isDeclaredNotConst());
this.setDeclaredVolatile(original.isDeclaredVolatile());
this.setDeclaredExport(original.isDeclaredExport());
this.setDeclaredRegister(original.getDeclaredRegister());
@ -389,14 +384,6 @@ public class Variable implements Symbol {
this.declaredConst = declaredConst;
}
public boolean isDeclaredNotConst() {
return declaredNotConst;
}
public void setDeclaredNotConst(boolean declaredNotConst) {
this.declaredNotConst = declaredNotConst;
}
public Integer getDeclaredAlignment() {
return declaredAlignment;
}

View File

@ -84,7 +84,6 @@ REGISTER: 'register' ;
ADDRESS: '__address' ;
ADDRESS_ZEROPAGE: '__zp' ;
ADDRESS_MAINMEM: '__mem' ;
NOTCONST: '__notconst' ;
FORM_SSA: '__ssa' ;
FORM_MA: '__ma' ;
CALLING: 'calling';

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCLexer.g4 by ANTLR 4.7
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCLexer.g4 by ANTLR 4.7.2
package dk.camelot64.kickc.parser;
@ -13,7 +13,7 @@ import org.antlr.v4.runtime.misc.*;
@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
public class KickCLexer extends Lexer {
static { RuntimeMetaData.checkVersion("4.7", RuntimeMetaData.VERSION); }
static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); }
protected static final DFA[] _decisionToDFA;
protected static final PredictionContextCache _sharedContextCache =
@ -55,74 +55,84 @@ public class KickCLexer extends Lexer {
"DEFAULT_MODE", "ASM_MODE"
};
public static final String[] ruleNames = {
"CURLY_BEGIN", "CURLY_END", "BRACKET_BEGIN", "BRACKET_END", "PAR_BEGIN",
"PAR_END", "SEMICOLON", "COLON", "COMMA", "RANGE", "CONDITION", "DOT",
"ARROW", "PLUS", "MINUS", "ASTERISK", "DIVIDE", "MODULO", "INC", "DEC",
"AND", "BIT_NOT", "BIT_XOR", "BIT_OR", "SHIFT_LEFT", "SHIFT_RIGHT", "EQUAL",
"NOT_EQUAL", "LESS_THAN", "LESS_THAN_EQUAL", "GREATER_THAN_EQUAL", "GREATER_THAN",
"LOGIC_AND", "LOGIC_OR", "ASSIGN", "ASSIGN_COMPOUND", "IMPORT", "TYPEDEF",
"PRAGMA", "RESERVE", "PC", "TARGET", "LINK", "CPU", "CODESEG", "DATASEG",
"ENCODING", "CONST", "EXTERN", "EXPORT", "ALIGN", "INLINE", "VOLATILE",
"INTERRUPT", "REGISTER", "ADDRESS", "ADDRESS_ZEROPAGE", "ADDRESS_MAINMEM",
"NOTCONST", "FORM_SSA", "FORM_MA", "CALLING", "CALLINGCONVENTION", "IF",
"ELSE", "WHILE", "DO", "FOR", "SWITCH", "RETURN", "BREAK", "CONTINUE",
"ASM", "DEFAULT", "CASE", "STRUCT", "ENUM", "SIZEOF", "TYPEID", "KICKASM",
"RESOURCE", "USES", "CLOBBERS", "BYTES", "CYCLES", "LOGIC_NOT", "SIGNEDNESS",
"SIMPLETYPE", "BOOLEAN", "KICKASM_BODY", "STRING", "CHAR", "NUMBER", "NUMFLOAT",
"BINFLOAT", "DECFLOAT", "HEXFLOAT", "NUMINT", "BININTEGER", "DECINTEGER",
"HEXINTEGER", "BINDIGIT", "DECDIGIT", "HEXDIGIT", "NAME", "NAME_START",
"NAME_CHAR", "WS", "COMMENT_LINE", "COMMENT_BLOCK", "ASM_BYTE", "ASM_MNEMONIC",
"ASM_IMM", "ASM_COLON", "ASM_COMMA", "ASM_PAR_BEGIN", "ASM_PAR_END", "ASM_BRACKET_BEGIN",
"ASM_BRACKET_END", "ASM_DOT", "ASM_SHIFT_LEFT", "ASM_SHIFT_RIGHT", "ASM_PLUS",
"ASM_MINUS", "ASM_LESS_THAN", "ASM_GREATER_THAN", "ASM_MULTIPLY", "ASM_DIVIDE",
"ASM_CURLY_BEGIN", "ASM_CURLY_END", "ASM_NUMBER", "ASM_NUMFLOAT", "ASM_BINFLOAT",
"ASM_DECFLOAT", "ASM_HEXFLOAT", "ASM_NUMINT", "ASM_BININTEGER", "ASM_DECINTEGER",
"ASM_HEXINTEGER", "ASM_BINDIGIT", "ASM_DECDIGIT", "ASM_HEXDIGIT", "ASM_CHAR",
"ASM_MULTI_REL", "ASM_MULTI_NAME", "ASM_NAME", "ASM_NAME_START", "ASM_NAME_CHAR",
"ASM_WS", "ASM_COMMENT_LINE", "ASM_COMMENT_BLOCK"
};
private static String[] makeRuleNames() {
return new String[] {
"CURLY_BEGIN", "CURLY_END", "BRACKET_BEGIN", "BRACKET_END", "PAR_BEGIN",
"PAR_END", "SEMICOLON", "COLON", "COMMA", "RANGE", "CONDITION", "DOT",
"ARROW", "PLUS", "MINUS", "ASTERISK", "DIVIDE", "MODULO", "INC", "DEC",
"AND", "BIT_NOT", "BIT_XOR", "BIT_OR", "SHIFT_LEFT", "SHIFT_RIGHT", "EQUAL",
"NOT_EQUAL", "LESS_THAN", "LESS_THAN_EQUAL", "GREATER_THAN_EQUAL", "GREATER_THAN",
"LOGIC_AND", "LOGIC_OR", "ASSIGN", "ASSIGN_COMPOUND", "IMPORT", "TYPEDEF",
"PRAGMA", "RESERVE", "PC", "TARGET", "LINK", "CPU", "CODESEG", "DATASEG",
"ENCODING", "CONST", "EXTERN", "EXPORT", "ALIGN", "INLINE", "VOLATILE",
"INTERRUPT", "REGISTER", "ADDRESS", "ADDRESS_ZEROPAGE", "ADDRESS_MAINMEM",
"NOTCONST", "FORM_SSA", "FORM_MA", "CALLING", "CALLINGCONVENTION", "IF",
"ELSE", "WHILE", "DO", "FOR", "SWITCH", "RETURN", "BREAK", "CONTINUE",
"ASM", "DEFAULT", "CASE", "STRUCT", "ENUM", "SIZEOF", "TYPEID", "KICKASM",
"RESOURCE", "USES", "CLOBBERS", "BYTES", "CYCLES", "LOGIC_NOT", "SIGNEDNESS",
"SIMPLETYPE", "BOOLEAN", "KICKASM_BODY", "STRING", "CHAR", "NUMBER",
"NUMFLOAT", "BINFLOAT", "DECFLOAT", "HEXFLOAT", "NUMINT", "BININTEGER",
"DECINTEGER", "HEXINTEGER", "BINDIGIT", "DECDIGIT", "HEXDIGIT", "NAME",
"NAME_START", "NAME_CHAR", "WS", "COMMENT_LINE", "COMMENT_BLOCK", "ASM_BYTE",
"ASM_MNEMONIC", "ASM_IMM", "ASM_COLON", "ASM_COMMA", "ASM_PAR_BEGIN",
"ASM_PAR_END", "ASM_BRACKET_BEGIN", "ASM_BRACKET_END", "ASM_DOT", "ASM_SHIFT_LEFT",
"ASM_SHIFT_RIGHT", "ASM_PLUS", "ASM_MINUS", "ASM_LESS_THAN", "ASM_GREATER_THAN",
"ASM_MULTIPLY", "ASM_DIVIDE", "ASM_CURLY_BEGIN", "ASM_CURLY_END", "ASM_NUMBER",
"ASM_NUMFLOAT", "ASM_BINFLOAT", "ASM_DECFLOAT", "ASM_HEXFLOAT", "ASM_NUMINT",
"ASM_BININTEGER", "ASM_DECINTEGER", "ASM_HEXINTEGER", "ASM_BINDIGIT",
"ASM_DECDIGIT", "ASM_HEXDIGIT", "ASM_CHAR", "ASM_MULTI_REL", "ASM_MULTI_NAME",
"ASM_NAME", "ASM_NAME_START", "ASM_NAME_CHAR", "ASM_WS", "ASM_COMMENT_LINE",
"ASM_COMMENT_BLOCK"
};
}
public static final String[] ruleNames = makeRuleNames();
private static final String[] _LITERAL_NAMES = {
null, null, null, null, null, null, null, null, "';'", null, null, "'..'",
"'?'", null, "'->'", null, null, null, null, "'%'", "'++'", "'--'", "'&'",
"'~'", "'^'", "'|'", null, null, "'=='", "'!='", null, "'<='", "'>='",
null, "'&&'", "'||'", "'='", null, "'import'", "'typedef'", "'#pragma'",
"'reserve'", "'pc'", "'target'", "'link'", "'cpu'", "'code_seg'", "'data_seg'",
"'encoding'", "'const'", "'extern'", "'export'", "'align'", "'inline'",
"'volatile'", "'interrupt'", "'register'", "'__address'", "'__zp'", "'__mem'",
"'__notconst'", "'__ssa'", "'__ma'", "'calling'", null, "'if'", "'else'",
"'while'", "'do'", "'for'", "'switch'", "'return'", "'break'", "'continue'",
"'asm'", "'default'", "'case'", "'struct'", "'enum'", "'sizeof'", "'typeid'",
"'kickasm'", "'resource'", "'uses'", "'clobbers'", "'bytes'", "'cycles'",
"'!'", null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, "'.byte'", null, "'#'"
};
private static final String[] _SYMBOLIC_NAMES = {
null, "TYPEDEFNAME", "CURLY_BEGIN", "CURLY_END", "BRACKET_BEGIN", "BRACKET_END",
"PAR_BEGIN", "PAR_END", "SEMICOLON", "COLON", "COMMA", "RANGE", "CONDITION",
"DOT", "ARROW", "PLUS", "MINUS", "ASTERISK", "DIVIDE", "MODULO", "INC",
"DEC", "AND", "BIT_NOT", "BIT_XOR", "BIT_OR", "SHIFT_LEFT", "SHIFT_RIGHT",
"EQUAL", "NOT_EQUAL", "LESS_THAN", "LESS_THAN_EQUAL", "GREATER_THAN_EQUAL",
"GREATER_THAN", "LOGIC_AND", "LOGIC_OR", "ASSIGN", "ASSIGN_COMPOUND",
"IMPORT", "TYPEDEF", "PRAGMA", "RESERVE", "PC", "TARGET", "LINK", "CPU",
"CODESEG", "DATASEG", "ENCODING", "CONST", "EXTERN", "EXPORT", "ALIGN",
"INLINE", "VOLATILE", "INTERRUPT", "REGISTER", "ADDRESS", "ADDRESS_ZEROPAGE",
"ADDRESS_MAINMEM", "NOTCONST", "FORM_SSA", "FORM_MA", "CALLING", "CALLINGCONVENTION",
"IF", "ELSE", "WHILE", "DO", "FOR", "SWITCH", "RETURN", "BREAK", "CONTINUE",
"ASM", "DEFAULT", "CASE", "STRUCT", "ENUM", "SIZEOF", "TYPEID", "KICKASM",
"RESOURCE", "USES", "CLOBBERS", "BYTES", "CYCLES", "LOGIC_NOT", "SIGNEDNESS",
"SIMPLETYPE", "BOOLEAN", "KICKASM_BODY", "STRING", "CHAR", "NUMBER", "NUMFLOAT",
"BINFLOAT", "DECFLOAT", "HEXFLOAT", "NUMINT", "BININTEGER", "DECINTEGER",
"HEXINTEGER", "NAME", "WS", "COMMENT_LINE", "COMMENT_BLOCK", "ASM_BYTE",
"ASM_MNEMONIC", "ASM_IMM", "ASM_COLON", "ASM_COMMA", "ASM_PAR_BEGIN",
"ASM_PAR_END", "ASM_BRACKET_BEGIN", "ASM_BRACKET_END", "ASM_DOT", "ASM_SHIFT_LEFT",
"ASM_SHIFT_RIGHT", "ASM_PLUS", "ASM_MINUS", "ASM_LESS_THAN", "ASM_GREATER_THAN",
"ASM_MULTIPLY", "ASM_DIVIDE", "ASM_CURLY_BEGIN", "ASM_CURLY_END", "ASM_NUMBER",
"ASM_NUMFLOAT", "ASM_BINFLOAT", "ASM_DECFLOAT", "ASM_HEXFLOAT", "ASM_NUMINT",
"ASM_BININTEGER", "ASM_DECINTEGER", "ASM_HEXINTEGER", "ASM_CHAR", "ASM_MULTI_REL",
"ASM_MULTI_NAME", "ASM_NAME", "ASM_WS", "ASM_COMMENT_LINE", "ASM_COMMENT_BLOCK"
};
private static String[] makeLiteralNames() {
return new String[] {
null, null, null, null, null, null, null, null, "';'", null, null, "'..'",
"'?'", null, "'->'", null, null, null, null, "'%'", "'++'", "'--'", "'&'",
"'~'", "'^'", "'|'", null, null, "'=='", "'!='", null, "'<='", "'>='",
null, "'&&'", "'||'", "'='", null, "'import'", "'typedef'", "'#pragma'",
"'reserve'", "'pc'", "'target'", "'link'", "'cpu'", "'code_seg'", "'data_seg'",
"'encoding'", "'const'", "'extern'", "'export'", "'align'", "'inline'",
"'volatile'", "'interrupt'", "'register'", "'__address'", "'__zp'", "'__mem'",
"'__notconst'", "'__ssa'", "'__ma'", "'calling'", null, "'if'", "'else'",
"'while'", "'do'", "'for'", "'switch'", "'return'", "'break'", "'continue'",
"'asm'", "'default'", "'case'", "'struct'", "'enum'", "'sizeof'", "'typeid'",
"'kickasm'", "'resource'", "'uses'", "'clobbers'", "'bytes'", "'cycles'",
"'!'", null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, "'.byte'", null, "'#'"
};
}
private static final String[] _LITERAL_NAMES = makeLiteralNames();
private static String[] makeSymbolicNames() {
return new String[] {
null, "TYPEDEFNAME", "CURLY_BEGIN", "CURLY_END", "BRACKET_BEGIN", "BRACKET_END",
"PAR_BEGIN", "PAR_END", "SEMICOLON", "COLON", "COMMA", "RANGE", "CONDITION",
"DOT", "ARROW", "PLUS", "MINUS", "ASTERISK", "DIVIDE", "MODULO", "INC",
"DEC", "AND", "BIT_NOT", "BIT_XOR", "BIT_OR", "SHIFT_LEFT", "SHIFT_RIGHT",
"EQUAL", "NOT_EQUAL", "LESS_THAN", "LESS_THAN_EQUAL", "GREATER_THAN_EQUAL",
"GREATER_THAN", "LOGIC_AND", "LOGIC_OR", "ASSIGN", "ASSIGN_COMPOUND",
"IMPORT", "TYPEDEF", "PRAGMA", "RESERVE", "PC", "TARGET", "LINK", "CPU",
"CODESEG", "DATASEG", "ENCODING", "CONST", "EXTERN", "EXPORT", "ALIGN",
"INLINE", "VOLATILE", "INTERRUPT", "REGISTER", "ADDRESS", "ADDRESS_ZEROPAGE",
"ADDRESS_MAINMEM", "NOTCONST", "FORM_SSA", "FORM_MA", "CALLING", "CALLINGCONVENTION",
"IF", "ELSE", "WHILE", "DO", "FOR", "SWITCH", "RETURN", "BREAK", "CONTINUE",
"ASM", "DEFAULT", "CASE", "STRUCT", "ENUM", "SIZEOF", "TYPEID", "KICKASM",
"RESOURCE", "USES", "CLOBBERS", "BYTES", "CYCLES", "LOGIC_NOT", "SIGNEDNESS",
"SIMPLETYPE", "BOOLEAN", "KICKASM_BODY", "STRING", "CHAR", "NUMBER",
"NUMFLOAT", "BINFLOAT", "DECFLOAT", "HEXFLOAT", "NUMINT", "BININTEGER",
"DECINTEGER", "HEXINTEGER", "NAME", "WS", "COMMENT_LINE", "COMMENT_BLOCK",
"ASM_BYTE", "ASM_MNEMONIC", "ASM_IMM", "ASM_COLON", "ASM_COMMA", "ASM_PAR_BEGIN",
"ASM_PAR_END", "ASM_BRACKET_BEGIN", "ASM_BRACKET_END", "ASM_DOT", "ASM_SHIFT_LEFT",
"ASM_SHIFT_RIGHT", "ASM_PLUS", "ASM_MINUS", "ASM_LESS_THAN", "ASM_GREATER_THAN",
"ASM_MULTIPLY", "ASM_DIVIDE", "ASM_CURLY_BEGIN", "ASM_CURLY_END", "ASM_NUMBER",
"ASM_NUMFLOAT", "ASM_BINFLOAT", "ASM_DECFLOAT", "ASM_HEXFLOAT", "ASM_NUMINT",
"ASM_BININTEGER", "ASM_DECINTEGER", "ASM_HEXINTEGER", "ASM_CHAR", "ASM_MULTI_REL",
"ASM_MULTI_NAME", "ASM_NAME", "ASM_WS", "ASM_COMMENT_LINE", "ASM_COMMENT_BLOCK"
};
}
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
/**

View File

@ -57,89 +57,88 @@ REGISTER=56
ADDRESS=57
ADDRESS_ZEROPAGE=58
ADDRESS_MAINMEM=59
NOTCONST=60
FORM_SSA=61
FORM_MA=62
CALLING=63
CALLINGCONVENTION=64
IF=65
ELSE=66
WHILE=67
DO=68
FOR=69
SWITCH=70
RETURN=71
BREAK=72
CONTINUE=73
ASM=74
DEFAULT=75
CASE=76
STRUCT=77
ENUM=78
SIZEOF=79
TYPEID=80
KICKASM=81
RESOURCE=82
USES=83
CLOBBERS=84
BYTES=85
CYCLES=86
LOGIC_NOT=87
SIGNEDNESS=88
SIMPLETYPE=89
BOOLEAN=90
KICKASM_BODY=91
STRING=92
CHAR=93
NUMBER=94
NUMFLOAT=95
BINFLOAT=96
DECFLOAT=97
HEXFLOAT=98
NUMINT=99
BININTEGER=100
DECINTEGER=101
HEXINTEGER=102
NAME=103
WS=104
COMMENT_LINE=105
COMMENT_BLOCK=106
ASM_BYTE=107
ASM_MNEMONIC=108
ASM_IMM=109
ASM_COLON=110
ASM_COMMA=111
ASM_PAR_BEGIN=112
ASM_PAR_END=113
ASM_BRACKET_BEGIN=114
ASM_BRACKET_END=115
ASM_DOT=116
ASM_SHIFT_LEFT=117
ASM_SHIFT_RIGHT=118
ASM_PLUS=119
ASM_MINUS=120
ASM_LESS_THAN=121
ASM_GREATER_THAN=122
ASM_MULTIPLY=123
ASM_DIVIDE=124
ASM_CURLY_BEGIN=125
ASM_CURLY_END=126
ASM_NUMBER=127
ASM_NUMFLOAT=128
ASM_BINFLOAT=129
ASM_DECFLOAT=130
ASM_HEXFLOAT=131
ASM_NUMINT=132
ASM_BININTEGER=133
ASM_DECINTEGER=134
ASM_HEXINTEGER=135
ASM_CHAR=136
ASM_MULTI_REL=137
ASM_MULTI_NAME=138
ASM_NAME=139
ASM_WS=140
ASM_COMMENT_LINE=141
ASM_COMMENT_BLOCK=142
FORM_SSA=60
FORM_MA=61
CALLING=62
CALLINGCONVENTION=63
IF=64
ELSE=65
WHILE=66
DO=67
FOR=68
SWITCH=69
RETURN=70
BREAK=71
CONTINUE=72
ASM=73
DEFAULT=74
CASE=75
STRUCT=76
ENUM=77
SIZEOF=78
TYPEID=79
KICKASM=80
RESOURCE=81
USES=82
CLOBBERS=83
BYTES=84
CYCLES=85
LOGIC_NOT=86
SIGNEDNESS=87
SIMPLETYPE=88
BOOLEAN=89
KICKASM_BODY=90
STRING=91
CHAR=92
NUMBER=93
NUMFLOAT=94
BINFLOAT=95
DECFLOAT=96
HEXFLOAT=97
NUMINT=98
BININTEGER=99
DECINTEGER=100
HEXINTEGER=101
NAME=102
WS=103
COMMENT_LINE=104
COMMENT_BLOCK=105
ASM_BYTE=106
ASM_MNEMONIC=107
ASM_IMM=108
ASM_COLON=109
ASM_COMMA=110
ASM_PAR_BEGIN=111
ASM_PAR_END=112
ASM_BRACKET_BEGIN=113
ASM_BRACKET_END=114
ASM_DOT=115
ASM_SHIFT_LEFT=116
ASM_SHIFT_RIGHT=117
ASM_PLUS=118
ASM_MINUS=119
ASM_LESS_THAN=120
ASM_GREATER_THAN=121
ASM_MULTIPLY=122
ASM_DIVIDE=123
ASM_CURLY_BEGIN=124
ASM_CURLY_END=125
ASM_NUMBER=126
ASM_NUMFLOAT=127
ASM_BINFLOAT=128
ASM_DECFLOAT=129
ASM_HEXFLOAT=130
ASM_NUMINT=131
ASM_BININTEGER=132
ASM_DECINTEGER=133
ASM_HEXINTEGER=134
ASM_CHAR=135
ASM_MULTI_REL=136
ASM_MULTI_NAME=137
ASM_NAME=138
ASM_WS=139
ASM_COMMENT_LINE=140
ASM_COMMENT_BLOCK=141
';'=8
'..'=11
'?'=12
@ -180,32 +179,31 @@ ASM_COMMENT_BLOCK=142
'__address'=57
'__zp'=58
'__mem'=59
'__notconst'=60
'__ssa'=61
'__ma'=62
'calling'=63
'if'=65
'else'=66
'while'=67
'do'=68
'for'=69
'switch'=70
'return'=71
'break'=72
'continue'=73
'asm'=74
'default'=75
'case'=76
'struct'=77
'enum'=78
'sizeof'=79
'typeid'=80
'kickasm'=81
'resource'=82
'uses'=83
'clobbers'=84
'bytes'=85
'cycles'=86
'!'=87
'.byte'=107
'#'=109
'__ssa'=60
'__ma'=61
'calling'=62
'if'=64
'else'=65
'while'=66
'do'=67
'for'=68
'switch'=69
'return'=70
'break'=71
'continue'=72
'asm'=73
'default'=74
'case'=75
'struct'=76
'enum'=77
'sizeof'=78
'typeid'=79
'kickasm'=80
'resource'=81
'uses'=82
'clobbers'=83
'bytes'=84
'cycles'=85
'!'=86
'.byte'=106
'#'=108

View File

@ -96,7 +96,6 @@ globalDirective
directive
: CONST #directiveConst
| NOTCONST #directiveNotConst
| ALIGN PAR_BEGIN NUMBER PAR_END #directiveAlign
| REGISTER ( PAR_BEGIN ( NAME ) PAR_END)? #directiveRegister
| ADDRESS_ZEROPAGE #directiveMemoryAreaZp

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7.2
package dk.camelot64.kickc.parser;
@ -325,18 +325,6 @@ public class KickCParserBaseListener implements KickCParserListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitDirectiveConst(KickCParser.DirectiveConstContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterDirectiveNotConst(KickCParser.DirectiveNotConstContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitDirectiveNotConst(KickCParser.DirectiveNotConstContext ctx) { }
/**
* {@inheritDoc}
*

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7.2
package dk.camelot64.kickc.parser;
@ -195,13 +195,6 @@ public class KickCParserBaseVisitor<T> extends AbstractParseTreeVisitor<T> imple
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitDirectiveConst(KickCParser.DirectiveConstContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitDirectiveNotConst(KickCParser.DirectiveNotConstContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7.2
package dk.camelot64.kickc.parser;
@ -297,18 +297,6 @@ public interface KickCParserListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitDirectiveConst(KickCParser.DirectiveConstContext ctx);
/**
* Enter a parse tree produced by the {@code directiveNotConst}
* labeled alternative in {@link KickCParser#directive}.
* @param ctx the parse tree
*/
void enterDirectiveNotConst(KickCParser.DirectiveNotConstContext ctx);
/**
* Exit a parse tree produced by the {@code directiveNotConst}
* labeled alternative in {@link KickCParser#directive}.
* @param ctx the parse tree
*/
void exitDirectiveNotConst(KickCParser.DirectiveNotConstContext ctx);
/**
* Enter a parse tree produced by the {@code directiveAlign}
* labeled alternative in {@link KickCParser#directive}.

View File

@ -1,4 +1,4 @@
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7
// Generated from /Users/jespergravgaard/c64/kickc/src/main/java/dk/camelot64/kickc/parser/KickCParser.g4 by ANTLR 4.7.2
package dk.camelot64.kickc.parser;
@ -182,13 +182,6 @@ public interface KickCParserVisitor<T> extends ParseTreeVisitor<T> {
* @return the visitor result
*/
T visitDirectiveConst(KickCParser.DirectiveConstContext ctx);
/**
* Visit a parse tree produced by the {@code directiveNotConst}
* labeled alternative in {@link KickCParser#directive}.
* @param ctx the parse tree
* @return the visitor result
*/
T visitDirectiveNotConst(KickCParser.DirectiveNotConstContext ctx);
/**
* Visit a parse tree produced by the {@code directiveAlign}
* labeled alternative in {@link KickCParser#directive}.

View File

@ -733,11 +733,6 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
return new Directive.Const();
}
@Override
public Object visitDirectiveNotConst(KickCParser.DirectiveNotConstContext ctx) {
return new Directive.NotConst();
}
@Override
public Object visitDirectiveInline(KickCParser.DirectiveInlineContext ctx) {
return new Directive.Inline();
@ -1442,7 +1437,6 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
Variable constVar = new Variable(lValue.getName(), scope, lValue.getType(), lValue.getDataSegment(), constantValue);
scope.add(constVar);
constVar.setDeclaredConst(lValue.isDeclaredConst());
constVar.setDeclaredNotConst(lValue.isDeclaredNotConst());
constVar.setDeclaredRegister(lValue.getDeclaredRegister());
constVar.setMemoryArea(lValue.getMemoryArea());
constVar.setDeclaredAsRegister(lValue.isDeclaredAsRegister());

View File

@ -38,9 +38,6 @@ public class Pass1EarlyConstantIdentification extends Pass1Base {
for(Variable variable : getProgram().getScope().getAllVariables(true)) {
SymbolVariableRef variableRef = variable.getRef();
if(!variable.isDeclaredConst() && !variable.isVolatile() && !variableRef.isIntermediate()) {
if(variable.isDeclaredNotConst())
// Skip explicit non-constants
continue;
if(variable.getScope() instanceof StructDefinition)
// Skip structs
continue;
@ -128,7 +125,6 @@ public class Pass1EarlyConstantIdentification extends Pass1Base {
constVar.setDeclaredAsRegister(variable.isDeclaredAsRegister());
constVar.setDeclaredNotRegister(variable.isDeclaredAsNotRegister());
constVar.setDeclaredConst(variable.isDeclaredConst());
constVar.setDeclaredNotConst(variable.isDeclaredNotConst());
constVar.setDeclaredRegister(variable.getDeclaredRegister());
constVar.setDeclaredVolatile(variable.isDeclaredVolatile());
constVar.setDeclaredExport(variable.isDeclaredExport());

View File

@ -216,7 +216,6 @@ public class Pass1UnwindStructValues extends Pass1Base {
memberVariable.setDeclaredVolatile(variable.isDeclaredVolatile());
memberVariable.setInferredVolatile(variable.isInferredVolatile());
memberVariable.setDeclaredConst(variable.isDeclaredConst());
memberVariable.setDeclaredNotConst(variable.isDeclaredNotConst());
memberVariable.setDeclaredExport(variable.isDeclaredExport());
variableUnwinding.setMemberUnwinding(member.getLocalName(), memberVariable.getRef());
getLog().append("Created struct value member variable " + memberVariable.toString(getProgram()));

View File

@ -152,7 +152,7 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization {
if(lValue instanceof VariableRef) {
VariableRef varRef = (VariableRef) lValue;
Variable var = getScope().getVariable(varRef);
if(var.isVolatile() || var.isDeclaredNotConst() || var.isKindLoadStore())
if(var.isVolatile() || var.isKindLoadStore())
// Do not examine volatiles and non-versioned variables
continue;
ConstantValue constant = getConstant(assignment.getrValue2());
@ -168,7 +168,7 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization {
if(getConstant(phiRValue.getrValue()) != null) {
VariableRef varRef = phiVariable.getVariable();
Variable var = getScope().getVariable(varRef);
if(var.isVolatile() || var.isDeclaredNotConst() || var.isKindLoadStore())
if(var.isVolatile() || var.isKindLoadStore())
// Do not examine volatiles and non-versioned variables
continue;
ConstantValue constant = getConstant(phiRValue.getrValue());
@ -182,7 +182,7 @@ public class Pass2ConstantIdentification extends Pass2SsaOptimization {
// Look for constants among non-versioned variables
for(Variable variable : getScope().getAllVariables(true)) {
if(variable.isVolatile() || variable.isDeclaredNotConst() || !variable.isKindLoadStore())
if(variable.isVolatile() || !variable.isKindLoadStore())
// Do not examine volatiles, non-constants or versioned variables
continue;
List<StatementLValue> assignments = getGraph().getAssignments(variable.getRef());

View File

@ -47,16 +47,6 @@ public class TestPrograms {
compileAndCompare("static-register-optimization-problem");
}
@Test
public void testDeclaredNotConstVar1() throws IOException, URISyntaxException {
compileAndCompare("declared-notconst-var-1");
}
@Test
public void testDeclaredNotConstVar0() throws IOException, URISyntaxException {
compileAndCompare("declared-notconst-var-0");
}
@Test
public void testDeclaredSsaVar0() throws IOException, URISyntaxException {
compileAndCompare("declared-ssa-var-0");
@ -824,20 +814,22 @@ public class TestPrograms {
compileAndCompare("struct-ptr-32");
}
@Test
public void testStructPtr31() throws IOException, URISyntaxException {
compileAndCompare("struct-ptr-31");
}
// TODO: Fix problem with structs containing arrays
// @Test
// public void testStructPtr31() throws IOException, URISyntaxException {
// compileAndCompare("struct-ptr-31");
// }
@Test
public void testStructPtr30() throws IOException, URISyntaxException {
compileAndCompare("struct-ptr-30");
}
@Test
public void testStructPtr29() throws IOException, URISyntaxException {
compileAndCompare("struct-ptr-29");
}
// TODO: Fix problem with structs containing pointer elements
//@Test
//public void testStructPtr29() throws IOException, URISyntaxException {
// compileAndCompare("struct-ptr-29");
//}
// TODO: Fix problem with stack-allocated structs that contain arrays!
// https://gitlab.com/camelot/kickc/issues/314

View File

@ -6,7 +6,7 @@ struct foo {
char thing2;
};
__mem __ma __notconst struct foo bar = { 'a', 'b' };
__mem __ma struct foo bar = { 'a', 'b' };
void main(void) {
const char* SCREEN = 0x0400;

View File

@ -9,14 +9,9 @@ void main(void) {
char __ssa __address(0x10) reg_zp_abs = '.';
char __ssa __mem reg_mem_flex = '.';
char __ssa __address(0x1000) reg_mem_abs = '.';
char __ma __notconst __zp notreg_zp_flex = '.';
char __ma __notconst __address(0x10) notreg_zp_abs = '.';
char __ma __notconst __mem notreg_mem_flex = '.';
char __ma __notconst __address(0x1000) notreg_mem_abs = '.';
char default_default = '.';
char reg_default = '.';
char __ma __notconst notreg_default = '.';
char __ssa __zp default_zp_flex = '.';
char __address(0x10) default_zp_abs = '.';
char __mem default_mem_flex = '.';
@ -26,14 +21,9 @@ void main(void) {
out(reg_zp_abs);
out(reg_mem_flex);
out(reg_mem_abs);
out(notreg_zp_flex);
out(notreg_zp_abs);
out(notreg_mem_flex);
out(notreg_mem_abs);
out(default_default);
out(reg_default);
out(notreg_default);
out(default_zp_flex);
out(default_zp_abs);
out(default_mem_flex);

View File

@ -1,11 +0,0 @@
// Tests declaring a (constant) variable as __notconst
char __notconst size = 40;
const char* SCREEN = 0x0400;
void main() {
for( char i=0;i<size;i++ ) {
SCREEN[i] = '*';
}
}

View File

@ -1,11 +0,0 @@
// Tests declaring a (constant) variable as __notconst
__notconst char size = 40;
__notconst char* SCREEN = 0x0400;
void main() {
for( char i=0;i<size;i++ ) {
SCREEN[i] = '*';
}
}

View File

@ -1,22 +1,15 @@
// Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store)
// Test a memory variable struct value
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
:BasicUpstart(main)
.pc = $80d "Program"
__bbegin:
lda #'a'
sta bar_thing1
lda #'b'
sta bar_thing2
jsr main
rts
.const bar_thing1 = 'a'
.const bar_thing2 = 'b'
main: {
.label SCREEN = $400
lda bar_thing1
lda #bar_thing1
sta SCREEN
lda bar_thing2
lda #bar_thing2
sta SCREEN+1
rts
}
bar_thing1: .byte 0
bar_thing2: .byte 0

View File

@ -1,19 +1,18 @@
@begin: scope:[] from
[0] (byte) bar_thing1 ← (byte) 'a'
[1] (byte) bar_thing2 ← (byte) 'b'
[0] phi()
to:@1
@1: scope:[] from @begin
[2] phi()
[3] call main
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[4] phi()
[3] phi()
(void()) main()
main: scope:[main] from @1
[5] *((const byte*) main::SCREEN) ← (byte) bar_thing1
[6] *((const byte*) main::SCREEN+(byte) 1) ← (byte) bar_thing2
[4] *((const byte*) main::SCREEN) ← (const byte) bar_thing1
[5] *((const byte*) main::SCREEN+(byte) 1) ← (const byte) bar_thing2
to:main::@return
main::@return: scope:[main] from main
[7] return
[6] return
to:@return

View File

@ -5,19 +5,19 @@ Adding struct value list initializer (byte) bar_thing1 ← (byte) 'a'
Adding struct value list initializer (byte) bar_thing2 ← (byte) 'b'
Replacing struct member reference (struct foo) bar.thing1 with member unwinding reference (byte) bar_thing1
Replacing struct member reference (struct foo) bar.thing2 with member unwinding reference (byte) bar_thing2
Identified constant variable (byte) bar_thing1
Identified constant variable (byte) bar_thing2
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte) bar_thing1 ← (byte) 'a'
(byte) bar_thing2 ← (byte) 'b'
to:@1
(void()) main()
main: scope:[main] from @1
(byte) main::i#0 ← (number) 0
*((const byte*) main::SCREEN + (byte) main::i#0) ← (byte) bar_thing1
*((const byte*) main::SCREEN + (byte) main::i#0) ← (const byte) bar_thing1
(byte) main::i#1 ← ++ (byte) main::i#0
*((const byte*) main::SCREEN + (byte) main::i#1) ← (byte) bar_thing2
*((const byte*) main::SCREEN + (byte) main::i#1) ← (const byte) bar_thing2
(byte) main::i#2 ← ++ (byte) main::i#1
to:main::@return
main::@return: scope:[main] from main
@ -35,8 +35,8 @@ SYMBOL TABLE SSA
(label) @2
(label) @begin
(label) @end
(byte) bar_thing1 notregister
(byte) bar_thing2 notregister
(const byte) bar_thing1 = (byte) 'a'
(const byte) bar_thing2 = (byte) 'b'
(byte) foo::thing1
(byte) foo::thing2
(void()) main()
@ -58,11 +58,11 @@ Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Simplifying expression containing zero main::SCREEN in [3] *((const byte*) main::SCREEN + (const byte) main::i#0) ← (byte) bar_thing1
Simplifying expression containing zero main::SCREEN in [1] *((const byte*) main::SCREEN + (const byte) main::i#0) ← (const byte) bar_thing1
Successful SSA optimization PassNSimplifyExpressionWithZero
Eliminating unused variable (byte) main::i#2 and assignment [5] (byte) main::i#2 ← ++ (byte) main::i#1
Eliminating unused variable (byte) main::i#2 and assignment [3] (byte) main::i#2 ← ++ (byte) main::i#1
Successful SSA optimization PassNEliminateUnusedVars
Constant right-side identified [3] (byte) main::i#1 ← ++ (const byte) main::i#0
Constant right-side identified [1] (byte) main::i#1 ← ++ (const byte) main::i#0
Successful SSA optimization Pass2ConstantRValueConsolidation
Constant (const byte) main::i#1 = ++main::i#0
Successful SSA optimization Pass2ConstantIdentification
@ -75,56 +75,49 @@ Consolidated array index constant in *(main::SCREEN+++0)
Successful SSA optimization Pass2ConstantAdditionElimination
Simplifying constant integer increment ++0
Successful SSA optimization Pass2ConstantSimplification
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
CALL GRAPH
Calls in [] to main:3
Calls in [] to main:2
Created 0 initial phi equivalence classes
Coalesced down to 0 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
[0] (byte) bar_thing1 ← (byte) 'a'
[1] (byte) bar_thing2 ← (byte) 'b'
[0] phi()
to:@1
@1: scope:[] from @begin
[2] phi()
[3] call main
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[4] phi()
[3] phi()
(void()) main()
main: scope:[main] from @1
[5] *((const byte*) main::SCREEN) ← (byte) bar_thing1
[6] *((const byte*) main::SCREEN+(byte) 1) ← (byte) bar_thing2
[4] *((const byte*) main::SCREEN) ← (const byte) bar_thing1
[5] *((const byte*) main::SCREEN+(byte) 1) ← (const byte) bar_thing2
to:main::@return
main::@return: scope:[main] from main
[7] return
[6] return
to:@return
VARIABLE REGISTER WEIGHTS
(byte) bar_thing1 notregister 1.3333333333333333
(byte) bar_thing2 notregister 1.3333333333333333
(byte) foo::thing1
(byte) foo::thing2
(void()) main()
(byte) main::i
Initial phi equivalence classes
Added variable bar_thing1 to zero page equivalence class [ bar_thing1 ]
Added variable bar_thing2 to zero page equivalence class [ bar_thing2 ]
Complete equivalence classes
[ bar_thing1 ]
[ bar_thing2 ]
Allocated mem[1] [ bar_thing1 ]
Allocated mem[1] [ bar_thing2 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
@ -136,22 +129,18 @@ Target platform is c64basic / MOS6502X
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.const bar_thing1 = 'a'
.const bar_thing2 = 'b'
// @begin
__bbegin:
// [0] (byte) bar_thing1 ← (byte) 'a' -- vbum1=vbuc1
lda #'a'
sta bar_thing1
// [1] (byte) bar_thing2 ← (byte) 'b' -- vbum1=vbuc1
lda #'b'
sta bar_thing2
// [2] phi from @begin to @1 [phi:@begin->@1]
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [3] call main
// [2] call main
jsr main
// [4] phi from @1 to @end [phi:@1->@end]
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
@ -159,42 +148,32 @@ __bend:
// main
main: {
.label SCREEN = $400
// [5] *((const byte*) main::SCREEN) ← (byte) bar_thing1 -- _deref_pbuc1=vbum1
lda bar_thing1
// [4] *((const byte*) main::SCREEN) ← (const byte) bar_thing1 -- _deref_pbuc1=vbuc2
lda #bar_thing1
sta SCREEN
// [6] *((const byte*) main::SCREEN+(byte) 1) ← (byte) bar_thing2 -- _deref_pbuc1=vbum1
lda bar_thing2
// [5] *((const byte*) main::SCREEN+(byte) 1) ← (const byte) bar_thing2 -- _deref_pbuc1=vbuc2
lda #bar_thing2
sta SCREEN+1
jmp __breturn
// main::@return
__breturn:
// [7] return
// [6] return
rts
}
// File Data
bar_thing1: .byte 0
bar_thing2: .byte 0
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] (byte) bar_thing1 ← (byte) 'a' [ bar_thing1 ] ( [ bar_thing1 ] ) always clobbers reg byte a
Statement [1] (byte) bar_thing2 ← (byte) 'b' [ bar_thing1 bar_thing2 ] ( [ bar_thing1 bar_thing2 ] ) always clobbers reg byte a
Statement [5] *((const byte*) main::SCREEN) ← (byte) bar_thing1 [ bar_thing2 ] ( main:3 [ bar_thing2 ] ) always clobbers reg byte a
Statement [6] *((const byte*) main::SCREEN+(byte) 1) ← (byte) bar_thing2 [ ] ( main:3 [ ] ) always clobbers reg byte a
Potential registers mem[1] [ bar_thing1 ] : mem[1] ,
Potential registers mem[1] [ bar_thing2 ] : mem[1] ,
Statement [4] *((const byte*) main::SCREEN) ← (const byte) bar_thing1 [ ] ( main:2 [ ] ) always clobbers reg byte a
Statement [5] *((const byte*) main::SCREEN+(byte) 1) ← (const byte) bar_thing2 [ ] ( main:2 [ ] ) always clobbers reg byte a
REGISTER UPLIFT SCOPES
Uplift Scope [] 1.33: mem[1] [ bar_thing1 ] 1.33: mem[1] [ bar_thing2 ]
Uplift Scope [foo]
Uplift Scope [main]
Uplift Scope []
Uplifting [] best 49 combination mem[1] [ bar_thing1 ] mem[1] [ bar_thing2 ]
Uplifting [foo] best 49 combination
Uplifting [main] best 49 combination
Attempting to uplift remaining variables inmem[1] [ bar_thing1 ]
Uplifting [] best 49 combination mem[1] [ bar_thing1 ]
Attempting to uplift remaining variables inmem[1] [ bar_thing2 ]
Uplifting [] best 49 combination mem[1] [ bar_thing2 ]
Uplifting [foo] best 33 combination
Uplifting [main] best 33 combination
Uplifting [] best 33 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -205,22 +184,18 @@ ASSEMBLER BEFORE OPTIMIZATION
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.const bar_thing1 = 'a'
.const bar_thing2 = 'b'
// @begin
__bbegin:
// [0] (byte) bar_thing1 ← (byte) 'a' -- vbum1=vbuc1
lda #'a'
sta bar_thing1
// [1] (byte) bar_thing2 ← (byte) 'b' -- vbum1=vbuc1
lda #'b'
sta bar_thing2
// [2] phi from @begin to @1 [phi:@begin->@1]
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [3] call main
// [2] call main
jsr main
// [4] phi from @1 to @end [phi:@1->@end]
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
@ -228,43 +203,45 @@ __bend:
// main
main: {
.label SCREEN = $400
// [5] *((const byte*) main::SCREEN) ← (byte) bar_thing1 -- _deref_pbuc1=vbum1
lda bar_thing1
// [4] *((const byte*) main::SCREEN) ← (const byte) bar_thing1 -- _deref_pbuc1=vbuc2
lda #bar_thing1
sta SCREEN
// [6] *((const byte*) main::SCREEN+(byte) 1) ← (byte) bar_thing2 -- _deref_pbuc1=vbum1
lda bar_thing2
// [5] *((const byte*) main::SCREEN+(byte) 1) ← (const byte) bar_thing2 -- _deref_pbuc1=vbuc2
lda #bar_thing2
sta SCREEN+1
jmp __breturn
// main::@return
__breturn:
// [7] return
// [6] return
rts
}
// File Data
bar_thing1: .byte 0
bar_thing2: .byte 0
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Replacing label __bbegin with __b1
Removing instruction __bbegin:
Removing instruction __b1_from___bbegin:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1:
Removing instruction __bend:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Adding RTS to root block
Succesful ASM optimization Pass5AddMainRts
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction __b1:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte) bar_thing1 notregister mem[1] 1.3333333333333333
(byte) bar_thing2 notregister mem[1] 1.3333333333333333
(const byte) bar_thing1 = (byte) 'a'
(const byte) bar_thing2 = (byte) 'b'
(byte) foo::thing1
(byte) foo::thing2
(void()) main()
@ -272,54 +249,42 @@ FINAL SYMBOL TABLE
(const byte*) main::SCREEN = (byte*) 1024
(byte) main::i
mem[1] [ bar_thing1 ]
mem[1] [ bar_thing2 ]
FINAL ASSEMBLER
Score: 46
Score: 18
// File Comments
// Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store)
// Test a memory variable struct value
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.const bar_thing1 = 'a'
.const bar_thing2 = 'b'
// @begin
__bbegin:
// bar = { 'a', 'b' }
// [0] (byte) bar_thing1 ← (byte) 'a' -- vbum1=vbuc1
lda #'a'
sta bar_thing1
// [1] (byte) bar_thing2 ← (byte) 'b' -- vbum1=vbuc1
lda #'b'
sta bar_thing2
// [2] phi from @begin to @1 [phi:@begin->@1]
// [1] phi from @begin to @1 [phi:@begin->@1]
// @1
// [3] call main
jsr main
rts
// [4] phi from @1 to @end [phi:@1->@end]
// [2] call main
// [3] phi from @1 to @end [phi:@1->@end]
// @end
// main
main: {
.label SCREEN = $400
// SCREEN[i++] = bar.thing1
// [5] *((const byte*) main::SCREEN) ← (byte) bar_thing1 -- _deref_pbuc1=vbum1
lda bar_thing1
// [4] *((const byte*) main::SCREEN) ← (const byte) bar_thing1 -- _deref_pbuc1=vbuc2
lda #bar_thing1
sta SCREEN
// SCREEN[i++] = bar.thing2
// [6] *((const byte*) main::SCREEN+(byte) 1) ← (byte) bar_thing2 -- _deref_pbuc1=vbum1
lda bar_thing2
// [5] *((const byte*) main::SCREEN+(byte) 1) ← (const byte) bar_thing2 -- _deref_pbuc1=vbuc2
lda #bar_thing2
sta SCREEN+1
// main::@return
// }
// [7] return
// [6] return
rts
}
// File Data
bar_thing1: .byte 0
bar_thing2: .byte 0

View File

@ -1,8 +1,8 @@
(label) @1
(label) @begin
(label) @end
(byte) bar_thing1 notregister mem[1] 1.3333333333333333
(byte) bar_thing2 notregister mem[1] 1.3333333333333333
(const byte) bar_thing1 = (byte) 'a'
(const byte) bar_thing2 = (byte) 'b'
(byte) foo::thing1
(byte) foo::thing2
(void()) main()
@ -10,5 +10,3 @@
(const byte*) main::SCREEN = (byte*) 1024
(byte) main::i
mem[1] [ bar_thing1 ]
mem[1] [ bar_thing2 ]

View File

@ -14,54 +14,32 @@ main: {
.const default_zp_abs = '.'
.const default_mem_flex = '.'
.const default_mem_abs = '.'
.label notreg_zp_flex = 2
.label notreg_zp_abs = $10
.label notreg_mem_abs = $1000
.label notreg_default = 3
lda #'.'
sta.z notreg_zp_flex
sta.z notreg_zp_abs
sta notreg_mem_flex
sta notreg_mem_abs
sta.z notreg_default
ldy #0
ldx #reg_zp_flex
ldx #0
lda #reg_zp_flex
jsr out
ldx #reg_zp_abs
lda #reg_zp_abs
jsr out
ldx #reg_mem_flex
lda #reg_mem_flex
jsr out
ldx #reg_mem_abs
lda #reg_mem_abs
jsr out
ldx.z notreg_zp_flex
lda #default_default
jsr out
ldx.z notreg_zp_abs
lda #reg_default
jsr out
ldx notreg_mem_flex
lda #default_zp_flex
jsr out
ldx notreg_mem_abs
lda #default_zp_abs
jsr out
ldx #default_default
lda #default_mem_flex
jsr out
ldx #reg_default
jsr out
ldx.z notreg_default
jsr out
ldx #default_zp_flex
jsr out
ldx #default_zp_abs
jsr out
ldx #default_mem_flex
jsr out
ldx #default_mem_abs
lda #default_mem_abs
jsr out
rts
notreg_mem_flex: .byte 0
}
// out(byte register(X) c)
// out(byte register(A) c)
out: {
txa
sta SCREEN,y
iny
sta SCREEN,x
inx
rts
}

View File

@ -10,80 +10,56 @@
(void()) main()
main: scope:[main] from @1
[4] (byte) main::notreg_zp_flex ← (byte) '.'
[5] (byte) main::notreg_zp_abs ← (byte) '.'
[6] (byte) main::notreg_mem_flex ← (byte) '.'
[7] (byte) main::notreg_mem_abs ← (byte) '.'
[8] (byte) main::notreg_default ← (byte) '.'
[9] call out
[4] phi()
[5] call out
to:main::@1
main::@1: scope:[main] from main
[10] phi()
[11] call out
[6] phi()
[7] call out
to:main::@2
main::@2: scope:[main] from main::@1
[12] phi()
[13] call out
[8] phi()
[9] call out
to:main::@3
main::@3: scope:[main] from main::@2
[14] phi()
[15] call out
[10] phi()
[11] call out
to:main::@4
main::@4: scope:[main] from main::@3
[16] (byte) out::c#4 ← (byte) main::notreg_zp_flex
[17] call out
[12] phi()
[13] call out
to:main::@5
main::@5: scope:[main] from main::@4
[18] (byte) out::c#5 ← (byte) main::notreg_zp_abs
[19] call out
[14] phi()
[15] call out
to:main::@6
main::@6: scope:[main] from main::@5
[20] (byte) out::c#6 ← (byte) main::notreg_mem_flex
[21] call out
[16] phi()
[17] call out
to:main::@7
main::@7: scope:[main] from main::@6
[22] (byte) out::c#7 ← (byte) main::notreg_mem_abs
[23] call out
[18] phi()
[19] call out
to:main::@8
main::@8: scope:[main] from main::@7
[24] phi()
[25] call out
[20] phi()
[21] call out
to:main::@9
main::@9: scope:[main] from main::@8
[26] phi()
[27] call out
to:main::@10
main::@10: scope:[main] from main::@9
[28] (byte) out::c#10 ← (byte) main::notreg_default
[29] call out
to:main::@11
main::@11: scope:[main] from main::@10
[30] phi()
[31] call out
to:main::@12
main::@12: scope:[main] from main::@11
[32] phi()
[33] call out
to:main::@13
main::@13: scope:[main] from main::@12
[34] phi()
[35] call out
to:main::@14
main::@14: scope:[main] from main::@13
[36] phi()
[37] call out
[22] phi()
[23] call out
to:main::@return
main::@return: scope:[main] from main::@14
[38] return
main::@return: scope:[main] from main::@9
[24] return
to:@return
(void()) out((byte) out::c)
out: scope:[out] from main main::@1 main::@10 main::@11 main::@12 main::@13 main::@14 main::@2 main::@3 main::@4 main::@5 main::@6 main::@7 main::@8 main::@9
[39] (byte) i#36 ← phi( main/(byte) 0 main::@1/(byte) i#17 main::@10/(byte) i#17 main::@11/(byte) i#17 main::@12/(byte) i#17 main::@13/(byte) i#17 main::@14/(byte) i#17 main::@2/(byte) i#17 main::@3/(byte) i#17 main::@4/(byte) i#17 main::@5/(byte) i#17 main::@6/(byte) i#17 main::@7/(byte) i#17 main::@8/(byte) i#17 main::@9/(byte) i#17 )
[39] (byte) out::c#15 ← phi( main/(const byte) main::reg_zp_flex main::@1/(const byte) main::reg_zp_abs main::@10/(byte) out::c#10 main::@11/(const byte) main::default_zp_flex main::@12/(const byte) main::default_zp_abs main::@13/(const byte) main::default_mem_flex main::@14/(const byte) main::default_mem_abs main::@2/(const byte) main::reg_mem_flex main::@3/(const byte) main::reg_mem_abs main::@4/(byte) out::c#4 main::@5/(byte) out::c#5 main::@6/(byte) out::c#6 main::@7/(byte) out::c#7 main::@8/(const byte) main::default_default main::@9/(const byte) main::reg_default )
[40] *((const byte*) SCREEN + (byte) i#36) ← (byte) out::c#15
[41] (byte) i#17 ← ++ (byte) i#36
out: scope:[out] from main main::@1 main::@2 main::@3 main::@4 main::@5 main::@6 main::@7 main::@8 main::@9
[25] (byte) i#26 ← phi( main/(byte) 0 main::@1/(byte) i#12 main::@2/(byte) i#12 main::@3/(byte) i#12 main::@4/(byte) i#12 main::@5/(byte) i#12 main::@6/(byte) i#12 main::@7/(byte) i#12 main::@8/(byte) i#12 main::@9/(byte) i#12 )
[25] (byte) out::c#10 ← phi( main/(const byte) main::reg_zp_flex main::@1/(const byte) main::reg_zp_abs main::@2/(const byte) main::reg_mem_flex main::@3/(const byte) main::reg_mem_abs main::@4/(const byte) main::default_default main::@5/(const byte) main::reg_default main::@6/(const byte) main::default_zp_flex main::@7/(const byte) main::default_zp_abs main::@8/(const byte) main::default_mem_flex main::@9/(const byte) main::default_mem_abs )
[26] *((const byte*) SCREEN + (byte) i#26) ← (byte) out::c#10
[27] (byte) i#12 ← ++ (byte) i#26
to:out::@return
out::@return: scope:[out] from out
[42] return
[28] return
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -3,15 +3,10 @@
(label) @end
(const byte*) SCREEN = (byte*) 1024
(byte) i
(byte) i#17 reg byte y 0.9999999999999999
(byte) i#36 reg byte y 16.0
(byte) i#12 reg byte x 0.9999999999999999
(byte) i#26 reg byte x 11.0
(void()) main()
(label) main::@1
(label) main::@10
(label) main::@11
(label) main::@12
(label) main::@13
(label) main::@14
(label) main::@2
(label) main::@3
(label) main::@4
@ -26,11 +21,6 @@
(const byte) main::default_mem_flex = (byte) '.'
(const byte) main::default_zp_abs !zp[-1]:16 = (byte) '.'
(const byte) main::default_zp_flex = (byte) '.'
(byte) main::notreg_default notregister zp[1]:3 0.2
(byte) main::notreg_mem_abs notregister !mem[-1]:4096 mem[1]:4096 0.26666666666666666
(byte) main::notreg_mem_flex notregister mem[1] 0.2857142857142857
(byte) main::notreg_zp_abs notregister !zp[-1]:16 zp[1]:16 0.3076923076923077
(byte) main::notreg_zp_flex notregister zp[1]:2 0.3333333333333333
(const byte) main::reg_default = (byte) '.'
(const byte) main::reg_mem_abs !mem[-1]:4096 = (byte) '.'
(const byte) main::reg_mem_flex = (byte) '.'
@ -39,17 +29,7 @@
(void()) out((byte) out::c)
(label) out::@return
(byte) out::c
(byte) out::c#10 reg byte x 4.0
(byte) out::c#15 reg byte x 12.0
(byte) out::c#4 reg byte x 4.0
(byte) out::c#5 reg byte x 4.0
(byte) out::c#6 reg byte x 4.0
(byte) out::c#7 reg byte x 4.0
(byte) out::c#10 reg byte a 2.0
reg byte x [ out::c#15 out::c#10 out::c#4 out::c#5 out::c#6 out::c#7 ]
reg byte y [ i#36 i#17 ]
zp[1]:2 [ main::notreg_zp_flex ]
zp[1]:16 [ main::notreg_zp_abs ]
mem[1] [ main::notreg_mem_flex ]
mem[1]:4096 [ main::notreg_mem_abs ]
zp[1]:3 [ main::notreg_default ]
reg byte a [ out::c#10 ]
reg byte x [ i#26 i#12 ]

View File

@ -1,23 +0,0 @@
// Tests declaring a (constant) variable as __notconst
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
.label SCREEN = $400
.label size = 2
__bbegin:
lda #$28
sta.z size
jsr main
rts
main: {
ldx #0
__b1:
cpx.z size
bcc __b2
rts
__b2:
lda #'*'
sta SCREEN,x
inx
jmp __b1
}

View File

@ -1,25 +0,0 @@
@begin: scope:[] from
[0] (byte) size#0 ← (byte) $28
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
(void()) main()
main: scope:[main] from @1
[4] phi()
to:main::@1
main::@1: scope:[main] from main main::@2
[5] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
[6] if((byte) main::i#2<(byte) size#0) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@1
[7] return
to:@return
main::@2: scope:[main] from main::@1
[8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) '*'
[9] (byte) main::i#1 ← ++ (byte) main::i#2
to:main::@1

View File

@ -1,385 +0,0 @@
Culled Empty Block (label) main::@4
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte) size#0 ← (number) $28
to:@1
(void()) main()
main: scope:[main] from @1
(byte) size#2 ← phi( @1/(byte) size#4 )
(byte) main::i#0 ← (number) 0
to:main::@1
main::@1: scope:[main] from main main::@2
(byte) size#1 ← phi( main/(byte) size#2 main::@2/(byte) size#3 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 )
(bool~) main::$0 ← (byte) main::i#2 < (byte) size#1
if((bool~) main::$0) goto main::@2
to:main::@return
main::@2: scope:[main] from main::@1
(byte) size#3 ← phi( main::@1/(byte) size#1 )
(byte) main::i#3 ← phi( main::@1/(byte) main::i#2 )
*((const byte*) SCREEN + (byte) main::i#3) ← (byte) '*'
(byte) main::i#1 ← ++ (byte) main::i#3
to:main::@1
main::@return: scope:[main] from main::@1
return
to:@return
@1: scope:[] from @begin
(byte) size#4 ← phi( @begin/(byte) size#0 )
call main
to:@2
@2: scope:[] from @1
to:@end
@end: scope:[] from @2
SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(const byte*) SCREEN = (byte*)(number) $400
(void()) main()
(bool~) main::$0
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
(byte) size
(byte) size#0
(byte) size#1
(byte) size#2
(byte) size#3
(byte) size#4
Adding number conversion cast (unumber) $28 in (byte) size#0 ← (number) $28
Adding number conversion cast (unumber) 0 in (byte) main::i#0 ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) size#0 ← (unumber)(number) $28
Inlining cast (byte) main::i#0 ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $28
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte) main::i#2 = (byte) main::i#3
Alias (byte) size#1 = (byte) size#3
Alias (byte) size#0 = (byte) size#4
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) size#2 (byte) size#0
Identical Phi Values (byte) size#1 (byte) size#2
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$0 [5] if((byte) main::i#2<(byte) size#0) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte) main::i#0
Constant inlined main::i#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:2
Created 1 initial phi equivalence classes
Coalesced [11] main::i#4 ← main::i#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
[0] (byte) size#0 ← (byte) $28
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
(void()) main()
main: scope:[main] from @1
[4] phi()
to:main::@1
main::@1: scope:[main] from main main::@2
[5] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
[6] if((byte) main::i#2<(byte) size#0) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@1
[7] return
to:@return
main::@2: scope:[main] from main::@1
[8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) '*'
[9] (byte) main::i#1 ← ++ (byte) main::i#2
to:main::@1
VARIABLE REGISTER WEIGHTS
(void()) main()
(byte) main::i
(byte) main::i#1 22.0
(byte) main::i#2 14.666666666666666
(byte) size
(byte) size#0 1.8571428571428572
Initial phi equivalence classes
[ main::i#2 main::i#1 ]
Added variable size#0 to zero page equivalence class [ size#0 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ size#0 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated zp[1]:3 [ size#0 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Tests declaring a (constant) variable as __notconst
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
.label size = 3
// @begin
__bbegin:
// [0] (byte) size#0 ← (byte) $28 -- vbuz1=vbuc1
lda #$28
sta.z size
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from___b1:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
.label i = 2
// [5] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
lda #0
sta.z i
jmp __b1
// main::@1
__b1:
// [6] if((byte) main::i#2<(byte) size#0) goto main::@2 -- vbuz1_lt_vbuz2_then_la1
lda.z i
cmp.z size
bcc __b2
jmp __breturn
// main::@return
__breturn:
// [7] return
rts
// main::@2
__b2:
// [8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) '*' -- pbuc1_derefidx_vbuz1=vbuc2
lda #'*'
ldy.z i
sta SCREEN,y
// [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
inc.z i
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
__b1_from___b2:
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
jmp __b1
}
// File Data
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) '*' [ size#0 main::i#2 ] ( main:2 [ size#0 main::i#2 ] ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:3 [ size#0 ]
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Statement [8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) '*' [ size#0 main::i#2 ] ( main:2 [ size#0 main::i#2 ] ) always clobbers reg byte a
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y ,
Potential registers zp[1]:3 [ size#0 ] : zp[1]:3 , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 36.67: zp[1]:2 [ main::i#2 main::i#1 ]
Uplift Scope [] 1.86: zp[1]:3 [ size#0 ]
Uplifting [main] best 278 combination reg byte x [ main::i#2 main::i#1 ]
Uplifting [] best 278 combination zp[1]:3 [ size#0 ]
Attempting to uplift remaining variables inzp[1]:3 [ size#0 ]
Uplifting [] best 278 combination zp[1]:3 [ size#0 ]
Allocated (was zp[1]:3) zp[1]:2 [ size#0 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Tests declaring a (constant) variable as __notconst
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
.label size = 2
// @begin
__bbegin:
// [0] (byte) size#0 ← (byte) $28 -- vbuz1=vbuc1
lda #$28
sta.z size
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from___b1:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
// [5] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
ldx #0
jmp __b1
// main::@1
__b1:
// [6] if((byte) main::i#2<(byte) size#0) goto main::@2 -- vbuxx_lt_vbuz1_then_la1
cpx.z size
bcc __b2
jmp __breturn
// main::@return
__breturn:
// [7] return
rts
// main::@2
__b2:
// [8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) '*' -- pbuc1_derefidx_vbuxx=vbuc2
lda #'*'
sta SCREEN,x
// [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
inx
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
__b1_from___b2:
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
jmp __b1
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1:
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __breturn:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5UnusedLabelElimination
Adding RTS to root block
Succesful ASM optimization Pass5AddMainRts
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte*) SCREEN = (byte*) 1024
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte x 22.0
(byte) main::i#2 reg byte x 14.666666666666666
(byte) size
(byte) size#0 size zp[1]:2 1.8571428571428572
reg byte x [ main::i#2 main::i#1 ]
zp[1]:2 [ size#0 ]
FINAL ASSEMBLER
Score: 218
// File Comments
// Tests declaring a (constant) variable as __notconst
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.label SCREEN = $400
.label size = 2
// @begin
__bbegin:
// size = 40
// [0] (byte) size#0 ← (byte) $28 -- vbuz1=vbuc1
lda #$28
sta.z size
// [1] phi from @begin to @1 [phi:@begin->@1]
// @1
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
jsr main
rts
// [3] phi from @1 to @end [phi:@1->@end]
// @end
// main
main: {
// [5] phi from main to main::@1 [phi:main->main::@1]
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
ldx #0
// main::@1
__b1:
// for( char i=0;i<size;i++ )
// [6] if((byte) main::i#2<(byte) size#0) goto main::@2 -- vbuxx_lt_vbuz1_then_la1
cpx.z size
bcc __b2
// main::@return
// }
// [7] return
rts
// main::@2
__b2:
// SCREEN[i] = '*'
// [8] *((const byte*) SCREEN + (byte) main::i#2) ← (byte) '*' -- pbuc1_derefidx_vbuxx=vbuc2
lda #'*'
sta SCREEN,x
// for( char i=0;i<size;i++ )
// [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
inx
// [5] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
jmp __b1
}
// File Data

View File

@ -1,16 +0,0 @@
(label) @1
(label) @begin
(label) @end
(const byte*) SCREEN = (byte*) 1024
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte x 22.0
(byte) main::i#2 reg byte x 14.666666666666666
(byte) size
(byte) size#0 size zp[1]:2 1.8571428571428572
reg byte x [ main::i#2 main::i#1 ]
zp[1]:2 [ size#0 ]

View File

@ -1,27 +0,0 @@
// Tests declaring a (constant) variable as __notconst
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
.label size = 2
.label SCREEN = 3
__bbegin:
lda #$28
sta.z size
lda #<$400
sta.z SCREEN
lda #>$400
sta.z SCREEN+1
jsr main
rts
main: {
ldy #0
__b1:
cpy.z size
bcc __b2
rts
__b2:
lda #'*'
sta (SCREEN),y
iny
jmp __b1
}

View File

@ -1,26 +0,0 @@
@begin: scope:[] from
[0] (byte) size#0 ← (byte) $28
[1] (byte*) SCREEN#0 ← (byte*) 1024
to:@1
@1: scope:[] from @begin
[2] phi()
[3] call main
to:@end
@end: scope:[] from @1
[4] phi()
(void()) main()
main: scope:[main] from @1
[5] phi()
to:main::@1
main::@1: scope:[main] from main main::@2
[6] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
[7] if((byte) main::i#2<(byte) size#0) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@1
[8] return
to:@return
main::@2: scope:[main] from main::@1
[9] *((byte*) SCREEN#0 + (byte) main::i#2) ← (byte) '*'
[10] (byte) main::i#1 ← ++ (byte) main::i#2
to:main::@1

View File

@ -1,428 +0,0 @@
Culled Empty Block (label) main::@4
Culled Empty Block (label) main::@3
Culled Empty Block (label) main::@5
Culled Empty Block (label) main::@6
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
(byte) size#0 ← (number) $28
(byte*) SCREEN#0 ← ((byte*)) (number) $400
to:@1
(void()) main()
main: scope:[main] from @1
(byte*) SCREEN#3 ← phi( @1/(byte*) SCREEN#4 )
(byte) size#2 ← phi( @1/(byte) size#4 )
(byte) main::i#0 ← (number) 0
to:main::@1
main::@1: scope:[main] from main main::@2
(byte*) SCREEN#2 ← phi( main/(byte*) SCREEN#3 main::@2/(byte*) SCREEN#1 )
(byte) size#1 ← phi( main/(byte) size#2 main::@2/(byte) size#3 )
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 )
(bool~) main::$0 ← (byte) main::i#2 < (byte) size#1
if((bool~) main::$0) goto main::@2
to:main::@return
main::@2: scope:[main] from main::@1
(byte) size#3 ← phi( main::@1/(byte) size#1 )
(byte) main::i#3 ← phi( main::@1/(byte) main::i#2 )
(byte*) SCREEN#1 ← phi( main::@1/(byte*) SCREEN#2 )
*((byte*) SCREEN#1 + (byte) main::i#3) ← (byte) '*'
(byte) main::i#1 ← ++ (byte) main::i#3
to:main::@1
main::@return: scope:[main] from main::@1
return
to:@return
@1: scope:[] from @begin
(byte*) SCREEN#4 ← phi( @begin/(byte*) SCREEN#0 )
(byte) size#4 ← phi( @begin/(byte) size#0 )
call main
to:@2
@2: scope:[] from @1
to:@end
@end: scope:[] from @2
SYMBOL TABLE SSA
(label) @1
(label) @2
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0
(byte*) SCREEN#1
(byte*) SCREEN#2
(byte*) SCREEN#3
(byte*) SCREEN#4
(void()) main()
(bool~) main::$0
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
(byte) size
(byte) size#0
(byte) size#1
(byte) size#2
(byte) size#3
(byte) size#4
Adding number conversion cast (unumber) $28 in (byte) size#0 ← (number) $28
Adding number conversion cast (unumber) 0 in (byte) main::i#0 ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast (byte) size#0 ← (unumber)(number) $28
Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400
Inlining cast (byte) main::i#0 ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast $28
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias (byte*) SCREEN#1 = (byte*) SCREEN#2
Alias (byte) main::i#2 = (byte) main::i#3
Alias (byte) size#1 = (byte) size#3
Alias (byte) size#0 = (byte) size#4
Alias (byte*) SCREEN#0 = (byte*) SCREEN#4
Successful SSA optimization Pass2AliasElimination
Identical Phi Values (byte) size#2 (byte) size#0
Identical Phi Values (byte*) SCREEN#3 (byte*) SCREEN#0
Identical Phi Values (byte) size#1 (byte) size#2
Identical Phi Values (byte*) SCREEN#1 (byte*) SCREEN#3
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition (bool~) main::$0 [6] if((byte) main::i#2<(byte) size#0) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte) main::i#0
Constant inlined main::i#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Adding NOP phi() at start of @1
Adding NOP phi() at start of @2
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
CALL GRAPH
Calls in [] to main:3
Created 1 initial phi equivalence classes
Coalesced [12] main::i#4 ← main::i#1
Coalesced down to 1 phi equivalence classes
Culled Empty Block (label) @2
Adding NOP phi() at start of @1
Adding NOP phi() at start of @end
Adding NOP phi() at start of main
FINAL CONTROL FLOW GRAPH
@begin: scope:[] from
[0] (byte) size#0 ← (byte) $28
[1] (byte*) SCREEN#0 ← (byte*) 1024
to:@1
@1: scope:[] from @begin
[2] phi()
[3] call main
to:@end
@end: scope:[] from @1
[4] phi()
(void()) main()
main: scope:[main] from @1
[5] phi()
to:main::@1
main::@1: scope:[main] from main main::@2
[6] (byte) main::i#2 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 )
[7] if((byte) main::i#2<(byte) size#0) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@1
[8] return
to:@return
main::@2: scope:[main] from main::@1
[9] *((byte*) SCREEN#0 + (byte) main::i#2) ← (byte) '*'
[10] (byte) main::i#1 ← ++ (byte) main::i#2
to:main::@1
VARIABLE REGISTER WEIGHTS
(byte*) SCREEN
(byte*) SCREEN#0 1.8571428571428572
(void()) main()
(byte) main::i
(byte) main::i#1 22.0
(byte) main::i#2 14.666666666666666
(byte) size
(byte) size#0 1.625
Initial phi equivalence classes
[ main::i#2 main::i#1 ]
Added variable size#0 to zero page equivalence class [ size#0 ]
Added variable SCREEN#0 to zero page equivalence class [ SCREEN#0 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ size#0 ]
[ SCREEN#0 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated zp[1]:3 [ size#0 ]
Allocated zp[2]:4 [ SCREEN#0 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Tests declaring a (constant) variable as __notconst
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.label size = 3
.label SCREEN = 4
// @begin
__bbegin:
// [0] (byte) size#0 ← (byte) $28 -- vbuz1=vbuc1
lda #$28
sta.z size
// [1] (byte*) SCREEN#0 ← (byte*) 1024 -- pbuz1=pbuc1
lda #<$400
sta.z SCREEN
lda #>$400
sta.z SCREEN+1
// [2] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [3] call main
// [5] phi from @1 to main [phi:@1->main]
main_from___b1:
jsr main
// [4] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
.label i = 2
// [6] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [6] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
lda #0
sta.z i
jmp __b1
// main::@1
__b1:
// [7] if((byte) main::i#2<(byte) size#0) goto main::@2 -- vbuz1_lt_vbuz2_then_la1
lda.z i
cmp.z size
bcc __b2
jmp __breturn
// main::@return
__breturn:
// [8] return
rts
// main::@2
__b2:
// [9] *((byte*) SCREEN#0 + (byte) main::i#2) ← (byte) '*' -- pbuz1_derefidx_vbuz2=vbuc1
lda #'*'
ldy.z i
sta (SCREEN),y
// [10] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
inc.z i
// [6] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
__b1_from___b2:
// [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
jmp __b1
}
// File Data
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] (byte*) SCREEN#0 ← (byte*) 1024 [ size#0 SCREEN#0 ] ( [ size#0 SCREEN#0 ] ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:3 [ size#0 ]
Statement [9] *((byte*) SCREEN#0 + (byte) main::i#2) ← (byte) '*' [ size#0 SCREEN#0 main::i#2 ] ( main:3 [ size#0 SCREEN#0 main::i#2 ] ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Statement [1] (byte*) SCREEN#0 ← (byte*) 1024 [ size#0 SCREEN#0 ] ( [ size#0 SCREEN#0 ] ) always clobbers reg byte a
Statement [9] *((byte*) SCREEN#0 + (byte) main::i#2) ← (byte) '*' [ size#0 SCREEN#0 main::i#2 ] ( main:3 [ size#0 SCREEN#0 main::i#2 ] ) always clobbers reg byte a
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y ,
Potential registers zp[1]:3 [ size#0 ] : zp[1]:3 , reg byte x , reg byte y ,
Potential registers zp[2]:4 [ SCREEN#0 ] : zp[2]:4 ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 36.67: zp[1]:2 [ main::i#2 main::i#1 ]
Uplift Scope [] 1.86: zp[2]:4 [ SCREEN#0 ] 1.62: zp[1]:3 [ size#0 ]
Uplifting [main] best 298 combination reg byte y [ main::i#2 main::i#1 ]
Uplifting [] best 298 combination zp[2]:4 [ SCREEN#0 ] zp[1]:3 [ size#0 ]
Attempting to uplift remaining variables inzp[1]:3 [ size#0 ]
Uplifting [] best 298 combination zp[1]:3 [ size#0 ]
Allocated (was zp[1]:3) zp[1]:2 [ size#0 ]
Allocated (was zp[2]:4) zp[2]:3 [ SCREEN#0 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Tests declaring a (constant) variable as __notconst
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.label size = 2
.label SCREEN = 3
// @begin
__bbegin:
// [0] (byte) size#0 ← (byte) $28 -- vbuz1=vbuc1
lda #$28
sta.z size
// [1] (byte*) SCREEN#0 ← (byte*) 1024 -- pbuz1=pbuc1
lda #<$400
sta.z SCREEN
lda #>$400
sta.z SCREEN+1
// [2] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [3] call main
// [5] phi from @1 to main [phi:@1->main]
main_from___b1:
jsr main
// [4] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
// [6] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [6] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1
ldy #0
jmp __b1
// main::@1
__b1:
// [7] if((byte) main::i#2<(byte) size#0) goto main::@2 -- vbuyy_lt_vbuz1_then_la1
cpy.z size
bcc __b2
jmp __breturn
// main::@return
__breturn:
// [8] return
rts
// main::@2
__b2:
// [9] *((byte*) SCREEN#0 + (byte) main::i#2) ← (byte) '*' -- pbuz1_derefidx_vbuyy=vbuc1
lda #'*'
sta (SCREEN),y
// [10] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuyy=_inc_vbuyy
iny
// [6] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
__b1_from___b2:
// [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
jmp __b1
}
// File Data
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b1_from___bbegin:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __b1:
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __breturn:
Removing instruction __b1_from___b2:
Succesful ASM optimization Pass5UnusedLabelElimination
Adding RTS to root block
Succesful ASM optimization Pass5AddMainRts
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0 SCREEN zp[2]:3 1.8571428571428572
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte y 22.0
(byte) main::i#2 reg byte y 14.666666666666666
(byte) size
(byte) size#0 size zp[1]:2 1.625
reg byte y [ main::i#2 main::i#1 ]
zp[1]:2 [ size#0 ]
zp[2]:3 [ SCREEN#0 ]
FINAL ASSEMBLER
Score: 238
// File Comments
// Tests declaring a (constant) variable as __notconst
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.label size = 2
.label SCREEN = 3
// @begin
__bbegin:
// size = 40
// [0] (byte) size#0 ← (byte) $28 -- vbuz1=vbuc1
lda #$28
sta.z size
// SCREEN = 0x0400
// [1] (byte*) SCREEN#0 ← (byte*) 1024 -- pbuz1=pbuc1
lda #<$400
sta.z SCREEN
lda #>$400
sta.z SCREEN+1
// [2] phi from @begin to @1 [phi:@begin->@1]
// @1
// [3] call main
// [5] phi from @1 to main [phi:@1->main]
jsr main
rts
// [4] phi from @1 to @end [phi:@1->@end]
// @end
// main
main: {
// [6] phi from main to main::@1 [phi:main->main::@1]
// [6] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuyy=vbuc1
ldy #0
// main::@1
__b1:
// for( char i=0;i<size;i++ )
// [7] if((byte) main::i#2<(byte) size#0) goto main::@2 -- vbuyy_lt_vbuz1_then_la1
cpy.z size
bcc __b2
// main::@return
// }
// [8] return
rts
// main::@2
__b2:
// SCREEN[i] = '*'
// [9] *((byte*) SCREEN#0 + (byte) main::i#2) ← (byte) '*' -- pbuz1_derefidx_vbuyy=vbuc1
lda #'*'
sta (SCREEN),y
// for( char i=0;i<size;i++ )
// [10] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuyy=_inc_vbuyy
iny
// [6] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
// [6] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@2->main::@1#0] -- register_copy
jmp __b1
}
// File Data

View File

@ -1,18 +0,0 @@
(label) @1
(label) @begin
(label) @end
(byte*) SCREEN
(byte*) SCREEN#0 SCREEN zp[2]:3 1.8571428571428572
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@return
(byte) main::i
(byte) main::i#1 reg byte y 22.0
(byte) main::i#2 reg byte y 14.666666666666666
(byte) size
(byte) size#0 size zp[1]:2 1.625
reg byte y [ main::i#2 main::i#1 ]
zp[1]:2 [ size#0 ]
zp[2]:3 [ SCREEN#0 ]