refactor(ast2ir): 重构ABI类型系统并修复union结构问题
- 将scc_ast_def.h中的attr_of从union改为struct以修复结构定义问题 - 添加type_abi依赖到ast2ir模块的cbuild.toml配置文件中 - 重命名scc_ast2ir.h中的abi字段为type_abi,并更新相关初始化函数签名 - 移除废弃的scc_abi_type.h和相关平台ABI头文件 - 添加辅助函数is_variadic_marker和fixed_param_count用于处理可变参数 - 添加数组和聚合类型初始化的辅助函数
This commit is contained in:
@@ -45,26 +45,26 @@ typedef struct {
|
||||
scc_x86_mem_t mem;
|
||||
scc_x86_reloc_op_t reloc;
|
||||
};
|
||||
u8 size;
|
||||
u8 size_bits;
|
||||
} scc_x86_operand_value_t;
|
||||
|
||||
static inline scc_x86_operand_value_t scc_x86_op_preg(scc_x86_reg_t reg,
|
||||
u8 size) {
|
||||
u8 size_bits) {
|
||||
scc_x86_operand_value_t o = {
|
||||
.kind = SCC_X86_OPR_REG,
|
||||
.reg = reg,
|
||||
.size = size,
|
||||
.size_bits = size_bits,
|
||||
};
|
||||
return o;
|
||||
}
|
||||
static inline scc_x86_reg_t scc_x86_op_vreg_reg(int vreg) {
|
||||
return (int)SCC_X86_REG_COUNT + vreg;
|
||||
}
|
||||
static inline scc_x86_operand_value_t scc_x86_op_vreg(int vreg, u8 size) {
|
||||
static inline scc_x86_operand_value_t scc_x86_op_vreg(int vreg, u8 size_bits) {
|
||||
scc_x86_operand_value_t o = {
|
||||
.kind = SCC_X86_OPR_REG,
|
||||
.reg = scc_x86_op_vreg_reg(vreg),
|
||||
.size = size,
|
||||
.size_bits = size_bits,
|
||||
};
|
||||
return o;
|
||||
}
|
||||
@@ -72,24 +72,24 @@ static inline scc_x86_operand_value_t scc_x86_op_relbr(i32 rel) {
|
||||
scc_x86_operand_value_t o = {
|
||||
.kind = SCC_X86_OPR_RELBR,
|
||||
.brdisp = rel,
|
||||
.size = 4,
|
||||
.size_bits = 32,
|
||||
};
|
||||
return o;
|
||||
}
|
||||
static inline scc_x86_operand_value_t scc_x86_op_imm(i64 imm, u8 size) {
|
||||
static inline scc_x86_operand_value_t scc_x86_op_imm(i64 imm, u8 size_bits) {
|
||||
scc_x86_operand_value_t o = {
|
||||
.kind = SCC_X86_OPR_IMM,
|
||||
.simm0 = imm,
|
||||
.size = size,
|
||||
.size_bits = size_bits,
|
||||
};
|
||||
return o;
|
||||
}
|
||||
static inline scc_x86_operand_value_t scc_x86_op_mem(scc_x86_mem_t mem,
|
||||
u8 size) {
|
||||
u8 size_bits) {
|
||||
scc_x86_operand_value_t o = {
|
||||
.kind = SCC_X86_OPR_MEM,
|
||||
.mem = mem,
|
||||
.size = size,
|
||||
.size_bits = size_bits,
|
||||
};
|
||||
return o;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ scc_x86_op_reloc_global_imm(const char *sym, i64 addend) {
|
||||
op.reloc.target = SCC_X86_RELOC_TARGET_SYMBOL;
|
||||
op.reloc.global_name = sym;
|
||||
op.reloc.addend = addend;
|
||||
op.size = 0;
|
||||
op.size_bits = 0;
|
||||
return op;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ scc_x86_op_reloc_global_relrip(const char *sym, i64 addend) {
|
||||
op.reloc.target = SCC_X86_RELOC_TARGET_SYMBOL;
|
||||
op.reloc.global_name = sym;
|
||||
op.reloc.addend = addend;
|
||||
op.size = 4;
|
||||
op.size_bits = 32;
|
||||
return op;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ scc_x86_op_reloc_global_relbr(const char *sym, i64 addend) {
|
||||
op.reloc.target = SCC_X86_RELOC_TARGET_SYMBOL;
|
||||
op.reloc.global_name = sym;
|
||||
op.reloc.addend = addend;
|
||||
op.size = 4;
|
||||
op.size_bits = 32;
|
||||
return op;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ static inline scc_x86_operand_value_t scc_x86_op_reloc_block(int bid,
|
||||
op.reloc.target = SCC_X86_RELOC_TARGET_BBLOCK;
|
||||
op.reloc.bblock_id = bid;
|
||||
op.reloc.addend = addend;
|
||||
op.size = 4;
|
||||
op.size_bits = 32;
|
||||
return op;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ scc_x86_op_reloc_global_mem(const char *sym, i64 addend) {
|
||||
op.reloc.global_name = sym;
|
||||
op.reloc.addend = addend;
|
||||
// 编码时需生成 RIP 相对寻址的 ModRM/SIB
|
||||
op.size = 0;
|
||||
op.size_bits = 0;
|
||||
return op;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user