IR生成文件即IRGenxx设计
This commit is contained in:
@@ -2,3 +2,18 @@
|
||||
// - 处理 if/while/return 等控制流构造
|
||||
// - 负责基本块创建、分支跳转与控制流收束
|
||||
|
||||
#include "irgen/IRGen.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "ast/AstNodes.h"
|
||||
#include "ir/IR.h"
|
||||
|
||||
void IRGenImpl::GenStmt(const ast::Stmt& stmt) {
|
||||
if (auto ret = dynamic_cast<const ast::ReturnStmt*>(&stmt)) {
|
||||
ir::Value* v = GenExpr(*ret->value);
|
||||
builder_.CreateRet(v);
|
||||
return;
|
||||
}
|
||||
throw std::runtime_error("不支持的语句类型");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user