37 #define DEBUG_NAME "compiler2/BasicBlockSchedulingPass"
39 #define VERIFY_LOOP_PROPERTY 1
40 #define VERIFY_PRED_PROPERTY 1
81 subloops.insert(loop->loop_begin(),loop->loop_end());
86 while ( !unsched.empty() || !subloops.empty()) {
105 assert(unsched.empty() || !subloops.empty());
109 LOG3(
"schedule subloop of " << loop <<
nl);
116 LOG3(
"finished: " << loop <<
nl);
130 BeginListTy::const_iterator
end()
const {
return bb_sched.end(); }
135 LoopTree *LT = get_Pass<LoopPass>();
140 insert(
begin(),loop_scheduler.begin(),loop_scheduler.end());
146 std::random_shuffle(bbs.begin(),bbs.end());
152 LOG(
"BasicBlockSchedule:" <<
nl);
161 #if VERIFY_LOOP_PROPERTY
164 if (inner == outer)
return;
165 push_loops_inbetween(active,inner->
get_parent(),outer);
166 active.push_back(inner);
189 ERROR_MSG(
"Schedule does not start with init basic block!",
191 <<
" but schedule starts with " << *
bb_begin());
196 for (
unsigned i = 0,
e =
bb_list.size() ;
i <
e ; ++
i) {
201 EndInst::SuccessorListTy::const_iterator it = EI->
succ_begin();
211 #if VERIFY_PRED_PROPERTY || VERIFY_LOOP_PROPERTY
212 LoopTree *LT = get_Pass<LoopPass>();
214 #if VERIFY_PRED_PROPERTY
223 if (handled.find(pred) == handled.end() && !LT->
is_backedge(pred,BI)) {
224 ERROR_MSG(
"Predecessor property violated!",
"predecessor (" << *pred
225 <<
") of " << *BI <<
"not already scheduled" );
233 #if VERIFY_LOOP_PROPERTY
237 active.push_back(NULL);
242 Loop *top = active.back();
244 if ( loop && finished.find(loop) != finished.end()) {
245 ERROR_MSG(
"Loop property violated!",
"Loop " << *loop
246 <<
" already finished but " << *BI <<
" occurred" );
258 assert(!active.empty());
259 finished.insert(top);
263 push_loops_inbetween(active,loop,lca);
std::set< Key, Compare, Allocator< Key > > type
alloc::list< BeginInst * >::type BeginListTy
virtual bool verify() const
Verify the Result.
bool is_ready(BeginInst *BI) const
BBListTy::const_iterator const_bb_iterator
PredecessorListTy::const_iterator const_pred_iterator
T find_least_common_ancestor(T a, T b)
const_bb_iterator bb_end() const
loop_iterator loop_begin()
This Instruction mark the start of a basic block.
This Instruction mark the end of a basic block.
std::deque< T, Allocator< T > > type
alloc::unordered_set< BeginInst * >::type BeginSetTy
virtual IFInst * to_IFInst()
#define ERROR_MSG(EXPR_SHORT, EXPR_LONG)
const_pred_iterator pred_begin() const
LoopScheduler(Method *M, LoopTree *LT)
constructor
std::list< T, Allocator< T > > type
alloc::unordered_set< Loop * >::type LoopSetTy
alloc::map< BeginInst *, BeginSetTy >::type DomSuccMapTy
BeginListTy::const_iterator end() const
SuccessorListTy::const_iterator succ_end() const
LoopBase * get_parent() const
Stores the interdependencies of a pass.
EndInst * get_EndInst() const
bool is_backedge(NodeType *src, NodeType *header) const
const_bb_iterator bb_end() const
void insert(bb_iterator pos, InputIterator first, InputIterator last)
alloc::set< BeginInst * >::type BeginSchedMapTy
Loop * get_parent(Loop *a)
SuccessorListTy::const_iterator succ_begin() const
const_bb_iterator bb_begin() const
bool is_scheduled(BeginInst *BI) const
#define LOG(STMT)
Analogous to DEBUG.
const_pred_iterator pred_end() const
BasicBlockListTy::const_iterator const_bb_iterator
virtual bool run(JITData &JD)
Run the Pass.
NodeType * get_header() const
LoopType * get_Loop(NodeType *BI) const
Get the inner most loop which contains BI or NULL if not contained in any loop.
static PassRegistry< BasicBlockSchedulingPass > X("BasicBlockSchedulingPass")
alloc::map< Loop *, BeginSetTy >::type LoopMapTy
virtual PassUsage & get_PassUsage(PassUsage &PA) const
Set the requirements for the pass.
void schedule_loop(Loop *loop)
BeginInst * get_init_bb() const
void add_requires()
PassName is required.
BeginListTy::const_iterator begin() const
const_bb_iterator bb_begin() const