37 #define DEBUG_NAME "compiler2/ScheduleLate"
45 struct ScheduleLate :
public std::unary_function<Instruction*,void> {
50 ScheduleLate(Instruction *
I, BeginInst *&
block, DominatorTree *
DT) :
51 I(I), block(block), DT(DT) {}
54 void operator()(Instruction* user) {
56 assert(user->get_BeginInst());
57 PHIInst *phi = user->to_PHIInst();
59 int index = phi->get_operand_index(
I);
61 BeginInst *pred = phi->get_BeginInst()->get_predecessor(index);
64 block =
DT->find_nearest_common_dom(
block,user->get_BeginInst());
70 struct ScheduleUser :
public std::unary_function<Instruction*,void> {
72 ScheduleUser(ScheduleLatePass *
parent) : parent(parent) {}
73 void operator()(Instruction* user) {
75 if (!user->get_BeginInst()) {
76 parent->schedule_late(user);
90 LOG1(
"schedule_late: " << I <<
nl);
101 LOG(
"scheduled to " << block <<
nl);
118 LOG1(
"Sched.Late: " << latest <<
nl);
121 while (latest != earliest) {
126 <<
" Loop latest: " << latest <<
" " <<
LT->
loop_nest(loop_latest) <<
nl);
133 LOG(
"scheduled to " << best <<
nl);
139 DT = get_Pass<DominatorPass>();
140 LT = get_Pass<LoopPass>();
141 early = get_Pass<ScheduleEarlyPass>();
143 for (Method::InstructionListTy::const_iterator
i = M->begin(),
144 e = M->end() ;
i !=
e ; ++
i) {
145 if ((*i)->is_floating()) {
146 (*i)->set_BeginInst(NULL);
149 for (Method::InstructionListTy::const_iterator
i = M->begin(),
150 e = M->end() ;
i !=
e ; ++
i) {
virtual bool run(JITData &JD)
Run the Pass.
const_dep_iterator rdep_begin() const
bool is_inner_loop(LoopType *inner, LoopType *outer) const
Test if a loop is a strictly inner loop of another loop.
UserListTy::const_iterator user_begin() const
This Instruction marks the start of a basic block.
void schedule_late(Instruction *I)
UserListTy::const_iterator user_end() const
InstID get_opcode() const
return the opcode of the instruction
NodeTy * get_idominator(NodeTy *a) const
Get the immediate dominator.
Stores the interdependencies of a pass.
void set_schedule(const Method *M)
const_dep_iterator rdep_end() const
BeginInst * get(const Instruction *I) const
#define LOG(STMT)
Analogous to DEBUG.
virtual PassUsage & get_PassUsage(PassUsage &PU) const
Set the requirements for the pass.
virtual bool set_BeginInst(BeginInst *b)
virtual BeginInst * get_BeginInst() const
Get the corresponding BeginInst.
int loop_nest(LoopType *loop) const
TODO: cache?
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")
void add_requires()
PassName is required.
Calculate the Dominator Tree.