Added SEA IR def -> use edges (along the use -> def).
The edges are stored in the "tail" object and will be used for type information propagation.
The .dot generation nowhas a switch to enable or disable displaying these edges.
Change-Id: Iaf3ce1d1efcda6f5d65c42c69bb1573786c90309
diff --git a/compiler/sea_ir/instruction_nodes.h b/compiler/sea_ir/instruction_nodes.h
index 103c16f..6f9bddd 100644
--- a/compiler/sea_ir/instruction_nodes.h
+++ b/compiler/sea_ir/instruction_nodes.h
@@ -57,6 +57,7 @@
// essentially creating SSA form.
void RenameToSSA(int reg_no, InstructionNode* definition) {
definition_edges_.insert(std::pair<int, InstructionNode*>(reg_no, definition));
+ definition->AddSSAUse(this);
}
// Returns the ordered set of Instructions that define the input operands of this instruction.
// Precondition: SeaGraph.ConvertToSSA().
@@ -69,6 +70,10 @@
return ssa_uses;
}
+ virtual void AddSSAUse(InstructionNode* use) {
+ used_in_.push_back(use);
+ }
+
void Accept(IRVisitor* v) {
v->Visit(this);
v->Traverse(this);
@@ -85,11 +90,14 @@
protected:
explicit InstructionNode(const art::Instruction* in):
- SeaNode(), instruction_(in), de_def_(false), region_(NULL) { }
+ SeaNode(), instruction_(in), used_in_(), de_def_(false), region_(NULL) { }
+ void ToDotSSAEdges(std::string& result) const;
protected:
const art::Instruction* const instruction_;
std::map<int, InstructionNode* > definition_edges_;
+ // Stores pointers to instructions that use the result of the current instruction.
+ std::vector<InstructionNode*> used_in_;
bool de_def_;
Region* region_;
};
@@ -136,15 +144,7 @@
result += "style=bold";
}
result += "];\n";
- // SSA definitions:
- for (std::map<int, InstructionNode* >::const_iterator def_it = definition_edges_.begin();
- def_it != definition_edges_.end(); def_it++) {
- if (NULL != def_it->second) {
- result += def_it->second->StringId() + " -> " + StringId() +"[color=gray,label=\"";
- result += art::StringPrintf("vR = %d", def_it->first);
- result += "\"] ; // ssa edge\n";
- }
- }
+ ToDotSSAEdges(result);
}
private: