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
00030
00036 #ifndef CTRUMP_ANALYZER_VAR_H
00037 #define CTRUMP_ANALYZER_VAR_H
00038
00039 #include "ctrump/ast/expr-code.h"
00040 #include "ctrump/common/dll.h"
00041
00042 #ifdef __cplusplus
00043 extern "C" {
00044 #endif
00045
00047 enum ctrump_subscript_nd_code {
00048 CTRUMP_SUBSCRIPT_TERMINAL,
00049 CTRUMP_SUBSCRIPT_LOAD_RECORD,
00050 CTRUMP_SUBSCRIPT_COEF_ARRAY,
00051 CTRUMP_SUBSCRIPT_RECORD_MEMBER,
00052 CTRUMP_SUBSCRIPT_RECORD_MEMBER_TERMINAL
00053 };
00054
00058 struct ctrump_subscript_coef_array {
00059 int coef;
00060 struct ctrump_expr *expr;
00061 };
00062
00066 struct ctrump_subscript_terminal {
00067 struct ctrump_expr *expr;
00068 struct ctrump_texpr *load_type;
00069 };
00070
00077 struct ctrump_subscript_coef_load_record {
00078
00079 struct ctrump_texpr *load_type;
00080 struct ctrump_expr *expr;
00081 };
00082
00089 struct ctrump_subscript_record_member {
00090 struct ctrump_texpr *record_type;
00091 const struct ctrump_symbol *member_name;
00092 };
00093
00100 struct ctrump_subscript_record_member_terminal {
00101 struct ctrump_texpr *record_type;
00102 struct ctrump_texpr *load_type;
00103 const struct ctrump_symbol *member_name;
00104 };
00105
00106
00136 struct ctrump_subscript_nd {
00137 enum ctrump_subscript_nd_code code;
00138
00139 union {
00140 struct ctrump_subscript_coef_array array_coef;
00141 struct ctrump_subscript_terminal terminal;
00142 struct ctrump_subscript_coef_load_record load_record;
00143 struct ctrump_subscript_record_member record_member;
00144 struct ctrump_subscript_record_member_terminal record_member_terminal;
00145 } u;
00146 };
00147
00151 struct ctrump_subscript {
00152 int num_nd_subscript;
00153 struct ctrump_subscript_nd *nd_subscripts;
00154 };
00155
00156
00161 struct ctrump_memory_access {
00162 #define CTRUMP_MEMORY_ACCESS_PTRREF (1<<0)
00163 #define CTRUMP_MEMORY_ACCESS_PARTIAL (1<<1)
00164 int flags;
00165
00166 struct ctrump_expr *array;
00167 int num_subscript;
00168 struct ctrump_subscript *subscripts;
00169
00170
00171 struct ctrump_stmt *at_stmt;
00172 struct ctrump_expr *at_expr;
00173 };
00174
00178 struct ctrump_memory_load {
00179 struct ctrump_memory_access mem_access;
00180 };
00181
00185 struct ctrump_memory_store {
00186 enum ctrump_expr_code store_op;
00188 struct ctrump_memory_access mem_access;
00189 struct ctrump_expr *val;
00190 };
00191
00195 struct ctrump_var_ref {
00196 struct ctrump_stmt *at;
00197 struct ctrump_expr *ref_expr;
00198 };
00199
00203 struct ctrump_var_store {
00204 enum ctrump_expr_code store_op;
00205 struct ctrump_var *var;
00206 int flags;
00207 struct ctrump_pdg_node *new_val;
00208 struct ctrump_expr *var_ref;
00210 struct ctrump_stmt *at;
00211 struct ctrump_expr *val;
00212 };
00213
00214 enum ctrump_load_store_t {
00215 CTRUMP_MEMORY_LOAD,
00216 CTRUMP_MEMORY_STORE,
00217 };
00218
00222 struct ctrump_ordered_memory_load_store_node {
00223 enum ctrump_load_store_t code;
00224 int op_index;
00225 };
00226
00227
00238 struct ctrump_load_store_set {
00239 int num_mem_load;
00240 int num_mem_store;
00241 int num_memop;
00242 int num_ref;
00243 int num_store;
00245
00246 struct ctrump_var_ref *refs;
00247 struct ctrump_var_store *stores;
00249
00250 struct ctrump_memory_load *mem_loads;
00251 struct ctrump_memory_store *mem_stores;
00254 struct ctrump_ordered_memory_load_store_node *ordered_load_store;
00255 };
00256
00257
00261 enum ctrump_pdg_node_code {
00262 CTRUMP_PDG_VALUE_EXPR,
00263 CTRUMP_PDG_VALUE_REDUCTION,
00264 CTRUMP_PDG_VALUE_INCREMENTAL,
00265 CTRUMP_PDG_VALUE_PHI,
00266 CTRUMP_PDG_VALUE_INITIALIZER,
00267 CTRUMP_PDG_VALUE_UNINITIALIZED,
00268 CTRUMP_PDG_VALUE_GLOBAL,
00269 CTRUMP_PDG_VALUE_ARG
00270 };
00271
00275 struct ctrump_phi_node {
00276 int id;
00277 int num_merge;
00278 int var_index;
00279 struct ctrump_bb *merge_at;
00280 struct ctrump_pdg_node **nodes;
00281 };
00282
00286 enum ctrump_reductive_expr_code {
00287 CTRUMP_REDUCTIVE_IDENTIFY,
00288 CTRUMP_REDUCTIVE_ADD,
00289 CTRUMP_REDUCTIVE_SUB,
00290 CTRUMP_REDUCTIVE_MUL,
00292 CTRUMP_REDUCTIVE_BOR,
00293 CTRUMP_REDUCTIVE_BAND,
00294 CTRUMP_REDUCTIVE_BXOR,
00296 CTRUMP_REDUCTIVE_LOR,
00297 CTRUMP_REDUCTIVE_LAND,
00299 CTRUMP_REDUCTIVE_FADD,
00300 CTRUMP_REDUCTIVE_FSUB,
00301 CTRUMP_REDUCTIVE_FMUL
00302 };
00303
00304
00309 struct ctrump_pdg_reductive_expr {
00310 enum ctrump_reductive_expr_code op;
00311 struct ctrump_pdg_node *prev_val;
00312 struct ctrump_expr *value;
00313 };
00314
00315
00319 enum ctrump_incremental_expr_code {
00320 CTRUMP_PDG_INC,
00321 CTRUMP_PDG_DEC,
00322 CTRUMP_PDG_FINC,
00323 CTRUMP_PDG_FDEC,
00324 };
00325
00329 struct ctrump_pdg_incremental_expr {
00330 enum ctrump_incremental_expr_code op;
00331 struct ctrump_pdg_node *prev_val;
00332 };
00333
00337 struct ctrump_pdg_store_expr {
00338 enum ctrump_expr_code store_op;
00339 struct ctrump_expr *val;
00340 };
00341
00345 struct ctrump_pdg_node {
00346 int id;
00347 enum ctrump_pdg_node_code code;
00348 struct ctrump_stmt *at;
00349
00350 union {
00351 struct ctrump_pdg_reductive_expr reduction;
00352 struct ctrump_pdg_incremental_expr incr;
00353 struct ctrump_pdg_store_expr expr;
00354 struct ctrump_phi_node *phi;
00355 struct ctrump_initializer_list *initializer;
00356 }u;
00357 };
00358
00359 #ifdef __cplusplus
00360 }
00361 #endif
00362
00363 #endif