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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef region_util_INCLUDED
00048 #define region_util_INCLUDED
00049
00050 #include "defs.h"
00051 #include "mempool.h"
00052 #include "opcode.h"
00053 #include "opcode_core.h"
00054 #include "opcode_gen_core.h"
00055 #include "srcpos.h"
00056 #include "wn_core.h"
00057 #include "wn_map.h"
00058 #include "preg_list.h"
00059 #include "stab.h"
00060 #include "wn_lower.h"
00061 #ifdef __cplusplus
00062 class POINTS_TO;
00063 #else
00064 #define POINTS_TO void
00065 #endif
00066
00067 #ifdef __cplusplus
00068 extern "C" {
00069 #endif
00070
00071
00072 struct cgrin;
00073
00074
00075
00076 typedef enum {
00077 RL_UNKNOWN,
00078 RL_SRC,
00079 RL_MP,
00080 RL_RGN_INIT,
00081 RL_IPA_PREOPT,
00082 RL_LNO_PREOPT,
00083 RL_LNO,
00084 RL_DU_PREOPT,
00085 RL_RAIL,
00086 RL_RBI,
00087 RL_PREOPT,
00088 RL_MAINOPT,
00089 RL_RVI1,
00090 RL_RVI2,
00091 RL_CG,
00092 RL_CGSCHED,
00093 RL_LAST
00094 } REGION_LEVEL;
00095
00096 struct region_flags_struct {
00097 mUINT16 level : 4;
00098 mUINT16 gra_flags : 4;
00099 mUINT16 return_flag : 1;
00100 mUINT16 glue_code_flag : 1;
00101 mUINT16 contains_black : 1;
00102 mUINT16 contains_bounds : 1;
00103 mUINT16 bounds_exist : 1;
00104 mUINT16 aliased_to_globals : 1;
00105 mUINT16 aliased_to_indirects : 1;
00106 mUINT16 contains_uplevel : 1;
00107 mUINT16 contains_barrier : 1;
00108 mUINT16 unused : 3;
00109 };
00110
00111 typedef enum {
00112 RID_FLAGS_has_reg_alloc = 0x1,
00113 RID_FLAGS_was_gra = 0x2
00114 } REGION_FLAGS;
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 typedef enum {
00128 RID_TYPE_undefined = 0x00,
00129 RID_TYPE_func_entry = 0x01,
00130 RID_TYPE_loop = 0x02,
00131 RID_TYPE_pragma = 0x04,
00132 RID_TYPE_olimit = 0x08,
00133 RID_TYPE_mp = 0x10,
00134 RID_TYPE_rpi = 0x20,
00135 RID_TYPE_cold = 0x40,
00136 RID_TYPE_swp = 0x80,
00137
00138 RID_TYPE_eh = 0x3f000,
00139 RID_TYPE_try = 0x01000,
00140 RID_TYPE_cleanup = 0x02000,
00141 RID_TYPE_exc_spec = 0x04000,
00142 RID_TYPE_mask = 0x08000,
00143 RID_TYPE_guard = 0x10000,
00144 RID_TYPE_null_cleanup = 0x20000
00145 } RID_TYPE;
00146
00147
00148 typedef enum {
00149 TT_REGION_USER_DEBUG = 0x0001,
00150 TT_REGION_LARGE_PU_DEBUG = 0x0002,
00151 TT_REGION_LARGE_PU_OFF = 0x0004,
00152 TT_REGION_RGN_INIT_DEBUG = 0x0008,
00153 TT_REGION_LNO_DEBUG = 0x0010,
00154 TT_REGION_RAIL_DEBUG = 0x0020,
00155 TT_REGION_RBI_DEBUG = 0x0040,
00156 TT_REGION_WOPT_DEBUG = 0x0080,
00157 TT_REGION_CG_DEBUG = 0x0100,
00158 TT_REGION_BOUND_DEBUG = 0x0200,
00159 TT_REGION_ALL = 0xffffffff
00160 } REGION_DEBUG_FLAGS;
00161
00162
00163
00164
00165 typedef enum {
00166 REGION_BOUND_UNKNOWN = FALSE,
00167 REGION_BOUND_EXISTS = TRUE
00168 } REGION_BOUND_EXIST;
00169
00170
00171
00172
00173 typedef enum {
00174 REGION_NO_RETURN = FALSE,
00175 REGION_RETURN = TRUE
00176 } REGION_RETURN_ENUM;
00177
00178 typedef union region_flags_union {
00179 UINT32 flags;
00180 struct region_flags_struct rfs;
00181 } URFLAG;
00182
00183
00184 #define RID_CREATE_NEW_ID -1
00185
00186 #define URFLAG_flags(r) ((r).flags)
00187 #define URFLAG_clear(r) ( (r).flags = 0 )
00188 #define URFLAG_rfs(r) ((r).rfs)
00189 #define URFLAG_level(r) ((r).rfs.level)
00190 #define URFLAG_type(r) ((r).rfs.type)
00191 #define URFLAG_gra_flags(r) ((r).rfs.gra_flags)
00192 #define URFLAG_return_flag(r) ((r).rfs.return_flag)
00193 #define URFLAG_glue_code_flag(r) ((r).rfs.glue_code_flag)
00194 #define URFLAG_contains_black(r) ((r).rfs.contains_black)
00195 #define URFLAG_contains_bounds(r) ((r).rfs.contains_bounds)
00196 #define URFLAG_bounds_exist(r) ((r).rfs.bounds_exist)
00197 #define URFLAG_aliased_to_globals(r) ((r).rfs.aliased_to_globals)
00198 #define URFLAG_aliased_to_indirects(r) ((r).rfs.aliased_to_indirects)
00199 #define URFLAG_contains_uplevel(r) ((r).rfs.contains_uplevel)
00200 #define URFLAG_contains_barrier(r) ((r).rfs.contains_barrier)
00201
00202 typedef struct points_to_ref {
00203 POINTS_TO *Pt;
00204 struct points_to_ref *Next;
00205 } POINTS_TO_SET;
00206
00207 struct EH_RANGE;
00208
00209
00210 typedef struct region_id {
00211 INT id;
00212
00213 RID_TYPE rid_type;
00214 INT depth;
00215
00216 SRCPOS srcpos;
00217
00218 UINT32 flags;
00219 struct cgrin *cginfo;
00220 INT32 num_exits;
00221
00222
00223 PREG_LIST *pregs_in;
00224 PREG_LIST **pregs_out;
00225
00226
00227
00228
00229 PREG_LIST *pregs_quad;
00230 PREG_LIST *pregs_complex_quad;
00231 POINTS_TO_SET *used_in;
00232 POINTS_TO_SET *def_in_live_out;
00233
00234 char *options;
00235
00236 WN *rwn;
00237
00238
00239 WN *parent_block;
00240
00241
00242
00243 struct region_id *parent;
00244 struct region_id *first_kid;
00245 struct region_id *next;
00246
00247 LOWER_ACTIONS lowered;
00248 struct EH_RANGE *eh_range_ptr;
00249
00250 } RID;
00251
00252
00253 #define RID_id(r) ((r)->id)
00254 #define RID_depth(r) ((r)->depth)
00255 #define RID_srcpos(r) ((r)->srcpos)
00256 #define RID_flags(r) ((r)->flags)
00257 #define RID_cginfo(r) ((r)->cginfo)
00258 #define RID_num_exits(r) ((r)->num_exits)
00259 #define RID_options(r) ((r)->options)
00260 #define RID_rwn(r) ((r)->rwn)
00261 #define RID_parent(r) ((r)->parent)
00262 #define RID_parent_block(r) ((r)->parent_block)
00263 #define RID_first_kid(r) ((r)->first_kid)
00264 #define RID_next(r) ((r)->next)
00265 #define RID_rloop(r) ((r)->rloop)
00266 #define RID_lowered(r) ((r)->lowered)
00267 #define RID_eh_range_ptr(r) ((r)->eh_range_ptr)
00268 #define RID_type(r) ((r)->rid_type)
00269
00270
00271 #define RID_level(r) (URFLAG_level(*((URFLAG *)(&RID_flags(r)))))
00272 #define RID_gra_flags(r) (URFLAG_gra_flags(*((URFLAG *)(&RID_flags(r)))))
00273 #define RID_has_return(r) (URFLAG_return_flag(*((URFLAG *)(&RID_flags(r)))))
00274 #define RID_is_glue_code(r) (URFLAG_glue_code_flag(*((URFLAG *)(&RID_flags(r)))))
00275 #define RID_contains_black(r) (URFLAG_contains_black(*((URFLAG *)(&RID_flags(r)))))
00276 #define RID_contains_bounds(r) (URFLAG_contains_bounds(*((URFLAG *)(&RID_flags(r)))))
00277 #define RID_bounds_exist(r) (URFLAG_bounds_exist(*((URFLAG *)(&RID_flags(r)))))
00278 #define RID_aliased_to_globals(r) (URFLAG_aliased_to_globals(*((URFLAG *)(&RID_flags(r)))))
00279 #define RID_aliased_to_indirects(r) (URFLAG_aliased_to_indirects(*((URFLAG *)(&RID_flags(r)))))
00280 #define RID_contains_uplevel(r) (URFLAG_contains_uplevel(*((URFLAG *)(&RID_flags(r)))))
00281 #define RID_contains_barrier(r) (URFLAG_contains_barrier(*((URFLAG *)(&RID_flags(r)))))
00282
00283
00284 #define RID_pregs_in(r) ((r)->pregs_in)
00285 #define RID_pregs_quad(r) ((r)->pregs_quad)
00286 #define RID_pregs_complex_quad(r) ((r)->pregs_complex_quad)
00287 #define RID_pregs_out(r) ((r)->pregs_out)
00288 #define RID_pregs_out_i(r,i) (((r)->pregs_out)?(((r)->pregs_out)[(i)]):((PREG_LIST *)NULL))
00289 #define RID_pregs_set_out_i(r,i) (((r)->pregs_out)[(i)])
00290 #define RID_used_in(r) ((r)->used_in)
00291 #define RID_def_in_live_out(r) ((r)->def_in_live_out)
00292
00293
00294 #define RID_has_reg_alloc(r) (RID_gra_flags(r) & RID_FLAGS_has_reg_alloc)
00295 #define RID_has_reg_alloc_Set(r) (RID_gra_flags(r) |= RID_FLAGS_has_reg_alloc)
00296 #define RID_has_reg_alloc_Reset(r) (RID_gra_flags(r) &= ~RID_FLAGS_has_reg_alloc)
00297 #define RID_was_gra(r) (RID_gra_flags(r) & RID_FLAGS_was_gra)
00298 #define RID_was_gra_Set(r) (RID_gra_flags(r) |= RID_FLAGS_was_gra)
00299 #define RID_was_gra__Reset(r) (RID_gra_flags(r) &= ~RID_FLAGS_was_gra)
00300
00301
00302 #define RID_TYPE_func_entry(r) (RID_type(r) & RID_TYPE_func_entry)
00303 #define RID_TYPE_func_entry_Set(r) (RID_type(r) = \
00304 (RID_TYPE)(RID_type(r) | RID_TYPE_func_entry))
00305 #define RID_TYPE_func_entry_Reset(r) (RID_type(r) = \
00306 (RID_TYPE)(RID_type(r) & ~RID_TYPE_func_entry))
00307
00308 #define RID_TYPE_loop(r) (RID_type(r) & RID_TYPE_loop)
00309 #define RID_TYPE_loop_Set(r) (RID_type(r) = \
00310 (RID_TYPE)(RID_type(r) | RID_TYPE_loop))
00311 #define RID_TYPE_loop_Reset(r) (RID_type(r) = \
00312 (RID_TYPE)(RID_type(r) & ~RID_TYPE_loop))
00313
00314 #define RID_TYPE_pragma(r) (RID_type(r) & RID_TYPE_pragma)
00315 #define RID_TYPE_pragma_Set(r) (RID_type(r) = \
00316 (RID_TYPE)(RID_type(r) | RID_TYPE_pragma))
00317 #define RID_TYPE_pragma_Reset(r) (RID_type(r) = \
00318 (RID_TYPE)(RID_type(r) & ~RID_TYPE_pragma))
00319
00320 #define RID_TYPE_olimit(r) (RID_type(r) & RID_TYPE_olimit)
00321 #define RID_TYPE_olimit_Set(r) (RID_type(r) = \
00322 (RID_TYPE)(RID_type(r) | RID_TYPE_olimit))
00323 #define RID_TYPE_olimit_Reset(r) (RID_type(r) = \
00324 (RID_TYPE)(RID_type(r) & ~RID_TYPE_olimit))
00325
00326 #define RID_TYPE_mp(r) (RID_type(r) & RID_TYPE_mp)
00327 #define RID_TYPE_mp_Set(r) (RID_type(r) = \
00328 (RID_TYPE)(RID_type(r) | RID_TYPE_mp))
00329 #define RID_TYPE_mp_Reset(r) (RID_type(r) = \
00330 (RID_TYPE)(RID_type(r) & ~RID_TYPE_mp))
00331
00332 #define RID_TYPE_rpi(r) (RID_type(r) & RID_TYPE_rpi)
00333 #define RID_TYPE_rpi_Set(r) (RID_type(r) = \
00334 (RID_TYPE)(RID_type(r) | RID_TYPE_rpi))
00335 #define RID_TYPE_rpi_Reset(r) (RID_type(r) = \
00336 (RID_TYPE)(RID_type(r) & ~RID_TYPE_rpi))
00337
00338 #define RID_TYPE_cold(r) (RID_type(r) & RID_TYPE_cold)
00339 #define RID_TYPE_cold_Set(r) (RID_type(r) = \
00340 (RID_TYPE)(RID_type(r) | RID_TYPE_cold))
00341 #define RID_TYPE_cold_Reset(r) (RID_type(r) = \
00342 (RID_TYPE)(RID_type(r) & ~RID_TYPE_cold))
00343
00344 #define RID_TYPE_swp(r) (RID_type(r) & RID_TYPE_swp)
00345 #define RID_TYPE_swp_Set(r) (RID_type(r) = \
00346 (RID_TYPE)(RID_type(r) | RID_TYPE_swp))
00347 #define RID_TYPE_swp_Reset(r) (RID_type(r) = \
00348 (RID_TYPE)(RID_type(r) & ~RID_TYPE_swp))
00349
00350 #define RID_TYPE_eh(r) (RID_type(r) & RID_TYPE_eh)
00351
00352
00353 #define RID_TYPE_try(r) (RID_type(r) & RID_TYPE_try)
00354 #define RID_TYPE_try_Set(r) (RID_type(r) = \
00355 (RID_TYPE)(RID_type(r) | RID_TYPE_try))
00356 #define RID_TYPE_try_Reset(r) (RID_type(r) = \
00357 (RID_TYPE)(RID_type(r) & ~RID_TYPE_try))
00358
00359 #define RID_TYPE_cleanup(r) (RID_type(r) & RID_TYPE_cleanup)
00360 #define RID_TYPE_cleanup_Set(r) (RID_type(r) = \
00361 (RID_TYPE)(RID_type(r) | RID_TYPE_cleanup))
00362 #define RID_TYPE_cleanup_Reset(r) (RID_type(r) = \
00363 (RID_TYPE)(RID_type(r) & ~RID_TYPE_cleanup))
00364
00365 #define RID_TYPE_exc_spec(r) (RID_type(r) & RID_TYPE_exc_spec)
00366 #define RID_TYPE_exc_spec_Set(r) (RID_type(r) = \
00367 (RID_TYPE)(RID_type(r) | RID_TYPE_exc_spec))
00368 #define RID_TYPE_exc_spec_Reset(r) (RID_type(r) = \
00369 (RID_TYPE)(RID_type(r) & ~RID_TYPE_exc_spec))
00370
00371 #define RID_TYPE_mask(r) (RID_type(r) & RID_TYPE_mask)
00372 #define RID_TYPE_mask_Set(r) (RID_type(r) = \
00373 (RID_TYPE)(RID_type(r) | RID_TYPE_mask))
00374 #define RID_TYPE_mask_Reset(r) (RID_type(r) = \
00375 (RID_TYPE)(RID_type(r) & ~RID_TYPE_mask))
00376
00377 #define RID_TYPE_guard(r) (RID_type(r) & RID_TYPE_guard)
00378 #define RID_TYPE_guard_Set(r) (RID_type(r) = \
00379 (RID_TYPE)(RID_type(r) | RID_TYPE_guard))
00380 #define RID_TYPE_guard_Reset(r) (RID_type(r) = \
00381 (RID_TYPE)(RID_type(r) & ~RID_TYPE_guard))
00382
00383 #define RID_TYPE_null_cleanup(r) (RID_type(r) & RID_TYPE_null_cleanup)
00384 #define RID_TYPE_null_cleanup_Set(r) (RID_type(r) = \
00385 (RID_TYPE)(RID_type(r) | RID_TYPE_null_cleanup))
00386 #define RID_TYPE_null_cleanup_Reset(r) (RID_type(r) = \
00387 (RID_TYPE)(RID_type(r) & ~RID_TYPE_guard))
00388
00389
00390 #define RID_TYPE_transparent(r) ( RID_TYPE_func_entry(r) \
00391 || RID_TYPE_mp(r) \
00392 || RID_TYPE_eh(r) \
00393 || RID_TYPE_swp(r) \
00394 || RID_TYPE_cold(r))
00395
00396
00397
00398
00399
00400
00401
00402
00403 #define REGION_STACK_SIZE 10
00404 typedef struct region_cs_iter {
00405 RID *me;
00406 RID *kid;
00407 RID_TYPE type;
00408 WN *parent_block;
00409 WN *region_marker[REGION_STACK_SIZE];
00410 INT32 region_marker_sp;
00411 BOOL is_pu;
00412 BOOL is_not_stacked;
00413 } REGION_CS_ITER;
00414
00415 #define REGION_CS_ITER_me(i) ((i)->me)
00416 #define REGION_CS_ITER_kid(i) ((i)->kid)
00417 #define REGION_CS_ITER_type(i) ((i)->type)
00418 #define REGION_CS_ITER_parent_block(i) ((i)->parent_block)
00419 #define REGION_CS_ITER_sp(i) ((i)->region_marker_sp)
00420 #define REGION_CS_ITER_marker(i,j) ((i)->region_marker[j])
00421 #define REGION_CS_ITER_is_pu(i) ((i)->is_pu)
00422 #define REGION_CS_ITER_is_not_stacked(i) ((i)->is_not_stacked)
00423 #define REGION_CS_ITER_wn(i) (RID_rwn((i)->kid))
00424
00425
00426
00427 extern WN_MAP RID_map;
00428 extern MEM_POOL REGION_mem_pool;
00429
00430
00431 extern INT32 New_Region_Id(void);
00432 extern INT32 Last_Region_Id(void);
00433
00434
00435 extern void REGION_new_wn(WN *, WN *);
00436
00437
00438 extern BOOL REGION_consistency_check(WN *);
00439
00440
00441 extern void REGION_update_alias_info(WN *, struct ALIAS_MANAGER *);
00442
00443
00444 extern RID *REGION_get_rid(const WN *);
00445
00446
00447 extern WN *REGION_find_pu(WN *);
00448
00449
00450 extern BOOL REGION_has_black_regions(RID *);
00451
00452
00453 extern void REGION_set_level(RID *, REGION_LEVEL);
00454
00455
00456 extern BOOL REGION_count_exits(WN *);
00457
00458
00459 extern void REGION_fix_up_exits(RID *, WN *);
00460
00461
00462 extern BOOL REGION_scan_exits(WN *, INT32);
00463
00464
00465
00466
00467 extern RID *RID_Create(INT, INT, WN *);
00468
00469
00470 extern void RID_Add_kid(RID *, RID *);
00471
00472
00473 extern void RID_unlink(RID *);
00474
00475
00476 extern void RID_replace(RID *old_rid, RID *new_rid);
00477
00478
00479 extern void RID_Delete(WN_MAP_TAB *, WN *);
00480 extern void RID_Delete2(RID *);
00481
00482
00483 extern void REGION_clone(WN *, WN *, WN *);
00484
00485
00486 extern void REGION_emit(RID *, WN *, INT32, INT32, INT64);
00487
00488
00489 extern void RID_copy_sets(RID *, RID *);
00490
00491
00492 extern REGION_LEVEL RID_preopt_level(INT);
00493
00494
00495 extern BOOL REGION_search_preg_set(PREG_LIST *, PREG_NUM);
00496
00497
00498 extern void REGION_add_wn_points_to(POINTS_TO_SET **, WN *,
00499 struct ALIAS_MANAGER *);
00500
00501
00502 extern void REGION_add_points_to(POINTS_TO_SET **, POINTS_TO *,
00503 struct ALIAS_MANAGER *);
00504
00505
00506 extern POINTS_TO *Points_to_copy(POINTS_TO *, MEM_POOL *);
00507
00508 extern void Get_symbol_info_for_cvt_io(POINTS_TO *, WN *);
00509
00510 extern POINTS_TO *Points_to(struct ALIAS_MANAGER *, WN *);
00511
00512
00513
00514 extern BOOL REGION_add_preg_in(RID *rid, PREG_NUM pr, TYPE_ID quad);
00515 extern BOOL REGION_add_preg_out(RID *rid, INT32 which_set, PREG_NUM pr,
00516 TYPE_ID quad);
00517
00518
00519
00520 extern BOOL REGION_remove_preg(RID *rid, PREG_NUM pr, BOOL outset);
00521
00522
00523 extern WN *REGION_add_exit(WN *, WN *, WN *);
00524
00525
00526 extern void REGION_delete_exit(RID *, INT32, WN *, BOOL);
00527
00528
00529 extern char *REGION_get_options_string(WN *);
00530
00531
00532 extern BOOL REGION_is_EH(WN *);
00533
00534
00535 extern BOOL REGION_is_mp(WN *);
00536
00537
00538 extern BOOL REGION_is_EH(WN *);
00539
00540
00541 extern BOOL WN_Fake_Call_EH_Region(WN *,WN_MAP);
00542
00543
00544
00545 extern REGION_KIND REGION_type_to_kind(RID *);
00546
00547
00548 extern void REGION_kind_to_type(WN *, RID *);
00549
00550
00551 extern void REGION_propagate_return(RID *);
00552
00553
00554 extern char *RID_level_str(RID *rid);
00555
00556
00557 extern char *RID_type_str(RID_TYPE type);
00558
00559
00560
00561 extern void RID_set_print(FILE *, RID *);
00562
00563 extern void Print_points_to(FILE *, POINTS_TO *);
00564
00565
00566 extern void RID_Fprint(FILE *, RID *);
00567
00568
00569 extern void RID_Tree_Print(FILE *, RID *);
00570
00571
00572 extern void RID_WN_Tree_Print(FILE *, WN *);
00573
00574 #ifdef __cplusplus
00575 }
00576 #endif
00577
00578 #endif