Complete Lab2 IR generation and document process
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user