From add95b14f74e6dbe04a6efe98ff0f20424930b73 Mon Sep 17 00:00:00 2001 From: Stefan Weigl-Bosker Date: Tue, 3 Feb 2026 14:59:53 -0500 Subject: [willow]: initial frontend work, unit tests (#8) --- willow/lib/IR/Instruction.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'willow/lib/IR/Instruction.cpp') diff --git a/willow/lib/IR/Instruction.cpp b/willow/lib/IR/Instruction.cpp index 587736d..a6e0c9b 100644 --- a/willow/lib/IR/Instruction.cpp +++ b/willow/lib/IR/Instruction.cpp @@ -1,4 +1,5 @@ #include +#include namespace willow { @@ -33,6 +34,19 @@ bool Instruction::isTerminatorOp(Opcode op) { } } -Successors Instruction::succs(); - +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 -- cgit v1.2.3