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:45:33 +01:00
parent ffbc958d47
commit 1b999c8c1d
7 changed files with 13 additions and 14 deletions

View File

@ -63,7 +63,7 @@ public class AsmFragmentSignature {
throw new AsmFragment.AluNotApplicableException("Error! ALU register only allowed as rValue2. " + assignment);
}
VariableRef assignmentRValue2 = (VariableRef) assignment.getrValue2();
Variable assignmentRValue2Var = program.getScope().getVariable(assignmentRValue2);
Variable assignmentRValue2Var = program.getSymbolInfos().getVariable(assignmentRValue2);
Registers.Register rVal2Register = assignmentRValue2Var.getAllocation();
if (!rVal2Register.getType().equals(Registers.RegisterType.REG_ALU_BYTE)) {
@ -256,7 +256,7 @@ public class AsmFragmentSignature {
}
if (value instanceof VariableRef) {
value = program.getScope().getVariable((VariableRef) value);
value = program.getSymbolInfos().getVariable((VariableRef) value);
}
if (value instanceof ConstantRef) {
value = program.getScope().getConstant((ConstantRef) value);

View File

@ -105,7 +105,7 @@ public class LiveRangeEquivalenceClassSet {
for (LiveRangeEquivalenceClass equivalenceClass : getEquivalenceClasses()) {
Registers.Register register = equivalenceClass.getRegister();
for (VariableRef variable : equivalenceClass.getVariables()) {
Variable var = program.getScope().getVariable(variable);
Variable var = program.getSymbolInfos().getVariable(variable);
var.setAllocation(register);
}
}

View File

@ -186,10 +186,9 @@ public class PhiTransitions {
for (int i = 0; i < assignments.size(); i++) {
PhiTransition.PhiAssignment assignment = assignments.get(i);
PhiTransition.PhiAssignment otherAssignment = otherAssignments.get(i);
ProgramScope scope = program.getScope();
if (assignment.getVariable() instanceof VariableRef && otherAssignment.getVariable() instanceof VariableRef) {
Variable var = scope.getVariable((VariableRef) assignment.getVariable());
Variable otherVar = scope.getVariable((VariableRef) otherAssignment.getVariable());
if (assignment.getVariable() != null && otherAssignment.getVariable() != null) {
Variable var = program.getSymbolInfos().getVariable(assignment.getVariable());
Variable otherVar = program.getSymbolInfos().getVariable(otherAssignment.getVariable());
if (!var.getAllocation().equals(otherVar.getAllocation())) {
return false;
}
@ -197,8 +196,8 @@ public class PhiTransitions {
return false;
}
if (assignment.getrValue() instanceof VariableRef && otherAssignment.getrValue() instanceof VariableRef) {
Variable var = scope.getVariable((VariableRef) assignment.getrValue());
Variable otherVar = scope.getVariable((VariableRef) otherAssignment.getrValue());
Variable var = program.getSymbolInfos().getVariable((VariableRef) assignment.getrValue());
Variable otherVar = program.getSymbolInfos().getVariable((VariableRef) otherAssignment.getrValue());
if (!var.getAllocation().equals(otherVar.getAllocation())) {
return false;
}

View File

@ -25,11 +25,11 @@ public class RegisterCombination {
* Allocate the registers of the combination into the programs register allocation
* (does not update the allocation in the equivalence classes).
*/
public void allocate(ProgramScope scope) {
public void allocate(Program program) {
for (LiveRangeEquivalenceClass equivalenceClass : allocation.keySet()) {
Registers.Register register = allocation.get(equivalenceClass);
for (VariableRef variable : equivalenceClass.getVariables()) {
Variable var = scope.getVariable(variable);
Variable var = program.getSymbolInfos().getVariable(variable);
var.setAllocation(register);
}
}

View File

@ -386,7 +386,7 @@ public class Pass4CodeGeneration {
private Registers.Register getRegister(RValue rValue) {
if (rValue instanceof VariableRef) {
VariableRef rValueRef = (VariableRef) rValue;
return program.getScope().getVariable(rValueRef).getAllocation();
return program.getSymbolInfos().getVariable(rValueRef).getAllocation();
} else {
return null;
}

View File

@ -112,7 +112,7 @@ public class Pass4RegisterUpliftCombinations extends Pass2Base {
// Reset register allocation to original zero page allocation
new Pass4RegistersFinalize(program).allocate(false);
// Apply the uplift combination
combination.allocate(program.getScope());
combination.allocate(program);
// Check the register allocation for whether a is register being allocated to two variables with overlapping live ranges
if (isAllocationOverlapping(program)) {
if (program.getLog().isVerboseUplift()) {

View File

@ -129,7 +129,7 @@ public class Pass4RegisterUpliftPotentialRegisterAnalysis extends Pass2Base {
// Reset register allocation to original zero page allocation
new Pass4RegistersFinalize(getProgram()).allocate(false);
// Apply the combination
combination.allocate(getProgram().getScope());
combination.allocate(getProgram());
// Generate ASM
AsmProgram asm = new AsmProgram();
asm.startSegment(statement.getIndex(), statement.toString(getProgram(), true));