mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-02-20 00:29:10 +00:00
Removed const/volatile from Variable. #121
This commit is contained in:
parent
38d62b5759
commit
8fd8bb1832
@ -59,13 +59,6 @@ public class VariableBuilder {
|
|||||||
SymbolType typeQualified = type.getQualified(this.isVolatile(), this.isNoModify());
|
SymbolType typeQualified = type.getQualified(this.isVolatile(), this.isNoModify());
|
||||||
|
|
||||||
Variable variable = new Variable(varName, getKind(), typeQualified, scope, getMemoryArea(), dataSegment, null);
|
Variable variable = new Variable(varName, getKind(), typeQualified, scope, getMemoryArea(), dataSegment, null);
|
||||||
|
|
||||||
// Todo: #121 remove!
|
|
||||||
variable.setNoModify(this.isNoModify());
|
|
||||||
variable.setVolatile(this.isVolatile());
|
|
||||||
variable.setToNoModify(this.isToNoModify());
|
|
||||||
variable.setToVolatile(this.isToVolatile());
|
|
||||||
|
|
||||||
variable.setExport(this.isExport());
|
variable.setExport(this.isExport());
|
||||||
variable.setPermanent(this.isPermanent());
|
variable.setPermanent(this.isPermanent());
|
||||||
variable.setOptimize(this.isOptimize());
|
variable.setOptimize(this.isOptimize());
|
||||||
|
@ -59,21 +59,9 @@ public class Variable implements Symbol {
|
|||||||
/** The type of the variable. VAR means the 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;
|
private SymbolType type;
|
||||||
|
|
||||||
/** Specifies that the variable is not allowed to be modified (const keyword) */
|
|
||||||
private boolean noModify;
|
|
||||||
|
|
||||||
/** Specifies that the variable is a local permanent variable (local variable static keyword) */
|
/** Specifies that the variable is a local permanent variable (local variable static keyword) */
|
||||||
private boolean permanent;
|
private boolean permanent;
|
||||||
|
|
||||||
/** Specifies that the variable must always live in memory to be available for any multi-threaded accees (eg. in interrupts). (volatile keyword) [Only Variables] */
|
|
||||||
private boolean isVolatile;
|
|
||||||
|
|
||||||
/** Specifies that the variable points to a volatile. (volatile* keyword) */
|
|
||||||
private boolean isToVolatile;
|
|
||||||
|
|
||||||
/** Specifies that the variable points to a a nomodify. (const* keyword) */
|
|
||||||
private boolean isToNoModify;
|
|
||||||
|
|
||||||
/** Specifies that the variable must always be added to the output ASM even if it is never used anywhere. (export keyword) */
|
/** Specifies that the variable must always be added to the output ASM even if it is never used anywhere. (export keyword) */
|
||||||
private boolean export;
|
private boolean export;
|
||||||
|
|
||||||
@ -193,13 +181,6 @@ public class Variable implements Symbol {
|
|||||||
version.setMemoryAlignment(phiMaster.getMemoryAlignment());
|
version.setMemoryAlignment(phiMaster.getMemoryAlignment());
|
||||||
version.setMemoryAddress(phiMaster.getMemoryAddress());
|
version.setMemoryAddress(phiMaster.getMemoryAddress());
|
||||||
version.setOptimize(phiMaster.isOptimize());
|
version.setOptimize(phiMaster.isOptimize());
|
||||||
|
|
||||||
// TODO: #121 remove
|
|
||||||
version.setVolatile(phiMaster.isVolatile());
|
|
||||||
version.setNoModify(phiMaster.isNoModify());
|
|
||||||
version.setToNoModify(phiMaster.isToNoModify());
|
|
||||||
version.setToVolatile(phiMaster.isToVolatile());
|
|
||||||
|
|
||||||
version.setRegister(phiMaster.getRegister());
|
version.setRegister(phiMaster.getRegister());
|
||||||
version.setPermanent(phiMaster.isPermanent());
|
version.setPermanent(phiMaster.isPermanent());
|
||||||
version.setExport(phiMaster.isExport());
|
version.setExport(phiMaster.isExport());
|
||||||
@ -243,12 +224,6 @@ public class Variable implements Symbol {
|
|||||||
constVar.setMemoryAddress(variable.getMemoryAddress());
|
constVar.setMemoryAddress(variable.getMemoryAddress());
|
||||||
constVar.setOptimize(variable.isOptimize());
|
constVar.setOptimize(variable.isOptimize());
|
||||||
constVar.setRegister(variable.getRegister());
|
constVar.setRegister(variable.getRegister());
|
||||||
// Todo: #121 remove
|
|
||||||
constVar.setVolatile(variable.isVolatile());
|
|
||||||
constVar.setNoModify(variable.isNoModify());
|
|
||||||
constVar.setToNoModify(variable.isToNoModify());
|
|
||||||
constVar.setToVolatile(variable.isToVolatile());
|
|
||||||
|
|
||||||
constVar.setPermanent(variable.isPermanent());
|
constVar.setPermanent(variable.isPermanent());
|
||||||
constVar.setExport(variable.isExport());
|
constVar.setExport(variable.isExport());
|
||||||
constVar.setComments(variable.getComments());
|
constVar.setComments(variable.getComments());
|
||||||
@ -268,13 +243,6 @@ public class Variable implements Symbol {
|
|||||||
copy.setMemoryAddress(original.getMemoryAddress());
|
copy.setMemoryAddress(original.getMemoryAddress());
|
||||||
copy.setOptimize(original.isOptimize());
|
copy.setOptimize(original.isOptimize());
|
||||||
copy.setPermanent(original.isPermanent());
|
copy.setPermanent(original.isPermanent());
|
||||||
|
|
||||||
// Todo: #121 remove
|
|
||||||
copy.setVolatile(original.isVolatile());
|
|
||||||
copy.setNoModify(original.isNoModify());
|
|
||||||
copy.setToNoModify(original.isToNoModify());
|
|
||||||
copy.setToVolatile(original.isToVolatile());
|
|
||||||
|
|
||||||
copy.setExport(original.isExport());
|
copy.setExport(original.isExport());
|
||||||
copy.setRegister(original.getRegister());
|
copy.setRegister(original.getRegister());
|
||||||
copy.setComments(original.getComments());
|
copy.setComments(original.getComments());
|
||||||
@ -296,24 +264,17 @@ public class Variable implements Symbol {
|
|||||||
if(isParameter && memberDefinition.isArray()) {
|
if(isParameter && memberDefinition.isArray()) {
|
||||||
// Array struct members are converted to pointers when unwound (use same kind as the struct variable)
|
// Array struct members are converted to pointers when unwound (use same kind as the struct variable)
|
||||||
SymbolTypePointer arrayType = (SymbolTypePointer) memberDefinition.getType();
|
SymbolTypePointer arrayType = (SymbolTypePointer) memberDefinition.getType();
|
||||||
SymbolType typeQualified = new SymbolTypePointer(arrayType.getElementType()).getQualified(structVar.isVolatile, structVar.isNoModify());
|
SymbolType typeQualified = new SymbolTypePointer(arrayType.getElementType()).getQualified(structVar.isVolatile(), structVar.isNoModify());
|
||||||
memberVariable = new Variable(name, structVar.getKind(), typeQualified, structVar.getScope(), memoryArea, structVar.getDataSegment(), null);
|
memberVariable = new Variable(name, structVar.getKind(), typeQualified, structVar.getScope(), memoryArea, structVar.getDataSegment(), null);
|
||||||
} else if(memberDefinition.isKindConstant()) {
|
} else if(memberDefinition.isKindConstant()) {
|
||||||
// Constant members are unwound as constants
|
// Constant members are unwound as constants
|
||||||
SymbolType typeQualified = memberDefinition.getType().getQualified(structVar.isVolatile, structVar.isNoModify());
|
SymbolType typeQualified = memberDefinition.getType().getQualified(structVar.isVolatile(), structVar.isNoModify());
|
||||||
memberVariable = new Variable(name, Kind.CONSTANT, typeQualified, structVar.getScope(), memoryArea, structVar.getDataSegment(), memberDefinition.getInitValue());
|
memberVariable = new Variable(name, Kind.CONSTANT, typeQualified, structVar.getScope(), memoryArea, structVar.getDataSegment(), memberDefinition.getInitValue());
|
||||||
} else {
|
} else {
|
||||||
// For others the kind is preserved from the member definition
|
// For others the kind is preserved from the member definition
|
||||||
SymbolType typeQualified = memberDefinition.getType().getQualified(structVar.isVolatile, structVar.isNoModify());
|
SymbolType typeQualified = memberDefinition.getType().getQualified(structVar.isVolatile(), structVar.isNoModify());
|
||||||
memberVariable = new Variable(name, structVar.getKind(),typeQualified, structVar.getScope(), memoryArea, structVar.getDataSegment(), memberDefinition.getInitValue());
|
memberVariable = new Variable(name, structVar.getKind(),typeQualified, structVar.getScope(), memoryArea, structVar.getDataSegment(), memberDefinition.getInitValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Todo: #121 fix struct member qualifiers - and remove!
|
|
||||||
memberVariable.setVolatile(structVar.isVolatile());
|
|
||||||
memberVariable.setNoModify(structVar.isNoModify());
|
|
||||||
memberVariable.setToNoModify(structVar.isToNoModify());
|
|
||||||
memberVariable.setToVolatile(structVar.isToVolatile());
|
|
||||||
|
|
||||||
memberVariable.setExport(structVar.isExport());
|
memberVariable.setExport(structVar.isExport());
|
||||||
memberVariable.setPermanent(structVar.isPermanent());
|
memberVariable.setPermanent(structVar.isPermanent());
|
||||||
return memberVariable;
|
return memberVariable;
|
||||||
@ -503,35 +464,19 @@ public class Variable implements Symbol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNoModify() {
|
public boolean isNoModify() {
|
||||||
return noModify;
|
return type.isNomodify();
|
||||||
}
|
|
||||||
|
|
||||||
public void setNoModify(boolean noModify) {
|
|
||||||
this.noModify = noModify;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVolatile() {
|
public boolean isVolatile() {
|
||||||
return isVolatile;
|
return type.isVolatile();
|
||||||
}
|
|
||||||
|
|
||||||
public void setVolatile(boolean aVolatile) {
|
|
||||||
this.isVolatile = aVolatile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isToNoModify() {
|
public boolean isToNoModify() {
|
||||||
return isToNoModify;
|
return type instanceof SymbolTypePointer && ((SymbolTypePointer) type).getElementType().isNomodify();
|
||||||
}
|
|
||||||
|
|
||||||
public void setToNoModify(boolean toNoModify) {
|
|
||||||
isToNoModify = toNoModify;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isToVolatile() {
|
public boolean isToVolatile() {
|
||||||
return isToVolatile;
|
return type instanceof SymbolTypePointer && ((SymbolTypePointer) type).getElementType().isVolatile();
|
||||||
}
|
|
||||||
|
|
||||||
public void setToVolatile(boolean toVolatile) {
|
|
||||||
isToVolatile = toVolatile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPermanent() {
|
public boolean isPermanent() {
|
||||||
|
@ -63,16 +63,12 @@ public class Pass1AddressOfHandling extends Pass2SsaOptimization {
|
|||||||
variable.setKind(Variable.Kind.LOAD_STORE);
|
variable.setKind(Variable.Kind.LOAD_STORE);
|
||||||
SymbolType typeQualified = variable.getType().getQualified(true, variable.getType().isNomodify());
|
SymbolType typeQualified = variable.getType().getQualified(true, variable.getType().isNomodify());
|
||||||
variable.setType(typeQualified);
|
variable.setType(typeQualified);
|
||||||
// TODO: #121 remove
|
|
||||||
variable.setVolatile(true);
|
|
||||||
getLog().append("Setting struct to load/store in variable affected by address-of " + stmtStr);
|
getLog().append("Setting struct to load/store in variable affected by address-of " + stmtStr);
|
||||||
//getLog().append("Setting struct to load/store in variable affected by address-of: " + variable.toString() + " in " + stmtStr);
|
//getLog().append("Setting struct to load/store in variable affected by address-of: " + variable.toString() + " in " + stmtStr);
|
||||||
} else {
|
} else {
|
||||||
variable.setKind(Variable.Kind.LOAD_STORE);
|
variable.setKind(Variable.Kind.LOAD_STORE);
|
||||||
SymbolType typeQualified = variable.getType().getQualified(true, variable.getType().isNomodify());
|
SymbolType typeQualified = variable.getType().getQualified(true, variable.getType().isNomodify());
|
||||||
variable.setType(typeQualified);
|
variable.setType(typeQualified);
|
||||||
// TODO: #121 remove
|
|
||||||
variable.setVolatile(true);
|
|
||||||
getLog().append("Setting inferred volatile on symbol affected by address-of " + stmtStr);
|
getLog().append("Setting inferred volatile on symbol affected by address-of " + stmtStr);
|
||||||
//getLog().append("Setting inferred volatile on symbol affected by address-of: " + variable.toString() + " in " + stmtStr);
|
//getLog().append("Setting inferred volatile on symbol affected by address-of: " + variable.toString() + " in " + stmtStr);
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,6 @@ public class Pass1AsmUsesHandling extends Pass2SsaOptimization {
|
|||||||
variable.setKind(Variable.Kind.LOAD_STORE);
|
variable.setKind(Variable.Kind.LOAD_STORE);
|
||||||
SymbolType typeQualified = variable.getType().getQualified(true, variable.getType().isNomodify());
|
SymbolType typeQualified = variable.getType().getQualified(true, variable.getType().isNomodify());
|
||||||
variable.setType(typeQualified);
|
variable.setType(typeQualified);
|
||||||
// TODO: #121 Remove
|
|
||||||
variable.setVolatile(true);
|
|
||||||
getLog().append("Setting inferred volatile on symbol affected by address-of: " + variable.toString() + " in " + stmtStr);
|
getLog().append("Setting inferred volatile on symbol affected by address-of: " + variable.toString() + " in " + stmtStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,6 @@ public class Pass2DeInlineWordDerefIdx extends Pass2SsaOptimization {
|
|||||||
programValue.set(new PointerDereferenceSimple(tmpVar.getRef()));
|
programValue.set(new PointerDereferenceSimple(tmpVar.getRef()));
|
||||||
SymbolType pointerType = SymbolTypeInference.inferType(getScope(), new AssignmentRValue(tmpVarAssignment));
|
SymbolType pointerType = SymbolTypeInference.inferType(getScope(), new AssignmentRValue(tmpVarAssignment));
|
||||||
tmpVar.setType(pointerType);
|
tmpVar.setType(pointerType);
|
||||||
if(((SymbolTypePointer)pointerType).getElementType().isNomodify())
|
|
||||||
tmpVar.setToNoModify(true);
|
|
||||||
if(((SymbolTypePointer)pointerType).getElementType().isVolatile())
|
|
||||||
tmpVar.setToVolatile(true);
|
|
||||||
optimized.set(true);
|
optimized.set(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1254,13 +1254,13 @@ byte main::initNES1_i#1
|
|||||||
byte main::initNES1_i#2
|
byte main::initNES1_i#2
|
||||||
number~ main::initNES1_waitForVBlank1_$0
|
number~ main::initNES1_waitForVBlank1_$0
|
||||||
bool~ main::initNES1_waitForVBlank1_$1
|
bool~ main::initNES1_waitForVBlank1_$1
|
||||||
byte*~ main::initNES1_waitForVBlank1_$2
|
to_volatile byte*~ main::initNES1_waitForVBlank1_$2
|
||||||
byte*~ main::initNES1_waitForVBlank1_$3
|
to_volatile byte*~ main::initNES1_waitForVBlank1_$3
|
||||||
bool~ main::initNES1_waitForVBlank1_$4
|
bool~ main::initNES1_waitForVBlank1_$4
|
||||||
number~ main::initNES1_waitForVBlank2_$0
|
number~ main::initNES1_waitForVBlank2_$0
|
||||||
bool~ main::initNES1_waitForVBlank2_$1
|
bool~ main::initNES1_waitForVBlank2_$1
|
||||||
byte*~ main::initNES1_waitForVBlank2_$2
|
to_volatile byte*~ main::initNES1_waitForVBlank2_$2
|
||||||
byte*~ main::initNES1_waitForVBlank2_$3
|
to_volatile byte*~ main::initNES1_waitForVBlank2_$3
|
||||||
bool~ main::initNES1_waitForVBlank2_$4
|
bool~ main::initNES1_waitForVBlank2_$4
|
||||||
byte main::screensizex1_return
|
byte main::screensizex1_return
|
||||||
byte main::screensizex1_return#0
|
byte main::screensizex1_return#0
|
||||||
|
@ -702,13 +702,13 @@ byte main::initNES1_i#1
|
|||||||
byte main::initNES1_i#2
|
byte main::initNES1_i#2
|
||||||
number~ main::initNES1_waitForVBlank1_$0
|
number~ main::initNES1_waitForVBlank1_$0
|
||||||
bool~ main::initNES1_waitForVBlank1_$1
|
bool~ main::initNES1_waitForVBlank1_$1
|
||||||
byte*~ main::initNES1_waitForVBlank1_$2
|
to_volatile byte*~ main::initNES1_waitForVBlank1_$2
|
||||||
byte*~ main::initNES1_waitForVBlank1_$3
|
to_volatile byte*~ main::initNES1_waitForVBlank1_$3
|
||||||
bool~ main::initNES1_waitForVBlank1_$4
|
bool~ main::initNES1_waitForVBlank1_$4
|
||||||
number~ main::initNES1_waitForVBlank2_$0
|
number~ main::initNES1_waitForVBlank2_$0
|
||||||
bool~ main::initNES1_waitForVBlank2_$1
|
bool~ main::initNES1_waitForVBlank2_$1
|
||||||
byte*~ main::initNES1_waitForVBlank2_$2
|
to_volatile byte*~ main::initNES1_waitForVBlank2_$2
|
||||||
byte*~ main::initNES1_waitForVBlank2_$3
|
to_volatile byte*~ main::initNES1_waitForVBlank2_$3
|
||||||
bool~ main::initNES1_waitForVBlank2_$4
|
bool~ main::initNES1_waitForVBlank2_$4
|
||||||
byte main::x
|
byte main::x
|
||||||
byte main::x#0
|
byte main::x#0
|
||||||
|
@ -537,13 +537,13 @@ byte main::initNES1_i#1
|
|||||||
byte main::initNES1_i#2
|
byte main::initNES1_i#2
|
||||||
number~ main::initNES1_waitForVBlank1_$0
|
number~ main::initNES1_waitForVBlank1_$0
|
||||||
bool~ main::initNES1_waitForVBlank1_$1
|
bool~ main::initNES1_waitForVBlank1_$1
|
||||||
byte*~ main::initNES1_waitForVBlank1_$2
|
to_volatile byte*~ main::initNES1_waitForVBlank1_$2
|
||||||
byte*~ main::initNES1_waitForVBlank1_$3
|
to_volatile byte*~ main::initNES1_waitForVBlank1_$3
|
||||||
bool~ main::initNES1_waitForVBlank1_$4
|
bool~ main::initNES1_waitForVBlank1_$4
|
||||||
number~ main::initNES1_waitForVBlank2_$0
|
number~ main::initNES1_waitForVBlank2_$0
|
||||||
bool~ main::initNES1_waitForVBlank2_$1
|
bool~ main::initNES1_waitForVBlank2_$1
|
||||||
byte*~ main::initNES1_waitForVBlank2_$2
|
to_volatile byte*~ main::initNES1_waitForVBlank2_$2
|
||||||
byte*~ main::initNES1_waitForVBlank2_$3
|
to_volatile byte*~ main::initNES1_waitForVBlank2_$3
|
||||||
bool~ main::initNES1_waitForVBlank2_$4
|
bool~ main::initNES1_waitForVBlank2_$4
|
||||||
byte main::s
|
byte main::s
|
||||||
byte main::s#0
|
byte main::s#0
|
||||||
|
@ -1803,8 +1803,8 @@ word* bsearch16u::return#3
|
|||||||
word* bsearch16u::return#4
|
word* bsearch16u::return#4
|
||||||
word* bsearch16u::return#5
|
word* bsearch16u::return#5
|
||||||
void doplasma(byte* doplasma::screen)
|
void doplasma(byte* doplasma::screen)
|
||||||
byte*~ doplasma::$0
|
to_nomodify byte*~ doplasma::$0
|
||||||
byte*~ doplasma::$1
|
to_nomodify byte*~ doplasma::$1
|
||||||
byte~ doplasma::$2
|
byte~ doplasma::$2
|
||||||
bool~ doplasma::$3
|
bool~ doplasma::$3
|
||||||
bool~ doplasma::$4
|
bool~ doplasma::$4
|
||||||
|
@ -59,12 +59,12 @@ __start::@return: scope:[__start] from __start::@2
|
|||||||
SYMBOL TABLE SSA
|
SYMBOL TABLE SSA
|
||||||
void __start()
|
void __start()
|
||||||
void incscreen(word incscreen::ptr)
|
void incscreen(word incscreen::ptr)
|
||||||
byte*~ incscreen::$0
|
to_nomodify byte*~ incscreen::$0
|
||||||
byte*~ incscreen::$10
|
to_nomodify byte*~ incscreen::$10
|
||||||
byte*~ incscreen::$11
|
to_nomodify byte*~ incscreen::$11
|
||||||
byte*~ incscreen::$20
|
to_nomodify byte*~ incscreen::$20
|
||||||
byte*~ incscreen::$21
|
to_nomodify byte*~ incscreen::$21
|
||||||
byte*~ incscreen::$9
|
to_nomodify byte*~ incscreen::$9
|
||||||
word incscreen::ptr
|
word incscreen::ptr
|
||||||
word incscreen::ptr#0
|
word incscreen::ptr#0
|
||||||
word incscreen::ptr#1
|
word incscreen::ptr#1
|
||||||
|
@ -69,7 +69,7 @@ byte~ main::$0
|
|||||||
byte~ main::$1
|
byte~ main::$1
|
||||||
byte*~ main::$10
|
byte*~ main::$10
|
||||||
bool~ main::$11
|
bool~ main::$11
|
||||||
struct Setting*~ main::$2
|
to_nomodify struct Setting*~ main::$2
|
||||||
bool~ main::$3
|
bool~ main::$3
|
||||||
bool~ main::$4
|
bool~ main::$4
|
||||||
bool~ main::$5
|
bool~ main::$5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user