1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-19 15:29:48 +00:00

Removed signed byte register usage by allowing the fragment binding to also look at the variable type.

This commit is contained in:
Jesper Gravgaard 2017-12-10 20:00:00 +01:00
parent e2aa0cd7e0
commit 5a819659a0
3 changed files with 7 additions and 99 deletions

View File

@ -16,32 +16,19 @@ public class Registers {
return new RegisterAByte();
}
public static Register getRegisterASigned() {
return new RegisterASignedByte();
}
public static Register getRegisterXSigned() {
return new RegisterXSignedByte();
}
public static Register getRegisterYSigned() {
return new RegisterYSignedByte();
}
public static Register getRegisterALU() {
return new RegisterALUByte();
}
/** The register type. */
public enum RegisterType {
REG_A_BYTE, REG_A_SBYTE,
REG_Y_BYTE, REG_Y_SBYTE,
REG_X_BYTE, REG_X_SBYTE,
REG_A_BYTE,
REG_Y_BYTE,
REG_X_BYTE,
REG_ALU,
ZP_BYTE, ZP_SBYTE,
ZP_BYTE,
ZP_PTR_BYTE,
ZP_WORD,
ZP_SWORD,
ZP_BOOL,
CONSTANT
}
@ -117,21 +104,6 @@ public class Registers {
}
}
/** A zero page address used as a register for a single signed byte variable. */
public static class RegisterZpSignedByte extends RegisterZp {
public RegisterZpSignedByte(int zp) {
super(zp);
}
@Override
public RegisterType getType() {
return RegisterType.ZP_SBYTE;
}
}
/** Two zero page addresses used as a register for a single unsigned word variable. */
@ -148,20 +120,6 @@ public class Registers {
}
/** Two zero page addresses used as a register for a single signed word variable. */
public static class RegisterZpSWord extends RegisterZp {
public RegisterZpSWord(int zp) {
super(zp);
}
@Override
public RegisterType getType() {
return RegisterType.ZP_SWORD;
}
}
/** A zero page address used as a register for a boolean variable. */
public static class RegisterZpBool extends RegisterZp {
@ -271,49 +229,6 @@ public class Registers {
}
/** The A signed register. */
public static class RegisterASignedByte extends RegisterCpuByte {
@Override
public RegisterType getType() {
return RegisterType.REG_A_SBYTE;
}
@Override
public String toString() {
return "reg sbyte a";
}
}
/** The X signed register. */
public static class RegisterXSignedByte extends RegisterCpuByte {
@Override
public RegisterType getType() {
return RegisterType.REG_X_SBYTE;
}
@Override
public String toString() {
return "reg sbyte x";
}
}
/** The Y signed register. */
public static class RegisterYSignedByte extends RegisterCpuByte {
@Override
public RegisterType getType() {
return RegisterType.REG_Y_SBYTE;
}
@Override
public String toString() {
return "reg sbyte y";
}
}
/** The special ALU register. */
public static class RegisterALUByte extends RegisterCpuByte {
@Override

View File

@ -30,13 +30,6 @@ public class Pass4RegisterUpliftPotentialInitialize extends Pass2Base {
Registers.getRegisterX(),
Registers.getRegisterY());
registerPotentials.setPotentialRegisters(equivalenceClass, potentials);
} else if (registerType.equals(Registers.RegisterType.ZP_SBYTE)) {
List<Registers.Register> potentials = Arrays.asList(
defaultRegister,
Registers.getRegisterASigned(),
Registers.getRegisterXSigned(),
Registers.getRegisterYSigned());
registerPotentials.setPotentialRegisters(equivalenceClass, potentials);
} else {
registerPotentials.setPotentialRegisters(equivalenceClass, Arrays.asList(defaultRegister));
}

View File

@ -144,10 +144,10 @@ public class Pass4RegistersFinalize extends Pass2Base {
currentZp = currentZp + 2;
return registerZpWord;
} else if (SymbolType.isSWord(varType)) {
Registers.RegisterZpSWord registerZpSWord =
new Registers.RegisterZpSWord(currentZp);
Registers.RegisterZpWord registerZpWord =
new Registers.RegisterZpWord(currentZp);
currentZp = currentZp + 2;
return registerZpSWord;
return registerZpWord;
} else if (varType.equals(SymbolType.BOOLEAN)) {
return new Registers.RegisterZpBool(currentZp++);
} else if (varType.equals(SymbolType.VOID)) {