feat(ir2amd64): 支持函数返回值处理

- 在RET节点中添加对返回值的处理逻辑
- 解析返回值位置并加载到RAX寄存器

refactor(pe_builder): 禁用PE构建器中的日志输出

- 定义空的LOG_INFO宏以禁用调试信息
- 避免在PE构建过程中产生不必要的日志输出
This commit is contained in:
zzy
2026-03-20 14:22:33 +08:00
parent de6f5d510a
commit a64e1f8330
2 changed files with 9 additions and 0 deletions

View File

@@ -156,6 +156,10 @@ static void parse_node(scc_ir2mcode_ctx_t *ctx, scc_ir_bblock_ref_t node_ref,
LOG_ERROR("Unsupported node type: %d", node->tag);
break;
case SCC_IR_NODE_RET: ///< 函数返回
if (node->data.ret.ret_val) {
scc_reg_loc_t *loc = parse_location(ctx, node->data.ret.ret_val);
load_value_to_reg(&ctx->mcode, loc, SCC_AMD64_RAX);
}
scc_mcode_amd64_mov_r64_r64(&ctx->mcode, SCC_AMD64_RSP, SCC_AMD64_RBP);
scc_mcode_amd64_pop_r64(&ctx->mcode, SCC_AMD64_RBP);
scc_mcode_amd64_ret(&ctx->mcode);

View File

@@ -1,5 +1,10 @@
#include <scc_pe_builder.h>
#ifdef LOG_INFO
#undef LOG_INFO
#endif
#define LOG_INFO(...)
#define reserve_align(offset, size) ((offset) + ((size) - 1)) & ~((size) - 1)
void scc_pe_builder_init(scc_pe_builder_t *builder, bool is_64,