#ifndef __SCC_IR_PROG_H__ #define __SCC_IR_PROG_H__ #include "ir_def.h" #include typedef struct { unsigned int node_uid; unsigned int type_uid; unsigned int bblock_uid; unsigned int func_uid; SCC_VEC(scc_ir_node_t) nodes; 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 uid2nodes; scc_hashtable_t uid2types; scc_hashtable_t uid2bblocks; scc_hashtable_t uid2funcs; } 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_node_ref_t scc_ir_module_add_node(scc_ir_module_t *ctx, const scc_ir_node_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_node_t *scc_ir_module_get_node(scc_ir_module_t *ctx, scc_ir_node_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); typedef struct scc_ir_cprog { scc_ir_module_t module; scc_ir_node_ref_vec_t global_vals; /* 全局变量 */ scc_ir_func_ref_vec_t func_defs; /* 所有函数定义 */ scc_ir_func_ref_vec_t func_decls; /* 所有函数包括定义的声明 */ } scc_ir_cprog_t; void scc_ir_cprog_init(scc_ir_cprog_t *in); void scc_ir_cprog_drop(scc_ir_cprog_t *in); #endif /* __SCC_IR_PROG_H__ */