fix(ir): 规范ir实现

This commit is contained in:
jing
2026-03-11 00:38:05 +08:00
parent c72ffa6e39
commit 8f448df4bc
8 changed files with 132 additions and 22 deletions

View File

@@ -6,7 +6,18 @@
namespace ir {
Function::Function(std::string name, std::shared_ptr<Type> ret_type)
: Value(std::move(ret_type), std::move(name)),
entry_(std::make_unique<BasicBlock>("entry")) {}
: Value(std::move(ret_type), std::move(name)) {
entry_ = CreateBlock("entry");
}
BasicBlock* Function::CreateBlock(const std::string& name) {
auto block = std::make_unique<BasicBlock>(name);
auto* ptr = block.get();
blocks_.push_back(std::move(block));
if (!entry_) {
entry_ = ptr;
}
return ptr;
}
} // namespace ir