stage1 重构代码新增c后端
This commit is contained in:
1 parent
fc2d8f8db4
commit
3714c2d142
24 files changed
+1539
-593
No files matched your search
+3
-14
@@ -1,18 +1,7 @@
|
||||
/* ir_opt.c - IR 层优化 pass
|
||||
/* ir_opt.c - IR 层优化 pass(默认关闭,splc0 --opt 驱动)。
|
||||
*
|
||||
* 通用函数内联(任意大小/形状的 callee,不再限叶子):
|
||||
* - callee 体内允许 control.call(嵌套调用)、分支/循环、多个返回、unit 返回;
|
||||
* - 参数:克隆体内 Param 的“使用处”替换为调用实参 ref;
|
||||
* - 控制流:克隆体追加到调用者末尾,内部 br/jmp/label 整体 +shift;
|
||||
* - 返回:
|
||||
* * 有返回值:在调用者追加 ret 槽(MemAlloca)与常量 1;每个 Ret 改为
|
||||
* jmp 到“MemStore(槽, val) + jmp(join)”,join 处 MemLoad(槽) 供使用者;
|
||||
* * 无返回值(unit):每个 Ret 直接 jmp 到调用点之后。
|
||||
* - 调用点改为 jmp 到克隆体入口;其使用者改指到 join 的 MemLoad(或 0)。
|
||||
* - 防环:若 callee(传递)可达 caller,则拒绝内联,保证调用图保持无环、
|
||||
* 内联过程终止(直接/间接递归都不会被内联)。
|
||||
* - 迭代到不动点(无环调用图上轮数有上界)。
|
||||
* 默认关闭(splc0 --opt 驱动),且只内联显式 `#inline` 标记的 callee。 */
|
||||
* 通用函数内联:任意 callee,仅内联显式 `#inline` 标记者。
|
||||
* 防环:callee 传递可达 caller 时拒绝,保证调用图无环、迭代到不动点。 */
|
||||
|
||||
#include "ir_opt.h"
|
||||
|
||||
|
||||
Reference in new issue
Block a user