CACAO
ScheduleEarlyPass.cpp
Go to the documentation of this file.
1 /* src/vm/jit/compiler2/ScheduleEarlyPass.cpp - ScheduleEarlyPass
2 
3  Copyright (C) 2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
32 
33 #include "toolbox/logging.hpp"
34 
35 #define DEBUG_NAME "compiler2/ScheduleEarly"
36 
37 namespace cacao {
38 namespace jit {
39 namespace compiler2 {
40 
42  LOG("schedule_early: " << I << nl);
43  for (Instruction::OperandListTy::const_iterator i = I->op_begin(),
44  e = I->op_end(); i != e; ++i) {
45  Instruction *op = (*i)->to_Instruction();
46  if (op && !op->get_BeginInst()) {
47  schedule_early(op);
48  }
49  }
50  if (I->get_BeginInst())
51  return;
52  BeginInst* block = NULL;
53  Instruction::OperandListTy::const_iterator i = I->op_begin();
54  Instruction::OperandListTy::const_iterator e = I->op_end();
55 
56  if (I->op_size() == 0) {
58  return;
59  }
60  for (;i != e; ++i) {
61  Instruction *op = (*i)->to_Instruction();
62  if (op) {
63  block = op->get_BeginInst();
64  ++i;
65  assert(block);
66  break;
67  }
68 
69  }
70  for ( ; i != e; ++i) {
71  Instruction *op = (*i)->to_Instruction();
72  if (op) {
73  BeginInst* i_block = op->get_BeginInst();
74  assert(i_block);
75  if ( DT->depth(block) < DT->depth(i_block) ) {
76  block = i_block;
77  }
78  }
79  }
80  assert(block);
81  I->set_BeginInst(block);
82 }
83 
85  DT = get_Pass<DominatorPass>();
86  M = JD.get_Method();
87  for (Method::InstructionListTy::const_iterator i = M->begin(),
88  e = M->end() ; i != e ; ++i) {
89  schedule_early(*i);
90  }
91  set_schedule(M);
92  // clear schedule
93  M->clear_schedule();
94  return true;
95 }
96 
100  return PU;
101 }
102 // the address of this variable is used to identify the pass
103 char ScheduleEarlyPass::ID = 0;
104 
105 // registrate Pass
106 static PassRegistry<ScheduleEarlyPass> X("ScheduleEarlyPass");
107 
108 } // end namespace compiler2
109 } // end namespace jit
110 } // end namespace cacao
111 
112 
113 /*
114  * These are local overrides for various environment variables in Emacs.
115  * Please do not remove this and leave it at the end of the file, where
116  * Emacs will automagically detect them.
117  * ---------------------------------------------------------------------
118  * Local variables:
119  * mode: c++
120  * indent-tabs-mode: t
121  * c-basic-offset: 4
122  * tab-width: 4
123  * End:
124  * vim:noexpandtab:sw=4:ts=4:
125  */
This Instruction mark the start of a basic block.
u2 op
Definition: disass.cpp:129
virtual PassUsage & get_PassUsage(PassUsage &PU) const
Set the requirements for the pass.
BeginInst *& block
int depth(NodeTy *node) const
Depth of a tree node.
virtual bool run(JITData &JD)
Run the Pass.
Stores the interdependencies of a pass.
Definition: PassUsage.hpp:55
Instruction super class.
Definition: Instruction.hpp:73
MIIterator i
const_op_iterator op_begin() const
MIIterator e
#define LOG(STMT)
Analogous to DEBUG.
Definition: logging.hpp:91
#define I(value)
Definition: codegen.c:279
virtual bool set_BeginInst(BeginInst *b)
virtual BeginInst * get_BeginInst() const
Get the corresponding BeginInst.
static PassRegistry< BasicBlockSchedulingPass > X("BasicBlockSchedulingPass")
Nl nl
Definition: OStream.cpp:56
const_op_iterator op_end() const
BeginInst * get_init_bb() const
Definition: MethodC2.hpp:133
void add_requires()
PassName is required.
Definition: PassUsage.hpp:78
Calculate the Dominator Tree.