Complete Lab2 IR generation and document process

This commit is contained in:
2026-04-16 00:21:35 +08:00
parent 6fc0c89072
commit 979d271ebe
23 changed files with 2583 additions and 471 deletions

View File

@@ -5,9 +5,14 @@
namespace ir {
Function::Function(std::string name, std::shared_ptr<Type> ret_type)
Function::Function(std::string name, std::shared_ptr<Type> ret_type,
std::vector<std::shared_ptr<Type>> param_types)
: Value(std::move(ret_type), std::move(name)) {
entry_ = CreateBlock("entry");
for (size_t i = 0; i < param_types.size(); ++i) {
arguments_.push_back(std::make_unique<Argument>(
param_types[i], "a" + std::to_string(i), this,
static_cast<unsigned>(i)));
}
}
BasicBlock* Function::CreateBlock(const std::string& name) {
@@ -29,4 +34,8 @@ const std::vector<std::unique_ptr<BasicBlock>>& Function::GetBlocks() const {
return blocks_;
}
const std::vector<std::unique_ptr<Argument>>& Function::GetArguments() const {
return arguments_;
}
} // namespace ir