#include namespace willow { UnaryInst::UnaryInst(Opcode op, Type type, Value *value, std::optional loc) : Instruction(op, type, loc) { addOperand(value); } BinaryInst::BinaryInst(Opcode op, Type type, Value *lhs, Value *rhs, std::optional loc) : Instruction(op, type, loc) { addOperand(lhs); addOperand(rhs); } BrInst::BrInst(Type type, Value *condition, BasicBlock *true_target, BasicBlock *false_target, std::optional loc) : Instruction(Opcode::Br, type, loc) { addOperand(condition); addOperand(true_target); addOperand(false_target); } Value *BrInst::getCondition() { return getOperand(0); } const Value *BrInst::getCondition() const { return getOperand(0); } BasicBlock *BrInst::getTrueTarget() { return static_cast(getOperand(1)); } const BasicBlock *BrInst::getTrueTarget() const { return static_cast(getOperand(1)); } BasicBlock *BrInst::getFalseTarget() { return static_cast(getOperand(2)); } const BasicBlock *BrInst::getFalseTarget() const { return static_cast(getOperand(2)); } RetInst::RetInst(Type voidty, std::optional loc) : Instruction(Opcode::Ret, voidty, loc) {} RetInst::RetInst(Type voidty, Value *val, std::optional loc) : Instruction(Opcode::Ret, voidty, loc) { addOperand(val); } PhiInst::PhiInst(Type type, std::initializer_list> args, std::optional loc) : Instruction(Opcode::Phi, type, loc) { for (auto [bb, v] : args) { addOperand(static_cast(bb)); addOperand(v); } } } // namespace willow