summaryrefslogtreecommitdiff
path: root/willow/lib/IR/TypeContext.cpp
diff options
context:
space:
mode:
authorStefan Weigl-Bosker <stefan@s00.xyz>2026-02-19 13:13:41 -0500
committerGitHub <noreply@github.com>2026-02-19 13:13:41 -0500
commit1fd2d6d88f5f78d879bf38bb3fba7fa2e749d3b0 (patch)
treeeb5a0740956812678131970687377339fad5a541 /willow/lib/IR/TypeContext.cpp
parentadd95b14f74e6dbe04a6efe98ff0f20424930b73 (diff)
downloadcompiler-1fd2d6d88f5f78d879bf38bb3fba7fa2e749d3b0.tar.gz
[willow]: initial IRBuilder API (#9)
- add IRBuilder api - remove `name` field from `Value` - fix some bugs in IList interface - more verifier tests
Diffstat (limited to 'willow/lib/IR/TypeContext.cpp')
-rw-r--r--willow/lib/IR/TypeContext.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/willow/lib/IR/TypeContext.cpp b/willow/lib/IR/TypeContext.cpp
index e69de29..21e5173 100644
--- a/willow/lib/IR/TypeContext.cpp
+++ b/willow/lib/IR/TypeContext.cpp
@@ -0,0 +1,31 @@
+#include <willow/IR/TypeContext.h>
+
+namespace willow {
+
+Type TypeContext::IntType(std::size_t width) {
+ auto [it, _] = icache.try_emplace(IntTypeImpl::Key{width},
+ std::make_unique<IntTypeImpl>(width));
+
+ return Type(it->second.get());
+}
+
+Type TypeContext::PtrType(Type pointee) {
+ auto [it, _] = pcache.try_emplace(
+ PtrTypeImpl::Key{pointee}, std::make_unique<PtrTypeImpl>(pointee));
+
+ return Type(it->second.get());
+}
+
+Type TypeContext::VoidType() { return Type(voidty.get()); }
+
+Type TypeContext::BasicBlockType() { return Type{labelty.get()}; }
+
+Type TypeContext::FunctionType(Type ret, std::initializer_list<Type> params) {
+ auto [it, _] =
+ fncache.try_emplace(FunctionTypeImpl::Key{ret, params},
+ std::make_unique<FunctionTypeImpl>(ret, params));
+
+ return Type(it->second.get());
+};
+
+};