mips without optimize

This commit is contained in:
colden
2025-12-12 20:14:00 +08:00
parent 84827838e2
commit c94bebf37b
130 changed files with 5462 additions and 4182 deletions

39
backend/mips/instr/MipsAlu.java Executable file
View File

@@ -0,0 +1,39 @@
package backend.mips.instr;
import backend.mips.Register;
import backend.mips.instr.type.MipsAluType;
import backend.mips.instr.type.MipsType;
public class MipsAlu extends MipsInstr {
private MipsAluType aluType;
private Register rd;
private Register rs;
private Register rt;
private int immediate;
private boolean isImInstr;
public MipsAlu(MipsAluType aluType, Register rd, Register rs, Register rt) {
super(MipsType.ALU);
this.aluType = aluType;
this.rd = rd;
this.rs = rs;
this.rt = rt;
this.immediate = 0;
this.isImInstr = false;
}
public MipsAlu(MipsAluType aluType, Register rd, Register rs, int immediate) {
super(MipsType.ALU);
this.aluType = aluType;
this.rd = rd;
this.rs = rs;
this.rt = null;
this.immediate = immediate;
this.isImInstr = true;
}
public String toString() {
return isImInstr ? aluType.toString() + " " + rd + ", " + rs + ", " + immediate + "\n"
: aluType.toString() + " " + rd + ", " + rs + ", " + rt + "\n";
}
}