feat(mir): 实现x86-64架构寄存器分配和指令选择优化
- 修改x86_64_isel.h接口,将func_meta替换为func指针,并添加新的isel函数原型 - 添加x86_64_reg_alloc.h头文件,提供架构特定的寄存器分配操作填充函数 - 更新frame_layout.h定义frame_layout上下文结构 - 重构reg_alloc.h中的寄存器分配操作结构体,将ops从指针改为值类型, 并将mark_reg_unused重命名为clean_mark_regs - 扩展scc_mir.h中的函数元数据,添加vregs_count字段和虚拟寄存器管理函数 - 重新定义MIR pass阶段枚举,添加FRAME_LAYOUT和PROLOGUE_EPILOGUE阶段 - 添加win64目标相关头文件和实现,提供Windows x64 ABI降低和寄存器分配填充 - 更新虚拟寄存器表示格式从$到%,修复alloca指令处理 - 重构寄存器分配算法,改进虚拟寄存器到物理寄存器/栈槽的映射机制 - 完善MIR pass调度,支持多阶段处理流程
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
#ifndef __SCC_FRAME_LAYOUT_H__
|
||||
#define __SCC_FRAME_LAYOUT_H__
|
||||
|
||||
#include "../scc_mir_module.h"
|
||||
|
||||
typedef struct scc_frame_layout {
|
||||
scc_mir_func_t *func;
|
||||
} scc_frame_layout_t;
|
||||
|
||||
void scc_frame_layout(scc_frame_layout_t *ctx, scc_mir_module_t *module);
|
||||
|
||||
#endif /* __SCC_FRAME_LAYOUT_H__ */
|
||||
|
||||
@@ -10,8 +10,6 @@ typedef enum {
|
||||
} scc_op_access_t;
|
||||
|
||||
typedef struct scc_reg_alloc_op {
|
||||
// ---- 指令生成(纯动作,无状态) ----
|
||||
|
||||
// preg → [slot]
|
||||
void (*emit_spill)(scc_mir_instr_vec_t *ctx, int preg, int slot);
|
||||
// [slot] → preg
|
||||
@@ -26,7 +24,7 @@ typedef struct scc_reg_alloc_op {
|
||||
|
||||
// 显式标记某个寄存器已占用 / 未占用(用于隐式寄存器、固定分配等)
|
||||
void (*mark_reg_used)(void *ctx, int preg);
|
||||
void (*mark_reg_unused)(void *ctx, int preg);
|
||||
void (*clean_mark_regs)(void *ctx);
|
||||
|
||||
// ---- 指令信息查询(只读) ----
|
||||
scc_op_access_t (*get_operand_access)(void *ctx, int opcode, int op_idx);
|
||||
@@ -35,8 +33,8 @@ typedef struct scc_reg_alloc_op {
|
||||
} scc_reg_alloc_op_t;
|
||||
|
||||
typedef struct scc_reg_alloc_ctx {
|
||||
const scc_reg_alloc_op_t *ops;
|
||||
scc_mir_func_meta_t *func_meta;
|
||||
scc_reg_alloc_op_t ops;
|
||||
scc_mir_func_t *func;
|
||||
scc_mir_instr_vec_t *instrs;
|
||||
} scc_reg_alloc_ctx_t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user