feat: 编译管线/类型层 crate 补全多级日志宏 + 关键路径日志

This commit is contained in:
2026-08-10 17:56:28 +08:00
parent 9fa8ae5b5f
commit 8a53bfb584
34 changed files with 421 additions and 1 deletions
+3
View File
@@ -43,8 +43,10 @@ impl Compiler {
pub fn compile(&self, program: &oxide_parser::Program) -> Result<CompiledModule, String> {
crate::compiler_debug!("compile: starting...");
let mut ir = Emitter::new().emit_program(program)?;
crate::compiler_debug!("compile: after emit {} insts", ir.insts.len());
if self.enable_dce {
oxide_dce::dce(&mut ir); // 顶层函数;nested 不递归
crate::compiler_debug!("compile: after DCE {} insts", ir.insts.len());
}
if self.enable_regalloc && !ir.const_overflow {
// 优化管线:liveness → 精确 DCE → 重算 liveness → RegAlloc
@@ -56,6 +58,7 @@ impl Compiler {
let cfg2 = oxide_cfg::build_cfg(&ir); // 精确 DCE 删指令后 inst 下标位移,CFG 重建
let live2 = oxide_liveness::liveness(&ir, &cfg2); // 重算,绝不用过期 live
oxide_regalloc::alloc(&mut ir, &live2)?; // 无可行染色 → RangeError 上抛
crate::compiler_debug!("compile: after regalloc {} insts", ir.insts.len());
}
crate::compiler_debug!("compile: done, {} instructions", ir.insts.len());
let mut module = lower(&ir)?;