refactor(irgen): 按新版文档拆分 IRGen 模块

This commit is contained in:
Lane0218
2025-12-27 14:44:11 +08:00
parent cf2e6e0b46
commit 35da726b00
8 changed files with 29 additions and 13 deletions

4
src/irgen/CMakeLists.txt Normal file
View File

@@ -0,0 +1,4 @@
# src/irgen/ 子模块构建脚本:
# - 编译 IR 生成相关源文件Driver/Func/Stmt/Exp/Decl
# - 作为 src/ 的子目标被链接到最终可执行文件(具体组织方式按工程实现选择)

View File

@@ -1,5 +0,0 @@
// AST -> IR平台无关、LLVM 风格):
// - 将带语义信息的 AST 翻译为 src/ir/* 中的 IR 结构
// - 负责控制流结构化翻译(基本块、分支、循环)
// - 生成函数与全局对象,翻译表达式求值与调用等

4
src/irgen/IRGenDecl.cpp Normal file
View File

@@ -0,0 +1,4 @@
// 声明翻译模块:
// - 处理全局变量与局部变量声明
// - 处理数组初始化、空间分配与初值生成等

View File

@@ -0,0 +1,4 @@
// IR 生成驱动Driver
// - 驱动 Visitor 遍历 AST调度各子模块完成翻译
// - 统一管理模块级翻译入口与上下文Module/IRBuilder 等)
// - 组织函数/语句/表达式/声明等翻译流程

4
src/irgen/IRGenExp.cpp Normal file
View File

@@ -0,0 +1,4 @@
// 表达式翻译模块:
// - 处理算术运算、比较、逻辑运算、函数调用等表达式
// - 生成对应的 IR 指令并返回 SSA 值

4
src/irgen/IRGenFunc.cpp Normal file
View File

@@ -0,0 +1,4 @@
// 函数翻译模块:
// - 处理函数定义、参数列表与返回值翻译
// - 创建并填充对应的 IR Function 对象

4
src/irgen/IRGenStmt.cpp Normal file
View File

@@ -0,0 +1,4 @@
// 语句翻译模块:
// - 处理 if/while/return 等控制流构造
// - 负责基本块创建、分支跳转与控制流收束