- 在argparse库中将所有null指针常量替换为nullptr - 更新头文件和源文件中的指针初始化和比较操作 - 修改测试文件中的相关断言检查 - 更新AST定义文件中的注释说明
50 lines
1.9 KiB
C
50 lines
1.9 KiB
C
#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);
|
|
|
|
static inline scc_ir_type_t *
|
|
scc_ir_module_get_type_by_value(scc_ir_module_t *ctx, scc_ir_value_ref_t ref) {
|
|
scc_ir_value_t *value = scc_ir_module_get_value(ctx, ref);
|
|
Assert(value != nullptr);
|
|
return scc_ir_module_get_type(ctx, value->type);
|
|
}
|
|
|
|
#endif /* __SCC_IR_MODULE_H__ */
|