refactor(ir): 将IR节点重构为值引用并添加字符串字面量支持
- 将scc_ir_node_ref_t重命名为scc_ir_value_ref_t,并更新所有相关API - 修改IR定义中的节点标签枚举为值标签枚举(scc_ir_node_tag_t -> scc_ir_value_tag_t) - 更新AST到IR转换器中所有节点引用的类型声明 - 添加对内置类型(VOID, CHAR, INT等)的完整映射实现 - 实现字符串字面量的常量数组创建功能 - 更新项目名称从"Simple Modual C Compiler"为"Simple C Compiler" - 在Doxyfile中排除external目录的文档生成 - 移除未使用的strpool字段并重命名decl到IR的映射表 BREAKING CHANGE: IR节点引用类型已更改,所有使用scc_ir_node_ref_t的地方需 替换为scc_ir_value_ref_t。
This commit is contained in:
42
libs/ir/include/ir_module.h
Normal file
42
libs/ir/include/ir_module.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef __SCC_IR_MODULE_H__
|
||||
#define __SCC_IR_MODULE_H__
|
||||
|
||||
#include "ir_def.h"
|
||||
#include <scc_hashtable.h>
|
||||
|
||||
typedef struct {
|
||||
unsigned int value_uid;
|
||||
unsigned int type_uid;
|
||||
unsigned int bblock_uid;
|
||||
unsigned int func_uid;
|
||||
SCC_VEC(scc_ir_value_t) values;
|
||||
SCC_VEC(scc_ir_type_t) types;
|
||||
SCC_VEC(scc_ir_bblock_t) bblocks;
|
||||
SCC_VEC(scc_ir_func_t) funcs;
|
||||
// UID -> ref index
|
||||
scc_hashtable_t uid2value;
|
||||
scc_hashtable_t uid2type;
|
||||
scc_hashtable_t uid2bblock;
|
||||
scc_hashtable_t uid2func;
|
||||
} scc_ir_module_t;
|
||||
|
||||
void scc_ir_module_init(scc_ir_module_t *ctx);
|
||||
void scc_ir_module_drop(scc_ir_module_t *ctx);
|
||||
scc_ir_type_ref_t scc_ir_module_add_type(scc_ir_module_t *ctx,
|
||||
const scc_ir_type_t *type);
|
||||
scc_ir_value_ref_t scc_ir_module_add_value(scc_ir_module_t *ctx,
|
||||
const scc_ir_value_t *node);
|
||||
scc_ir_bblock_ref_t scc_ir_module_add_bblock(scc_ir_module_t *ctx,
|
||||
const scc_ir_bblock_t *bblock);
|
||||
scc_ir_func_ref_t scc_ir_module_add_func(scc_ir_module_t *ctx,
|
||||
const scc_ir_func_t *func);
|
||||
scc_ir_type_t *scc_ir_module_get_type(scc_ir_module_t *ctx,
|
||||
scc_ir_type_ref_t ref);
|
||||
scc_ir_value_t *scc_ir_module_get_value(scc_ir_module_t *ctx,
|
||||
scc_ir_value_ref_t ref);
|
||||
scc_ir_bblock_t *scc_ir_module_get_bblock(scc_ir_module_t *ctx,
|
||||
scc_ir_bblock_ref_t ref);
|
||||
scc_ir_func_t *scc_ir_module_get_func(scc_ir_module_t *ctx,
|
||||
scc_ir_func_ref_t ref);
|
||||
|
||||
#endif /* __SCC_IR_MODULE_H__ */
|
||||
Reference in New Issue
Block a user