summaryrefslogtreecommitdiff
path: root/willow/lib/IR/Instruction.cpp
diff options
context:
space:
mode:
authorStefan Weigl-Bosker <stefan@s00.xyz>2026-02-19 18:45:44 -0500
committerStefan Weigl-Bosker <stefan@s00.xyz>2026-02-19 18:45:44 -0500
commitaf3d0ad1926eb825f64152cf217fc9a4777f0be3 (patch)
tree8d7f73ce6c3c89863418382d8d553a06c668bbb3 /willow/lib/IR/Instruction.cpp
parentd11fbc8268f5775ad783f8570478daad4a9e81cf (diff)
downloadcompiler-more-tests.tar.gz
[willow]: more cleanup, testsmore-tests
Diffstat (limited to 'willow/lib/IR/Instruction.cpp')
-rw-r--r--willow/lib/IR/Instruction.cpp12
1 files changed, 12 insertions, 0 deletions
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) {