summaryrefslogtreecommitdiff
path: root/willow/lib/IR/Instruction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'willow/lib/IR/Instruction.cpp')
-rw-r--r--willow/lib/IR/Instruction.cpp18
1 files changed, 16 insertions, 2 deletions
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 <willow/IR/Instruction.h>
+#include <willow/IR/Instructions.h>
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<JmpInst *>(this);
+ return Successors{inst->getTarget()};
+ }
+ case Br: {
+ auto inst = static_cast<BrInst *>(this);
+ return Successors{inst->getTrueTarget(), inst->getFalseTarget()};
+ }
+ default:
+ return Successors{};
+ }
+}
}; // namespace willow