feat(cbuild): 添加 lir 库依赖并注释掉未使用的模块
- 添加 { name = "lir", path = "./libs/lir" } 依赖项
- 注释掉 ir2mcode 和 sccf2target 模块以暂时禁用
refactor(ast2ir): 修复类型转换问题并简化哈希表初始化
- 修复 compute_type_layout 函数中的类型转换警告
- 在表达式处理末尾添加 UNREACHABLE() 断言
- 移除 begin_func 中的 param_names 参数
- 使用 scc_hashtable_usize_init 替代自定义比较函数
refactor(ir): 简化函数构建器接口并修复返回值处理
- 移除 scc_ir_builder_begin_func 中的 param_names 参数
- 修改 scc_ir_builder_ret_void 以正确处理 void 返回值
- 初始化返回值节点而不是直接设置为 0
refactor(ir): 简化模块初始化中的哈希表配置
- 移除自定义 hash_key 和 cmp_key 函数
- 使用 scc_hashtable_usize_init 统一初始化哈希表
feat(lir): 添加低层中间表示库基础结构
- 创建 lir 库的包配置文件
- 定义 LIR 的基本数据结构、指令类型和操作枚举
- 实现 LIR 构建器和模块管理功能
- 添加 LIR 转换器头文件和转储功能
This commit is contained in:
@@ -74,6 +74,7 @@ void scc_hashtable_init(scc_hashtable_t *ht,
|
||||
scc_hashtable_equal_func_t cmp_func, void *userdata);
|
||||
|
||||
void scc_hashtable_cstr_init(scc_hashtable_t *ht);
|
||||
void scc_hashtable_usize_init(scc_hashtable_t *ht);
|
||||
|
||||
/**
|
||||
* @brief 插入/更新键值对
|
||||
|
||||
@@ -31,6 +31,19 @@ void scc_hashtable_cstr_init(scc_hashtable_t *ht) {
|
||||
scc_hashtable_init(ht, ht_strhash, ht_strcmp, nullptr);
|
||||
}
|
||||
|
||||
static u32 ht_usizehash(const void *key, void *userdata) {
|
||||
(void)userdata;
|
||||
return (u32)(usize)key;
|
||||
}
|
||||
|
||||
static int ht_usizecmp(const void *key1, const void *key2, void *userdata) {
|
||||
(void)userdata;
|
||||
return (usize)key1 - (usize)key2;
|
||||
}
|
||||
void scc_hashtable_usize_init(scc_hashtable_t *ht) {
|
||||
scc_hashtable_init(ht, ht_usizehash, ht_usizecmp, nullptr);
|
||||
}
|
||||
|
||||
static int next_power_of_two(int n) {
|
||||
n--;
|
||||
n |= n >> 1;
|
||||
|
||||
Reference in New Issue
Block a user