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

View File

@@ -0,0 +1,42 @@
package backend.mips.instr;
import backend.mips.instr.type.MipsCompareType;
import backend.mips.instr.type.MipsType;
import backend.mips.Register;
public class MipsComp extends MipsInstr {
private MipsCompareType compareType;
private Register rd;
private Register rs;
private Register rt;
private int immediate;
private boolean isImmediate;
public MipsComp(MipsCompareType compareType, Register rd, Register rs, Register rt) {
super(MipsType.COMPARE);
this.compareType = compareType;
this.rd = rd;
this.rs = rs;
this.rt = rt;
this.immediate = 0;
this.isImmediate = false;
}
public MipsComp(MipsCompareType compareType, Register rd, Register rs, int immediate) {
super(MipsType.COMPARE);
this.compareType = compareType;
this.rd = rd;
this.rs = rs;
this.rt = null;
this.immediate = immediate;
this.isImmediate = true;
}
public String toString() {
if (this.isImmediate) {
return this.compareType.toString() + " " + this.rd + ", " + this.rs + ", " + this.immediate + "\n";
} else {
return this.compareType.toString() + " " + this.rd + ", " + this.rs + ", " + this.rt + "\n";
}
}
}