summaryrefslogtreecommitdiff
path: root/willow/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorStefan Weigl-Bosker <stefan@s00.xyz>2026-02-19 18:51:48 -0500
committerGitHub <noreply@github.com>2026-02-19 18:51:48 -0500
commitc2d4209f85f46cc91163bc47cc43db252c94acf6 (patch)
tree8d7f73ce6c3c89863418382d8d553a06c668bbb3 /willow/lib/IR/Function.cpp
parentd11fbc8268f5775ad783f8570478daad4a9e81cf (diff)
downloadcompiler-c2d4209f85f46cc91163bc47cc43db252c94acf6.tar.gz
[willow]: more cleanup, tests (#12)
Diffstat (limited to 'willow/lib/IR/Function.cpp')
-rw-r--r--willow/lib/IR/Function.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/willow/lib/IR/Function.cpp b/willow/lib/IR/Function.cpp
new file mode 100644
index 0000000..500d917
--- /dev/null
+++ b/willow/lib/IR/Function.cpp
@@ -0,0 +1,26 @@
+#include <willow/IR/Function.h>
+
+namespace willow {
+
+BasicBlock *Function::addBlock(std::unique_ptr<BasicBlock> block) {
+ auto p = block.get();
+ blocks.push_back(std::move(block));
+ p->setParent(this);
+ return p;
+}
+
+const BasicBlock *Function::entryBlock() const {
+ if (blocks.empty())
+ return nullptr;
+ else
+ return blocks.front().get();
+}
+
+BasicBlock *Function::entryBlock() {
+ if (blocks.empty())
+ return nullptr;
+ else
+ return blocks.front().get();
+}
+
+}; // namespace willow