fix(ir): 规范ir实现
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user