feat(ast2ir): 添加指针运算支持并修复整数字面量解析
- 实现了指针解引用(*)和取地址(&)操作符的IR转换 - 添加parse_lexme2const_int函数统一处理整数字面量解析 - 支持数组大小表达式的常量解析 - 修复函数缺少返回语句的问题,在函数末尾添加默认ret指令 refactor(ir_builder): 调整函数参数类型处理逻辑 - 修改函数参数以指针形式传递,更新参数类型处理方式 - 优化参数节点创建过程,将参数类型包装为指针类型 fix(ir_dump): 修正IR输出格式问题 - 调整基本块和函数的输出格式,确保正确的换行和缩进 - 统一输出格式,提升可读性 feat(ir2mcode): 添加帧管理器头文件定义 - 定义frame_manager.h接口,包含栈帧分配相关函数声明 - 提供栈槽分配、寄存器保存、偏移计算等功能接口 refactor(reg_alloc): 添加初始栈大小配置 - 在寄存器分配器中增加init_stack_size字段 - 支持初始化栈大小设置,为后续帧管理功能做准备 test: 添加指针操作测试用例 - 新增14_pointer.c测试文件,验证指针取地址和解引用功能 - 在expect.toml中添加对应的期望返回值
This commit is contained in:
@@ -198,9 +198,11 @@ static void parse_value(scc_ir2mcode_ctx_t *ctx, scc_ir_bblock_ref_t node_ref,
|
||||
scc_mcode_amd64_mov_r32_m32(
|
||||
&ctx->sect_mcode, SCC_AMD64_RAX,
|
||||
SCC_AMD64_RCX); // 32位加载自动清零高位
|
||||
} else { // 8
|
||||
} else if (width == 8) { // 8
|
||||
scc_mcode_amd64_mov_r64_m64(&ctx->sect_mcode, SCC_AMD64_RAX,
|
||||
SCC_AMD64_RCX);
|
||||
} else {
|
||||
UNREACHABLE();
|
||||
}
|
||||
// 存储结果
|
||||
store_value_from_reg(&ctx->sect_mcode, &to, SCC_AMD64_RAX);
|
||||
@@ -503,6 +505,8 @@ static int equal_func(const void *key1, const void *key2) {
|
||||
}
|
||||
|
||||
static void parse_function(scc_ir2mcode_ctx_t *ctx, scc_ir_func_t *func) {
|
||||
// FIXME using API instead
|
||||
ctx->reg_alloc.init_stack_size = 8;
|
||||
ctx->noderef2regloc = scc_reg_alloc(&ctx->reg_alloc, func);
|
||||
// 对齐到 16 字节
|
||||
// FIXME
|
||||
|
||||
Reference in New Issue
Block a user