feat(compiler): 启用 ir2mcode 和 sccf2target 库并实现 x86_64 代码生成
- 在 cbuild.toml 中启用 ir2mcode 和 sccf2target 依赖库 - 修改 justfile 中的构建命令,使用 release 模式并更新 tokei 统计排除 mcode 目录 - 重构 LIR 中的地址操作数类型,将 SCC_LIR_INSTR_KIND_ADDR 重命名为 SCC_LIR_INSTR_KIND_MEM - 实现完整的 MIR 到 x86_64 机器码转换,包括: - 添加 move、compare、binary operation 等指令发射函数 - 实现条件分支和跳转指令生成 - 支持算术、逻辑、移位等基本操作 - 添加调用和返回指令处理 - 实现栈分配和寄存器分配功能 - 完善 ir2mcode 模块,将 MIR 指令转换为机器码 - 更新 ir2sccf 模块,集成机器码生成功能 - 添加 mcode 库的架构支持和内存管理功能 - 修复 PE 文件生成中的空指针检查问题
This commit is contained in:
@@ -37,7 +37,7 @@ typedef enum {
|
||||
SCC_LIR_INSTR_KIND_IMM, // 整数立即数
|
||||
SCC_LIR_INSTR_KIND_FIMM, // 浮点立即数
|
||||
SCC_LIR_INSTR_KIND_SYMBOL, // 全局符号 (函数名、全局变量、字符串常量)
|
||||
SCC_LIR_INSTR_KIND_ADDR // 复杂地址表达式 (base + index*scale + offset)
|
||||
SCC_LIR_INSTR_KIND_MEM, // 复杂地址表达式 (base + index*scale + offset)
|
||||
} scc_lir_instr_kind_t;
|
||||
|
||||
/**
|
||||
@@ -73,8 +73,7 @@ typedef struct scc_lir_instr {
|
||||
#define SCC_LIR_SYMBOL(s) \
|
||||
((scc_lir_val_t){.kind = SCC_LIR_INSTR_KIND_SYMBOL, .data.symbol = (s)})
|
||||
#define SCC_LIR_ADDR(b, i, s, o) \
|
||||
((scc_lir_val_t){.kind = SCC_LIR_INSTR_KIND_ADDR, \
|
||||
.data.addr = {b, i, s, o}})
|
||||
((scc_lir_val_t){.kind = SCC_LIR_INSTR_KIND_MEM, .data.addr = {b, i, s, o}})
|
||||
|
||||
#define SCC_LIR_SIZE_8 1
|
||||
#define SCC_LIR_SIZE_16 2
|
||||
|
||||
@@ -159,7 +159,7 @@ static void dump_operand(scc_lir_dump_ctx_t *ctx, const scc_lir_val_t *op) {
|
||||
scc_tree_dump_append_fmt(td, "@%s",
|
||||
op->data.symbol ? op->data.symbol : "<null>");
|
||||
break;
|
||||
case SCC_LIR_INSTR_KIND_ADDR: {
|
||||
case SCC_LIR_INSTR_KIND_MEM: {
|
||||
const scc_lir_addr_t *addr = &op->data.addr;
|
||||
scc_tree_dump_append(td, "[");
|
||||
if (addr->base != -1) {
|
||||
|
||||
Reference in New Issue
Block a user