diff options
Diffstat (limited to 'willow/lib/IR/TypeContext.cpp')
| -rw-r--r-- | willow/lib/IR/TypeContext.cpp | 31 |
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()); +}; + +}; |