feat(cbuild): 更新项目配置以支持HIR中间表示
- 统一包名格式化,添加空格对齐 - 将依赖项从ir和lir重命名为hir,移除lir注释 - 为ast2ir模块添加正确的包名称"scc_ast2ir" - 更新依赖引用路径指向新的HIR库结构 - 移除注释掉的ir2mcode和sccf2target依赖项 refactor(ast2ir): 迁移到HIR中间表示替换IR表示 - 更新头文件包含,使用hir_builder.h替代ir_builder.h - 修改上下文结构体,将scc_ir_builder_t替换为scc_hir_builder_t - 更新函数签名,将参数类型从scc_ir_*转换为scc_hir_* - 调整返回值类型,将scc_ir_value_ref_t和scc_ir_type_ref_t 分别替换为scc_hir_value_ref_t和scc_hir_type_ref_t - 重新排列头文件包含顺序以满足依赖关系
This commit is contained in:
81
libs/ir/cfg/src/scc_cfg.c
Normal file
81
libs/ir/cfg/src/scc_cfg.c
Normal file
@@ -0,0 +1,81 @@
|
||||
#include <scc_cfg.h>
|
||||
|
||||
void scc_cfg_module_init(scc_cfg_module_t *module) {
|
||||
scc_vec_init(module->bblocks);
|
||||
scc_vec_init(module->funcs);
|
||||
scc_vec_init(module->symbols);
|
||||
scc_hashtable_cstr_init(&module->symbol_map);
|
||||
|
||||
// 0 for null
|
||||
scc_vec_push(module->bblocks, (scc_cfg_bblock_t){0});
|
||||
scc_vec_push(module->funcs, (scc_cfg_func_t){0});
|
||||
scc_vec_push(module->symbols, (scc_cfg_symbol_t){0});
|
||||
}
|
||||
|
||||
void scc_cfg_module_drop(scc_cfg_module_t *module) {
|
||||
scc_vec_free(module->bblocks);
|
||||
scc_vec_free(module->funcs);
|
||||
scc_vec_free(module->symbols);
|
||||
scc_hashtable_drop(&module->symbol_map);
|
||||
}
|
||||
|
||||
scc_cfg_func_id_t scc_cfg_module_add_func(scc_cfg_module_t *module,
|
||||
const scc_cfg_func_t *func) {
|
||||
scc_cfg_func_id_t id = scc_vec_size(module->funcs);
|
||||
scc_vec_push(module->funcs, *func);
|
||||
Assert(id != SCC_CFG_ID_nullptr);
|
||||
return id;
|
||||
}
|
||||
|
||||
scc_cfg_func_t *scc_cfg_module_unsafe_get_func(scc_cfg_module_t *module,
|
||||
scc_cfg_func_id_t id) {
|
||||
if (id == SCC_CFG_ID_nullptr) {
|
||||
Panic("nullptr func id");
|
||||
}
|
||||
if (id >= scc_vec_size(module->funcs)) {
|
||||
Panic("invalid func id");
|
||||
}
|
||||
return &scc_vec_at(module->funcs, id);
|
||||
}
|
||||
|
||||
scc_cfg_bblock_id_t scc_cfg_module_add_bblock(scc_cfg_module_t *module,
|
||||
const scc_cfg_bblock_t *bblock) {
|
||||
scc_cfg_func_id_t id = scc_vec_size(module->bblocks);
|
||||
scc_vec_push(module->bblocks, *bblock);
|
||||
Assert(id != SCC_CFG_ID_nullptr);
|
||||
return id;
|
||||
}
|
||||
|
||||
scc_cfg_bblock_t *scc_cfg_module_unsafe_get_bblock(scc_cfg_module_t *module,
|
||||
scc_cfg_bblock_id_t id) {
|
||||
if (id == SCC_CFG_ID_nullptr) {
|
||||
Panic("nullptr bblocks id");
|
||||
}
|
||||
if (id >= scc_vec_size(module->bblocks)) {
|
||||
Panic("invalid bblocks id");
|
||||
}
|
||||
return &scc_vec_at(module->bblocks, 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) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void scc_cfg_bblock_add_pred(scc_cfg_bblock_t *bb,
|
||||
scc_cfg_bblock_id_t pred_id) {}
|
||||
|
||||
void scc_cfg_bblock_remove_pred(scc_cfg_bblock_t *bb,
|
||||
scc_cfg_bblock_id_t pred_id) {}
|
||||
|
||||
void scc_cfg_bblock_clear_pred(scc_cfg_bblock_t *bb) {}
|
||||
|
||||
void scc_cfg_bblock_add_succ(scc_cfg_bblock_t *bb,
|
||||
scc_cfg_bblock_id_t succ_id) {}
|
||||
|
||||
void scc_cfg_bblock_remove_succ(scc_cfg_bblock_t *bb,
|
||||
scc_cfg_bblock_id_t succ_id) {}
|
||||
|
||||
void scc_cfg_bblock_clear_succs(scc_cfg_bblock_t *bb) {}
|
||||
Reference in New Issue
Block a user