00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00035 #ifndef CTRUMP_PARSER_CFG_H
00036 #define CTRUMP_PARSER_CFG_H
00037
00038 #include "ctrump/common/mempool.h"
00039 #include "ctrump/common/bitmap.h"
00040 #include "ctrump/common/intmap.h"
00041 #include "ctrump/analyzer/var.h"
00042 #include "ctrump/ast/location.h"
00043
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047
00048 struct ctrump_fundef;
00049 struct ctrump_expr;
00050
00054 struct ctrump_cfg_var_info {
00055 int index;
00056 struct ctrump_var *var;
00057 };
00058
00062 struct ctrump_bb {
00063 int id;
00064 int id_in_cfg;
00066 #define CTRUMP_BB_LOOP_ENTRY (1<<0)
00067 int flags;
00069 int num_preds;
00070 int num_succs;
00071 int num_exprs;
00072 int num_dom_children;
00073 int num_dfs;
00074 int num_phi;
00076 struct ctrump_bb **succs;
00077 struct ctrump_bb **preds;
00078 struct ctrump_expr **exprs;
00079 struct ctrump_bb **dom_children;
00080 struct ctrump_phi_node *phi_nodes;
00082 struct ctrump_bb **dfs;
00084 int num_var;
00085 ctrump_bitmap_t kill;
00086 ctrump_bitmap_t use;
00087 ctrump_bitmap_t live;
00089 struct ctrump_loop_cfg_info *loop_belong_to;
00090
00091 struct ctrump_load_store_set load_store;
00092 };
00093
00094 #define CTRUMP_BB_IS_LOOP_ENTRY(b) ((b)->flags & CTRUMP_BB_LOOP_ENTRY)
00095
00100 struct ctrump_cfg {
00101 int id;
00102
00103 struct ctrump_bb *head;
00104 struct ctrump_bb *tail;
00106 int num_bb;
00107 int num_var;
00109 struct ctrump_bb **basic_blocks;
00110 ctrump_bitmap_t addressed;
00111 ctrump_bitmap_t global;
00113 struct ctrump_cfg_var_info *var_info;
00115 int num_loop;
00116 struct ctrump_loop_info_node **loop_tree_roots;
00117 };
00118
00124 enum ctrump_build_cfg_error_code {
00125 CTRUMP_BUILD_CFG_ERROR_UNDEFINED_LABEL,
00126 CTRUMP_BUILD_CFG_ERROR_REDEFINE_LABEL,
00127 CTRUMP_BUILD_CFG_ERROR_CONTINUE_IN_NOT_LOOP,
00128 CTRUMP_BUILD_CFG_ERROR_BREAK_IN_NOT_LOOP,
00129 CTRUMP_BUILD_CFG_ERROR_INVALID_LVALUE,
00130 CTRUMP_BUILD_CFG_ERROR_INVALID_ADDRESSOP
00131 };
00132
00136 struct ctrump_build_cfg_error {
00137 enum ctrump_build_cfg_error_code code;
00138 const struct ctrump_stmt *stmt;
00139 };
00140
00141
00145 int
00146 ctrump_build_cfg(struct ctrump_cfg *ret,
00147 struct ctrump_intmap *var_info_map,
00148 struct ctrump_build_cfg_error *error,
00149 const struct ctrump_fundef *def,
00150 struct ctrump_mempool *cfg_pool,
00151 struct ctrump_mempool *varmap_pool,
00152 int num_ast,
00153 int id_begin);
00154
00155 #ifdef __cplusplus
00156 }
00157 #endif
00158
00159 #endif