feat(compiler): 实现HIR到LIR的函数定义标记和直接/间接调用区分

- 在HIR函数元数据中添加defined字段来标记函数是否已定义
- 在AST到IR转换过程中设置函数定义状态
- 修改LIR模块函数声明接口以支持定义状态参数
- 实现直接调用和间接调用的区别处理,通过符号查找确定调用类型
- 更新LIR调用指令结构以支持直接和间接调用的不同表示方式
- 调整x86后端指令选择以正确处理不同类型的调用

fix(x86-isel): 优化x86指令发射和操作数大小处理

- 移除move/load/store函数中的size参数,改由操作数本身携带大小信息
- 简化x86指令操作数结构,减少操作数数量限制
- 添加专门的mov系列表单选择函数,根据操作数类型和大小自动选择正确的指令形式
- 修正间接调用的指令形式为CALL_NEAR_MEMV而非GPRV
- 添加向量版本的load/store/move发射函数

refactor(reg-alloc): 更新寄存器分配迭代器接口

- 为分配迭代器的替换方法添加size参数,以便正确处理不同大小的寄存器
This commit is contained in:
zzy
2026-05-23 15:33:54 +08:00
parent d78b91894e
commit ea553718f0
21 changed files with 495 additions and 444 deletions

View File

@@ -185,21 +185,16 @@ typedef struct scc_lir_ins {
scc_lir_bblock_id_t jmp_target;
struct scc_lir_call {
const char *callee;
scc_lir_val_t *args;
int arg_count;
scc_lir_val_t ret_vreg;
u64 clobber_mask;
union {
const char *callee_name;
scc_lir_val_t callee_target;
};
} call;
struct scc_lir_call_indirect {
scc_lir_val_t target;
scc_lir_val_t *args;
int arg_count;
scc_lir_val_t ret_vreg;
u64 clobber_mask;
} call_indirect;
scc_lir_val_t ret_val;
struct scc_lir_parallel_copy {

View File

@@ -33,11 +33,11 @@ void scc_lir_module_drop(scc_lir_module_t *lir_module);
* @brief 添加一个函数声明(外部或未定义)
* @param mod 模块
* @param name 函数名
* @param attr 属性
* @param defined 是否定义
* @return 符号指针
*/
scc_lir_symbol_id_t scc_lir_module_add_func_decl(scc_lir_module_t *lir_module,
const char *name);
const char *name, int defined);
/**
* @brief 添加一个全局数据符号(定义或外部)
@@ -56,4 +56,8 @@ scc_lir_symbol_id_t scc_lir_module_add_data(scc_lir_module_t *lir_module,
const u8 *init_data, usize size,
u32 align);
scc_lir_symbol_t *
scc_lir_module_unsafe_lookup_symbol(const scc_lir_module_t *lir_module,
const char *name);
#endif /* __SCC_LIR_MODULE_H__ */