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 #ifndef bb_INCLUDED
00428 #define bb_INCLUDED
00429
00430 #include <vector>
00431 #include "mempool_allocator.h"
00432
00433 #include "region_util.h"
00434 #include "symtab.h"
00435
00436 #include "srcpos.h"
00437 #include "annotations.h"
00438 #include "op.h"
00439 #include "bbregs.h"
00440
00441
00442 struct tn;
00443 struct bblist;
00444 class WN;
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454 typedef INT32 BB_NUM;
00455 typedef mINT32 mBB_NUM;
00456 #define BB_NUM_MAX INT32_MAX
00457
00458 typedef struct bb {
00459 struct bb *next;
00460 struct bb *prev;
00461 struct bblist *preds;
00462 struct bblist *succs;
00463 OPS ops;
00464 mBB_NUM id;
00465 #if defined(TARG_IA64)
00466 UINT64 flags;
00467 #else
00468 UINT32 flags;
00469 #endif
00470 UINT16 nest_level;
00471 mUINT16 next_op_map_idx;
00472 mUINT16 unrollings;
00473 float freq;
00474 struct bb *loop_head_bb;
00475 RID *rid;
00476 WN *branch_wn;
00477 struct bbregs *bbregs;
00478 struct annotation *annotations;
00479 #ifdef KEY
00480 struct bb *aux;
00481 #endif
00482 #if defined(TARG_IA64) || defined(TARG_SL) || defined(TARG_MIPS)
00483 INT bb_cycle;
00484 #if !defined(TARG_SL)
00485 mBB_NUM id_before_profile;
00486 #endif
00487 #endif
00488 } BB;
00489
00490 #ifndef CAN_USE_BB
00491 #define CAN_USE_BB(a) (a)
00492 #endif
00493
00494
00495
00496 #define BB_next(b) (CAN_USE_BB(b)->next)
00497 #define BB_prev(x) (CAN_USE_BB(x)->prev)
00498 #define BB_preds(x) (CAN_USE_BB(x)->preds)
00499 #define BB_succs(x) (CAN_USE_BB(x)->succs)
00500 #define BB_cycle(x) (CAN_USE_BB(x)->bb_cycle)
00501 #if 0
00502
00503
00504
00505
00506 #define BB_ops(x) (CAN_USE_BB(x)->ops)
00507 #endif
00508 #define BB_flag(b) (CAN_USE_BB(b)->flags)
00509 #define BB_nest_level(b) (CAN_USE_BB(b)->nest_level)
00510 #define BB_rid(b) (CAN_USE_BB(b)->rid)
00511 #define BB_next_op_map_idx(b) (CAN_USE_BB(b)->next_op_map_idx)
00512 #define BB_freq(x) (CAN_USE_BB(x)->freq)
00513 #define BB_branch_wn(x) (CAN_USE_BB(x)->branch_wn)
00514 #define BB_bbregs(x) (CAN_USE_BB(x)->bbregs)
00515 #define BB_annotations(x) (CAN_USE_BB(x)->annotations)
00516
00517
00518 #define BB_id(b) (CAN_USE_BB(b)->id+0)
00519 #if defined(TARG_IA64)
00520 #define BB_id_before_profile(b) (CAN_USE_BB(b)->id_before_profile+0)
00521 #endif
00522 #define BB_first_op(b) (CAN_USE_BB(b)->ops.first+0)
00523 #define BB_last_op(b) (CAN_USE_BB(b)->ops.last+0)
00524 #define BB_unrollings(b) (CAN_USE_BB(b)->unrollings+0)
00525 #define BB_loop_head_bb(b) (CAN_USE_BB(b)->loop_head_bb+0)
00526 #define BB_loophead(bb) (BB_loop_head_bb(bb) == (bb))
00527 #ifdef KEY
00528 #define BB_aux(b) (CAN_USE_BB(b)->aux)
00529 #endif
00530
00531 inline void Set_BB_unrollings(BB *bb, UINT16 u) {
00532 bb->unrollings = u;
00533 }
00534
00535 inline void Set_BB_loop_head_bb(BB *bb, BB *head) {
00536 bb->loop_head_bb = head;
00537 }
00538
00539 #define BBM_ENTRY 0x0001
00540 #define BBM_HANDLER 0x0002
00541 #define BBM_EXIT 0x0004
00542 #define BBM_CALL 0x0008
00543 #define BBM_LABEL 0x0010
00544 #define BBM_PRAGMA 0x0020
00545 #define BBM_NOTE 0x0040
00546 #define BBM_UNREACHABLE 0x0080
00547
00548 #define BBM_UNROLLED_FULLY 0x0100
00549 #define BBM_INNERMOST 0x0200
00550 #define BBM_SCHEDULED 0x0400
00551 #define BBM_REG_ALLOC 0x0800
00552 #define BBM_LOCAL_FLAG1 0x1000
00553 #define BBM_FREQ_FB 0x2000
00554 #define BBM_GRA_SPILL 0x4000
00555 #define BBM_SCHEDULED_HBS 0x8000
00556 #define BBM_ROTATING_KERNEL 0x10000
00557 #define BBM_MOD_ROTATING_REGISTERS 0x20000
00558 #define BBM_MOD_PRED_ROTATING_REGISTERS 0x40000
00559 #define BBM_ASM 0x00080000
00560 #define BBM_PREDICATE_PROMOTE 0x00100000
00561
00562 #define BBM_POST_LABEL 0x00200000
00563
00564
00565 #ifdef KEY
00566 #define BBM_NON_LOCAL_LABEL 0x00400000
00567 #endif
00568
00569 #if defined(TARG_IA64) || defined(TARG_SL) || defined(TARG_MIPS)
00570 #define BBM_EDGE_SPLITTING 0x00800000
00571
00572 #ifdef TARG_IA64
00573 #define BBM_RECOVERY 0x01000000
00574 #define BBM_CHK_SPLIT 0x02000000
00575 #define BBM_EMITTED 0x04000000
00576 #define BBM_PROFILE_SPLITTED 0x08000000
00577 #define BBM_PROFILE_CHANGED 0x10000000
00578 #define BBM_PROFILE_ADDED 0x20000000
00579 #define BBM_CHK_SPLIT_HEAD 0x40000000
00580 #define BBM_PARTIAL_BUNDLE 0x80000000
00581 #define BBM_CHK_SPLIT_TAIL 0x200000000 //bug fix for OSP_212
00582 #elif defined(TARG_SL)
00583 #define BBM_ZDL_PROLOG 0x01000000
00584 #define BBM_ZDL_BODY 0x02000000
00585 #define BBM_HAS_TAG 0x04000000
00586 #define BBM_SCHEDULED_SIZE 0x08000000
00587 #define BBM_FREQ_UNBALANCED 0x10000000
00588 #endif // TARG_SL
00589
00590 #define BB_edge_splitting(x) (BB_flag(x) & BBM_EDGE_SPLITTING)
00591 #define Set_BB_edge_splitting(x) (BB_flag(x) |= BBM_EDGE_SPLITTING)
00592 #define Reset_BB_edge_splitting(x) (BB_flag(x) &= ~BBM_EDGE_SPLITTING)
00593 #endif // TARG_IA64 || TARG_SL
00594
00595
00596 #if defined (TARG_SL)
00597
00598
00599
00600 #define BB_zdl_prolog(x) (BB_flag(x) & BBM_ZDL_PROLOG)
00601 #define Set_BB_zdl_prolog(x) (BB_flag(x) |= BBM_ZDL_PROLOG)
00602 #define Reset_BB_zdl_prolog(x) (BB_flag(x) &= ~BBM_ZDL_PROLOG)
00603
00604
00605
00606
00607 #define BB_zdl_body(x) (BB_flag(x) & BBM_ZDL_BODY)
00608 #define Set_BB_zdl_body(x) (BB_flag(x) |= BBM_ZDL_BODY)
00609 #define Reset_BB_zdl_body(x) (BB_flag(x) &= ~BBM_ZDL_BODY)
00610
00611 #define BB_has_tag(x) (BB_flag(x) & BBM_HAS_TAG)
00612 #define Set_BB_has_tag(x) (BB_flag(x) |= BBM_HAS_TAG)
00613 #define Reset_BB_has_tag(x) (BB_flag(x) &=~ BBM_HAS_TAG)
00614
00615 #define BB_SCHED_SIZE(x) (BB_flag(x) & BBM_SCHEDULED_SIZE)
00616 #define Set_BB_sched_size(x) (BB_flag(x) |= BBM_SCHEDULED_SIZE)
00617 #define Reset_BB_sched_size(x) (BB_flag(x) &= ~BBM_SCHEDULED_SIZE)
00618
00619 #define BB_freq_unbalanced(x) (BB_flag(x) & BBM_FREQ_UNBALANCED)
00620 #define Set_BB_freq_unbalanced(x) (BB_flag(x) |= BBM_FREQ_UNBALANCED)
00621 #define Reset_BB_freq_unbalanced(x) (BB_flag(x) &= ~BBM_FREQ_UNBALANCED)
00622 #endif // TARG_SL
00623
00624 #define BB_entry(x) (BB_flag(x) & BBM_ENTRY)
00625 #define BB_handler(bb) (BB_flag(bb) & BBM_HANDLER)
00626 #define BB_exit(x) (BB_flag(x) & BBM_EXIT)
00627 #define BB_call(x) (BB_flag(x) & BBM_CALL)
00628 #define BB_has_label(x) (BB_flag(x) & BBM_LABEL)
00629 #define BB_has_pragma(x) (BB_flag(x) & BBM_PRAGMA)
00630 #define BB_has_note(x) (BB_flag(x) & BBM_NOTE)
00631 #define BB_unreachable(x) (BB_flag(x) & BBM_UNREACHABLE)
00632 #define BB_unrolled_fully(x) (BB_flag(x) & BBM_UNROLLED_FULLY)
00633 #define BB_innermost(x) (BB_flag(x) & BBM_INNERMOST)
00634 #define BB_scheduled(bb) (BB_flag(bb) & BBM_SCHEDULED)
00635 #define BB_reg_alloc(bb) (BB_flag(bb) & BBM_REG_ALLOC)
00636 #define BB_local_flag1(bb) (BB_flag(bb) & BBM_LOCAL_FLAG1)
00637 #define BB_freq_fb_based(bb) (BB_flag(bb) & BBM_FREQ_FB)
00638 #define BB_gra_spill(bb) (BB_flag(bb) & BBM_GRA_SPILL)
00639 #define BB_scheduled_hbs(bb) (BB_flag(bb) & BBM_SCHEDULED_HBS)
00640 #define BB_rotating_kernel(bb) (BB_flag(bb) & BBM_ROTATING_KERNEL)
00641 #define BB_mod_rotating_registers(bb) (BB_flag(bb) & BBM_MOD_ROTATING_REGISTERS)
00642 #define BB_mod_pred_rotating_registers(bb) (BB_flag(bb) & BBM_MOD_PRED_ROTATING_REGISTERS)
00643 #define BB_asm(bb) (BB_flag(bb) & BBM_ASM)
00644 #define BB_predicate_promote(bb) (BB_flag(bb) & BBM_PREDICATE_PROMOTE)
00645 #define BB_has_post_label(x) (BB_flag(x) & BBM_POST_LABEL)
00646 #ifdef KEY
00647 #define BB_has_non_local_label(x) (BB_flag(x) & BBM_NON_LOCAL_LABEL)
00648 #endif
00649 #ifdef TARG_IA64
00650 #define BB_recovery(x) (BB_flag(x) & BBM_RECOVERY)
00651 #define BB_chk_split(x) (BB_flag(x) & BBM_CHK_SPLIT)
00652 #define BB_chk_split_head(x) (BB_flag(x) & BBM_CHK_SPLIT_HEAD)
00653 #define BB_emitted(x) (BB_flag(x) & BBM_EMITTED)
00654 #define BB_profile_splitted(x) (BB_flag(x) & BBM_PROFILE_SPLITTED)
00655 #define BB_profile_changed(x) (BB_flag(x) & BBM_PROFILE_CHANGED)
00656 #define BB_profile_added(x) (BB_flag(x) & BBM_PROFILE_ADDED)
00657 #define BB_partial_bundle(x) (BB_flag(x) & BBM_PARTIAL_BUNDLE)
00658 #define BB_chk_split_tail(x) (BB_flag(x) & BBM_CHK_SPLIT_TAIL)//bug fix for OSP_212
00659 #endif
00660
00661 #define Set_BB_entry(x) (BB_flag(x) |= BBM_ENTRY)
00662 #define Set_BB_handler(bb) (BB_flag(bb) |= BBM_HANDLER)
00663 #define Set_BB_exit(x) (BB_flag(x) |= BBM_EXIT)
00664 #define Set_BB_call(x) (BB_flag(x) |= BBM_CALL)
00665 #define Set_BB_has_label(x) (BB_flag(x) |= BBM_LABEL)
00666 #define Set_BB_has_pragma(x) (BB_flag(x) |= BBM_PRAGMA)
00667 #define Set_BB_has_note(x) (BB_flag(x) |= BBM_NOTE)
00668 #define Set_BB_unreachable(x) (BB_flag(x) |= BBM_UNREACHABLE)
00669 #define Set_BB_unrolled_fully(x)(BB_flag(x) |= BBM_UNROLLED_FULLY)
00670 #define Set_BB_innermost(x) (BB_flag(x) |= BBM_INNERMOST)
00671 #define Set_BB_scheduled(bb) (BB_flag(bb) |= BBM_SCHEDULED)
00672 #define Set_BB_reg_alloc(bb) (BB_flag(bb) |= BBM_REG_ALLOC)
00673 #define Set_BB_local_flag1(bb) (BB_flag(bb) |= BBM_LOCAL_FLAG1)
00674 #define Set_BB_freq_fb_based(bb)(BB_flag(bb) |= BBM_FREQ_FB)
00675 #define Set_BB_gra_spill(bb) (BB_flag(bb) |= BBM_GRA_SPILL)
00676 #define Set_BB_scheduled_hbs(bb)(BB_flag(bb) |= BBM_SCHEDULED_HBS)
00677 #define Set_BB_rotating_kernel(bb) (BB_flag(bb) |= BBM_ROTATING_KERNEL)
00678 #define Set_BB_mod_rotating_registers(bb) (BB_flag(bb) |= BBM_MOD_ROTATING_REGISTERS)
00679 #define Set_BB_mod_pred_rotating_registers(bb) (BB_flag(bb) |= BBM_MOD_PRED_ROTATING_REGISTERS)
00680 #define Set_BB_asm(bb) (BB_flag(bb) |= BBM_ASM)
00681 #define Set_BB_predicate_promote(bb) (BB_flag(bb) |= BBM_PREDICATE_PROMOTE)
00682 #define Set_BB_has_post_label(x) (BB_flag(x) |= BBM_POST_LABEL)
00683 #ifdef KEY
00684 #define Set_BB_has_non_local_label(x) (BB_flag(x) |= BBM_NON_LOCAL_LABEL)
00685 #endif
00686
00687 #ifdef TARG_IA64
00688 #define Set_BB_recovery(x) (BB_flag(x) |= BBM_RECOVERY)
00689 #define Set_BB_chk_split(x) (BB_flag(x) |= BBM_CHK_SPLIT)
00690 #define Set_BB_chk_split_head(x) (BB_flag(x) |= BBM_CHK_SPLIT_HEAD)
00691 #define Set_BB_emitted(x) (BB_flag(x) |= BBM_EMITTED)
00692 #define Set_BB_profile_splitted(x) (BB_flag(x) |= BBM_PROFILE_SPLITTED)
00693 #define Set_BB_profile_changed(x) (BB_flag(x) |= BBM_PROFILE_CHANGED)
00694 #define Set_BB_profile_added(x) (BB_flag(x) |= BBM_PROFILE_ADDED)
00695 #define Set_BB_partial_bundle(x) (BB_flag(x) |= BBM_PARTIAL_BUNDLE)
00696 #define Set_BB_chk_split_tail(x) (BB_flag(x) |= BBM_CHK_SPLIT_TAIL)//bug fix for OSP_212
00697 #endif
00698 #define Reset_BB_entry(x) (BB_flag(x) &= ~BBM_ENTRY)
00699 #define Reset_BB_handler(bb) (BB_flag(bb) &= ~BBM_HANDLER)
00700 #define Reset_BB_exit(x) (BB_flag(x) &= ~BBM_EXIT)
00701 #define Reset_BB_call(x) (BB_flag(x) &= ~BBM_CALL)
00702 #define Reset_BB_has_label(x) (BB_flag(x) &= ~BBM_LABEL)
00703 #define Reset_BB_has_pragma(x) (BB_flag(x) &= ~BBM_PRAGMA)
00704 #define Reset_BB_has_note(x) (BB_flag(x) &= ~BBM_NOTE)
00705 #define Reset_BB_unreachable(x) (BB_flag(x) &= ~BBM_UNREACHABLE)
00706 #define Reset_BB_unrolled_fully(x) (BB_flag(x) &= ~BBM_UNROLLED_FULLY)
00707 #define Reset_BB_innermost(x) (BB_flag(x) &= ~BBM_INNERMOST)
00708 #define Reset_BB_scheduled(bb) (BB_flag(bb) &= ~BBM_SCHEDULED)
00709 #define Reset_BB_reg_alloc(bb) (BB_flag(bb) &= ~BBM_REG_ALLOC)
00710 #define Reset_BB_local_flag1(bb) (BB_flag(bb) &= ~BBM_LOCAL_FLAG1)
00711 #define Reset_BB_freq_fb_based(bb) (BB_flag(bb) &= ~BBM_FREQ_FB)
00712 #define Reset_BB_gra_spill(bb) (BB_flag(bb) &= ~BBM_GRA_SPILL)
00713 #define Reset_BB_scheduled_hbs(bb) (BB_flag(bb) &= ~BBM_SCHEDULED_HBS)
00714 #define Reset_BB_rotating_kernel(bb) (BB_flag(bb) &= ~BBM_ROTATING_KERNEL)
00715 #define Reset_BB_mod_rotating_registers(bb) (BB_flag(bb) &= ~BBM_MOD_ROTATING_REGISTERS)
00716 #define Reset_BB_mod_pred_rotating_registers(bb) (BB_flag(bb) &= ~BBM_MOD_PRED_ROTATING_REGISTERS)
00717 #define Reset_BB_asm(bb) (BB_flag(bb) &= ~BBM_ASM)
00718 #define Reset_BB_predicate_promote(bb) (BB_flag(bb) &= ~BBM_PREDICATE_PROMOTE)
00719 #define Reset_BB_has_post_label(x) (BB_flag(x) &= ~BBM_POST_LABEL)
00720
00721 #ifdef TARG_IA64
00722 #define Reset_BB_recovery(x) (BB_flag(x) &= ~BBM_RECOVERY)
00723 #define Reset_BB_chk_split(x) (BB_flag(x) &= ~BBM_CHK_SPLIT)
00724 #define Reset_BB_chk_split_head(x) (BB_flag(x) &= ~BBM_CHK_SPLIT_HEAD)
00725 #define Reset_BB_emitted(x) (BB_flag(x) &= ~BBM_EMITTED)
00726 #define Reset_BB_profile_splitted(x) (BB_flag(x) &= ~BBM_PROFILE_SPLITTED)
00727 #define Reset_BB_profile_changed(x) (BB_flag(x) &= ~BBM_PROFILE_CHANGED)
00728 #define Resset_BB_profile_added(x) (BB_flag(x) &= ~BBM_PROFILE_ADDED)
00729 #define Reset_BB_partial_bundle(x) (BB_flag(x) &= ~BBM_PARTIAL_BUNDLE)
00730 #define Reset_BB_chk_split_tail(x) (BB_flag(x) &= ~BBM_CHK_SPLIT_TAIL)//bug fix for OSP_212
00731 #endif
00732 #ifdef KEY
00733 #define Reset_BB_has_non_local_label(x) (BB_flag(x) &= ~BBM_NON_LOCAL_LABEL)
00734 #endif
00735 #define BB_tail_call(bb) ( (BB_flag(bb) & (BBM_CALL | BBM_EXIT)) \
00736 == (BBM_CALL | BBM_EXIT))
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746 typedef enum {
00747 BBKIND_UNKNOWN,
00748 BBKIND_GOTO,
00749 BBKIND_LOGIF,
00750 BBKIND_VARGOTO,
00751 BBKIND_INDGOTO,
00752 BBKIND_RETURN,
00753 BBKIND_CALL,
00754 BBKIND_REGION_EXIT,
00755 BBKIND_TAIL_CALL,
00756 #ifdef TARG_IA64
00757 BBKIND_CHK,
00758 #endif
00759 #if defined(TARG_SL)
00760 BBKIND_ZDL_BODY,
00761 BBKIND_FORK,
00762 #endif
00763 BBKIND_LAST
00764 } BBKIND;
00765
00766 #define VALID_BBKIND(k) (k>=BBKIND_UNKNOWN && k<BBKIND_LAST)
00767
00768 extern const char *BBKIND_Name (BBKIND k);
00769 extern BBKIND BB_kind (BB *bb);
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788 #include "bb_list.h"
00789
00790 typedef struct bblist {
00791 BB *item;
00792 struct bblist *next;
00793 float prob;
00794 #if defined(TARG_IA64) || defined(TARG_SL) || defined(TARG_MIPS)
00795 float freq;
00796 #endif
00797 mUINT16 flags;
00798 } BBLIST;
00799
00800 #define BBLIST_item(b) ((b)->item)
00801 #define BBLIST_next(b) ((b)->next)
00802 #define BBLIST_prob(b) ((b)->prob)
00803 #define BBLIST_flags(b) ((b)->flags)
00804 #if defined(TARG_IA64) || defined(TARG_SL) || defined(TARG_MIPS)
00805 #define BBLIST_freq(b) ((b)->freq)
00806 #endif
00807
00808 #define BLM_PROB_FB 0x0001
00809 #define BLM_ON_TREE 0x0002
00810 #define BLM_PROB_HINT 0x0004
00811
00812 #define BBLIST_prob_hint_based(b) (BBLIST_flags(b) & BLM_PROB_HINT)
00813 #define Set_BBLIST_prob_hint_based(b) (BBLIST_flags(b) |= BLM_PROB_HINT)
00814 #define Reset_BBLIST_prob_hint_based(b) (BBLIST_flags(b) &= ~BLM_PROB_HINT)
00815
00816 #define BBLIST_prob_fb_based(b) (BBLIST_flags(b) & BLM_PROB_FB)
00817 #define Set_BBLIST_prob_fb_based(b) (BBLIST_flags(b) |= BLM_PROB_FB)
00818 #define Reset_BBLIST_prob_fb_based(b) (BBLIST_flags(b) &= ~BLM_PROB_FB)
00819
00820 #define BBLIST_on_tree(b) (BBLIST_flags(b) & BLM_ON_TREE)
00821 #define Set_BBLIST_on_tree(b) (BBLIST_flags(b) |= BLM_ON_TREE)
00822 #define Reset_BBLIST_on_tree(b) (BBLIST_flags(b) &= ~BLM_ON_TREE)
00823
00824
00825 #define FOR_ALL_BBLIST_ITEMS(list,item) \
00826 for (item = list; item != NULL; item = BBLIST_next(item))
00827
00828
00829 #define FOR_ALL_BB_STLLIST_ITEMS_FWD(list,item) \
00830 for (item = list.begin(); item != list.end(); item++)
00831
00832
00833 #define FOR_ALL_BB_STLLIST_ITEMS_BKWD(list,item) \
00834 for (item = list.rbegin(); item != list.rend(); item++)
00835
00836 #define FOR_ALL_BB_SUCCS(bb,succ) FOR_ALL_BBLIST_ITEMS(BB_succs(bb),succ)
00837 #define FOR_ALL_BB_PREDS(bb,pred) FOR_ALL_BBLIST_ITEMS(BB_preds(bb),pred)
00838 #define BB_First_Succ(bb) \
00839 ((BB_succs(bb) != NULL) ? BBLIST_item(BB_succs(bb)) : NULL)
00840 #define BB_First_Pred(bb) \
00841 ((BB_preds(bb) != NULL) ? BBLIST_item(BB_preds(bb)) : NULL)
00842
00843 extern void BBlist_Free (BBLIST **lst);
00844 extern INT BBlist_Len (BBLIST *lst);
00845 extern BBLIST *BBlist_Find_BB(BBLIST *lst, BB *bb);
00846 extern BBLIST* BBlist_Fall_Thru_Succ(BB *bb);
00847 extern BBLIST* BBlist_Fall_Thru_Pred(BB *bb);
00848
00849 inline BBLIST *BB_Find_Succ(BB *bb, BB *succ)
00850 {
00851 return BBlist_Find_BB(BB_succs(bb), succ);
00852 }
00853
00854 inline BBLIST *BB_Find_Pred(BB *bb, BB *pred)
00855 {
00856 return BBlist_Find_BB(BB_preds(bb), pred);
00857 }
00858
00859 inline BOOL BB_in_succs(BB *bb, BB *b)
00860 {
00861 return BBlist_Find_BB(BB_succs(bb), b) != NULL;
00862 }
00863
00864 inline BOOL BB_in_preds(BB *bb, BB *b)
00865 {
00866 return BBlist_Find_BB(BB_preds(bb), b) != NULL;
00867 }
00868
00869 inline INT32 BB_succs_len(BB *bb)
00870 {
00871 return BBlist_Len(BB_succs(bb));
00872 }
00873
00874 inline INT32 BB_preds_len(BB *bb)
00875 {
00876 return BBlist_Len(BB_preds(bb));
00877 }
00878
00879 inline BOOL BBlist_Has_One_Element(BBLIST *bblist)
00880 {
00881 return bblist && BBLIST_next(bblist) == NULL;
00882 }
00883
00884 inline BOOL BB_Has_One_Succ(BB *bb)
00885 {
00886 return BBlist_Has_One_Element(BB_succs(bb));
00887 }
00888
00889 inline BOOL BB_Has_One_Pred(BB *bb)
00890 {
00891 return BBlist_Has_One_Element(BB_preds(bb));
00892 }
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903 extern BB *REGION_First_BB;
00904
00905
00906
00907
00908 extern BB_NUM PU_BB_Count;
00909
00910
00911
00912
00913 extern BB_LIST *Entry_BB_Head;
00914 extern BB_LIST *Exit_BB_Head;
00915
00916 extern BB **BB_Vec;
00917 #define BBvec(i) BB_Vec[i]
00918
00919
00920 #include "bb_map.h"
00921
00922 #include "bb_set.h"
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961 struct BB_REGION {
00962 typedef mempool_allocator<BB*> allocator_type;
00963 typedef vector<BB*, allocator_type> bb_vector;
00964 allocator_type data_allocator;
00965 bb_vector entries;
00966 bb_vector exits;
00967 bool has_omega;
00968
00969
00970 void Verify() const;
00971
00972 bool Has_omega() const { return has_omega; }
00973 void Set_has_omega() { has_omega = true; }
00974
00975
00976
00977 BB_REGION(MEM_POOL *pool)
00978 :data_allocator(pool),
00979 entries(0, (BB*)NULL, data_allocator),
00980 exits(0, (BB*)NULL, data_allocator),
00981 has_omega(false)
00982 {}
00983
00984
00985
00986 BB_REGION(BB_SET *bbs, MEM_POOL *pool);
00987 void Print(void) const;
00988 };
00989
00990 extern BB_SET *BB_REGION_to_BB_SET(BB_SET *bbs, const BB_REGION& r,
00991 MEM_POOL *pool);
00992 extern void BB_REGION_to_Vector (vector<BB*>& c, const BB_REGION& r);
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021 class BB_VISITED_COUNTER {
01022 MEM_POOL *pool;
01023 INT current_version;
01024 INT size;
01025 INT *counter;
01026
01027 public:
01028
01029 void Set_visited(BB *bb) const { counter[BB_id(bb)] = current_version; }
01030
01031
01032 BOOL Visited(BB *bb) const { return counter[BB_id(bb)] == current_version; }
01033
01034
01035
01036
01037 void Init() {
01038 INT required_size = PU_BB_Count + 2;
01039 if (required_size > size) {
01040 #pragma mips_frequency_hint NEVER
01041 if (size == 0)
01042 counter = (INT *) MEM_POOL_Alloc(pool, required_size * sizeof(INT));
01043 else
01044 counter = (INT *) MEM_POOL_Realloc(pool, counter, size * sizeof(INT), required_size * sizeof(INT));
01045 for (INT i = size; i < required_size; i++)
01046 counter[i] = 0;
01047 size = required_size;
01048 }
01049 if (++current_version == 0) {
01050 #pragma mips_frequency_hint NEVER
01051 for (INT i = 0; i < size; i++)
01052 counter[i] = 0;
01053 }
01054 }
01055
01056 BB_VISITED_COUNTER(MEM_POOL *m)
01057 :current_version(0),counter(NULL), size(0), pool(m)
01058 {}
01059 };
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073 extern BB *Gen_BB(void);
01074 extern BB *Gen_BB_N(INT n);
01075 extern BB *Gen_BB_Like (BB *model);
01076 extern BB *Gen_And_Append_BB(BB *prev_bb);
01077 extern BB *Gen_And_Insert_BB_Before(BB *point);
01078 extern BB *Gen_And_Insert_BB_After(BB *point);
01079 extern void Chain_BBs(BB* bb1, BB* bb2);
01080 extern void Target_Simple_Fall_Through_BB(BB* bb, BB* target_bb);
01081 extern void Target_Logif_BB(BB* bb, BB* br_targ_bb, float br_targ_prob,
01082 BB* fall_through);
01083 extern void Target_Cond_Branch(BB* bb, BB* br_targ_bb, float br_targ_prob);
01084 extern void Negate_Logif_BB(BB *bb);
01085 extern void Add_Goto_Op(BB *bb, BB *target_bb);
01086 extern void Add_Goto(BB *bb, BB *target_bb);
01087 extern BB* Create_Dummy_BB( BB *dest_bb );
01088 extern LABEL_IDX Gen_Label_For_BB (BB *bb);
01089 extern BOOL Is_Label_For_BB(LABEL_IDX label, BB *bb);
01090 extern BOOL Change_Switchtable_Entries(ST *tbl, BB *old_tgt, BB *new_tgt);
01091 extern void Change_Succ(BB *pred, BB *old_succ, BB *new_succ);
01092 extern void Change_Succ_Prob(BB *pred, BB *succ, float prob);
01093
01094
01095 extern void BB_Add_Annotation(BB *bb, ANNOTATION_KIND kind, void *info);
01096 extern INT BB_Copy_Annotations(BB *to_bb, BB *from_bb, ANNOTATION_KIND kind);
01097 extern INT BB_Copy_All_Annotations(BB *to_bb, BB *from_bb);
01098
01099
01100 extern void Free_BB_Memory ( void );
01101
01102
01103
01104
01105 extern void Link_Pred_Succ (BB *pred, BB *succ);
01106 #if defined (KEY)
01107 extern void Link_Pred_Succ_with_Prob(BB *pred, BB *succ, float prob,
01108 BOOL via_feedback = FALSE,
01109 BOOL set_prob = FALSE,
01110 BOOL via_hint =FALSE,
01111 BOOL incr_prob=TRUE);
01112 #else
01113 extern void Link_Pred_Succ_with_Prob(BB *pred, BB *succ, float prob,
01114 BOOL via_feedback = FALSE,
01115 BOOL set_prob = FALSE);
01116 #endif
01117 extern BBLIST *BBlist_Add_BB(BBLIST **lst, BB *bb);
01118 extern void BBlist_Delete_BB(BBLIST **lst, BB *bb);
01119 #if defined(KEY)
01120 extern BBLIST *BBlist_Add_BB_with_Prob(BBLIST **lst, BB *bb, float prob,
01121 BOOL via_feedback = FALSE,
01122 BOOL set_prob = FALSE,
01123 BOOL via_hint = FALSE,
01124 BOOL incr_prob = TRUE);
01125
01126 #else
01127 extern BBLIST *BBlist_Add_BB_with_Prob(BBLIST **lst, BB *bb, float prob,
01128 BOOL via_feedback = FALSE,
01129 BOOL set_prob = FALSE,
01130 BOOL incr_prob = TRUE);
01131 #endif
01132
01133
01134 extern void Unlink_Pred_Succ (BB *pred, BB *succ);
01135
01136
01137
01138
01139 extern BB *BB_Unique_Successor_Not_In_Set( BB *bb, BB_MAP map );
01140
01141
01142
01143
01144
01145 extern BB *BB_Unique_Successor( BB *bb );
01146 extern BB *BB_Unique_Predecessor( BB *bb );
01147 extern BB *BB_Unique_Source( BB *bb );
01148 extern void Remove_Explicit_Branch (BB *bb);
01149 extern BB *BB_Fall_Thru_Successor( BB *bb );
01150 extern BB *BB_Fall_Thru_Predecessor( BB *bb );
01151 extern BOOL BB_Retarget_Branch(BB *bb, BB *from, BB *to);
01152 extern BOOL BB_Can_Retarget_Branch(BB *bb, BB *from);
01153
01154 extern BB *BB_Other_Successor(BB *bb, BB *succ);
01155 extern BB *BB_Other_Predecessor(BB *bb, BB *pred);
01156
01157 inline BOOL BB_Is_Unique_Successor( BB *bb, BB *succ )
01158 {
01159 return BB_Unique_Successor(bb) == succ;
01160 }
01161
01162 inline BOOL BB_Is_Unique_Predecessor( BB *bb, BB *pred)
01163 {
01164 return BB_Unique_Predecessor(bb) == pred;
01165 }
01166
01167 #define BB_Delete_Successors(bb) BBlist_Free(&BB_succs(bb))
01168 #define BB_Delete_Predecessors(bb) BBlist_Free(&BB_preds(bb))
01169
01170
01171
01172
01173
01174 extern void BB_PU_Initialize(void);
01175
01176 extern void BB_REGION_Initialize(void);
01177
01178
01179 extern struct op *BB_branch_op (BB *);
01180
01181 #ifdef TARG_IA64
01182
01183 extern OP* Last_Non_Nop_op (BB *);
01184 extern OP* BB_Last_chk_op(BB *);
01185 #endif
01186
01187
01188 extern struct op* BB_xfer_op( BB *bb );
01189
01190
01191 extern struct op* BB_copy_xfer_op( BB *bb );
01192
01193
01194 extern struct op* BB_call_op(BB* bb);
01195
01196
01197 extern struct op *BB_entry_sp_adj_op (BB *bb);
01198 extern struct op *BB_exit_sp_adj_op (BB *bb);
01199
01200
01201 extern void Set_BB_entry_sp_adj_op (BB *bb, struct op *);
01202 extern void Set_BB_exit_sp_adj_op (BB *bb, struct op *);
01203
01204
01205 extern void Remove_BB (BB *);
01206
01207
01208 extern void Insert_BB ( BB *bb, BB *after );
01209
01210
01211
01212
01213 extern void Move_BB ( BB *bb, BB *after );
01214
01215
01216
01217
01218 extern BB *Append_Region_BBs( BB *prev, RID *rid );
01219
01220
01221 extern void BB_Mark_Unreachable_Blocks (void);
01222
01223
01224 extern void BB_Transfer_Exitinfo(BB* from, BB* to);
01225 extern void BB_Transfer_Entryinfo(BB* from, BB* to);
01226 extern void BB_Transfer_Callinfo(BB* from, BB* to);
01227 extern void BB_Transfer_Asminfo (BB *from, BB *to);
01228
01229
01230 extern void Print_BB_Header ( BB *bp,
01231 BOOL flow_info_only, BOOL print_tn_info );
01232 #pragma mips_frequency_hint NEVER Print_BB_Header
01233 extern void Trace_BB ( BB *bp, char *msg );
01234 #pragma mips_frequency_hint NEVER Trace_BB
01235 extern void Print_BB ( BB *bp );
01236 #pragma mips_frequency_hint NEVER Print_BB
01237 extern void Print_BB_No_Srclines ( BB *bp );
01238 #pragma mips_frequency_hint NEVER Print_BB_No_Srclines
01239 extern void Print_BB_Pragmas( BB *bp );
01240 #pragma mips_frequency_hint NEVER Print_BB_Pragmas
01241 extern void Print_All_BBs ( void );
01242 #pragma mips_frequency_hint NEVER Print_All_BBs
01243 extern void Print_All_BB_Headers ( void );
01244 #pragma mips_frequency_hint NEVER Print_All_BB_Headers
01245 extern void Print_Entry_Chain ( char *banner );
01246 #pragma mips_frequency_hint NEVER Print_Entry_Chain
01247 extern void Print_Flow_Graph ( char *banner, BOOL verbose );
01248 #pragma mips_frequency_hint NEVER Print_Flow_Graph
01249 extern void Print_LOOPINFO( LOOPINFO *info );
01250 #pragma mips_frequency_hint NEVER Print_LOOPINFO
01251
01252 #define BB_length(bb) OPS_length(&(bb)->ops)
01253
01254
01255 UINT16 BB_New_Op_Map_Idx(BB *bb);
01256
01257 void BB_Insert_Op_Before(BB *bb, OP *point, OP *op);
01258 void BB_Insert_Op_After(BB *bb, OP *point, OP *op);
01259 void BB_Append_Op(BB *bb, OP *op);
01260 void BB_Prepend_Op(BB *bb, OP *op);
01261 void BB_Insert_Ops_Before(BB *bb, OP *point, OPS *ops);
01262 void BB_Insert_Ops_After(BB *bb, OP *point, OPS *ops);
01263 void BB_Append_Ops(BB *bb, OPS *ops);
01264 void BB_Prepend_Ops(BB *bb, OPS *ops);
01265 void BB_Insert_Op(BB *bb, OP *point, OP *op, BOOL before);
01266 void BB_Insert_Ops(BB *bb, OP *point, OPS *ops, BOOL before);
01267
01268 void BB_Insert_Noops(OP *op, INT num, BOOL before);
01269
01270 void BB_Move_Op(BB *to_bb, OP *point, BB *from_bb, OP *op, BOOL before);
01271 void BB_Move_Op_Before(BB *to_bb, OP *point, BB *from_bb, OP *op);
01272 void BB_Move_Op_After(BB *to_bb, OP *point, BB *from_bb, OP *op);
01273 void BB_Move_Op_To_Start(BB *to_bb, BB *from_bb, OP *op);
01274 void BB_Move_Op_To_End(BB *to_bb, BB *from_bb, OP *op);
01275
01276 void BB_Sink_Op_Before(BB *bb, OP *op, OP *point);
01277 void BB_Update_OP_Order(BB *bb);
01278 void BB_Verify_OP_Order(BB *bb);
01279
01280 BOOL BB_Move_Delay_Slot_Op (BB *bb);
01281
01282 void BB_Append_All(BB *to_bb, BB *from_bb);
01283 void BB_Prepend_All(BB *to_bb, BB *from_bb);
01284
01285 OP *BB_Remove_Branch(BB *bb);
01286 void BB_Remove_Ops(BB *bb, OPS *ops);
01287 void BB_Remove_Op(BB *bb, OP *op);
01288 void BB_Remove_All(BB *bb);
01289
01290 extern SRCPOS BB_Loop_Srcpos(BB *bb);
01291 inline INT32 BB_Loop_Lineno(BB *bb)
01292 {
01293 return Srcpos_To_Line(BB_Loop_Srcpos(bb));
01294 }
01295
01296 BOOL BB_Add_Ancestors(struct bs **set, BB *bb, BB *start_bb, MEM_POOL *pool);
01297
01298 BOOL BB_Has_Exc_Label(BB *bb);
01299 BOOL BB_Has_Addr_Taken_Label(BB *bb);
01300 BOOL BB_Has_Outer_Block_Label(BB *bb);
01301
01302 struct bb_map *BB_Depth_First_Map(struct bs *region, BB *entry);
01303 struct bb_map *BB_Topological_Map(struct bs *region, BB *entry);
01304
01305 BOOL BB_Is_Cold(BB *bb);
01306 #if defined(TARG_SL)
01307 BOOL BB_Is_Hot(BB* bb);
01308 #endif
01309 ST *Gen_ST_For_BB(BB *bb);
01310 ST *BB_st(BB *bb);
01311
01312 void Split_BBs();
01313
01314 extern BB_SET* Find_BB_Parents(BB* bb);
01315
01316 #ifdef Is_True_On
01317 extern void Verify_BB(BB *);
01318 #else
01319 #define Verify_BB(bb)
01320 #endif
01321
01322
01323
01324
01325
01326 inline BOOL BB_compile(BB *bb)
01327 {
01328 return (BB_rid(bb) == NULL || RID_level(BB_rid(bb)) < RL_CGSCHED);
01329 }
01330
01331
01332 void draw_flow_graph(void);
01333 void verify_flow_graph(void);
01334
01335 #endif