Files
scc/libs/ir/hir/include/scc_hir_layout.h
zzy 31d7e91ef1 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用于处理可变参数
- 添加数组和聚合类型初始化的辅助函数
2026-06-01 12:14:13 +08:00

40 lines
1.1 KiB
C

#ifndef __SCC_HIR_LAYOUT_H__
#define __SCC_HIR_LAYOUT_H__
#include <scc_hir_module.h>
#include <scc_type_abi.h>
#define SCC_ALIGN_UP(x, align) (((x) + (align)-1) & ~((align)-1))
/// 结构体/联合体字段布局
typedef struct scc_hir_field_layout {
int offset;
int size;
int align;
} scc_hir_field_layout_t;
/// 聚合体布局结果 (FLEX)
typedef struct scc_hir_aggregate_layout {
int size;
int align;
int field_count;
scc_hir_field_layout_t fields[];
} scc_hir_aggregate_layout_t;
int scc_hir_type_size(scc_hir_module_t *mod, scc_hir_type_ref_t type,
const scc_type_abi_t *abi);
int scc_hir_type_align(scc_hir_module_t *mod, scc_hir_type_ref_t type,
const scc_type_abi_t *abi);
int scc_hir_field_offset(scc_hir_module_t *mod, scc_hir_type_ref_t type,
int field_idx, const scc_type_abi_t *abi);
scc_hir_aggregate_layout_t *
scc_hir_aggregate_layout(scc_hir_module_t *mod, scc_hir_type_ref_t type,
const scc_type_abi_t *abi);
void scc_hir_aggregate_layout_free(scc_hir_aggregate_layout_t *layout);
#endif /* __SCC_HIR_LAYOUT_H__ */