feat(ast2ir): 实现C11类型提升系统并重构HIR基本块管理
- 新增 scc_ast2ir_promote.c 实现整数提升(6.3.1.1)和寻常算术转换(6.3.1.8) - 重构 HIR Builder: bblock → create_bblock + append_bblock,引入BBList链表管理 - AST2IR 全面集成类型提升:二元运算、赋值、函数调用参数、自增/自减操作符 - 变参函数支持:跳过 ... 假参数,实现默认参数提升(float→double等) - 简化 HIR Dump 实现 - MIR: Win64 ABI改进、x86指令选择优化 - 新增 printf 测试用例
This commit is contained in:
@@ -120,11 +120,11 @@ static inline int scc_x86_patch_imm0_ex(scc_mcode_t *mcode, usize offset,
|
||||
|
||||
static inline void scc_x86_patch(scc_mcode_t *mcode,
|
||||
scc_x86_patch_type_t patch_type, u64 offset,
|
||||
i64 value) {
|
||||
u64 value) {
|
||||
switch (patch_type) {
|
||||
case SCC_X86_PATCH_PC32:
|
||||
scc_x86_patch_brdisp(mcode, offset - 4,
|
||||
scc_x86_op_relbr(value - offset));
|
||||
i32 rel = value - offset;
|
||||
scc_x86_patch_brdisp(mcode, offset - 4, scc_x86_op_relbr(rel));
|
||||
break;
|
||||
default:
|
||||
TODO();
|
||||
|
||||
@@ -218,9 +218,13 @@ static int scale_to_enc(uint8_t scale) {
|
||||
|
||||
/* 修正:位移大小只由数值范围决定,与基址寄存器无关 */
|
||||
static int disp_size(int32_t disp, scc_x86_reg_t base) {
|
||||
(void)base;
|
||||
if (disp == 0)
|
||||
if (disp == 0) {
|
||||
/* RBP/R13 with disp=0: must use mod=01 + disp8=0,
|
||||
because mod=00 + r/m=101 means RIP-relative */
|
||||
if (base == SCC_X86_REG_RBP || base == SCC_X86_REG_R13)
|
||||
return 8;
|
||||
return 0;
|
||||
}
|
||||
if (disp >= -128 && disp <= 127)
|
||||
return 8;
|
||||
return 32;
|
||||
@@ -496,10 +500,12 @@ int scc_x86_encode_inst(scc_mcode_t *mcode, scc_x86_iform_t iform,
|
||||
} else if (ops[i].kind == SCC_X86_OPR_MEM) {
|
||||
base_reg = ops[i].mem.base;
|
||||
idx_reg = ops[i].mem.index;
|
||||
} else if (ops[i].kind == SCC_X86_OPR_IMM ||
|
||||
ops[i].kind == SCC_X86_OPR_RELBR) {
|
||||
} else if (ops[i].kind == SCC_X86_OPR_IMM) {
|
||||
imm_val = ops[i].imm0;
|
||||
imm_idx = i;
|
||||
} else if (ops[i].kind == SCC_X86_OPR_RELBR) {
|
||||
imm_val = ops[i].brdisp; // i32 → i64 自动符号扩展
|
||||
imm_idx = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user