1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-08-02 09:29:35 +00:00

Using cached symbol table for faster uplift

This commit is contained in:
jespergravgaard 2017-11-11 18:22:45 +01:00
parent 796edcc05b
commit ffbc958d47
6 changed files with 9 additions and 9 deletions

View File

@ -67,7 +67,7 @@ public class Pass4AssertNoCpuClobber extends Pass2Base {
// Non-assigned alive variables must not be clobbered
for (VariableRef aliveVar : aliveVars) {
Variable variable = getProgram().getScope().getVariable(aliveVar);
Variable variable = getProgram().getSymbolInfos().getVariable(aliveVar);
Registers.Register aliveVarRegister = variable.getAllocation();
if (aliveVarRegister.isZp()) {
// No need to check a zp-register - here we are only interested in CPU registers

View File

@ -219,7 +219,7 @@ public class Pass4CodeGeneration {
boolean isAlu = false;
if (lValue instanceof VariableRef) {
VariableRef lValueRef = (VariableRef) lValue;
Registers.Register lValRegister = program.getScope().getVariable(lValueRef).getAllocation();
Registers.Register lValRegister = program.getSymbolInfos().getVariable(lValueRef).getAllocation();
if (lValRegister.getType().equals(Registers.RegisterType.REG_ALU_BYTE)) {
asm.addComment(statement + " // ALU");
StatementAssignment assignmentAlu = assignment;

View File

@ -68,8 +68,8 @@ public class Pass4LiveRangeEquivalenceClassesFinalize extends Pass2Base {
for (VariableRef preference : preferences) {
LiveRangeEquivalenceClass preferenceEquivalenceClass = liveRangeEquivalenceClassSet.getEquivalenceClass(preference);
if (preferenceEquivalenceClass != null) {
Variable potentialVariable = getProgram().getScope().getVariable(preference);
Variable lValVariable = getProgram().getScope().getVariable(lValVar);
Variable potentialVariable = getProgram().getSymbolInfos().getVariable(preference);
Variable lValVariable = getProgram().getSymbolInfos().getVariable(lValVar);
if (lValVariable.getType().equals(potentialVariable.getType())) {
if (!lValLiveRange.overlaps(preferenceEquivalenceClass.getLiveRange())) {
chosen = preferenceEquivalenceClass;

View File

@ -30,7 +30,7 @@ public class Pass4RegisterUpliftRemains extends Pass2Base {
getLog().append("Attempting to uplift remaining variables in"+equivalenceClass);
RegisterCombinationIterator combinationIterator = new RegisterCombinationIterator(Arrays.asList(equivalenceClass), getProgram().getRegisterPotentials());
VariableRef variableRef = equivalenceClass.getVariables().get(0);
Scope testedScope = getProgram().getScope().getVariable(variableRef).getScope();
Scope testedScope = getProgram().getSymbolInfos().getVariable(variableRef).getScope();
Pass4RegisterUpliftCombinations.chooseBestUpliftCombination(combinationIterator, maxCombinations, unknownFragments, testedScope.getRef(), getProgram());
}
}

View File

@ -110,7 +110,7 @@ public class Pass4RegistersFinalize extends Pass2Base {
if (register == null || register.isZp()) {
String before = register == null ? null : register.toString();
VariableRef variableRef = equivalenceClass.getVariables().get(0);
Variable variable = getProgram().getScope().getVariable(variableRef);
Variable variable = getProgram().getSymbolInfos().getVariable(variableRef);
register = allocateNewRegisterZp(variable);
equivalenceClass.setRegister(register);
if (before == null || !before.equals(register.toString())) {

View File

@ -47,9 +47,9 @@ public class Pass4ZeroPageCoalesce extends Pass2Base {
private boolean canCoalesce(LiveRangeEquivalenceClass myEquivalenceClass, LiveRangeEquivalenceClass otherEquivalenceClass) {
VariableRef myVariableRef = myEquivalenceClass.getVariables().get(0);
Variable myVariable = getProgram().getScope().getVariable(myVariableRef);
Variable myVariable = getProgram().getSymbolInfos().getVariable(myVariableRef);
VariableRef otherVariableRef = otherEquivalenceClass.getVariables().get(0);
Variable otherVariable = getProgram().getScope().getVariable(otherVariableRef);
Variable otherVariable = getProgram().getSymbolInfos().getVariable(otherVariableRef);
if (myVariable.getType().equals(otherVariable.getType())) {
// Types match
if (myEquivalenceClass.getRegister().isZp() && otherEquivalenceClass.getRegister().isZp()) {
@ -59,7 +59,7 @@ public class Pass4ZeroPageCoalesce extends Pass2Base {
getProgram().getLiveRangeEquivalenceClassSet().storeRegisterAllocation();
// Try out the coalesce to test if it works
for (VariableRef var : otherEquivalenceClass.getVariables()) {
Variable variable = getProgram().getScope().getVariable(var);
Variable variable = getProgram().getSymbolInfos().getVariable(var);
variable.setAllocation(myEquivalenceClass.getRegister());
}
if(!Pass4RegisterUpliftCombinations.isAllocationOverlapping(getProgram())) {