30 #define DEBUG_NAME "compiler2/Matcher"
32 #define OP_LABEL(p) ((p)->get_opcode())
33 #define LEFT_CHILD(p) (getOperand(p, 0))
34 #define RIGHT_CHILD(p) (getOperand(p, 1))
35 #define STATE_LABEL(p) (state_labels[p])
47 os::abort(
"Wildcard Instruction does not support Visitor");
65 LOG(
"Performing pattern matching" <<
nl);
68 LOG(
"Handling root node " << inst <<
nl);
70 LOG(
"Result: root is excluded node, must be handled manually" <<
nl);
75 roots[inst]->insert(_inst);
80 burm_label(inst, inst);
81 LOG(
"Result: " <<
nl);
90 LOG(
"Determining tree root nodes" <<
nl);
107 for (InstSetTy::const_iterator it =
inst_in_bb.begin(),
113 LOG(
"Found root: " << inst <<
" Reason: excluded node" <<
nl);
121 LOG(
"Found root: " << inst <<
" Reason: multiple users" <<
nl);
129 LOG(
"Found root: " << inst <<
" Reason: no users" <<
nl);
139 LOG(
"Found root: " << inst <<
" Reason: users in another basic block" <<
nl);
148 LOG(
"Found root: " << inst <<
" Reason: used by excluded node" <<
nl);
154 LOG(
"Found " <<
roots.size() <<
" roots" <<
nl);
165 if (proxyops->find(pos) != proxyops->end()){
166 shared_ptr<Instruction> proxy = (proxyops->find(pos)->second);
172 bool no_operand = (pos >= op->
op_size());
186 if (no_operand || dep ||
204 (*proxyops)[
pos] = proxy;
205 LOG(
"Creating proxy: " << op <<
" op " << pos <<
" (= " << operand <<
")" <<
nl);
211 revdeps[operand]->insert(root);
212 LOG(
"Proxied operand is dependency for " << root <<
nl);
221 const short *nts = burm_nts[eruleno];
225 std::string indentation;
226 for (i = 0; i <
indent; i++)
228 LOG(indentation << burm_string[eruleno] <<
" (Rule: " << eruleno <<
" Root: " << p <<
nl);
229 burm_kids(p, eruleno, kids);
230 for (i = 0; nts[
i]; i++)
235 LOG(
"root: " << inst <<
nl);
237 for (InstSetTy::const_iterator it =
roots[inst]->begin(),
e =
roots[inst]->end(); it !=
e; ++it){
241 for (InstSetTy::const_iterator it =
revdeps[inst]->begin(),
e =
revdeps[inst]->end(); it !=
e; ++it){
248 LOG(
"Scheduling:" <<
nl);
252 LOG(
"Scheduling Phi Instructions:" <<
nl);
256 (*i)->accept(*
LV,
true);
259 LOG(
"Dependencies btw. roots" <<
nl);
264 LOG(
"Scheduling Trees:" <<
nl);
266 LOG(
roots.size() <<
" trees left to schedule" <<
nl);
271 if (
i->second->size() > 0)
continue;
274 if (
i->first->to_EndInst() && (
roots.size() > 1))
continue;
275 candidate =
i->first;
280 candidate =
i->first;
284 LOG(
"Scheduling " << candidate <<
nl);
289 i->second->erase(candidate);
291 roots.erase(candidate);
298 LOG(
"Excluded node is lowered manually" <<
nl);
303 const short *nts = burm_nts[eruleno];
305 burm_kids(p, eruleno, kids);
306 for (
int i = 0; nts[
i];
i++)
312 if (burm_isinstruction[
id]){
314 LOG(inst <<
" is wildcard, no lowering required" <<
nl);
316 LOG(
"Rule " << burm_templates[
id] <<
" is basic Instruction, using LoweringVisitor" <<
nl);
320 LOG(
"Lowering " << inst <<
" with rule " << burm_templates[
id] <<
nl);
const_inst_iterator inst_end(const BeginInst *BI) const
Value * get_operand(size_t i)
virtual Instruction * to_Instruction()
virtual NoInst * to_NoInst()
UserListTy::const_iterator user_begin() const
const_inst_iterator inst_begin(const BeginInst *BI) const
static const ExcludeSetTy excluded_nodes
This Instruction mark the start of a basic block.
virtual void accept(InstructionVisitor &v, bool copyOperands)=0
Visitor.
virtual void lowerComplex(Instruction *I, int ruleId)
_Base::const_iterator const_iterator
alloc::set< Instruction * >::type InstSetTy
JNIEnv jthread jobject jclass jlong size
OperandListTy::const_iterator const_op_iterator
alloc::unordered_map< int, shared_ptr< Instruction > >::type ProxyMapByInstTy
InstID get_opcode() const
return the opcode of the instruction
void printDependencies(Instruction *inst)
void dumpCover(Instruction *p, int goalnt, int indent)
Instruction * getOperand(Instruction *op, unsigned pos)
virtual void accept(InstructionVisitor &v, bool copyOperands)
Visitor.
bool checkIsNodeExcluded(Instruction *inst)
Instruction * createProxy(Instruction *op, unsigned pos, Instruction *operand, bool dependency)
Instruction::InstID tmp[]
virtual Instruction * to_Instruction()
const_op_iterator op_begin() const
#define LOG(STMT)
Analogous to DEBUG.
alloc::unordered_set< Instruction * >::type::const_iterator const_inst_iterator
size_t user_size() const
Get the number of (unique) users.
virtual void accept(InstructionVisitor &v, bool copyOperands)
Visitor.
virtual BeginInst * get_BeginInst() const
Get the corresponding BeginInst.
virtual BeginInst * to_BeginInst()
alloc::set< Instruction::InstID >::type ExcludeSetTy
void lowerRule(Instruction *inst, RuleId id)
void lowerTree(Instruction *p, int goalnt)
const_op_iterator op_end() const
virtual PHIInst * to_PHIInst()