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
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521 #if !defined(opt_bb_INCLUDED) || defined(opt_bb_CXX)
00522 #ifndef opt_bb_INCLUDED
00523 #ifdef _KEEP_RCS_ID
00524 static char *opt_bbrcs_id = opt_bb_INCLUDED"$Revision$";
00525 #endif
00526
00527 #ifndef opt_base_INCLUDED
00528 #include "cxx_base.h"
00529 #endif
00530 #ifndef opt_defs_INCLUDED
00531 #include "opt_defs.h"
00532 #endif
00533 #include "wn.h"
00534 #include "wn_util.h"
00535 #ifndef opt_stmt_INCLUDED
00536 #include "opt_stmt.h"
00537 #endif
00538 #ifndef opt_wn_INCLUDED
00539 #include "opt_wn.h"
00540 #endif
00541 #ifndef srcpos_INCLUDED
00542 #include "srcpos.h"
00543 #endif
00544
00545 #include "defs.h"
00546 #include "cxx_memory.h"
00547 #include "opt_util.h"
00548 #include "region_util.h"
00549
00550
00551 typedef struct region_id RID;
00552 class BB_LIST;
00553 class BB_NODE;
00554 class BB_NODE_SET;
00555 class BB_REGION;
00556 class CFG;
00557 class CODEREP;
00558 class CODEREP_LIST;
00559 class DU_MANAGER;
00560 class CODEMAP;
00561 class EMITTER;
00562 class EXP_PHI;
00563 class EXP_PHI_LIST;
00564 class MAIN_EMITTER;
00565 class IDX_32_SET;
00566 class ITABLE;
00567 class IVR;
00568 class IV_CAND;
00569 class OPT_STAB;
00570 class PHI_LIST;
00571 class RVI_ANN_LIST;
00572 class EXP_OCCURS_CONTAINER;
00573
00574 class BB_IFINFO {
00575 private:
00576 SRCPOS _thenloc;
00577 SRCPOS _elseloc;
00578 BB_NODE *_cond;
00579 BB_NODE *_then;
00580 BB_NODE *_else;
00581 BB_NODE *_merge;
00582 BB_IFINFO(const BB_IFINFO&);
00583 BB_IFINFO& operator = (const BB_IFINFO&);
00584 public:
00585 BB_IFINFO(void);
00586 BB_IFINFO(SRCPOS thenloc,
00587 SRCPOS elseloc,
00588 BB_NODE *bb_cond,
00589 BB_NODE *bb_then,
00590 BB_NODE *bb_else,
00591 BB_NODE *bb_merge) { _thenloc = thenloc;
00592 _elseloc = elseloc;
00593 _cond = bb_cond;
00594 _then = bb_then;
00595 _else = bb_else;
00596 _merge = bb_merge;
00597 }
00598 ~BB_IFINFO(void);
00599 SRCPOS Thenloc(void) const { return _thenloc; }
00600 SRCPOS Elseloc(void) const { return _elseloc; }
00601 BB_NODE *Cond(void) const { return _cond; }
00602 BB_NODE *Then(void) const { return _then; }
00603 BB_NODE *Else(void) const { return _else; }
00604 BB_NODE *Merge(void) const { return _merge; }
00605 };
00606
00607 enum LOOP_FLAGS {
00608 LOOP_EMPTY = 0x0,
00609 LOOP_DO = 0x1,
00610 LOOP_WHILE = 0x2,
00611 LOOP_REPEAT = 0x4,
00612 LOOP_PREOPT = 0x10,
00613 LOOP_PRE_DO = 0x11,
00614 LOOP_PRE_WHILE = 0x12,
00615 LOOP_PRE_REPEAT = 0x14,
00616 LOOP_TYPES = 0x17,
00617 LOOP_ORIGINAL_DO = 0x20,
00618 LOOP_IS_MP = 0x40,
00619 LOOP_IS_PDO = 0x80,
00620 LOOP_HAS_REAL_OCC = 0x100,
00621
00622
00623
00624 };
00625
00626 enum MP_TY { MP_REGION, MP_DOACROSS = 0x40, MP_PDO = 0x80};
00627
00628 #if defined(TARG_SL) //PARA_EXTENSION
00629 enum SL2_PARA_TY { SL2_PARA_REGION};
00630 #endif
00631
00632 class BB_LOOP : public SLIST_NODE{
00633 private:
00634
00635 BB_LOOP *_child;
00636 BB_LOOP *_parent;
00637
00638
00639
00640 WN *_loopstmt;
00641 WN *_index;
00642 union {
00643 BB_NODE *_start;
00644 BB_NODE *_dohead;
00645 } _u1;
00646 BB_NODE *_end;
00647 BB_NODE *_body;
00648 BB_NODE *_step;
00649 union {
00650 BB_NODE *_merge;
00651 BB_NODE *_dotail;
00652 } _u2;
00653 BB_NODE_SET *_body_set;
00654
00655
00656
00657
00658 BOOL well_formed;
00659 BOOL has_entry_guard;
00660 BOOL _valid_doloop;
00661 BB_NODE *header;
00662 BB_NODE *tail;
00663 BB_NODE *preheader;
00664 BB_NODE *loopback;
00665 INT header_pred_count;
00666 INT preheader_pred_num;
00667 INT loopback_pred_num;
00668 bool test_at_entry;
00669 bool test_at_exit;
00670 bool exit_early;
00671 INT depth;
00672 INT max_depth;
00673
00674 BB_NODE_SET *_true_body_set;
00675
00676
00677
00678 CODEREP *_iv;
00679 CODEREP *_iv_replacement;
00680
00681
00682 IDX_32_SET *_lftr_non_candidates;
00683
00684
00685
00686 STMTREP *_trip_count_stmt;
00687 CODEREP *_trip_count_expr;
00688 CODEREP *_entry_test;
00689
00690 WN *_wn_trip_count;
00691 LOOP_FLAGS _flags;
00692 WN *_orig_wn;
00693 BOOL _promoted_do;
00694 INT32 _size_estimate;
00695
00696 BB_LOOP(const BB_LOOP&);
00697 BB_LOOP& operator = (const BB_LOOP&);
00698
00699 DECLARE_SLIST_NODE_CLASS(BB_LOOP)
00700
00701
00702 BOOL Invariant_cr_rec( CODEREP * ) const;
00703
00704 public:
00705 BB_LOOP(void);
00706 BB_LOOP( WN *index,
00707 BB_NODE *start,
00708 BB_NODE *end,
00709 BB_NODE *body,
00710 BB_NODE *step,
00711 BB_NODE *merge) {
00712 _child = NULL;
00713 _parent = NULL;
00714 _loopstmt = NULL;
00715 _index = index;
00716 _u1._start = start;
00717 _end = end;
00718 _body = body;
00719 _step = step;
00720 _u2._merge = merge;
00721 _body_set = NULL;
00722 _true_body_set = NULL;
00723 _trip_count_stmt = NULL;
00724 _trip_count_expr = NULL;
00725 _entry_test = NULL;
00726 _wn_trip_count = NULL;
00727 _iv = NULL;
00728 _iv_replacement = NULL;
00729 _lftr_non_candidates = NULL;
00730 _flags = LOOP_EMPTY;
00731 _orig_wn = NULL;
00732 _promoted_do = FALSE;
00733 has_entry_guard = FALSE;
00734 well_formed = FALSE;
00735 _valid_doloop = TRUE;
00736 header = NULL;
00737 _size_estimate = 0;
00738 }
00739 ~BB_LOOP(void);
00740 BB_LOOP *Child(void) const { return _child;}
00741 BB_LOOP *Parent(void) const { return _parent;}
00742 WN *Loopstmt(void) const { return _loopstmt; }
00743 WN *Index(void) const { return _index; }
00744 BB_NODE *Start(void) const { return _u1._start; }
00745 BB_NODE *Dohead(void) const { return _u1._dohead; }
00746 BB_NODE *End(void) const { return _end; }
00747 BB_NODE *Body(void) const { return _body; }
00748 BB_NODE *Step(void) const { return _step; }
00749 void Set_merge(BB_NODE *b){ _u2._merge = b; }
00750 BB_NODE *Merge(void) const { return _u2._merge; }
00751 BB_NODE *Dotail(void) const { return _u2._dotail; }
00752 BB_NODE *Header(void) const { return header; }
00753 void Set_header(BB_NODE *h) { header = h; }
00754 BB_NODE *Tail(void) const { return tail; }
00755 void Set_tail(BB_NODE *t) { tail = t; }
00756 BB_NODE *Preheader(void) const { return preheader; }
00757 void Set_preheader(BB_NODE *p) { preheader = p; }
00758 BB_NODE *Loopback(void) const { return loopback; }
00759 void Set_loopback(BB_NODE *l) { loopback = l; }
00760 BB_NODE_SET *Body_set(void) const { return _body_set; }
00761 BB_NODE_SET *True_body_set(void) const { return _true_body_set; }
00762 BOOL Valid_doloop() const { return _valid_doloop; }
00763 void Set_valid_doloop() { _valid_doloop = TRUE; }
00764 void Reset_valid_doloop() { _valid_doloop = FALSE; }
00765 void Set_child(BB_LOOP *l){ _child = l; }
00766 void Set_parent
00767 (BB_LOOP *l) { _parent = l; }
00768 void Set_loopstmt(WN *l) { _loopstmt = l; }
00769 void Set_body_set
00770 (BB_NODE_SET *s) { _body_set = s; }
00771 void Set_true_body_set
00772 (BB_NODE_SET *s) { _true_body_set = s; }
00773 BB_LOOP *Append (BB_LOOP*);
00774 BB_LOOP *Append_list(BB_LOOP *);
00775 void Print(FILE *fp=stderr) const;
00776 void Init_bit_vectors(ITABLE *, MEM_POOL *);
00777 void Summarize_taltered( void );
00778 void Summarize_naltered( void );
00779 WN *Orig_wn(void) const { return _orig_wn; }
00780 void Set_orig_wn(WN *wn) { _orig_wn = wn; }
00781 BOOL Promoted_do() const { return _promoted_do; }
00782 void Set_promoted_do() { _promoted_do = TRUE; }
00783 BOOL Well_formed() const { return well_formed; }
00784 void Set_well_formed() { well_formed = TRUE; }
00785 void Reset_well_formed() { well_formed = FALSE; }
00786 BOOL Has_entry_guard() const { return has_entry_guard; }
00787 void Set_has_entry_guard() { has_entry_guard = TRUE; }
00788 void Reset_has_entry_guard() { has_entry_guard = FALSE; }
00789 INT Depth() const { return depth; }
00790 INT Max_depth() const { return max_depth; }
00791 void Set_depth(INT d) { depth = d; }
00792 void Set_max_depth(INT d) { max_depth = d; }
00793
00794
00795 BOOL Contains(const BB_LOOP* l) const;
00796
00797
00798 BOOL Invariant_cr( CODEREP * ) const;
00799
00800 BOOL Index_relative_expr( CODEREP *expr,
00801 const CODEREP *index ) const;
00802
00803 BOOL Test_at_entry(void) const { return test_at_entry; }
00804 BOOL Test_at_exit(void) const { return test_at_exit; }
00805 BOOL Exit_early(void) const { return exit_early; }
00806 void Set_test_at_entry(bool b) { test_at_entry = b; }
00807 void Set_test_at_exit(bool b) { test_at_exit = b; }
00808 void Set_exit_early(bool b) { exit_early = b; }
00809
00810 INT Header_pred_count(void) const { return header_pred_count; }
00811 INT Preheader_pred_num(void) const { return preheader_pred_num; }
00812 INT Loopback_pred_num(void) const { return loopback_pred_num; }
00813 void Set_header_pred_count(INT i) { header_pred_count = i; }
00814 void Set_preheader_pred_num(INT i) { preheader_pred_num = i; }
00815 void Set_loopback_pred_num(INT i) { loopback_pred_num = i; }
00816
00817
00818 BOOL Loop_is_guarded(void) { return (_flags == LOOP_DO || _flags == LOOP_WHILE); }
00819
00820 LOOP_FLAGS Flags(void) const { return _flags; }
00821 void Set_flag(LOOP_FLAGS f) { _flags =(LOOP_FLAGS)(_flags|f);}
00822 BOOL Is_flag_set(LOOP_FLAGS f)const{ return _flags & f; }
00823 void Clear_flag(LOOP_FLAGS f) { _flags = (LOOP_FLAGS) (_flags & ~f); }
00824 CODEREP *Iv(void) const { return _iv; }
00825 void Set_iv(CODEREP *cr) { _iv = cr; }
00826 CODEREP *Iv_replacement(void) const { return _iv_replacement; }
00827 void Set_iv_replacement(CODEREP *cr){ _iv_replacement = cr; }
00828 IDX_32_SET *Lftr_non_candidates(void) const { return _lftr_non_candidates; }
00829 void Set_lftr_non_candidates(IDX_32_SET *x) { _lftr_non_candidates = x; }
00830 STMTREP *Trip_count_stmt(void) const { return _trip_count_stmt; }
00831 void Set_trip_count_stmt(STMTREP *stmt) { _trip_count_stmt = stmt; }
00832 CODEREP *Trip_count_expr(void) const { return _trip_count_expr; }
00833 void Set_trip_count_expr(CODEREP *expr) { _trip_count_expr = expr; }
00834 CODEREP *Entry_test(void) const { return _entry_test; }
00835 void Set_entry_test(CODEREP *expr) { _entry_test = expr; }
00836 WN *Wn_trip_count(void) const { return _wn_trip_count; }
00837 void Set_wn_trip_count(WN *wn) { _wn_trip_count = wn; }
00838 INT32 Size_estimate(void) const { return _size_estimate; }
00839 void Set_size_estimate(INT32 n) { _size_estimate = n; }
00840 void Incr_size_estimate(INT32 n) { _size_estimate += n; }
00841 };
00842
00843 class BB_LOOP_CONTAINER : public SLIST {
00844 private:
00845 DECLARE_SLIST_CLASS( BB_LOOP_CONTAINER, BB_LOOP )
00846
00847 BB_LOOP_CONTAINER(const BB_LOOP_CONTAINER&);
00848 BB_LOOP_CONTAINER& operator = (const BB_LOOP_CONTAINER&);
00849
00850 public:
00851 ~BB_LOOP_CONTAINER(void) {}
00852
00853 void Append (BB_LOOP *loop,
00854 MEM_POOL *pool);
00855 };
00856
00857 class BB_LOOP_CONST_ITER : public SLIST_ITER {
00858 DECLARE_SLIST_CONST_ITER_CLASS( BB_LOOP_CONST_ITER, BB_LOOP, BB_LOOP_CONTAINER )
00859 public:
00860 void Init() {}
00861 };
00862
00863 class BB_LOOP_ITER : public SLIST_ITER {
00864 DECLARE_SLIST_ITER_CLASS( BB_LOOP_ITER, BB_LOOP, BB_LOOP_CONTAINER )
00865 public:
00866 void Init() {}
00867 };
00868
00869
00870
00871
00872
00873
00874 class BB_SWITCH {
00875 friend class BB_NODE;
00876 private:
00877 BB_NODE *_def_blk;
00878 BB_NODE **_case_blks;
00879 INT32 _num_entries;
00880
00881 BB_SWITCH(void);
00882
00883 public:
00884 BB_SWITCH( INT32 num_entries, MEM_POOL *mem_pool ) :
00885 _num_entries(num_entries)
00886 {
00887 _case_blks = (BB_NODE **)
00888 OPT_POOL_Alloc(mem_pool, num_entries*sizeof(BB_NODE*), -1);
00889 _def_blk = NULL;
00890 }
00891 ~BB_SWITCH(void) {}
00892 };
00893
00894
00895
00896 enum { IO_TAB_SIZE = 5 };
00897
00898
00899 class BB_LIST : public SLIST_NODE {
00900 private:
00901 BB_NODE *node;
00902 BB_LIST(const BB_LIST&);
00903 BB_LIST& operator = (const BB_LIST&);
00904
00905 public:
00906 BB_LIST(void) {}
00907 BB_LIST(BB_NODE *nd) {node = nd;}
00908 ~BB_LIST(void) {}
00909
00910 DECLARE_SLIST_NODE_CLASS( BB_LIST )
00911 BB_LIST *Append (BB_NODE *bb,
00912 MEM_POOL *pool);
00913
00914 BB_LIST *Prepend(BB_NODE *bb, MEM_POOL *pool)
00915 {
00916 BB_LIST *new_bblst = (BB_LIST*)CXX_NEW( BB_LIST(bb), pool );
00917 new_bblst->Set_Next(this);
00918 return new_bblst;
00919 }
00920
00921 BB_LIST *Remove (BB_NODE *bb,
00922 MEM_POOL *pool);
00923 BOOL Contains(BB_NODE *bb)const;
00924 void Print (FILE *fp=stderr)
00925 const;
00926
00927 void Init(BB_NODE *nd) { node = nd; }
00928 void Clear(void) { node = NULL; }
00929 INT32 Pos(BB_NODE *bb);
00930 void Set_node(BB_NODE *bb) { node = bb; }
00931
00932
00933
00934
00935
00936 BOOL Multiple_bbs(void) const { return Next() != NULL; }
00937
00938
00939 BB_NODE *Node(void) const {return node;}
00940 };
00941
00942 class BB_LIST_CONTAINER : public SLIST {
00943 private:
00944 DECLARE_SLIST_CLASS( BB_LIST_CONTAINER, BB_LIST )
00945
00946 BB_LIST_CONTAINER(const BB_LIST_CONTAINER&);
00947 BB_LIST_CONTAINER& operator = (const BB_LIST_CONTAINER&);
00948
00949 public:
00950 ~BB_LIST_CONTAINER(void) {};
00951
00952 void Append (BB_NODE *bb,
00953 MEM_POOL *pool);
00954 void Prepend (BB_NODE *bb,
00955 MEM_POOL *pool);
00956 void Remove(BB_NODE *bb,
00957 MEM_POOL *pool);
00958
00959 BB_NODE *Remove_head(MEM_POOL *pool);
00960 BOOL Contains(BB_NODE *bb)
00961 const;
00962 };
00963
00964 class BB_LIST_ITER : public SLIST_ITER {
00965 DECLARE_SLIST_CONST_ITER_CLASS( BB_LIST_ITER, BB_LIST, BB_LIST_CONTAINER )
00966 public:
00967 void Init(void) {}
00968 void Validate_unique(FILE *fp=stderr);
00969
00970 BB_NODE *First_bb(void) { return (First()) ? Cur()->Node():NULL; }
00971 BB_NODE *Next_bb(void) { return (Next()) ? Cur()->Node():NULL; }
00972 BB_NODE *Cur_bb(void) { return (Cur()) ? Cur()->Node():NULL; }
00973 BB_NODE *First_elem(void) { return (First()) ? Cur()->Node():NULL; }
00974 BB_NODE *Next_elem(void) { return (Next()) ? Cur()->Node():NULL; }
00975 };
00976
00977 enum BB_FLAG {
00978 BB_WILLEXIT = 0x001,
00979 BB_REACHED = 0x002,
00980 BB_DFORDER = 0x004,
00981
00982 BB_HASUJP = 0x008,
00983 BB_WNGEND = 0x010,
00984 BB_HASPRAGMA = 0x020,
00985 BB_IFMERGE = 0x040,
00986 BB_HASCALL = 0x080,
00987 BB_CALLREL = 0x100,
00988 BB_VN_PROCESSED = 0x200,
00989 BB_MP_REGION = 0x400,
00990 BB_TLBS_PROCESSING = 0x800,
00991 BB_REGIONEND = 0x1000,
00992 #if defined(TARG_SL) //PARA_EXTENSION
00993 BB_SL2_PARA_REGION = 0x2000,
00994 #endif
00995 };
00996
00997 #define BB_VISIT (BB_DFORDER)
00998
00999
01000
01001 enum BB_KIND {
01002 BB_UNKNOWN,
01003
01004
01005
01006
01007
01008 BB_GOTO,
01009 BB_LOGIF,
01010 BB_VARGOTO,
01011 BB_ENTRY,
01012 BB_EXIT,
01013 BB_DOSTART,
01014 BB_DOEND,
01015 BB_DOSTEP,
01016 BB_DOHEAD,
01017 BB_DOTAIL,
01018 BB_IO,
01019 BB_WHILEEND,
01020 BB_REGIONSTART,
01021 BB_REGIONEXIT,
01022 BB_REPEATBODY,
01023 BB_REPEATEND,
01024 BB_SUMMARY
01025 };
01026 #endif // opt_bb_INCLUDED
01027
01028 #if defined(opt_bb_CXX) && !defined(BB_kind_name_DEFINED)
01029 #define BB_kind_name_DEFINED "BB_kind_name"
01030 static const char *BB_kind_name[] = {
01031 "UNKNOWN",
01032 "GOTO",
01033 "LOGIF",
01034 "VARGOTO",
01035 "ENTRY",
01036 "EXIT",
01037 "DOSTART",
01038 "DOEND",
01039 "DOSTEP",
01040 "DOHEAD",
01041 "DOTAIL",
01042 "IO",
01043 "WHILEEND",
01044 "REGIONSTART",
01045 "REGIONEXIT",
01046 "REPEATBODY",
01047 "REPEATEND",
01048 "SUMMARY"
01049 };
01050 #endif // opt_bb_CXX
01051
01052 #ifndef opt_bb_INCLUDED
01053 #define opt_bb_INCLUDED "opt_bb.h"
01054 class BB_NODE : public CHAIN_NODE {
01055 DECLARE_CHAIN_NODE_CLASS( BB_NODE )
01056 private:
01057 IDTYPE _id;
01058
01059 INT _loopdepth;
01060 mUINT16 _rid_id;
01061 BB_FLAG _flags;
01062 BB_KIND _kind;
01063 BB_LIST *_pred;
01064 BB_LIST *_succ;
01065 BB_NODE *_idom;
01066 BB_NODE *_ipdom;
01067 BB_LIST *_dom_bbs;
01068 BB_LIST *_pdom_bbs;
01069 IDTYPE _dom_dfs_id;
01070 IDTYPE _dom_dfs_last;
01071 IDTYPE _pdom_dfs_id;
01072 IDTYPE _pdom_dfs_last;
01073 BB_NODE_SET *_dom_frontier;
01074 BB_NODE_SET *_rcfg_dom_frontier;
01075
01076 struct {
01077 mINT32 _labnam;
01078 WN *_lab_loop_info;
01079 } _labels;
01080 WN *_firststmt;
01081 WN *_laststmt;
01082 STMT_LIST _stmtlist;
01083 BB_LOOP *_innermost;
01084 BB_LOOP *_loop;
01085 union {
01086 BB_IFINFO *_ifinfo;
01087 BB_SWITCH *_switchinfo;
01088 BB_SWITCH *_ioinfo;
01089 WN *_entrywn;
01090 BB_REGION *_regioninfo;
01091
01092
01093 } _hi;
01094
01095 PHI_LIST *_phi_list;
01096 EXP_PHI_LIST
01097 *_iphi_list;
01098
01099 SRCPOS _linenum;
01100 UINT32 _freq;
01101
01102 union {
01103 IDTYPE _rpo_id;
01104 } _u0;
01105
01106
01107 union {
01108 IDX_32_SET *_loc_appear;
01109 } _u1;
01110 union {
01111 IDX_32_SET *_loc_def;
01112 } _u2;
01113 union {
01114 EXP_PHI *_exp_phi;
01115 IDX_32_SET *_loc_upwd;
01116 } _u3;
01117 union {
01118 IDX_32_SET *_defreach;
01119 } _u4;
01120 union {
01121 IDX_32_SET *_live_at_exit;
01122 } _u5;
01123 union {
01124 IDX_32_SET *_live_out;
01125 } _u6;
01126 union {
01127 IDX_32_SET *_loc_mu_ref;
01128 } _u7;
01129 union {
01130 IDX_32_SET *_loc_chi_def;
01131 } _u8;
01132 union {
01133 WN *_loc_mu_wn;
01134 } _u9;
01135 union {
01136 RVI_ANN_LIST *_rvi_anns;
01137 } _u10;
01138 union {
01139 IDX_32 _last_stid_bitpos;
01140 } _u11;
01141 union {
01142 BOOL _last_stid_has_chi;
01143 } _u12;
01144 union {
01145 IDX_32_SET *_unstored_defs;
01146 } _u13;
01147
01148 BB_NODE& operator = (const BB_NODE&);
01149
01150
01151 public:
01152 void Clear(void);
01153
01154 BB_NODE(void) { Clear(); }
01155 BB_NODE(IDTYPE i) { Clear(); _id = i; }
01156 BB_NODE(const BB_NODE&);
01157
01158 ~BB_NODE(void) {}
01159
01160 void Print(FILE *fp=stderr) const;
01161 void PrintVis(void) const;
01162 void Print_wn(FILE *fp=stderr) const;
01163 void Print_ssa(FILE *fp=stderr) const;
01164 void Print_head(FILE *fp=stderr)
01165 const;
01166 void Print_locattr(FILE
01167 *fp=stderr);
01168 void Validate(FILE *fp = stderr)
01169 const;
01170 void Gen_wn(EMITTER *);
01171
01172 void Gen_insertions(MAIN_EMITTER *);
01173 WN *Find_outermost_loopstmt
01174 (CODEREP *cr) const;
01175
01176
01177
01178
01179 void Append_pred(BB_NODE *bb,
01180 MEM_POOL *pool) { _pred = _pred->Append(bb,pool); }
01181 void Append_succ(BB_NODE *bb,
01182 MEM_POOL *pool) { _succ = _succ->Append(bb,pool); }
01183 void Remove_pred(BB_NODE *bb, MEM_POOL *pool)
01184 { if (_pred != NULL)
01185 _pred = _pred->Remove(bb,pool);
01186 }
01187 void Remove_succ(BB_NODE *bb, MEM_POOL *pool)
01188 { if (_succ != NULL)
01189 _succ = _succ->Remove(bb,pool);
01190 }
01191 void Replace_pred( BB_NODE *old_pred, BB_NODE *new_pred );
01192 void Replace_succ( BB_NODE *old_succ, BB_NODE *new_succ );
01193
01194 void Connect_wn(WN *wn)
01195 { STMT_CONTAINER stmt_cont(Firststmt(), Laststmt());
01196 stmt_cont.Append(wn);
01197 }
01198
01199
01200 CODEREP *Find_cr(const CODEREP *cr);
01201
01202 CODEREP *Find_def(const CODEREP *cr);
01203
01204
01205 CODEREP *Find_def_by_auxid(const CODEREP *cr);
01206
01207
01208
01209 void Insert_wn_after( WN *wn, WN *after_this );
01210
01211
01212 void Insert_wn_before( WN *wn, WN *before_this );
01213
01214 void Append_wn_before_branch(WN *wn);
01215
01216 void Prepend_wn_after_labels(WN *wn);
01217
01218 void Connect_wn_list(WN *wn_f, WN *wn_l)
01219 { STMT_CONTAINER stmt_cont(Firststmt(), Laststmt());
01220 stmt_cont.Append_list(wn_f, wn_l);
01221 }
01222
01223 void Add_pragma(WN *wn, STMTREP *stmt, MEM_POOL *pool);
01224 BOOL Is_first(void) const {return Prev() == NULL;}
01225 BOOL Is_last(void) const {return Next() == NULL;}
01226
01227 WN *Get_do_start(void) const;
01228 WN *Get_do_end(void) const;
01229 WN *Get_do_step(void) const;
01230
01231
01232 IDTYPE Id(void) const { return _id;}
01233 void Set_id(IDTYPE i ) { _id = i;}
01234 IDTYPE Rpo_id(void) const { return _u0._rpo_id; }
01235 void Set_rpo_id(IDTYPE id) { _u0._rpo_id = id; }
01236 mUINT8 Loopdepth(void) const { return _loopdepth;}
01237 void Set_loopdepth(mUINT8 dep){ _loopdepth = dep;}
01238 mUINT16 Rid_id(void) const { return _rid_id;}
01239 void Set_rid_id(mUINT16 id) { _rid_id = id;}
01240 BB_FLAG Flag(void) const { return _flags; }
01241 BOOL Willexit(void) const { return (_flags & BB_WILLEXIT);}
01242 void Set_willexit(void) { _flags=(BB_FLAG)(_flags|BB_WILLEXIT);}
01243 void Reset_willexit(void) { _flags=(BB_FLAG)(_flags&~BB_WILLEXIT);}
01244 void Reset_visit(void) { _flags=(BB_FLAG)(_flags&~BB_VISIT);}
01245 void Set_flag(INT32 f) { _flags=(BB_FLAG)(_flags|f);}
01246 BOOL Wngend(void) const { return (_flags & BB_WNGEND);}
01247 void Set_wngend(void) { _flags=(BB_FLAG)(_flags|BB_WNGEND);}
01248 void Reset_wngend(void) { _flags=(BB_FLAG)(_flags&~BB_WNGEND);}
01249 BOOL Reached(void) const { return (_flags & BB_REACHED);}
01250 void Set_reached(void ) { _flags=(BB_FLAG)(_flags|BB_REACHED);}
01251 void Reset_reached(void ) { _flags=(BB_FLAG)(_flags&~BB_REACHED);}
01252 BOOL Dforder(void) const { return (_flags & BB_DFORDER);}
01253 void Set_dforder(void ) { _flags=(BB_FLAG)(_flags|BB_DFORDER);}
01254 void Reset_dforder(void ) { _flags=(BB_FLAG)(_flags&~BB_DFORDER);}
01255 BOOL Hasujp(void) const { return (_flags & BB_HASUJP);}
01256 void Set_hasujp(void) { _flags=(BB_FLAG)(_flags|BB_HASUJP);}
01257 void Reset_hasujp(void) { _flags=(BB_FLAG)(_flags&~BB_HASUJP);}
01258 void Set_ifmerge(void) { _flags=(BB_FLAG)(_flags|BB_IFMERGE);}
01259 void Reset_ifmerge(void) { _flags=(BB_FLAG)(_flags&~BB_IFMERGE);}
01260 BOOL Ifmerge(void) const { return (_flags & BB_IFMERGE); }
01261 BOOL Haspragma(void) const { return (_flags & BB_HASPRAGMA);}
01262 void Set_haspragma(void) { _flags=(BB_FLAG)(_flags|BB_HASPRAGMA);}
01263 void Reset_haspragma(void) { _flags=(BB_FLAG)(_flags&~BB_HASPRAGMA);}
01264 BOOL Hascall(void) const { return (_flags & BB_HASCALL);}
01265 void Set_hascall(void) { _flags=(BB_FLAG)(_flags|BB_HASCALL);}
01266 void Reset_hascall(void) { _flags=(BB_FLAG)(_flags&~BB_HASCALL);}
01267 BOOL VN_processed(void)const { return (_flags & BB_VN_PROCESSED);}
01268 void Set_vn_processed(void) { _flags=(BB_FLAG)(_flags|BB_VN_PROCESSED);}
01269 BOOL MP_region(void) const { return (_flags & BB_MP_REGION);}
01270 void Set_MP_region(void) { _flags=(BB_FLAG)(_flags|BB_MP_REGION);}
01271 void Reset_MP_region(void) { _flags=(BB_FLAG)(_flags&~BB_MP_REGION);}
01272 #if defined(TARG_SL) //PARA_EXTENSION
01273 BOOL SL2_para_region(void) const { return (_flags & BB_SL2_PARA_REGION);}
01274 void Set_SL2_para_region(void) { _flags=(BB_FLAG)(_flags|BB_SL2_PARA_REGION);}
01275 void Reset_SL2_para_region(void) { _flags=(BB_FLAG)(_flags&~BB_SL2_PARA_REGION);}
01276 BOOL Parallel_Region(void) { return (SL2_para_region() || MP_region()); }
01277 #else
01278 BOOL Parallel_Region(void) { return MP_region(); }
01279 #endif
01280 BOOL TLBS_processing(void) const { return (_flags & BB_TLBS_PROCESSING);}
01281 void Set_TLBS_processing(void) { _flags=(BB_FLAG)(_flags|BB_TLBS_PROCESSING);}
01282 void Reset_TLBS_processing(void) { _flags=(BB_FLAG)(_flags&~BB_TLBS_PROCESSING);}
01283 BOOL Callrel(void) const { return (_flags & BB_CALLREL);}
01284 void Set_callrel(void) { _flags=(BB_FLAG)(_flags|BB_CALLREL);}
01285 void Reset_callrel(void) { _flags=(BB_FLAG)(_flags&~BB_CALLREL);}
01286 BOOL Regionend(void) const { return (_flags & BB_REGIONEND);}
01287 void Set_regionend(void) { _flags=(BB_FLAG)(_flags|BB_REGIONEND);}
01288 void Reset_regionend(void) { _flags=(BB_FLAG)(_flags&~BB_REGIONEND);}
01289
01290 BB_KIND Kind(void) const { return _kind;}
01291 void Set_kind(BB_KIND k) { _kind = k; }
01292
01293 const char *Kind_name(void) const;
01294 BB_LIST *Pred(void) const { return _pred;}
01295 void Set_pred(BB_LIST *bblst) { _pred = bblst;}
01296 BB_NODE *Nth_pred(INT32) const;
01297 BB_NODE *Nth_succ(INT32) const;
01298 BB_LIST *Succ(void) const { return _succ;}
01299 void Set_succ(BB_LIST *bblst) { _succ = bblst;}
01300
01301
01302 BB_NODE *Idom(void) const { return _idom; }
01303 void Set_idom(BB_NODE *domin) { _idom = domin; }
01304 BB_NODE *Ipdom(void) const { return _ipdom; }
01305 void Set_ipdom(BB_NODE *pdomin){ _ipdom = pdomin; }
01306 BB_LIST *Dom_bbs(void) const { return _dom_bbs; }
01307 void Set_dom_bbs(BB_LIST *bblst){ _dom_bbs = bblst; }
01308 void Add_dom_bbs(BB_NODE *bb,
01309 MEM_POOL *p) { _dom_bbs = _dom_bbs->Append(bb,p); }
01310 BB_LIST *Pdom_bbs(void) const { return _pdom_bbs; }
01311 void Set_pdom_bbs
01312 (BB_LIST *bblst){ _pdom_bbs = bblst; }
01313 void Add_pdom_bbs(BB_NODE *bb,
01314 MEM_POOL *p){ _pdom_bbs = _pdom_bbs->Append(bb,p);}
01315 IDTYPE Dom_dfs_id(void) const { return _dom_dfs_id; }
01316 IDTYPE Dom_dfs_last(void) const { return _dom_dfs_last; }
01317 void Set_dom_dfs_id(IDTYPE id) { _dom_dfs_id = id; }
01318 void Set_dom_dfs_last(IDTYPE id) { _dom_dfs_last = id; }
01319 IDTYPE Pdom_dfs_id(void) const { return _pdom_dfs_id; }
01320 IDTYPE Pdom_dfs_last(void) const { return _pdom_dfs_last; }
01321 void Set_pdom_dfs_id(IDTYPE id) { _pdom_dfs_id = id; }
01322 void Set_pdom_dfs_last(IDTYPE id) { _pdom_dfs_last = id; }
01323 mUINT32 Dom_descendant_cnt(void) const
01324 { return _dom_dfs_last - _dom_dfs_id; }
01325 mUINT32 Pdom_descendant_cnt(void) const
01326 { return _pdom_dfs_last - _pdom_dfs_id; }
01327
01328 BOOL Dominates_strictly( const BB_NODE *bb ) const {
01329 Is_True(bb != NULL, ("BB_NODE::Dominates_strictly(BB%u, NULL)", Id()));
01330 return ( bb->Dom_dfs_id() > Dom_dfs_id() &&
01331 bb->Dom_dfs_id() <= Dom_dfs_last() ); }
01332
01333 BOOL Postdominates_strictly( const BB_NODE *bb ) const {
01334 Is_True(bb != NULL, ("BB_NODE::Postdominates_strictly(BB%u, NULL)", Id()));
01335 return ( bb->Pdom_dfs_id() > Pdom_dfs_id() &&
01336 bb->Pdom_dfs_id() <= Pdom_dfs_last() ); }
01337
01338 BOOL Dominates( const BB_NODE *bb ) const {
01339 Is_True(bb != NULL, ("BB_NODE::Dominates(BB%u, NULL)", Id()));
01340 return ( bb->Dom_dfs_id() >= Dom_dfs_id() &&
01341 bb->Dom_dfs_id() <= Dom_dfs_last() ); }
01342
01343 BOOL Postdominates( const BB_NODE *bb ) const {
01344 Is_True(bb != NULL, ("BB_NODE::Postdominates(BB%u, NULL)", Id()));
01345 return ( bb->Pdom_dfs_id() >= Pdom_dfs_id() &&
01346 bb->Pdom_dfs_id() <= Pdom_dfs_last() ); }
01347
01348
01349 const BB_NODE *Falls_thru_to(void) const;
01350
01351 BB_NODE_SET *Dom_frontier(void)const { return _dom_frontier; }
01352 void Set_dom_frontier
01353 (BB_NODE_SET *b) { _dom_frontier = b; }
01354 BB_NODE_SET *Rcfg_dom_frontier
01355 (void) const { return _rcfg_dom_frontier; }
01356 void Set_rcfg_dom_frontier
01357 (BB_NODE_SET *b) { _rcfg_dom_frontier = b; }
01358 void Compute_rcfg_itrdom_frontier( BB_NODE_SET *itrcd) const;
01359
01360 INT32 Labnam(void) const { return _labels._labnam;}
01361 void Set_labnam(mUINT32 l ) { _labels._labnam = l;}
01362 WN *Label_loop_info(void) const
01363 { return _labels._lab_loop_info; }
01364 void Set_label_loop_info(WN *li)
01365 { _labels._lab_loop_info = li; }
01366
01367 SRCPOS Linenum(void) const { return _linenum; }
01368 void Set_linenum(SRCPOS ln) { _linenum = ln; }
01369 UINT32 Freq(void) const { return _freq; }
01370 void Set_freq(UINT32 n) { _freq = n; }
01371
01372
01373 EXP_PHI *Exp_phi(void) const { return _u3._exp_phi; }
01374 void Set_exp_phi(EXP_PHI *ep) { _u3._exp_phi = ep; }
01375
01376
01377
01378
01379
01380 IDX_32_SET *Loc_appear(void) const { return _u1._loc_appear; }
01381 IDX_32_SET *Loc_def(void) const { return _u2._loc_def; }
01382 IDX_32_SET *Loc_upwd(void) const { return _u3._loc_upwd; }
01383
01384 IDX_32_SET *Defreach(void) const { return _u4._defreach; }
01385 IDX_32_SET *Live_at_exit(void) const { return _u5._live_at_exit; }
01386 IDX_32_SET *Live_out(void) const { return _u6._live_out; }
01387 IDX_32_SET *Loc_mu_ref(void) const { return _u7._loc_mu_ref; }
01388 IDX_32_SET *Loc_chi_def(void) const { return _u8._loc_chi_def; }
01389 WN *Loc_mu_wn(void) const { return _u9._loc_mu_wn; }
01390 RVI_ANN_LIST *Rvi_anns(void) const { return _u10._rvi_anns; }
01391 IDX_32 Last_stid_bitpos(void) const { return _u11._last_stid_bitpos;}
01392 BOOL Last_stid_has_chi(void) const { return _u12._last_stid_has_chi;}
01393 IDX_32_SET *Unstored_defs(void) const { return _u13._unstored_defs;}
01394
01395
01396 void Set_loc_appear(IDX_32_SET *set) { _u1._loc_appear = set; }
01397 void Set_loc_def(IDX_32_SET *set) { _u2._loc_def = set; }
01398 void Set_loc_upwd(IDX_32_SET *set) { _u3._loc_upwd = set; }
01399 void Set_defreach(IDX_32_SET *set) { _u4._defreach = set; }
01400 void Set_live_at_exit(IDX_32_SET *set){ _u5._live_at_exit = set; }
01401 void Set_live_out(IDX_32_SET *set) { _u6._live_out = set; }
01402 void Set_loc_mu_ref(IDX_32_SET *set) { _u7._loc_mu_ref = set; }
01403 void Set_loc_chi_def(IDX_32_SET *set) { _u8._loc_chi_def = set; }
01404 void Set_loc_mu_wn(WN *mwn) { _u9._loc_mu_wn = mwn; }
01405 void Set_rvi_anns(RVI_ANN_LIST *ral) { _u10._rvi_anns = ral; }
01406 void Set_last_stid_bitpos(IDX_32 i) { _u11._last_stid_bitpos = i;}
01407 void Set_last_stid_has_chi(BOOL b) { _u12._last_stid_has_chi = b;}
01408 void Set_unstored_defs(IDX_32_SET *s) { _u13._unstored_defs = s;}
01409
01410
01411
01412 void Set_subinsert ( CODEREP *cr );
01413 void Reset_subdelete( CODEREP *cr );
01414
01415 WN *Firststmt(void) const { return _firststmt;}
01416 void Set_firststmt(WN *stmt) { _firststmt = stmt; }
01417 WN *Laststmt(void) const { return _laststmt;}
01418 void Set_laststmt(WN *stmt) { _laststmt = stmt; }
01419 void Insert_last(WN *);
01420
01421 void Init_stmt(WN *stmt) { _firststmt = _laststmt = stmt; }
01422
01423 WN *Branch_wn(void) const;
01424
01425 WN *Label_wn(void) const;
01426 BB_LOOP *Innermost(void) const { return _innermost; }
01427 void Set_innermost(BB_LOOP *i){ _innermost = i; }
01428 WN *Entrywn(void) const { Is_True(Kind() == BB_ENTRY,
01429 ("BB is not entry_BB"));
01430 return _hi._entrywn; }
01431 void Set_entrywn(WN *wn) { _hi._entrywn = wn; }
01432 BB_LOOP *Loop(void) const { return _loop;}
01433 void Set_loop(BB_LOOP *li) { _loop = li; }
01434 void Print_loop(BB_LOOP *l);
01435 WN *Loopindex(void) const { Is_True(Kind() != BB_LOGIF,
01436 ("Illegal use of loop"));
01437 return (_loop)?
01438 _loop->Index() : NULL; }
01439 WN *Loopstmt(void) const { Is_True(Kind() != BB_LOGIF,
01440 ("Illegal use of loop"));
01441 return (_loop)?
01442 _loop->Loopstmt() : NULL; }
01443 void Set_loopstmt(WN *loop) { Is_True(Kind() != BB_LOGIF,
01444 ("Illegal use of loop"));
01445 _loop->Set_loopstmt(loop); }
01446 BB_NODE_SET *Loopbodyset(void) const { Is_True(Kind() != BB_LOGIF,
01447 ("Illegal use of loop"));
01448 return (_loop)?
01449 _loop->Body_set() : NULL; }
01450 void Set_loopbodyset
01451 (BB_NODE_SET *s) { Is_True(Kind() != BB_LOGIF,
01452 ("Illegal use of loop"));
01453 if (_loop)
01454 _loop->Set_body_set(s); }
01455 BB_NODE *Loopstart(void) const { Is_True(Kind() != BB_LOGIF,
01456 ("Illegal use of loop"));
01457 return (_loop)?
01458 _loop->Start() : NULL; }
01459 BB_NODE *Loophead(void) const { Is_True(Kind() != BB_LOGIF,
01460 ("Illegal use of loop"));
01461 return (_loop)?
01462 _loop->Dohead() : NULL; }
01463 BB_NODE *Loopend(void) const { Is_True(Kind() != BB_LOGIF,
01464 ("Illegal use of loop"));
01465 return (_loop)?
01466 _loop->End() : NULL; }
01467 BB_NODE *Loopbody(void) const { Is_True(Kind() != BB_LOGIF,
01468 ("Illegal use of loop"));
01469 return (_loop)?
01470 _loop->Body() : NULL; }
01471 BB_NODE *Loopstep(void) const { Is_True(Kind() != BB_LOGIF,
01472 ("Illegal use of loop"));
01473 return (_loop)?
01474 _loop->Step() : NULL; }
01475 BB_NODE *Loopmerge(void) const { Is_True(Kind() != BB_LOGIF,
01476 ("Illegal use of loop"));
01477 return (_loop)?
01478 _loop->Merge() : NULL; }
01479 BB_NODE *Looptail(void) const { Is_True(Kind() != BB_LOGIF,
01480 ("Illegal use of loop"));
01481 return (_loop)?
01482 _loop->Dotail() : NULL; }
01483 BB_IFINFO *Ifinfo(void) const { Is_True(Kind() == BB_LOGIF || Ifmerge(),
01484 ("Illegal use of ifinfo"));
01485 return _hi._ifinfo;}
01486 void Set_ifinfo(BB_IFINFO
01487 *ii) { Is_True((Kind() == BB_LOGIF) || Ifmerge(),
01488 ("Illegal use of ifinfo"));
01489 _hi._ifinfo = ii; }
01490 SRCPOS Then_loc(void) const { Is_True(Kind() == BB_LOGIF,
01491 ("Illegal use of ifinfo"));
01492 return (_hi._ifinfo)?
01493 _hi._ifinfo->Thenloc() : 0; }
01494 SRCPOS Else_loc(void) const { Is_True(Kind() == BB_LOGIF,
01495 ("Illegal use of ifinfo"));
01496 return (_hi._ifinfo)?
01497 _hi._ifinfo->Elseloc() : 0; }
01498 BB_NODE *If_cond(void) const { Is_True(Kind() == BB_LOGIF || Ifmerge(),
01499 ("Illegal use of ifinfo"));
01500 return (_hi._ifinfo)?
01501 _hi._ifinfo->Cond() : NULL; }
01502 BB_NODE *If_then(void) const { Is_True(Kind() == BB_LOGIF,
01503 ("Illegal use of ifinfo"));
01504 return (_hi._ifinfo)?
01505 _hi._ifinfo->Then() : NULL; }
01506 BB_NODE *If_else(void) const { Is_True(Kind() == BB_LOGIF,
01507 ("Illegal use of ifinfo"));
01508 return (_hi._ifinfo)?
01509 _hi._ifinfo->Else() : NULL; }
01510 BB_NODE *If_merge(void) const { Is_True(Kind() == BB_LOGIF,
01511 ("Illegal use of ifinfo"));
01512 return (_hi._ifinfo)?
01513 _hi._ifinfo->Merge() : NULL; }
01514
01515 BB_SWITCH *Switchinfo(void) const { Is_True(Kind() == BB_VARGOTO,
01516 ("Illegal use of switchinfo"));
01517 return _hi._switchinfo;}
01518 void Set_switchinfo
01519 (BB_SWITCH *si) { Is_True(Kind() == BB_VARGOTO,
01520 ("Illegal use of switchinfo"));
01521 _hi._switchinfo = si;}
01522 BB_NODE *Switchcase
01523 (INT32 case_elt) const { Is_True(Kind() == BB_VARGOTO,
01524 ("Illegal use of switchinfo"));
01525 return
01526 _hi._switchinfo->_case_blks[case_elt];}
01527 void Set_switchcase
01528 (BB_NODE *bb,
01529 INT32 case_elt ) { _hi._switchinfo->_case_blks[case_elt]
01530 = bb; }
01531 BB_NODE *Switchdefault(void) const{ return _hi._switchinfo->_def_blk; }
01532 void Set_switchdefault
01533 ( BB_NODE *default_bb ){ _hi._switchinfo->_def_blk=default_bb; }
01534 INT32 Switchentries(void) const{ return _hi._switchinfo->_num_entries; }
01535
01536 BB_SWITCH *IOinfo(void) const
01537 { Is_True(Kind() == BB_IO,
01538 ("Illegal use of IOinfo"));
01539 return _hi._ioinfo;
01540 }
01541 void Set_ioinfo (BB_SWITCH *ioi)
01542 { Is_True(Kind() == BB_IO,
01543 ("Illegal use of IOinfo"));
01544 _hi._ioinfo = ioi;
01545 }
01546 BB_NODE *IO_bb (INT32 i) const
01547 { Is_True(Kind() == BB_IO,
01548 ("Illegal use of IOinfo"));
01549 return _hi._ioinfo->_case_blks[i];}
01550 void Set_io_bb (BB_NODE *bb, INT32 i )
01551 { Is_True( i < IO_TAB_SIZE, ("Too many BBs") );
01552 _hi._ioinfo->_case_blks[i] = bb;
01553 }
01554 void Set_io_entries( INT32 num_entries )
01555 { Is_True( num_entries <= IO_TAB_SIZE,
01556 ("Too many IO control statements") );
01557 _hi._ioinfo->_num_entries = num_entries;
01558 }
01559 INT32 IO_entries(void) const
01560 { return _hi._ioinfo->_num_entries; }
01561
01562
01563
01564
01565 BB_REGION *Regioninfo(void) const
01566 { Is_True(Kind() == BB_REGIONSTART ||
01567 Kind() == BB_REGIONEXIT ||
01568 Kind() == BB_EXIT,
01569 ("Illegal use of Regioninfo, %s",Kind_name()) );
01570 return _hi._regioninfo;
01571 }
01572 void Set_regioninfo(BB_REGION *region)
01573 { Is_True(Kind() == BB_REGIONSTART ||
01574 Kind() == BB_REGIONEXIT ||
01575 Kind() == BB_EXIT,
01576 ("Illegal use of Regioninfo, %s",Kind_name()) );
01577 _hi._regioninfo = region;
01578 }
01579
01580
01581
01582
01583
01584 const STMT_LIST *Stmtlist(void) const { return &_stmtlist; }
01585 STMT_LIST *Stmtlist(void) { return &_stmtlist; }
01586 const STMTREP *First_stmtrep(void) const { return Stmtlist()->Head(); }
01587 STMTREP *First_stmtrep(void) { return Stmtlist()->Head(); }
01588 const STMTREP *Last_stmtrep(void) const { return Stmtlist()->Tail(); }
01589 STMTREP *Last_stmtrep(void) { return Stmtlist()->Tail(); }
01590
01591 STMTREP *Add_stmtnode(WN*,
01592 MEM_POOL*);
01593
01594 void Append_stmtrep(STMTREP*);
01595
01596
01597 void Prepend_stmtrep
01598 (STMTREP *s);
01599
01600
01601 void Remove_stmtrep(STMTREP*);
01602
01603 void Append_stmt_before_branch(STMTREP *stmt);
01604
01605 STMTREP *Branch_stmtrep(void);
01606
01607
01608 STMTREP *Label_stmtrep(void);
01609
01610
01611 void Add_label(CFG *cfg);
01612 void Remove_label_stmtrep();
01613 void Add_label_stmtrep
01614 (MEM_POOL *pool);
01615
01616
01617 PHI_LIST *Phi_list(void) const { return _phi_list; }
01618 void Set_phi_list(PHI_LIST *p){ _phi_list = p; }
01619 void Remove_phi_reference( INT32 whichpred );
01620
01621 EXP_PHI_LIST
01622 *Iphi_list(void) const { return _iphi_list; }
01623 void Set_iphi_list(EXP_PHI_LIST *i)
01624 { _iphi_list = i; }
01625
01626 void Insert_tree(CODEREP *);
01627
01628 void Insert_stmtrep_before(STMTREP *, STMTREP *);
01629 void Insert_stmtrep_after(STMTREP *, STMTREP *);
01630 BOOL Update_freq_from_WN(const WN*);
01631 void Set_next(BB_NODE *bb) { Set_Next(bb); }
01632 void Set_prev(BB_NODE *bb) { Set_Prev(bb); }
01633 BOOL Is_empty();
01634
01635
01636 BOOL Clonable(BOOL allow_loop_cloning,
01637 const BVECTOR *cr_vol_map = NULL);
01638 INT32 Code_size_est(void) const;
01639 #if defined(TARG_SL)
01640
01641
01642 BOOL Preds_or_succs_from_different_region(BOOL is_pred = TRUE);
01643 #endif
01644 };
01645
01646
01647
01648
01649
01650 class BB_REGION {
01651 friend class BB_NODE;
01652
01653 private:
01654 BB_NODE *_region_start;
01655 BB_NODE *_region_end;
01656 RID *_rid;
01657 BB_REGION *_parent;
01658 WN *_region_exits;
01659 WN *_region_pragmas;
01660 WN *_orig_wn;
01661 INT32 _region_num_exits;
01662 INT64 _region_line_num;
01663 INITO_IDX _ereg_supp;
01664
01665
01666 BB_REGION(void);
01667 BB_REGION(const BB_REGION&);
01668 BB_REGION& operator = (const BB_REGION&);
01669
01670 public:
01671 BB_REGION(BB_NODE *region_start, BB_NODE *region_end, RID *rid,
01672 BB_REGION *parent, WN *pragmas, WN *exits,
01673 INITO_IDX ereg_supp, INT64 linenum, WN *orig_wn) :
01674 _region_start(region_start),
01675 _region_end(region_end),
01676 _rid(rid),
01677 _parent(parent),
01678 _ereg_supp(ereg_supp),
01679 _region_line_num(linenum),
01680 _orig_wn(orig_wn)
01681 {
01682 _region_num_exits = RID_num_exits(_rid);
01683
01684
01685
01686 _region_pragmas = WN_COPY_Tree_With_Map(pragmas);
01687 _region_exits = WN_COPY_Tree_With_Map(exits);
01688
01689 if (_region_end != NULL)
01690 _region_end->Set_regionend();
01691 }
01692
01693 BB_NODE *Region_start(void) const { return _region_start; }
01694 void Set_region_start(BB_NODE *region_start) { _region_start= region_start;}
01695 BB_NODE *Region_end(void) const { return _region_end; }
01696 void Set_region_end(BB_NODE *region_end)
01697 {
01698 _region_end = region_end;
01699 if (_region_end != NULL)
01700 _region_end->Set_regionend();
01701 }
01702 RID *Rid(void) const { return _rid; }
01703 void Set_rid(RID *rid) { _rid = rid; }
01704 BB_REGION *Parent(void) const { return _parent; }
01705 void Set_parent(BB_REGION *parent) { _parent = parent; }
01706 INITO_IDX Ereg_supp(void) const { return _ereg_supp; }
01707 INT64 Region_line_num(void) const { return _region_line_num; }
01708
01709
01710 WN *Region_pragma_list(void) const { return _region_pragmas; }
01711 void Set_region_pragmas(WN *pragmas) { _region_pragmas = pragmas; }
01712 WN *Region_exit_list(void) const { return _region_exits; }
01713 INT32 Region_num_exits(void) const { return _region_num_exits; }
01714 void Set_region_num_exits(RID *rid)
01715 { Is_True(rid != NULL, ("BB_REGION::Set_region_num_exits, NULL RID"));
01716 _region_num_exits = RID_num_exits(rid);
01717 }
01718 WN *Orig_wn(void) const { return _orig_wn; }
01719 void Set_orig_wn(WN *wn) { _orig_wn = wn; }
01720
01721
01722
01723 void Find_first_last_stmt(BB_NODE *, BB_NODE *, WN **, WN **);
01724
01725 };
01726
01727 #endif // opt_bb_INCLUDED
01728 #endif // opt_bb_INCLUDED || opt_bb_CXX