feat(mir): 添加寄存器分配 pass 支持
- 实现了核心寄存器分配接口 scc_reg_alloc.h - 添加 x86_64 架构特定的寄存器分配实现 - 实现基础的虚拟寄存器到物理寄存器分配逻辑 - 支持栈槽分配和重载/存储指令生成 fix(argparse): 修复帮助信息打印中的枚举类型显示 - 将固定大小缓冲区改为动态字符串处理 - 正确显示枚举类型的选项值和可选值列表 - 使用 | 分隔符展示多个可选值 refactor(main): 调整编译流程中的 pass 阶段支持 - 更新配置文件中各编译阶段的名称定义 - 添加对寄存器分配、帧布局等中间表示 pass 的支持 - 重构主流程以支持不同 MIR 阶段的代码输出
This commit is contained in:
@@ -161,9 +161,9 @@ void setup_argparse(scc_argparse_t *argparse, scc_config_t *config,
|
||||
[SCC_EMIT_STAGE_LIR] = "lir", // -L
|
||||
[SCC_EMIT_STAGE_MIR] = "mir", // -M
|
||||
|
||||
[SCC_EMIT_STAGE_MIR_PASS_REG_ALLOC] = "",
|
||||
[SCC_EMIT_STAGE_MIR_PASS_FLAME_LAYOUT] = "",
|
||||
[SCC_EMIT_STAGE_MIR_PASS_PROLOG_EPILOG] = "",
|
||||
[SCC_EMIT_STAGE_MIR_PASS_REG_ALLOC] = "reg_alloc",
|
||||
[SCC_EMIT_STAGE_MIR_PASS_FLAME_LAYOUT] = "frame_layout",
|
||||
[SCC_EMIT_STAGE_MIR_PASS_PROLOG_EPILOG] = "prolog_epilog",
|
||||
[SCC_EMIT_STAGE_FLATBIN] = "flatbin",
|
||||
[SCC_EMIT_STAGE_SCCF] = "sccf",
|
||||
[SCC_EMIT_STAGE_TARGET] = "target",
|
||||
|
||||
24
src/main.c
24
src/main.c
@@ -11,6 +11,8 @@
|
||||
#include <scc_lir_dump.h>
|
||||
#include <scc_mir_dump.h>
|
||||
|
||||
#include <scc_mir_pass.h>
|
||||
|
||||
#include <scc_ir2mcode.h>
|
||||
#include <scc_ir2sccf.h>
|
||||
#include <sccf2pe.h>
|
||||
@@ -271,7 +273,25 @@ sstream_drop:
|
||||
scc_mir_module_t mir_module;
|
||||
scc_mir_module_init(&mir_module);
|
||||
scc_lir2mir(&mir_module, &lir_module);
|
||||
if (config.emit_stage == SCC_EMIT_STAGE_MIR) {
|
||||
|
||||
switch (config.emit_stage) {
|
||||
case SCC_EMIT_STAGE_MIR:
|
||||
goto mir_dump;
|
||||
case SCC_EMIT_STAGE_MIR_PASS_REG_ALLOC:
|
||||
scc_mir_pass(&mir_module, SCC_MIR_STAGE_REGALLOC);
|
||||
goto mir_dump;
|
||||
case SCC_EMIT_STAGE_MIR_PASS_FLAME_LAYOUT:
|
||||
scc_mir_pass(&mir_module, SCC_MIR_STAGE_POST_REGALLOC);
|
||||
goto mir_dump;
|
||||
case SCC_EMIT_STAGE_MIR_PASS_PROLOG_EPILOG:
|
||||
scc_mir_pass(&mir_module, SCC_MIR_STAGE_POST_REGALLOC);
|
||||
goto mir_dump;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
do {
|
||||
mir_dump:
|
||||
scc_mir_dump_ctx_t mir_dump_ctx;
|
||||
scc_tree_dump_t tree_dump;
|
||||
if (fp == nullptr) {
|
||||
@@ -285,7 +305,7 @@ sstream_drop:
|
||||
scc_tree_dump_flush(&tree_dump, tree_dump_output, GET_VALID_FP(fp));
|
||||
scc_tree_dump_drop(&tree_dump);
|
||||
return 0;
|
||||
}
|
||||
} while (0);
|
||||
|
||||
if (config.emit_stage == SCC_EMIT_STAGE_FLATBIN) {
|
||||
scc_mcode_t mcode = {0};
|
||||
|
||||
Reference in New Issue
Block a user