From 1fd2d6d88f5f78d879bf38bb3fba7fa2e749d3b0 Mon Sep 17 00:00:00 2001 From: Stefan Weigl-Bosker Date: Thu, 19 Feb 2026 13:13:41 -0500 Subject: [willow]: initial IRBuilder API (#9) - add IRBuilder api - remove `name` field from `Value` - fix some bugs in IList interface - more verifier tests --- willow/lib/IR/TypeContext.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'willow/lib/IR/TypeContext.cpp') 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 + +namespace willow { + +Type TypeContext::IntType(std::size_t width) { + auto [it, _] = icache.try_emplace(IntTypeImpl::Key{width}, + std::make_unique(width)); + + return Type(it->second.get()); +} + +Type TypeContext::PtrType(Type pointee) { + auto [it, _] = pcache.try_emplace( + PtrTypeImpl::Key{pointee}, std::make_unique(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 params) { + auto [it, _] = + fncache.try_emplace(FunctionTypeImpl::Key{ret, params}, + std::make_unique(ret, params)); + + return Type(it->second.get()); +}; + +}; -- cgit v1.2.3