#include #include namespace willow { bool Instruction::isTerminatorOp(Opcode op) { using enum Opcode; switch (op) { case Jmp: case Br: case Call: case Ret: return true; case Add: case Mul: case Sub: case Div: case Mod: case Shl: case Shr: case Ashl: case Ashr: case Eq: case Lt: case Gt: case Le: case Ge: case And: case Or: case Not: case Phi: case Alloca: return false; } } void Instruction::setOperand(std::size_t index, Value *operand) { assert(index < operands.size() && "Operand index out of bounds"); assert(operand && "Operand cannot be null"); Value *old = operands[index]; if (old == operand) return; old->delUse(this); operands[index] = operand; operand->addUse(this); } Successors Instruction::succs() { using enum Opcode; switch (op) { case Jmp: { auto inst = static_cast(this); return Successors{inst->getTarget()}; } case Br: { auto inst = static_cast(this); return Successors{inst->getTrueTarget(), inst->getFalseTarget()}; } default: return Successors{}; } } }; // namespace willow