Files
MY_COMPILER/backend/mips/instr/MipsJump.java
2025-12-12 20:14:00 +08:00

34 lines
871 B
Java

package backend.mips.instr;
import backend.mips.Register;
import backend.mips.instr.type.MipsJumpType;
import backend.mips.instr.type.MipsType;
public class MipsJump extends MipsInstr {
private MipsJumpType jumpType;
private String label;
private Register rd;
public MipsJump(MipsJumpType jumpType, String label) {
super(MipsType.JUMP);
this.jumpType = jumpType;
this.label = label;
this.rd = null;
}
public MipsJump(MipsJumpType jumpType, Register rd) {
super(MipsType.JUMP);
this.jumpType = jumpType;
this.label = null;
this.rd = rd;
}
public String toString() {
if (this.rd == null) {
return this.jumpType.toString() + " " + this.label + "\n";
} else {
return this.jumpType.toString() + " " + this.rd + "\n";
}
}
}