37 #define DEBUG_NAME "compiler2/GlobalValueNumberingPass"
41 "globalvaluenumberingpass","globalvaluenumberingpass",compiler2_stat)
43 "total number of CONSTInst nodes",compiler2_globalvaluenumberingpass_stat)
45 "total number of arithmetical nodes",compiler2_globalvaluenumberingpass_stat)
47 "total number of PHIInst nodes",compiler2_globalvaluenumberingpass_stat)
49 "total number of ARRAYBOUNDSCHECKInst nodes",compiler2_globalvaluenumberingpass_stat)
51 "number of redundant CONSTInst nodes",compiler2_globalvaluenumberingpass_stat)
53 "number of redundant arithmetical nodes",compiler2_globalvaluenumberingpass_stat)
55 "number of redundant PHIInst nodes",compiler2_globalvaluenumberingpass_stat)
57 "number of redundant ARRAYBOUNDSCHECKInst nodes",compiler2_globalvaluenumberingpass_stat)
60 if ((INST)->get_opcode() == Instruction::CONSTInstID) {
\
62 }
else if ((INST)->is_arithmetic()) {
\
64 }
else if ((INST)->get_opcode() == Instruction::PHIInstID) {
\
66 }
else if ((INST)->get_opcode() == Instruction::ARRAYBOUNDSCHECKInstID) {
\
69 #define STAT_TOTAL_NODES(INST) STAT_NODE_COUNT_HELPER(INST, 1, total)
70 #define STAT_REDUNDANT_NODES(INST, CNT) STAT_NODE_COUNT_HELPER(INST, CNT, redundant)
91 if (I->has_side_effects()
92 || I->get_opcode() == Instruction::LOADInstID
93 || I->get_opcode() == Instruction::ALOADInstID) {
100 CONSTInst *constInst = I->to_CONSTInst();
105 switch (constInst->get_type()) {
108 constInst->get_Int());
112 constInst->get_Long());
116 constInst->get_Float());
120 constInst->get_Double());
124 assert(0 &&
"illegal type");
132 PHIInst *phiInst = I->to_PHIInst();
134 BeginInst *bb = phiInst->get_BeginInst();
137 && !I->to_EndInst()) {
189 for (PartitionTy::const_iterator
i =
partition.begin(),
193 for (
int operandIndex = 0; operandIndex <
max_arity; operandIndex++) {
197 pair->second = operandIndex;
209 if (!inverseVector) {
214 inverseVector->push_back(users);
217 return (*inverseVector)[op_index];
225 oe = I->
op_end(); oi != oe; oi++) {
238 flags =
new std::vector<bool>(
max_arity);
246 (*flags)[
index] = flag;
251 return (*flags)[
index];
258 pair->second =
index;
285 assert(block->size() > instructions->size());
290 e = instructions->end();
i !=
e;
i++) {
296 for (
int operandIndex = 0; operandIndex <
max_arity; operandIndex++) {
298 && block->size() <= new_block->size()) {
307 for (PartitionTy::const_iterator
i =
partition.begin(),
310 if (block->size() > 1) {
348 e = instructions->end();
i !=
e;
i++) {
357 e = block->end();
i !=
e;
i++) {
366 for (PartitionTy::const_iterator
i =
partition.begin(),
368 LOG(
"=============================================================" <<
nl);
376 template <
typename T>
378 while (!lst->empty()) {
384 template <
typename T1,
typename T2,
typename Iterator>
393 template <
typename T1,
typename T2>
417 LOG(
"BEFORE PARTITIONING" <<
nl);
422 BlockTy *block = workListPair->first;
423 int operandIndex = workListPair->second;
426 std::list<BlockTy*> touched;
429 e = block->end();
i !=
e;
i++) {
433 for (InstructionListTy::const_iterator ui = usersForIndex->begin(),
434 ue = usersForIndex->end(); ui != ue; ui++) {
440 touched.push_back(userBlock);
443 touchedInstructions->insert(user);
450 for (std::list<BlockTy*>::const_iterator
i = touched.begin(),
451 e = touched.end();
i !=
e;
i++) {
455 if (touchedInstructions->size() > 0
456 && touchedBlock->size() != touchedInstructions->size()) {
457 LOG(
"split block (" << touchedBlock->size() <<
", " << touchedInstructions->size() <<
")" <<
nl);
461 split(touchedBlock, touchedInstructions);
463 touchedInstructions->clear();
467 LOG(
nl <<
"AFTER PARTITIONING" <<
nl);
BlockTy * get_block(Instruction *inst)
unordered_set< Instruction * > TouchedInstListTy
#define STATISTICS(x)
Wrapper for statistics only code.
const_dep_iterator rdep_begin() const
unordered_map< int64_t, BlockTy * > LongBlockMapTy
#define STAT_REGISTER_SUBGROUP(var, name, description, group)
Register a statistics group and add it to a group.
void init_worklist_and_touchedblocks()
unordered_map< int32_t, BlockTy * > IntBlockMapTy
void eliminate_redundancies()
_Base::const_iterator const_iterator
unordered_map< float, BlockTy * > FloatBlockMapTy
_Base::const_iterator const_iterator
InstructionListTy * get_users(Instruction *inst, int op_index)
void append_dep(Instruction *I)
std::list< Instruction * > InstructionListTy
unordered_map< double, BlockTy * > DoubleBlockMapTy
Inst2BlockMapTy inst2BlockMap
OperandListTy::const_iterator const_op_iterator
void add_schedule_before()
Schedule before PassName.
unordered_set< Instruction * > BlockTy
InstID get_opcode() const
return the opcode of the instruction
virtual bool run(JITData &JD)
Run the Pass.
bool is_in_worklist(BlockTy *block, int index)
void replace_value(Value *v)
Replace this Value this the new one in all users.
unordered_map< Instruction::InstID, BlockTy *, hash< int > > OpcodeBlockMapTy
these types are needed for the creation of the inital blocks
void delete_in_range(unordered_map< T1, T2 > *map, Iterator begin, Iterator end)
void set_in_worklist(BlockTy *block, int index, bool flag)
#define STAT_REDUNDANT_NODES(INST, CNT)
std::vector< bool > * get_worklist_flags(BlockTy *block)
void remove_dep(Instruction *I)
BlockTy * get_or_create_block(T1 &map, T2 key)
Stores the interdependencies of a pass.
void init_operand_inverse(Method::const_iterator begin, Method::const_iterator end)
#define STAT_REGISTER_GROUP_VAR(type, var, init, name, description, group)
Register an statistics variable and add it to a group.
Block2TouchedInstListMapTy block2TouchedInstListMap
virtual Instruction * to_Instruction()
void split(BlockTy *block, TouchedInstListTy *instructions)
const_dep_iterator rdep_end() const
void add_to_worklist(BlockTy *block, int operandIndex)
std::pair< BlockTy *, int > WorkListPairTy
unordered_map< BeginInst *, BlockTy * > BBBlockMapTy
DepListTy::const_iterator const_dep_iterator
InstructionListTy::const_iterator const_iterator
const_iterator end() const
const_op_iterator op_begin() const
static int arity(BlockTy *block)
std::vector< InstructionListTy * > OperandIndex2UsersTy
OperandInverseMapTy operandInverseMap
#define LOG(STMT)
Analogous to DEBUG.
void print_block(BlockTy *block)
static int compute_max_arity(Method::const_iterator begin, Method::const_iterator end)
jmethodID jint const void jint const jvmtiAddrLocationMap * map
#define STAT_TOTAL_NODES(INST)
#define STAT_DECLARE_GROUP(var)
Declare an external group (or subgroup).
const_iterator begin() const
TouchedInstListTy * get_touched_instructions(BlockTy *block)
void init_partition(Method::const_iterator begin, Method::const_iterator end)
void add_to_block(BlockTy *block, Instruction *inst)
virtual PassUsage & get_PassUsage(PassUsage &PU) const
Set the requirements for the pass.
void clean_up_operand_inverse()
WorkListPairTy * selectAndDeleteFromWorkList()
static PassRegistry< BasicBlockSchedulingPass > X("BasicBlockSchedulingPass")
BlockTy * create_block()
creates and returns a new block and does some setup work needed for the further execution of the part...
void print_instructions(TouchedInstListTy *instructions)
void eliminate_redundancies_in_block(BlockTy *block)
const_op_iterator op_end() const
void add_requires()
PassName is required.
#define STAT_NODE_COUNT_HELPER(INST, CNT, INFIX)