From c2d4209f85f46cc91163bc47cc43db252c94acf6 Mon Sep 17 00:00:00 2001 From: Stefan Weigl-Bosker Date: Thu, 19 Feb 2026 18:51:48 -0500 Subject: [willow]: more cleanup, tests (#12) --- willow/lib/IR/Instruction.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'willow/lib/IR/Instruction.cpp') diff --git a/willow/lib/IR/Instruction.cpp b/willow/lib/IR/Instruction.cpp index a6e0c9b..517b6f9 100644 --- a/willow/lib/IR/Instruction.cpp +++ b/willow/lib/IR/Instruction.cpp @@ -34,6 +34,18 @@ bool Instruction::isTerminatorOp(Opcode op) { } } +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) { -- cgit v1.2.3