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:
@@ -38,4 +38,33 @@ void scc_ast2ir_stmt(scc_ast2ir_ctx_t *ctx, const scc_ast_stmt_t *stmt);
|
||||
scc_hir_type_ref_t scc_ast2ir_type(scc_ast2ir_ctx_t *ctx,
|
||||
const scc_ast_qual_type_t *ast_type);
|
||||
|
||||
// ====== 类型提升(Type Promotion)接口 ======
|
||||
|
||||
/**
|
||||
* @brief 整数提升(C11 6.3.1.1)
|
||||
* 对 _Bool、char、short 等秩低于 int 的类型提升为 int/unsigned int
|
||||
* @param type_ref 原始类型引用
|
||||
* @return 提升后的类型的引用,若无需提升则返回原始类型
|
||||
*/
|
||||
scc_hir_type_ref_t scc_ast2ir_integer_promotion(scc_ast2ir_ctx_t *ctx,
|
||||
scc_hir_type_ref_t type_ref);
|
||||
|
||||
/**
|
||||
* @brief 寻常算术转换(C11 6.3.1.8)
|
||||
* 对二元算术操作的两个操作数类型找到公共类型
|
||||
* @return 公共类型的引用
|
||||
*/
|
||||
scc_hir_type_ref_t scc_ast2ir_usual_arithmetic_conversion(
|
||||
scc_ast2ir_ctx_t *ctx, scc_hir_type_ref_t t1_ref,
|
||||
scc_hir_type_ref_t t2_ref);
|
||||
|
||||
/**
|
||||
* @brief 插入类型转换指令
|
||||
* 根据源类型和目标类型自动选择 SEXT/ZEXT/TRUNC/F2I/I2F/F2F
|
||||
* @return 转换后的值引用
|
||||
*/
|
||||
scc_hir_value_ref_t scc_ast2ir_emit_conversion(scc_ast2ir_ctx_t *ctx,
|
||||
scc_hir_value_ref_t value,
|
||||
scc_hir_type_ref_t target_type);
|
||||
|
||||
#endif /* __SCC_AST2IR_H__ */
|
||||
|
||||
Reference in New Issue
Block a user