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 #include "tracing.h"
00052 #include "errors.h"
00053
00054 #include "op.h"
00055 #include "bb.h"
00056 #include "be_util.h"
00057
00058 #include "gra_live.h"
00059
00060 #include "ipfec_defs.h"
00061 #include "ipfec_options.h"
00062
00063 #include "region.h"
00064 #include "dag.h"
00065
00066 #include "sched_util.h"
00067 #include "sched_heur.h"
00068 #include "sched_cflow.h"
00069 #include "sched_cand.h"
00070 #include "sched_rgn_info.h"
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084 typedef enum {
00085 SIGNIFICANT_LESS ,
00086 SIGNIFICANT_GREAT,
00087 ROUGHLY_EQU,
00088 } F_CMP_RESULT ;
00089
00090 static F_CMP_RESULT
00091 Fuzzy_Cmp (float f1, float f2, float deviation) {
00092
00093 if (f1 < f2 - deviation) {
00094 return SIGNIFICANT_LESS ;
00095 } else if (f1 > f2 + deviation) {
00096 return SIGNIFICANT_GREAT ;
00097 }
00098
00099 return ROUGHLY_EQU;
00100 }
00101
00102 enum { LD_VIOLATE_DATA_DEP_MAX=2,};
00103 enum { LD_VIOLATE_CHK_DEP_MAX=1,} ;
00104 enum { LD_VIOLATE_CNTL_DEP_MAX=LD_VIOLATE_CHK_DEP_MAX + 5,};
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 FAVOR_DELAY_HEUR :: FAVOR_DELAY_HEUR (MEM_POOL* mp) :
00117 _mp(mp), _heur_map (mp) {
00118
00119 _target_block = NULL;
00120 _xfer_op = NULL;
00121
00122 _rgn_scope = NULL;
00123 _bb_scope = NULL;
00124
00125 _initialize = FALSE ;
00126
00127 _trace_cand_sel = FALSE;
00128 _trace_file = NULL;
00129 }
00130
00131 FAVOR_DELAY_HEUR :: ~FAVOR_DELAY_HEUR (void) {
00132
00133 _trace_cand_sel = FALSE ;
00134
00135 if (_trace_file) {
00136 fclose(_trace_file);
00137 _trace_file = NULL ;
00138 }
00139
00140 }
00141
00142
00143 void
00144 FAVOR_DELAY_HEUR :: Reset_BB_OPs_etime (BB *bb) {
00145 OP * op ;
00146 FOR_ALL_BB_OPs (bb, op) {
00147 Set_OP_etime (op, 0);
00148 }
00149 }
00150
00151
00152 void
00153 FAVOR_DELAY_HEUR :: Find_Significant_Pred_For_Target_Blk (void) {
00154
00155 if (!Is_In_Global_Scope ()) {
00156 _significant_pred = NULL;
00157 return ;
00158 }
00159
00160
00161
00162
00163 float v=0.0f;
00164 REGIONAL_CFG_NODE* node = Regional_Cfg_Node(_target_block);
00165 _significant_pred = NULL;
00166
00167 for (REGIONAL_CFG_EDGE* e = node->First_Pred () ;
00168 e;
00169 e = e->Next_Pred ()) {
00170
00171 REGIONAL_CFG_NODE* pred = e->Src ();
00172
00173
00174
00175 if (pred->Is_Region ()) continue ;
00176
00177 BB* b = pred->BB_Node ();
00178 if (BB_call(b)) continue ;
00179
00180 float t = BB_freq(b) * e->Prob ();
00181
00182 if (t > v) { _significant_pred = b; }
00183 }
00184 }
00185
00186 void
00187 FAVOR_DELAY_HEUR :: Estimate_Cand_Etime (OP* op) {
00188
00189 if (!_significant_pred) {
00190 Set_OP_etime (op, 0);
00191 return ;
00192 }
00193
00194 for (ARC_LIST* list = OP_preds(op);
00195 list ;
00196 list = ARC_LIST_rest(list)) {
00197
00198 ARC* arc = ARC_LIST_first (list) ;
00199 OP * pred = ARC_pred (arc);
00200
00201 mINT16 latency = ARC_latency (arc);
00202 if (IPFEC_Adjust_Variable_Latency) {
00203
00204 latency += CGTARG_adjust_latency (
00205 arc, ip_invalid,
00206 ip_invalid);
00207 }
00208
00209 if (latency <= 1) { continue ;}
00210
00211 if (OP_bb(pred) != _significant_pred) {
00212 continue;
00213 }
00214
00215 INT32 start_cyc = OP_scycle(pred) + latency -
00216 BB_cycle(_significant_pred);
00217
00218 if (start_cyc > 0) {
00219 Set_OP_etime (op, start_cyc);
00220 }
00221
00222 }
00223 }
00224
00225 void
00226 FAVOR_DELAY_HEUR :: Adjust_Etime_For_Target_Block (void) {
00227
00228 OP* op;
00229 FOR_ALL_BB_OPs(_target_block, op) {
00230 Estimate_Cand_Etime (op);
00231 }
00232 }
00233
00234 void
00235 FAVOR_DELAY_HEUR :: Reset_BB_OPs_etime (const BB_VECTOR *bbs) {
00236
00237 for (BB_VECTOR_CONST_ITER iter = bbs->begin () ;
00238 iter != bbs->end () ; iter++) {
00239
00240 Reset_BB_OPs_etime (*iter);
00241
00242 }
00243 }
00244
00245
00246 BOOL
00247 FAVOR_DELAY_HEUR :: BB_Need_Adjusting_Delay (BB *bb) {
00248
00249 if (BB_scheduled(bb) ||
00250 BB_Is_Isolated_From_Sched (bb)) {
00251 return FALSE ;
00252 }
00253
00254 BB_HEUR_STUFF * bb_info = Get_BB_Heur_Stuff (bb) ;
00255 return (BOOL)bb_info->_heur_need_adjust;
00256 }
00257
00258 void
00259 FAVOR_DELAY_HEUR :: Set_BB_Need_Adjusting_Delay (BB *bb) {
00260
00261 if (BB_scheduled(bb) || BB_Is_Isolated_From_Sched (bb)) {
00262 DevWarn ("BB:%d has been scheduled or isolated but "
00263 "it is still required to adjust Delay",
00264 BB_id (bb));
00265 }
00266
00267 BB_HEUR_STUFF * bb_info = Get_BB_Heur_Stuff (bb) ;
00268 bb_info-> _heur_need_adjust = TRUE;
00269 }
00270
00271 void
00272 FAVOR_DELAY_HEUR :: Set_BB_Need_Not_Adjusting_Delay (BB * bb) {
00273
00274 BB_HEUR_STUFF * bb_info = Get_BB_Heur_Stuff (bb) ;
00275
00276 if (bb_info) {
00277 bb_info-> _heur_need_adjust = FALSE ;
00278 }
00279 }
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289 void
00290 FAVOR_DELAY_HEUR :: Compute_Delay (
00291 OP *op, SUCC_INFO * succ_info, INT32 succ_num) {
00292
00293 BOOL Is_Leaf = TRUE ;
00294 BOOL delay_base_on_home_bb_op = TRUE;
00295
00296 OP_HEUR_INFO *op_info = Get_OP_Heur_Info (op) ;
00297 BB * home_bb = OP_bb(op);
00298
00299 float max_delay_base_on_home_bb = -1.0f ;
00300 float max_delay_base_on_succ_bb = -1.0f ;
00301
00302 if (succ_info) {
00303 for (INT i = 0 ; i < succ_num ; i++) {
00304 succ_info[i].max_delay = 0.0f ;
00305 }
00306 }
00307
00308 for (ARC_LIST* list = OP_succs(op);
00309 list ; list = ARC_LIST_rest(list)) {
00310 ARC * arc = ARC_LIST_first (list) ;
00311 OP * succ = ARC_succ (arc);
00312
00313 switch (ARC_kind(arc)) {
00314 case CG_DEP_POSTBR :
00315 case CG_DEP_PREBR :
00316 case CG_DEP_CTLSPEC :
00317 continue ;
00318
00319 case CG_DEP_PRECHK :
00320 case CG_DEP_POSTCHK :
00321 if (!OP_chk(op)) continue ;
00322 break ;
00323 }
00324
00325 BB * descendant_bb = OP_bb(succ);
00326
00327 Is_Leaf = FALSE ;
00328
00329 mINT16 latency = ARC_latency(arc) ;
00330
00331 if (ARC_kind(arc) == CG_DEP_POSTBR) {
00332 latency = 1 ;
00333 for (INT i = 0 ; i < succ_num ; i++) {
00334 if (descendant_bb == succ_info[i].succ) {
00335 latency = succ_info[i].flow_shift_latency ;
00336 break ;
00337 }
00338 }
00339 }
00340
00341
00342 float delay = latency + Get_OP_Heur_Info(succ)->_delay;
00343
00344 if (home_bb == descendant_bb) {
00345 max_delay_base_on_home_bb = (max_delay_base_on_home_bb > delay) ?
00346 max_delay_base_on_home_bb : delay ;
00347
00348 } else {
00349
00350 delay_base_on_home_bb_op = FALSE ;
00351
00352 if (!succ_info) {
00353 max_delay_base_on_succ_bb =
00354 (max_delay_base_on_succ_bb > delay) ?
00355 max_delay_base_on_succ_bb : delay ;
00356 } else {
00357 for (INT i = 0 ; i < succ_num ; i++) {
00358 if ((descendant_bb == succ_info[i].succ ||
00359 _cflow_mgr->BB1_Reachable_From_BB2 (
00360 descendant_bb,succ_info[i].succ)) &&
00361 succ_info[i].max_delay < delay) {
00362 succ_info[i].max_delay = delay ;
00363 }
00364 }
00365 }
00366
00367 }
00368 }
00369
00370
00371 if (Is_Leaf) {
00372 if (TOP_is_xfer(OP_code(op))) { op_info->_delay = 1.0f ; }
00373 else if (OP_load(op)) { op_info->_delay = 2.0f ; }
00374 else { op_info->_delay = 1.0f ; } ;
00375
00376 return ;
00377 }
00378
00379 if (delay_base_on_home_bb_op) {
00380 op_info->_delay = op_info->_delay > max_delay_base_on_home_bb ?
00381 op_info->_delay : max_delay_base_on_home_bb ;
00382 return ;
00383 }
00384
00385 if (succ_info) {
00386 max_delay_base_on_succ_bb = 0.0f;
00387
00388 for (INT i = 0 ; i < succ_num ; i++) {
00389 max_delay_base_on_succ_bb +=
00390 succ_info[i].max_delay * succ_info[i].reach_prob ;
00391 }
00392 }
00393
00394 float f = max_delay_base_on_succ_bb > max_delay_base_on_home_bb ?
00395 max_delay_base_on_succ_bb : max_delay_base_on_home_bb ;
00396 op_info->_delay = op_info->_delay > f ? op_info->_delay : f ;
00397
00398 }
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408 void
00409 FAVOR_DELAY_HEUR :: Compute_Delay (BB * bb) {
00410
00411
00412
00413 if (!BB_Need_Adjusting_Delay (bb)) { return ; }
00414
00415 REGIONAL_CFG_NODE * node = NULL;
00416 REGIONAL_CFG * cfg = NULL ;
00417 SUCC_INFO succs_info[8], * psucc_info = NULL;
00418 INT32 succ_num = 0 ;
00419
00420 if (Is_In_Global_Scope()) {
00421
00422 node = Regional_Cfg_Node (bb) ;
00423 cfg = Home_Region(bb)->Regional_Cfg () ;
00424 succ_num = node->Succ_Num ();
00425
00426 if (succ_num > 8) {
00427 psucc_info = TYPE_ALLOCA_N(SUCC_INFO,succ_num) ;
00428 } else {
00429 psucc_info = &succs_info[0] ;
00430 }
00431
00432 INT32 bb_succ_num = 0 ;
00433
00434 for (CFG_SUCC_EDGE_ITER iter(node); iter != 0; ++iter) {
00435
00436 REGIONAL_CFG_EDGE * edge;
00437
00438 edge = *iter;
00439 REGIONAL_CFG_NODE * succ_node = edge->Dest() ;
00440
00441 if (succ_node->Is_Region()) continue ;
00442 BB* succ_bb = succ_node->BB_Node();
00443
00444 psucc_info[bb_succ_num].succ = succ_bb ;
00445 psucc_info[bb_succ_num].flow_shift_latency =
00446 (succ_bb == BB_next(bb)) ? 1 :
00447 CGTARG_Branch_Taken_Penalty ();
00448 psucc_info[bb_succ_num].reach_prob = cfg->Edge_Prob (edge) ;
00449 psucc_info[bb_succ_num++].max_delay = 0.0f;
00450 }
00451
00452 succ_num = bb_succ_num ;
00453 if (!bb_succ_num) { psucc_info = NULL ; }
00454 }
00455
00456 OP * op ;
00457 FOR_ALL_BB_OPs_REV (bb, op) {
00458 Compute_Delay (op, psucc_info, succ_num);
00459 }
00460
00461 Set_BB_Need_Not_Adjusting_Delay (bb);
00462 }
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473 void
00474 FAVOR_DELAY_HEUR :: Compute_Delay (REGION *rgn) {
00475
00476 for (REVERSE_TOPO_REGIONAL_CFG_ITER iter(rgn->Regional_Cfg()) ;
00477 iter != 0 ; ++iter) {
00478 if ((*iter)->Is_Region()) continue ;
00479 BB * bb = (*iter)->BB_Node ();
00480 if (BB_exit (bb) || BB_entry (bb)) continue;
00481
00482 Compute_Delay (bb);
00483 }
00484
00485 }
00486
00487 void
00488 FAVOR_DELAY_HEUR :: Adjust_Delay (REGION *rgn) {
00489
00490 for (REVERSE_TOPO_REGIONAL_CFG_ITER iter(rgn->Regional_Cfg()) ;
00491 iter != 0 ; ++iter) {
00492 if ((*iter)->Is_Region()) continue ;
00493
00494 BB * bb = (*iter)->BB_Node () ;
00495 if (BB_entry (bb) || BB_exit(bb) ||
00496 !BB_Need_Adjusting_Delay (bb)) {
00497 continue ;
00498 }
00499
00500 Compute_Delay (bb);
00501 }
00502 }
00503
00504
00505 void
00506 FAVOR_DELAY_HEUR :: Compute_FanOut (OP* op) {
00507
00508 INT fanout = 0 ;
00509
00510 for (ARC_LIST* list = OP_succs(op);
00511 list ; list = ARC_LIST_rest(list)) {
00512
00513 ARC * arc = ARC_LIST_first (list) ;
00514 switch (ARC_kind (arc)) {
00515 CG_DEP_PRECHK :
00516 CG_DEP_PREBR :
00517 break ;
00518 default :
00519 ++ fanout ;
00520 }
00521 }
00522
00523 OP_HEUR_INFO * info = Get_OP_Heur_Info (op) ;
00524 fanout = max(fanout,1);
00525
00526 info -> _fan_out = fanout ;
00527 }
00528
00529 void
00530 FAVOR_DELAY_HEUR :: Compute_FanOut_For_All_OP (BB *bb) {
00531
00532 OP * op ;
00533 FOR_ALL_BB_OPs (bb, op) {
00534 Compute_FanOut (op);
00535 }
00536 }
00537
00538 void
00539 FAVOR_DELAY_HEUR :: Compute_FanOut_For_All_OP (REGION *rgn) {
00540
00541 for (TOPOLOGICAL_REGIONAL_CFG_ITER iter (rgn->Regional_Cfg()) ;
00542 iter != 0 ; ++ iter) {
00543
00544 if ((*iter)->Is_Region ()) continue ;
00545
00546 BB * bb = (*iter)->BB_Node () ;
00547 if (BB_entry (bb) || BB_exit (bb)) continue ;
00548
00549 Compute_FanOut_For_All_OP (bb);
00550 }
00551 }
00552
00553 void
00554 FAVOR_DELAY_HEUR :: Alloc_Heur_Data (BB * bb) {
00555
00556 BB_HEUR_STUFF * bb_heur_stuff =
00557 CXX_NEW (BB_HEUR_STUFF(bb,_mp), _mp);
00558
00559 _heur_map.Set_Map (bb, bb_heur_stuff) ;
00560 }
00561
00562 void
00563 FAVOR_DELAY_HEUR :: Alloc_Heur_Data (REGION * rgn) {
00564
00565 for (TOPOLOGICAL_REGIONAL_CFG_ITER iter(rgn->Regional_Cfg());
00566 iter != 0; ++iter) {
00567
00568 if ((*iter)->Is_Region ()) continue;
00569
00570 BB * bb = (*iter)->BB_Node ();
00571 if (BB_entry(bb) || BB_exit(bb)) continue ;
00572
00573 Alloc_Heur_Data (bb);
00574 }
00575 }
00576
00577
00578 void
00579 FAVOR_DELAY_HEUR :: Initialize (
00580 REGION *rgn,
00581 RGN_CFLOW_MGR* cflow_mgr) {
00582
00583 Is_True (!_rgn_scope && !_bb_scope, ("Initialized twice"));
00584
00585 _initialize = TRUE;
00586
00587 _rgn_scope = rgn ;
00588 _cflow_mgr = cflow_mgr;
00589
00590 Alloc_Heur_Data (rgn);
00591
00592 Compute_Delay (rgn);
00593
00594 Compute_FanOut_For_All_OP (rgn);
00595
00596 _trace_file = NULL;
00597 _trace_cand_sel = FALSE ;
00598 }
00599
00600 void
00601 FAVOR_DELAY_HEUR :: Initialize (BB *bb, RGN_CFLOW_MGR* cflow_mgr) {
00602
00603 Is_True (!_rgn_scope && !_bb_scope, ("Initialized twice"));
00604
00605 _bb_scope = bb;
00606 _cflow_mgr = cflow_mgr;
00607
00608 Alloc_Heur_Data (bb);
00609
00610 Set_BB_Need_Adjusting_Delay (bb);
00611 Compute_FanOut_For_All_OP (bb);
00612
00613 _trace_file = NULL;
00614 _trace_cand_sel = FALSE ;
00615
00616 _initialize = TRUE;
00617 }
00618
00619
00620 void
00621 FAVOR_DELAY_HEUR :: Finialize (void) {
00622 }
00623
00624 void *
00625 FAVOR_DELAY_HEUR :: Detach_OP_Heur_Info (OP * op) {
00626
00627 BB_HEUR_STUFF * bb_heur_stuff =
00628 (BB_HEUR_STUFF *)_heur_map.Get_Map (OP_bb(op)) ;
00629 Is_True (bb_heur_stuff,
00630 ("fail to get BB:%d's heuristic stuff!",
00631 BB_id(OP_bb(op))));
00632
00633 OP_HEUR_INFO * op_info = bb_heur_stuff->Get_OP_Heur_Info (op) ;
00634 bb_heur_stuff->Set_OP_Heur_Info (op, NULL);
00635
00636 return op_info;
00637 }
00638
00639
00640 void
00641 FAVOR_DELAY_HEUR :: Attach_OP_Heur_Info (OP * op, void * Heur_Data) {
00642
00643 OP_HEUR_INFO * info = (OP_HEUR_INFO *)Heur_Data;
00644
00645 if (info &&
00646 (info->_magic_num != OP_HEUR_INFO_MAGIC_NUM ||
00647 info->_op != op)) {
00648 Fail_FmtAssertion (
00649 "It is not a valid heuristic structure for OP[%d] (BB:%d)!\n",
00650 OP_map_idx(op), BB_id(OP_bb(op)));
00651 }
00652
00653 BB_HEUR_STUFF * bb_heur_stuff =
00654 (BB_HEUR_STUFF *)_heur_map.Get_Map (OP_bb(op)) ;
00655
00656 bb_heur_stuff->Set_OP_Heur_Info (op, info);
00657 }
00658
00659
00660 void
00661 FAVOR_DELAY_HEUR :: Adjust_Heur_Stuff_When_BB_Changed
00662 (BB * new_target,SRC_BB_MGR& src_bb_mgr) {
00663
00664 Is_True (_initialize, ("FAVOR_DELAY_HEUR has not yet initialized!"));
00665 Is_True (_rgn_scope || _bb_scope == new_target,
00666 ("target bb change while scheduling scope is not 'global'"));
00667
00668 _target_block = new_target ;
00669 _xfer_op = BB_xfer_op(new_target);
00670
00671 const BB_VECTOR * bbs = src_bb_mgr.Src_BBs ();
00672 Reset_BB_OPs_etime (bbs);
00673
00674 if (Is_In_Global_Scope ()) {
00675
00676
00677 Compute_Delay (_rgn_scope);
00678 } else {
00679 Compute_Delay (_bb_scope);
00680 }
00681
00682 Find_Significant_Pred_For_Target_Blk ();
00683
00684 if (Is_In_Global_Scope ()) {
00685 Adjust_Etime_For_Target_Block ();
00686 }
00687 }
00688
00689 void
00690 FAVOR_DELAY_HEUR :: Compute_Heur_Data_For_Inserted_OP (OP *op) {
00691
00692 OP_HEUR_INFO * heur_info = Get_OP_Heur_Info (op);
00693
00694 if (!heur_info) {
00695 heur_info = CXX_NEW (OP_HEUR_INFO(op),_mp);
00696 Attach_OP_Heur_Info (op, heur_info);
00697 }
00698
00699 if (!Is_In_Global_Scope ()) {
00700 Compute_Delay (op, NULL, 0);
00701 return ;
00702 }
00703
00704 REGIONAL_CFG_NODE * node = NULL;
00705 REGIONAL_CFG * cfg = NULL ;
00706 SUCC_INFO succs_info[8], * psucc_info = NULL;
00707 INT32 succ_num = 0 ;
00708
00709 node = Regional_Cfg_Node (OP_bb(op)) ;
00710 cfg = Home_Region(OP_bb(op))->Regional_Cfg () ;
00711 succ_num = node->Succ_Num ();
00712
00713 if (succ_num > 8) {
00714 psucc_info = TYPE_ALLOCA_N(SUCC_INFO,succ_num) ;
00715 } else {
00716 psucc_info = &succs_info[0] ;
00717 }
00718
00719 INT32 bb_succ_num = 0 ;
00720
00721 for (CFG_SUCC_EDGE_ITER iter(node); iter != 0; ++iter) {
00722
00723 REGIONAL_CFG_EDGE * edge ;
00724 edge = *iter ;
00725
00726 REGIONAL_CFG_NODE * succ_node = edge->Dest() ;
00727
00728 if (succ_node->Is_Region()) continue ;
00729 BB * succ_bb = succ_node->BB_Node();
00730
00731 psucc_info[bb_succ_num].succ = succ_bb ;
00732 psucc_info[bb_succ_num].reach_prob = cfg->Edge_Prob (edge) ;
00733 psucc_info[bb_succ_num].flow_shift_latency = 1 ;
00734 psucc_info[bb_succ_num++].max_delay = 0.0f;
00735 }
00736
00737 succ_num = bb_succ_num ;
00738 if (!bb_succ_num) { psucc_info = NULL ; }
00739
00740 Compute_Delay (op, psucc_info, succ_num);
00741 Compute_FanOut (op);
00742 }
00743
00744 void
00745 FAVOR_DELAY_HEUR :: Compute_Heur_Data_For_Appended_OP (OP *op) {
00746 Compute_Heur_Data_For_Inserted_OP (op);
00747 }
00748
00749 void
00750 FAVOR_DELAY_HEUR :: Compute_Heur_Data_For_Prepended_OP (OP *op) {
00751
00752 }
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771 CYCLE
00772 FAVOR_DELAY_HEUR::Exclude_Unqualifed_Cand_Under_Etime_Constraint
00773 (CAND_LIST& cand_lst, E_Time_Constraint* constraint) {
00774
00775 CYCLE e_time = CYCLE_MAX ;
00776
00777 OP_HEUR_INFO* op_sched_info = NULL;
00778
00779 if (_trace_cand_sel) {
00780
00781 fputs ("Exclude candidates which not qualified due to "
00782 "etime constraint\n", _trace_file);
00783 }
00784
00785 if (constraint->constraint == NO_LATER) {
00786
00787 for (CAND_LIST_ITER cand_iter(&cand_lst);
00788 !cand_iter.done (); cand_iter.step ()) {
00789
00790 CANDIDATE * cand = cand_iter.cur ();
00791
00792 if (cand_lst.Cand_Has_Been_Tried (cand)) {
00793 continue ;
00794 }
00795
00796 mINT16 etime_tmp = (mINT16)Get_Cand_Issue_Cyc (cand);
00797 if (etime_tmp > constraint->threshold) {
00798
00799
00800
00801 cand_lst.Set_Cand_Has_Been_Tried (cand);
00802 if (_trace_cand_sel) {
00803
00804 fprintf (_trace_file,
00805 "[OP%3d][BB%3d] does not satisfy e-time constraint (%d>%d)\n",
00806 OP_map_idx(cand->Op()),
00807 BB_id(OP_bb(cand->Op())),
00808 etime_tmp,
00809 constraint->threshold);
00810
00811 }
00812
00813 continue ;
00814 }
00815
00816 e_time = min(etime_tmp, e_time);
00817 }
00818
00819 return e_time ;
00820 }
00821
00822
00823 Is_True (constraint->constraint == AS_EARLY_AS_POSSIBLE,
00824 ("Unknown e-time constraint type(%d)",
00825 constraint->constraint));
00826
00827 for (CAND_LIST_ITER cand_iter(&cand_lst);
00828 !cand_iter.done (); cand_iter.step ()) {
00829
00830 CANDIDATE* cand = cand_iter.cur ();
00831
00832 if (cand_lst.Cand_Has_Been_Tried (cand)) {
00833 continue ;
00834 }
00835
00836 mINT16 etime_tmp = (mINT16)Get_Cand_Issue_Cyc (cand);
00837 e_time = min (etime_tmp, e_time);
00838 }
00839
00840 if (e_time == CYCLE_MAX) return CYCLE_MAX ;
00841 if (constraint->threshold != CYCLE_MAX) {
00842 e_time = max(e_time, constraint->threshold);
00843 }
00844
00845 E_Time_Constraint tmp ;
00846 tmp.threshold = e_time ;
00847 tmp.constraint = NO_LATER ;
00848
00849 return Exclude_Unqualifed_Cand_Under_Etime_Constraint (
00850 cand_lst, &tmp);
00851
00852 }
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868 CANDIDATE*
00869 FAVOR_DELAY_HEUR :: Choose_Better_Of_Tie
00870 (CANDIDATE * cand1, OP_HEUR_INFO * info1,
00871 CANDIDATE * cand2, OP_HEUR_INFO * info2,
00872 BOOL comes_from_targ_bb) {
00873
00874
00875
00876
00877 if (!cand1->Is_Spec () && cand2->Is_Spec ()) {
00878 return cand1 ;
00879 } else if (cand1->Is_Spec () && !cand2->Is_Spec ()) {
00880 if (_trace_cand_sel) {
00881 fprintf (_trace_file,
00882 "favor [OP%3d][BB%3d] because it's non-speculative\n",
00883 OP_map_idx(cand2->Op()),
00884 BB_id(OP_bb(cand2->Op())));
00885 }
00886 return cand2 ;
00887 }
00888
00889 if (!comes_from_targ_bb) {
00890
00891
00892
00893
00894
00895
00896
00897
00898 switch ((INT)Fuzzy_Cmp(info1->_delay, info2->_delay, 0.005f)) {
00899 case SIGNIFICANT_LESS:
00900
00901 if (_trace_cand_sel) {
00902 fprintf (_trace_file,
00903 "favor [OP%3d][BB%3d] since its delay(not weight "
00904 "by reach prob) is significant greater (%f > %f)\n",
00905 OP_map_idx(cand2->Op()),
00906 BB_id(OP_bb(cand2->Op())),
00907 info2->_delay,
00908 info1->_delay);
00909 }
00910
00911 return cand2 ;
00912 case SIGNIFICANT_GREAT:
00913 return cand1 ;
00914 case ROUGHLY_EQU :
00915 break ;
00916 default :
00917 Fail_FmtAssertion ("Unknown fuzzy-comparison result\n");
00918 }
00919 }
00920
00921
00922
00923
00924 if (OP_like_store(cand1->Op())) {
00925 return cand1 ;
00926 } else if (OP_like_store (cand2->Op())) {
00927 if (_trace_cand_sel) {
00928 fprintf (_trace_file,
00929 "favor [OP%3d][BB%3d] since it is like store\n",
00930 OP_map_idx(cand2->Op()),
00931 BB_id(OP_bb(cand2->Op())));
00932 }
00933
00934 return cand2 ;
00935 }
00936
00937
00938
00939 if (info1->_issuable_port_num <
00940 info2->_issuable_port_num) {
00941 return cand1;
00942 } else if (info1->_issuable_port_num > info2->_issuable_port_num) {
00943
00944 if (_trace_cand_sel) {
00945 fprintf (_trace_file,
00946 "favor [OP%3d][BB%3d] since it has less issuable ports (%d < %d)\n",
00947 OP_map_idx(cand2->Op()),
00948 BB_id(OP_bb(cand2->Op())),
00949 info2->_issuable_port_num,
00950 info1->_issuable_port_num);
00951 }
00952
00953 return cand2;
00954 }
00955
00956
00957
00958
00959
00960 INT int_tmp1, int_tmp2 ;
00961
00962 int_tmp1 = info1->_fan_out ;
00963 int_tmp2 = info2->_fan_out ;
00964
00965 if (int_tmp1 > int_tmp2) {
00966 return cand1 ;
00967 } else if (int_tmp1 < int_tmp2) {
00968
00969 if (_trace_cand_sel) {
00970 fprintf (_trace_file,
00971 "favor [OP%3d][BB%3d] since it has more fan-outs (%d > %d)\n",
00972 OP_map_idx(cand2->Op()),
00973 BB_id(OP_bb(cand2->Op())),
00974 int_tmp2, int_tmp1);
00975 }
00976
00977 return cand2 ;
00978 }
00979
00980 return cand1;
00981 }
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993 CANDIDATE*
00994 FAVOR_DELAY_HEUR :: Select_Best_Candidate (
00995 CAND_LIST& cand_lst,
00996 BB* target,
00997 E_Time_Constraint* etime_constraint) {
00998
00999 CYCLE e_time = Exclude_Unqualifed_Cand_Under_Etime_Constraint
01000 (cand_lst,etime_constraint);
01001
01002 if (etime_constraint->threshold < e_time) {
01003 etime_constraint->threshold = e_time ;
01004 }
01005
01006 if (e_time == CYCLE_MAX) {
01007
01008 Is_True (cand_lst.All_Cands_Have_Been_Tried (),
01009 ("Not all candidates have been tried!")) ;
01010
01011 if (_trace_cand_sel) {
01012 fputs ("none of candidate satisfy e-time constraint\n",
01013 _trace_file);
01014 }
01015
01016 return NULL ;
01017
01018 }
01019
01020 #ifdef Is_True_On
01021 if (etime_constraint->constraint == NO_LATER) {
01022 Is_True (e_time <= etime_constraint->threshold,
01023 ("e_time(%d) > threshold (%d)\n",
01024 e_time, etime_constraint->threshold));
01025 }
01026 #endif
01027
01028
01029 CANDIDATE* best_cand_of_other_bb = NULL,
01030 * best_cand_of_target_bb = NULL ;
01031
01032 float weigh_delay_of_best_cand_of_other_bb = -100.0f;
01033 float delay_of_best_cand_of_target_bb = -1.0f;
01034
01035 OP_HEUR_INFO* targ_bb_cand_heur = NULL,
01036 * other_bb_cand_heur = NULL ;
01037
01038
01039
01040
01041 for (CAND_LIST_ITER cand_iter(&cand_lst);
01042 !cand_iter.done (); cand_iter.step ()) {
01043
01044 CANDIDATE* cand = cand_iter.cur ();
01045
01046
01047
01048 if (cand_lst.Cand_Has_Been_Tried (cand)) { continue ; }
01049
01050 BB* home_bb = OP_bb (cand->Op ());
01051 OP_HEUR_INFO * op_sched_info = Get_OP_Heur_Info (cand->Op ()) ;
01052
01053 #define DELAY_DEVIATION (0.05f)
01054
01055 BOOL choose_current = FALSE ;
01056
01057
01058
01059
01060 if (home_bb == target) {
01061
01062
01063
01064
01065
01066 switch (Fuzzy_Cmp (op_sched_info->_delay,
01067 targ_bb_cand_heur ?
01068 targ_bb_cand_heur->_delay : -1.0f,
01069 DELAY_DEVIATION)) {
01070 case SIGNIFICANT_LESS: continue ;
01071
01072 case SIGNIFICANT_GREAT:
01073 if (_trace_cand_sel) {
01074 fprintf (_trace_file,
01075 "best cand of targ-bb change to [OP%3d][BB%3d]"
01076 "since its delay(%f) is significantly greater\n",
01077 OP_map_idx(cand->Op()),
01078 BB_id(OP_bb(cand->Op())),
01079 op_sched_info->_delay);
01080 }
01081 choose_current = TRUE; break ;
01082
01083 case ROUGHLY_EQU:
01084 if (Choose_Better_Of_Tie (best_cand_of_target_bb,
01085 targ_bb_cand_heur,
01086 cand, op_sched_info,
01087 TRUE)
01088 != best_cand_of_target_bb) {
01089 choose_current = TRUE ;
01090 }
01091
01092 break;
01093
01094 default:
01095 Fail_FmtAssertion ("Unknown fuzzy-comparision result\n");
01096 }
01097
01098 if (choose_current) {
01099 best_cand_of_target_bb = cand;
01100 delay_of_best_cand_of_target_bb = op_sched_info->_delay;
01101 targ_bb_cand_heur = op_sched_info ;
01102 }
01103
01104 } else {
01105
01106 INT32 reach_prob =
01107 _cflow_mgr->Reachable_Prob (_target_block,home_bb);
01108
01109 float delay = op_sched_info->_delay * reach_prob;
01110 switch (Fuzzy_Cmp (delay,
01111 weigh_delay_of_best_cand_of_other_bb,
01112 DELAY_DEVIATION * REACH_PROB_SCALE)) {
01113 case SIGNIFICANT_LESS:
01114 break ;
01115
01116 case SIGNIFICANT_GREAT:
01117
01118 if (_trace_cand_sel) {
01119 fprintf (_trace_file,
01120 "best cand of non-targ-bb change to [OP%3d][BB%3d] "
01121 "since its delay is significantly greater (%f)\n",
01122 OP_map_idx(cand->Op()),
01123 BB_id(OP_bb(cand->Op())),
01124 op_sched_info->_delay);
01125 }
01126 choose_current = TRUE; break ;
01127
01128 case ROUGHLY_EQU :
01129 if (Choose_Better_Of_Tie (best_cand_of_other_bb,
01130 other_bb_cand_heur,
01131 cand, op_sched_info,
01132 FALSE)
01133 != best_cand_of_other_bb) {
01134 choose_current = TRUE ;
01135 }
01136
01137 break ;
01138
01139 default :
01140 Fail_FmtAssertion ("Unknown fuzzy-comparison result\n");
01141 }
01142
01143 if (choose_current) {
01144 best_cand_of_other_bb = cand ;
01145 weigh_delay_of_best_cand_of_other_bb = delay;
01146 other_bb_cand_heur = op_sched_info ;
01147 }
01148
01149 }
01150
01151 }
01152
01153 CANDIDATE * best;
01154
01155 if (best_cand_of_other_bb &&
01156 weigh_delay_of_best_cand_of_other_bb >
01157 delay_of_best_cand_of_target_bb*REACH_PROB_SCALE &&
01158 !best_cand_of_other_bb->Is_Spec()) {
01159 best = best_cand_of_other_bb;
01160 } else {
01161 best = best_cand_of_target_bb ?
01162 best_cand_of_target_bb:
01163 best_cand_of_other_bb;
01164 }
01165
01166 if (_trace_cand_sel) {
01167 fprintf (_trace_file,
01168 "At last the best candidate is [OP%3d][BB%3d]\n",
01169 OP_map_idx(best->Op()),
01170 BB_id(OP_bb(best->Op())));
01171 }
01172
01173 Is_True (best != NULL,
01174 ("there are must be at least one candidate"));
01175
01176 return best ;
01177
01178 }
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189 CANDIDATE*
01190 FAVOR_DELAY_HEUR :: Select_Best_Candidate (
01191 CAND_LIST& m_ready_cand_lst,
01192 CAND_LIST& p_ready_cand_lst,
01193 BB* target,
01194 E_Time_Constraint* etime_constraint) {
01195
01196 E_Time_Constraint Metc_tmp = *etime_constraint;
01197
01198 if (IPFEC_Stress_Spec) {
01199 return Select_Best_Candidate_For_Stress_Spec_Purpose (
01200 m_ready_cand_lst,
01201 p_ready_cand_lst,
01202 target,
01203 etime_constraint);
01204 }
01205
01206
01207
01208
01209 CANDIDATE* m_cand = Select_Best_Candidate (
01210 m_ready_cand_lst,
01211 target,
01212 &Metc_tmp);
01213
01214 if (m_cand) {
01215
01216
01217
01218
01219
01220
01221
01222 } else {
01223 Is_True (m_ready_cand_lst.All_Cands_Have_Been_Tried (),
01224 ("There are at least one M-ready candidate "
01225 "for BB:%d\n", BB_id (target)));
01226 }
01227
01228
01229
01230 CANDIDATE* p_cand = NULL;
01231 E_Time_Constraint Petc_tmp = *etime_constraint;
01232
01233 if (p_ready_cand_lst.All_Cands_Have_Been_Tried () ||
01234 !(p_cand = Select_Best_Candidate
01235 (p_ready_cand_lst, target, &Petc_tmp))) {
01236
01237 *etime_constraint = Metc_tmp ;
01238 return m_cand;
01239 }
01240
01241
01242
01243
01244 BOOL choose_m_cand = TRUE;
01245
01246 if (!m_cand) {
01247 choose_m_cand = FALSE;
01248 } else {
01249
01250
01251 switch (etime_constraint->constraint) {
01252 case AS_EARLY_AS_POSSIBLE:
01253 {
01254 CYCLE immediate_prev_cyc = etime_constraint->threshold;
01255 if (Metc_tmp.threshold > immediate_prev_cyc + 1 &&
01256 Metc_tmp.threshold > Petc_tmp.threshold) {
01257 choose_m_cand = FALSE;
01258 }
01259 }
01260 break;
01261
01262 case NO_LATER:
01263
01264
01265
01266
01267 break;
01268
01269 default:
01270 FmtAssert (FALSE, ("Unknown constraint!"));
01271 }
01272 }
01273
01274 if (choose_m_cand) {
01275 *etime_constraint = Metc_tmp;
01276 return m_cand;
01277 }
01278
01279 *etime_constraint = Petc_tmp;
01280 return p_cand;
01281 }
01282
01283
01284 CYCLE
01285 FAVOR_DELAY_HEUR :: Get_Cand_Issue_Cyc (CANDIDATE *cand) {
01286 return Get_OP_Heur_Info (cand->Op()) -> _e_time ;
01287 }
01288
01289 void
01290 FAVOR_DELAY_HEUR :: Adjust_Heur_After_Cand_Sched
01291 (OP *op, CYCLE issue_cyc) {
01292
01293 for (ARC_LIST* arcs = OP_succs(op);
01294 arcs != NULL;
01295 arcs = ARC_LIST_rest(arcs)) {
01296
01297 ARC * arc = ARC_LIST_first(arcs);
01298 OP * succ = ARC_succ(arc);
01299 mUINT16 latency = ARC_latency (arc);
01300
01301 OP_HEUR_INFO * op_info = Get_OP_Heur_Info (succ) ;
01302
01303 Is_True (op_info,
01304 ("OP[%d] of BB:%d has no heuristic data!",
01305 OP_map_idx(succ), BB_id(OP_bb(succ))));
01306
01307 CYCLE succ_issue_cyc =
01308 op_info->_etime_set_by_which_bb == OP_bb(op) ?
01309 op_info->_e_time : 0 ;
01310
01311 if (!latency) {
01312 succ_issue_cyc = max(issue_cyc, succ_issue_cyc) ;
01313 } else if (issue_cyc + 1 >= succ_issue_cyc) {
01314 succ_issue_cyc = issue_cyc + 1;
01315 }
01316
01317 op_info->_e_time = succ_issue_cyc ;
01318 op_info->_etime_set_by_which_bb = _target_block ;
01319 }
01320 }
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330 void
01331 FAVOR_DELAY_HEUR:: Adjust_Heur_After_Sched_One_Cyc
01332 (OP_Vector& op_vect, CYCLE issue_cyc) {
01333
01334 for (OP_Vector_Iter iter = op_vect.begin () ;
01335 iter != op_vect.end () ; iter ++) {
01336
01337 OP * op = *iter ;
01338 for (ARC_LIST* arcs = OP_succs(op);
01339 arcs != NULL;
01340 arcs = ARC_LIST_rest(arcs)) {
01341
01342 ARC* arc = ARC_LIST_first(arcs);
01343 OP* succ = ARC_succ(arc);
01344
01345 extern BOOL Is_MMX_Dependency (OP*, OP*,CG_DEP_KIND) ;
01346 extern INT32 MMX_Dep_Latency (void);
01347
01348 if (Is_MMX_Dependency (ARC_pred(arc), ARC_succ(arc),
01349 ARC_kind(arc))) {
01350 INT32 l = MMX_Dep_Latency ();
01351 if (l > ARC_latency(arc)) {
01352 arc->latency = l;
01353 }
01354 }
01355
01356 mUINT16 latency = ARC_latency (arc);
01357
01358 if (IPFEC_Adjust_Variable_Latency) {
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369 latency += CGTARG_adjust_latency (
01370 arc,
01371 ip_invalid,
01372 ip_invalid);
01373 }
01374
01375 OP_HEUR_INFO* op_info = Get_OP_Heur_Info (succ) ;
01376
01377 Is_True (op_info,
01378 ("OP[%d] of BB:%d has no heuristic data!",
01379 OP_map_idx(succ), BB_id(OP_bb(succ))));
01380
01381 CYCLE succ_issue_cyc =
01382 op_info->_etime_set_by_which_bb == OP_bb(op) ?
01383 op_info->_e_time : 0 ;
01384
01385 if (issue_cyc + latency > succ_issue_cyc) {
01386 succ_issue_cyc = issue_cyc + latency ;
01387 }
01388
01389 op_info->_e_time = succ_issue_cyc ;
01390 op_info->_etime_set_by_which_bb = _target_block ;
01391
01392 }
01393
01394 }
01395 }
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405 BOOL
01406 FAVOR_DELAY_HEUR :: Upward_Global_Sched_Is_Profitable
01407 (CANDIDATE* cand, SRC_BB_INFO* bb_info,
01408 RGN_CFLOW_MGR* cflow_info) {
01409
01410 if (cand->Is_Spec ()) {
01411 return Upward_Spec_Global_Sched_Is_Profitable
01412 (cand, bb_info, cflow_info);
01413 }
01414
01415 return Upward_Useful_Sched_Is_Profitable
01416 (cand, bb_info, cflow_info);
01417 }
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432 BOOL
01433 FAVOR_DELAY_HEUR :: Upward_Code_Motion_Inc_Live_Range_Greatly
01434 (CANDIDATE* cand, SRC_BB_INFO* bb_info,
01435 RGN_CFLOW_MGR* cflow_info) {
01436
01437 REGION_VECTOR* rv = cand->Move_Across_Rgns ();
01438 OP* op = cand->Op ();
01439
01440 if (rv->size () > 0) {
01441
01442 BOOKEEPING_LST* bkl = cand->Bookeeping_Lst ();
01443 BOOKEEPING* bk;
01444
01445 for (REGION_VECTOR_ITER iter = rv->begin () ;
01446 iter != rv->end ();
01447 ++ iter) {
01448
01449 REGION* r = *iter ;
01450 if (!Is_Large_Region (r)) {
01451 continue;
01452 }
01453
01454 for (bk = bkl->First_Item ();
01455 bk != NULL;
01456 bk = bkl->Next_Item (bk)) {
01457
01458 INT inc_live_out = 0 ;
01459 BB* cs_elem = bk->Get_Placement ();
01460
01461 for (INT i = OP_results (op) - 1 ; i >= 0 ; i--) {
01462
01463 TN * result = OP_result(op, i) ;
01464 if (TN_is_constant (result) ||
01465 TN_is_const_reg(result)) {
01466 continue ;
01467 }
01468
01469 if (!TN_is_global_reg(result)) {
01470 ++ inc_live_out;
01471 } else if (GRA_LIVE_TN_Live_Outof_BB (result,cs_elem)) {
01472 -- inc_live_out ;
01473 } else {
01474 ++ inc_live_out ;
01475 }
01476
01477 }
01478
01479 for (INT i = OP_opnds (op) - 1 ; i >= 0 ; i--) {
01480
01481 TN * src_opnd = OP_opnd(op,i);
01482 if (TN_is_constant(src_opnd) ||
01483 TN_is_const_reg(src_opnd)) {
01484 continue ;
01485 }
01486
01487 if (!TN_is_global_reg(src_opnd)) {
01488 ++ inc_live_out;
01489 } else if (GRA_LIVE_TN_Live_Outof_BB (src_opnd,cs_elem)) {
01490 -- inc_live_out ;
01491 } else {
01492 ++ inc_live_out ;
01493 }
01494 }
01495
01496 if (inc_live_out > 0) {
01497 return TRUE;
01498 }
01499 }
01500
01501 }
01502 }
01503
01504 return FALSE ;
01505 }
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521 BOOL
01522 FAVOR_DELAY_HEUR::Upward_Spec_Global_Sched_Is_Profitable
01523 (CANDIDATE* cand, SRC_BB_INFO* bb_info,
01524 RGN_CFLOW_MGR* cflow_info) {
01525
01526 OP* op = cand->Op ();
01527 BB* home = OP_bb(op);
01528 PROBABILITY useful_exec_prob = cand->Useful_Exec_Prob ();
01529
01530 Is_True (cand->Spec_Type () != SPEC_NONE,
01531 ("candidate's code motion type is expected to be speculation"));
01532
01533
01534 INT32 across_chk_num = 0;
01535 INT32 data_spec_num = 0 ;
01536 INT32 cntl_spec_num = 0;
01537
01538 if (OP_load (op)) {
01539
01540
01541 INT32 spec_count = 0 ;
01542
01543 UNRESOLVED_DEP* dep ;
01544 UNRESOLVED_DEP_LST* dep_lst = cand->Unresolved_Dep_List();
01545
01546 for (dep = dep_lst->First_Item ();
01547 dep != NULL;
01548 dep = dep_lst->Next_Item(dep)) {
01549
01550 SPEC_TYPE spec_type = dep->Spec_Type ();
01551
01552 switch (spec_type) {
01553 case SPEC_NONE :
01554 continue;
01555
01556 case SPEC_CNTL :
01557 if (OP_chk(dep->Pred ())) {
01558 ++across_chk_num ;
01559 }
01560
01561 ++ cntl_spec_num ;
01562 break ;
01563
01564 case SPEC_DATA :
01565 ++ data_spec_num ;
01566 break ;
01567
01568 default:
01569 Fail_FmtAssertion("Unknown SPEC_TYPE(%d) \n", spec_type);
01570 }
01571
01572 }
01573
01574
01575 if (across_chk_num > LD_VIOLATE_CHK_DEP_MAX ||
01576 data_spec_num > LD_VIOLATE_DATA_DEP_MAX ||
01577 cntl_spec_num > LD_VIOLATE_CNTL_DEP_MAX) {
01578 return FALSE ;
01579 }
01580
01581 if (OP_no_alias (op) ||
01582 Load_Has_Valid_Vaddr (op) && !across_chk_num && !data_spec_num) {
01583
01584
01585
01586
01587 if (useful_exec_prob <
01588 SPEC_SAFE_LOAD_WITHOUT_TRANSFORM_REACH_PROB) {
01589 return FALSE;
01590 }
01591 } else if (useful_exec_prob < UNSAFE_CNTL_SPEC_PROB) {
01592 return FALSE;
01593 }
01594
01595 } else if (SAFE_CNTL_SPEC_PROB > useful_exec_prob) {
01596 return FALSE;
01597 }
01598
01599 return !Upward_Code_Motion_Inc_Live_Range_Greatly
01600 (cand, bb_info, cflow_info);
01601 }
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618 BOOL
01619 FAVOR_DELAY_HEUR::Upward_Useful_Sched_Is_Profitable
01620 (CANDIDATE* cand, SRC_BB_INFO* bb_info,
01621 RGN_CFLOW_MGR* cflow_info) {
01622
01623 return !Upward_Code_Motion_Inc_Live_Range_Greatly
01624 (cand, bb_info, cflow_info);
01625 }
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635 BOOL
01636 FAVOR_DELAY_HEUR::Renaming_Is_Profitable (CANDIDATE *cand)
01637 {
01638 OP* op = cand->Op();
01639 BB* home_bb = OP_bb(op);
01640
01641
01642
01643
01644
01645
01646
01647
01648
01649
01650 if (OP_results(op) != 1 || TN_is_dedicated(OP_result(op, 0)) ||
01651 OP_renamed(op) || OP_cond_def(op) || OP_speculative(op) && OP_load(op))
01652 return FALSE;
01653
01654
01655 for (ARC_LIST* arcs = OP_succs(op); arcs; ) {
01656 ARC *arc = ARC_LIST_first(arcs);
01657 arcs = ARC_LIST_rest(arcs);
01658 OP* succ = ARC_succ (arc);
01659 if (ARC_kind(arc) == CG_DEP_REGIN &&
01660 !(OP_speculative(succ) && OP_load(succ)) &&
01661 OP_bb(op) == OP_bb(succ))
01662 return TRUE;
01663 }
01664
01665 return FALSE;
01666 }
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678 BOOL
01679 FAVOR_DELAY_HEUR :: It_is_Better_No_New_Cycle_For_Cur_BB (void) {
01680
01681 return (_xfer_op && OP_Scheduled(_xfer_op)) ||
01682 OP_Scheduled(BB_last_op(_target_block));
01683
01684 }
01685
01686 CANDIDATE *
01687 FAVOR_DELAY_HEUR :: Select_Best_Candidate_For_Stress_Spec_Purpose
01688 (CAND_LIST& m_ready_cand_lst,
01689 CAND_LIST& p_ready_cand_lst,
01690 BB * targ,
01691 E_Time_Constraint * etime_constraint) {
01692
01693
01694 return NULL ;
01695 }
01696
01697 CANDIDATE*
01698 FAVOR_DELAY_HEUR :: Select_Best_Candidate_For_Stress_Spec_Purpose
01699 (CAND_LIST& cand_lst, BB * targ,
01700 E_Time_Constraint * etime_constraint) {
01701
01702
01703 return NULL ;
01704 }