Files
scc/libs/ir/hir/include/scc_hir_module.h
zzy e850b5c981 feat(ir): 启用LIR模块并重构HIR组件结构
- 在cbuild.toml中启用lir依赖项,取消注释相关配置
- 重构libs/README.md文档,添加详细的库说明和层级结构
- 重命名头文件以统一命名规范:ast_def.h → scc_ast_def.h,
  ast_dump.h → scc_ast_dump.h, hir相关文件添加scc前缀
- 更新include路径以匹配新的文件命名
- 在cfg模块中添加symbol ID类型和linkage枚举,完善符号表功能
- 实现cfg模块中的符号添加、查找和获取功能
- 修改HIR中meta字段替换原有的attribute字段,更新相关访问宏
- 修复HIR构建器中的函数元数据访问错误
- 为LIR模块创建完整的头文件结构,包括指令定义、转换器等组件
2026-04-21 20:35:37 +08:00

51 lines
2.0 KiB
C

#ifndef __SCC_HIR_MODULE_H__
#define __SCC_HIR_MODULE_H__
#include "scc_hir_def.h"
#include <scc_cfg.h>
#include <scc_hashtable.h>
typedef struct {
scc_cfg_module_t cfg_module;
scc_cfg_id_t value_uid;
scc_cfg_id_t type_uid;
SCC_VEC(scc_hir_value_t) values;
SCC_VEC(scc_hir_type_t) types;
// UID -> ref index
scc_hashtable_t uid2value;
scc_hashtable_t uid2type;
SCC_VEC(scc_hir_bblock_meta_t *) bblock_meta;
SCC_VEC(scc_hir_func_meta_t *) funcs_meta;
} scc_hir_module_t;
void scc_hir_module_init(scc_hir_module_t *ctx);
void scc_hir_module_drop(scc_hir_module_t *ctx);
scc_hir_type_ref_t scc_hir_module_add_type(scc_hir_module_t *ctx,
const scc_hir_type_t *type);
scc_hir_value_ref_t scc_hir_module_add_value(scc_hir_module_t *ctx,
const scc_hir_value_t *node);
scc_hir_bblock_ref_t scc_hir_module_add_bblock(scc_hir_module_t *ctx,
const scc_hir_bblock_t *bblock);
scc_hir_func_ref_t scc_hir_module_add_func(scc_hir_module_t *ctx,
const scc_hir_func_t *func);
scc_hir_type_t *scc_hir_module_get_type(scc_hir_module_t *ctx,
scc_hir_type_ref_t ref);
scc_hir_value_t *scc_hir_module_get_value(scc_hir_module_t *ctx,
scc_hir_value_ref_t ref);
scc_hir_bblock_t *scc_hir_module_get_bblock(scc_hir_module_t *ctx,
scc_hir_bblock_ref_t ref);
scc_hir_func_t *scc_hir_module_get_func(scc_hir_module_t *ctx,
scc_hir_func_ref_t ref);
static inline scc_hir_type_t *
scc_hir_module_get_type_by_value(scc_hir_module_t *ctx,
scc_hir_value_ref_t ref) {
scc_hir_value_t *value = scc_hir_module_get_value(ctx, ref);
Assert(value != nullptr);
return scc_hir_module_get_type(ctx, value->type);
}
#endif /* __SCC_HIR_MODULE_H__ */