1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-25 11:32:07 +00:00
This commit is contained in:
jespergravgaard 2017-08-20 21:20:07 +02:00
parent ffce3298ef
commit 1982d01297
4 changed files with 4 additions and 51 deletions

View File

@ -209,7 +209,7 @@ public class Compiler {
private void pass4RegisterAllocation(Program program) {
new Pass4ZeroPageAllocation(program).allocate();
new Pass4LiveRangeEquivalenceClassesFinalize(program).allocate();
new Pass4RegistersFinalize(program).allocate(true);
// Initial Code generation

View File

@ -6,11 +6,11 @@ import java.util.ArrayList;
import java.util.List;
/**
* Zero Page Register Allocation for variables based on live ranges and phi equivalence classes.
* Finalize live range equivalence classes ensuring that all variables is in an equivalence class
*/
public class Pass4ZeroPageAllocation extends Pass2Base {
public class Pass4LiveRangeEquivalenceClassesFinalize extends Pass2Base {
public Pass4ZeroPageAllocation(Program program) {
public Pass4LiveRangeEquivalenceClassesFinalize(Program program) {
super(program);
}
@ -33,14 +33,6 @@ public class Pass4ZeroPageAllocation extends Pass2Base {
getLog().append(liveRangeEquivalenceClass.toString());
}
// Allocate zeropage registers to equivalence classes
// for (LiveRangeEquivalenceClass liveRangeEquivalenceClass : liveRangeEquivalenceClassSet.getEquivalenceClasses()) {
// List<VariableRef> variables = liveRangeEquivalenceClass.getVariables();
// Variable firstVar = getProgram().getScope().getVariable(variables.get(0));
// RegisterAllocation.Register zpRegister = allocateNewRegisterZp(firstVar.getType());
// liveRangeEquivalenceClass.setRegister(zpRegister);
// getLog().append("Allocated " + zpRegister + " to " + liveRangeEquivalenceClass);
// }
getProgram().setLiveRangeEquivalenceClassSet(liveRangeEquivalenceClassSet);
}
@ -97,39 +89,4 @@ public class Pass4ZeroPageAllocation extends Pass2Base {
}
/**
* The current zero page used to create new registers when needed.
*/
private int currentZp = 2;
/**
* Create a new register for a specific variable type.
*
* @param varType The variable type to create a register for.
* The register type created uses one or more zero page locations based on the variable type
* @return The new zeropage register
*/
private RegisterAllocation.Register allocateNewRegisterZp(SymbolType varType) {
if (varType.equals(SymbolTypeBasic.BYTE)) {
return new RegisterAllocation.RegisterZpByte(currentZp++);
} else if (varType.equals(SymbolTypeBasic.WORD)) {
RegisterAllocation.RegisterZpWord registerZpWord =
new RegisterAllocation.RegisterZpWord(currentZp);
currentZp = currentZp + 2;
return registerZpWord;
} else if (varType.equals(SymbolTypeBasic.BOOLEAN)) {
return new RegisterAllocation.RegisterZpBool(currentZp++);
} else if (varType.equals(SymbolTypeBasic.VOID)) {
// No need to setRegister register for VOID value
return null;
} else if (varType instanceof SymbolTypePointer) {
RegisterAllocation.RegisterZpPointerByte registerZpPointerByte =
new RegisterAllocation.RegisterZpPointerByte(currentZp);
currentZp = currentZp + 2;
return registerZpPointerByte;
} else {
throw new RuntimeException("Unhandled variable type " + varType);
}
}
}

View File

@ -1,8 +1,6 @@
byte STAR = 81;
byte[40*25] SCREEN = $0400;
main();
void main() {

View File

@ -1,8 +1,6 @@
byte STAR = 81;
byte[40*25] SCREEN = $0400;
main();
void main() {