// IR Function: // - 保存参数列表、基本块列表 // - 记录函数属性/元信息(按需要扩展) #include "ir/IR.h" namespace ir { Function::Function(std::string name, std::shared_ptr ret_type) : Value(std::move(ret_type), std::move(name)) { entry_ = CreateBlock("entry"); } BasicBlock* Function::CreateBlock(const std::string& name) { auto block = std::make_unique(name); auto* ptr = block.get(); ptr->SetParent(this); blocks_.push_back(std::move(block)); if (!entry_) { entry_ = ptr; } return ptr; } BasicBlock* Function::GetEntry() { return entry_; } const BasicBlock* Function::GetEntry() const { return entry_; } const std::vector>& Function::GetBlocks() const { return blocks_; } } // namespace ir