IR生成文件即IRGenxx设计

This commit is contained in:
jing
2025-12-29 20:30:16 +08:00
parent e1c1f2a40d
commit bb7f42e06e
7 changed files with 166 additions and 0 deletions

View File

@@ -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("不支持的语句类型");
}