Files
MY_COMPILER/midend/llvm/instr/CmpInstr.java
2025-12-10 17:58:17 +08:00

33 lines
759 B
Java

package midend.llvm.instr;
import midend.llvm.value.IrValue;
import midend.llvm.type.IrInterType;
public class CmpInstr extends IrInstr {
private CmpType cmpType;
public CmpInstr(String name, String op, IrValue lhs, IrValue rhs) {
super(IrInterType.BOOL, name, IrInstrType.CMP);
cmpType = CmpType.getCmpType(op);
addUse(lhs);
addUse(rhs);
}
public CmpType getCmpType() {
return cmpType;
}
public IrValue getLhs() {
return getUse(0);
}
public IrValue getRhs() {
return getUse(1);
}
public String toString() {
return getName() + " = " + "icmp " + cmpType.toString()
+ " i32 " + getLhs().getName() + ", " + getRhs().getName();
}
}