移除了在全局变量声明处理中对全局值向量的直接推送操作, 以优化内存管理和值引用的一致性。 fix(hir): 修复表达式索引类型检查中的空指针访问 修正了表达式处理中索引类型的获取方式,从使用类型指针改为使用类型引用, 并更新了空值检查条件以避免潜在的空指针解引用问题。 perf(hir): 优化类型大小计算性能 将类型大小计算逻辑从模块内部实现替换为使用HIR布局系统提供的统一接口, 提高计算效率和代码复用性。 refactor(hir): 统一字符串常量构建流程 重构了字符串常量的创建过程,简化了类型定义步骤并确保包含正确的空终止符。 fix(dump): 改进全局分配值转储的健壮性 添加了对空初始化值的检查,当全局分配没有初始值时显示零初始化器, 避免访问空指针导致的程序崩溃。 refactor(x86): 增强操作数编码的安全性 在x86指令编码中添加了对操作数字节对齐的断言检查,确保所有操作数都符合 字节边界对齐要求。 chore(build): 更新头文件包含路径和初始化参数 调整了头文件包含路径格式,并更新了HIR程序和模块的初始化函数签名, 传入ABI参数以支持更准确的目标平台特性。
40 lines
1.2 KiB
C
40 lines
1.2 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__ */
|