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模块创建完整的头文件结构,包括指令定义、转换器等组件
This commit is contained in:
zzy
2026-04-21 20:35:37 +08:00
parent 0fbfb36262
commit e850b5c981
30 changed files with 1588 additions and 2627 deletions

View File

@@ -8,6 +8,7 @@
typedef usize scc_cfg_id_t;
typedef scc_cfg_id_t scc_cfg_bblock_id_t;
typedef scc_cfg_id_t scc_cfg_func_id_t;
typedef scc_cfg_id_t scc_cfg_symbol_id_t;
typedef SCC_VEC(scc_cfg_bblock_id_t) scc_cfg_bblock_id_vec_t;
typedef SCC_VEC(void *) scc_cfg_value_vec_t;
@@ -22,7 +23,7 @@ struct scc_cfg_bblock {
scc_cfg_bblock_id_vec_t preds; // 前驱
scc_cfg_bblock_id_vec_t succs; // 后继
scc_cfg_value_vec_t values; // using cast
void *attribute;
void *meta;
};
struct scc_cfg_func {
@@ -33,7 +34,7 @@ struct scc_cfg_func {
scc_hashtable_t bblock_map; // id -> index
scc_cfg_bblock_id_t entry_bblock_id; // maybe it will always 0
void *attribute;
void *meta;
};
typedef enum {
@@ -42,10 +43,16 @@ typedef enum {
SCC_CFG_SYMBOL_KIND_EXTERN,
} scc_cfg_symbol_kind_t;
typedef enum {
SCC_CFG_SYMBOL_LINK_GLOABL,
SCC_CFG_SYMBOL_LINK_LOCAL,
} scc_cfg_symbol_linkage_t;
struct scc_cfg_symbol {
const char *name;
scc_cfg_symbol_kind_t kind;
void *attribute;
scc_cfg_symbol_linkage_t linkage;
void *meta;
};
typedef SCC_VEC(scc_cfg_bblock_t) scc_cfg_bblock_vec_t;
@@ -74,10 +81,12 @@ scc_cfg_bblock_id_t scc_cfg_module_add_bblock(scc_cfg_module_t *module,
const scc_cfg_bblock_t *bblock);
scc_cfg_bblock_t *scc_cfg_module_unsafe_get_bblock(scc_cfg_module_t *module,
scc_cfg_bblock_id_t id);
void scc_cfg_module_add_symbol(scc_cfg_module_t *module,
const scc_cfg_symbol_t *symbol);
scc_cfg_id_t scc_cfg_module_lookup_symbol(const scc_cfg_module_t *module,
const char *name);
scc_cfg_symbol_id_t scc_cfg_module_add_symbol(scc_cfg_module_t *module,
const scc_cfg_symbol_t *symbol);
scc_cfg_symbol_t *scc_cfg_module_unsafe_get_symbol(scc_cfg_module_t *module,
scc_cfg_symbol_id_t id);
scc_cfg_symbol_id_t scc_cfg_module_lookup_symbol(const scc_cfg_module_t *module,
const char *name);
static inline const scc_cfg_symbol_t *
scc_cfg_module_unsafe_lookup_symbol(const scc_cfg_module_t *module,