#ifndef __SCC_HIR_LAYOUT_H__ #define __SCC_HIR_LAYOUT_H__ #include "scc_hir_module.h" #include #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__ */