37 lines
1.0 KiB
Java
37 lines
1.0 KiB
Java
package backend.mips.instr;
|
|
|
|
import backend.mips.instr.type.MipsBranchType;
|
|
import backend.mips.instr.type.MipsType;
|
|
import backend.mips.Register;
|
|
|
|
public class MipsBranch extends MipsInstr{
|
|
private MipsBranchType branchType;
|
|
private Register rs;
|
|
private Register rt;
|
|
private String label;
|
|
|
|
public MipsBranch(MipsBranchType branchType, Register rs, Register rt, String label) {
|
|
super(MipsType.BRANCH);
|
|
this.branchType = branchType;
|
|
this.rs = rs;
|
|
this.rt = rt;
|
|
this.label = label;
|
|
}
|
|
|
|
public MipsBranch(MipsBranchType branchType, Register rs, String label) {
|
|
super(MipsType.BRANCH);
|
|
this.branchType = branchType;
|
|
this.rs = rs;
|
|
this.rt = null;
|
|
this.label = label;
|
|
}
|
|
|
|
public String toString() {
|
|
if (this.rt == null) {
|
|
return this.branchType.toString() + " " + this.rs + ", " + this.label + "\n";
|
|
} else {
|
|
return this.branchType.toString() + " " + this.rs + ", " + this.rt + ", " + this.label + "\n";
|
|
}
|
|
}
|
|
}
|