13 #ifndef LLVM_ANALYSIS_DDG_H 14 #define LLVM_ANALYSIS_DDG_H 116 InstList = N.InstList;
122 InstList = std::move(N.InstList);
128 assert(!InstList.empty() &&
"Instruction List is empty.");
133 static_cast<const SimpleDDGNode *
>(
this)->getInstructions());
150 setKind((InstList.size() == 0 && Input.
size() == 1)
153 InstList.insert(InstList.end(), Input.
begin(), Input.
end());
248 bool isDefUse()
const {
return Kind == EdgeKind::RegisterDefUse; }
255 bool isRooted()
const {
return Kind == EdgeKind::Rooted; }
270 :
Name(N), DI(DepInfo),
Root(nullptr) {}
280 assert(
Root &&
"Root node is not available yet. Graph construction may " 281 "still be in progress\n");
349 assert(
RN &&
"Failed to allocate memory for DDG root node.");
355 assert(SN &&
"Failed to allocate memory for simple DDG node.");
361 assert(Pi &&
"Failed to allocate memory for pi-block node.");
367 assert(
E &&
"Failed to allocate memory for edge");
368 Graph.connect(Src, Tgt, *
E);
373 assert(
E &&
"Failed to allocate memory for edge");
374 Graph.connect(Src, Tgt, *
E);
379 assert(
E &&
"Failed to allocate memory for edge");
380 assert(isa<RootDDGNode>(Src) &&
"Expected root node");
381 Graph.connect(Src, Tgt, *
E);
387 assert(PiNode &&
"Expected a pi-block node.");
388 return PiNode->getNodes();
391 bool shouldCreatePiBlocks()
const final override;
407 using Result = std::unique_ptr<DataDependenceGraph>;
515 #endif // LLVM_ANALYSIS_DDG_H
DataDependenceGraph::const_iterator nodes_iterator
DGEdge< NodeType, EdgeType > & operator=(const DGEdge< NodeType, EdgeType > &E)
DDGEdge(const DDGEdge &E)
static NodeRef getEntryNode(const DataDependenceGraph *DG)
DDGNode & operator=(DDGNode &&N)
NodeType & getRoot() const
Return the root node of the graph.
This class represents lattice values for constants.
static bool classof(const DDGNode *N)
Define classof to be able to use isa<>, cast<>, dyn_cast<>, etc.
static nodes_iterator nodes_end(DataDependenceGraph *DG)
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
static NodeRef getEntryNode(NodeRef N)
Data Dependency Graph Edge.
Data Dependence Graph Node The graph can represent the following types of nodes:
DataDependenceGraph(DataDependenceGraph &&G)
static ChildIteratorType child_begin(NodeRef N)
virtual ~DependenceGraphInfo()
DDGAnalysisPrinterPass(raw_ostream &OS)
DDGEdge & operator=(DDGEdge &&E)
DDGEdge & createMemoryEdge(DDGNode &Src, DDGNode &Tgt) final override
SimpleDDGNode & operator=(SimpleDDGNode &&N)
static nodes_iterator nodes_end(const DataDependenceGraph *DG)
const NodeType & getTargetNode() const
Retrieve the target node this edge connects to.
static ChildEdgeIteratorType child_edge_begin(NodeRef N)
const InstructionListType & getInstructions() const
Get the list of instructions in this node.
An efficient, type-erasing, non-owning reference to a callable.
static nodes_iterator nodes_begin(DataDependenceGraph *DG)
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
void setKind(NodeKind K)
Setter for the kind of this node.
DependenceInfo - This class is the main dependence-analysis driver.
bool isMemoryDependence() const
Return true if this is a memory dependence edge, and false otherwise.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
static ChildEdgeIteratorType child_edge_begin(NodeRef N)
Concrete implementation of a pure data dependence graph builder.
const_iterator begin() const
static nodes_iterator nodes_begin(const DataDependenceGraph *DG)
PiBlockDDGNode & operator=(PiBlockDDGNode &&N)
static ChildEdgeIteratorType child_edge_end(NodeRef N)
DDGNode & operator=(const DDGNode &N)
DDGBuilder(DataDependenceGraph &G, DependenceInfo &D, const BasicBlockListType &BBs)
DDGNode & createRootNode() final override
Create the root node of the graph.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
DGNode< NodeType, EdgeType > & operator=(const DGNode< NodeType, EdgeType > &N)
Subclass of DDGNode representing a pi-block.
Instruction * getFirstInstruction() const
Get the first/last instruction in the node.
bool isRooted() const
Return true if this is an edge stemming from the root node, and false otherwise.
A CRTP mix-in to automatically provide informational APIs needed for passes.
DDGNode & createPiBlock(const NodeListType &L) final override
Create a pi-block node in the graph representing a group of nodes in an SCC of the graph...
DDGEdge & operator=(const DDGEdge &E)
typename EdgeListTy::const_iterator const_iterator
This header provides classes for managing per-loop analyses.
static ChildIteratorType child_begin(NodeRef N)
static NodeRef getEntryNode(DataDependenceGraph *DG)
EdgeKind getKind() const
Get the edge kind.
Textual printer pass for the DDG of a loop.
DDGNode(const NodeKind K)
SimpleDDGNode & operator=(const SimpleDDGNode &N)
typename DDGNode *::UnknownGraphTypeError NodeRef
const_iterator end() const
A set of analyses that are preserved following a run of a transformation pass.
Represent an edge in the directed graph.
EdgeKind
The kind of edge in the DDG.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static ChildIteratorType child_end(NodeRef N)
A CRTP mix-in that provides informational APIs needed for analysis passes.
static bool classof(const RootDDGNode *N)
const StringRef getName() const
Return the label that is used to name this graph.
NodeKind getKind() const
Getter for the kind of this node.
Determine the kind of a node from its type.
DDGEdge & createRootedEdge(DDGNode &Src, DDGNode &Tgt) final override
static ChildEdgeIteratorType child_edge_end(NodeRef N)
const versions of the grapth trait specializations for DDG
DDGNode & createFineGrainedNode(Instruction &I) final override
Create an atomic node in the graph given a single instruction.
static DDGNode * DDGGetTargetNode(DGEdge< DDGNode, DDGEdge > *P)
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
std::unique_ptr< DataDependenceGraph > Result
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
InstructionListType & getInstructions()
Encapsulate some common data and functionality needed for different variations of data dependence gra...
Represent a node in the directed graph.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
bool isDefUse() const
Return true if this is a def-use edge, and false otherwise.
DDGNode::const_iterator ChildEdgeIteratorType
const_iterator end() const
const PiNodeList & getNodes() const
Get the list of nodes in this pi-block.
Instruction * getLastInstruction() const
const NodeListType & getNodesInPiBlock(const DDGNode &N) final override
Subclass of DDGNode representing the root node of the graph.
SmallVector< NodeAddr< NodeBase * >, 4 > NodeList
non-const versions of the grapth trait specializations for DDG
Analysis pass that builds the DDG for a loop.
RootDDGNode(RootDDGNode &&N)
DependenceGraphInfo(const std::string &N, const DependenceInfo &DepInfo)
static const DDGNode * DDGGetTargetNode(const DGEdge< DDGNode, DDGEdge > *P)
Represents a single loop in the control flow graph.
typename EdgeListTy::iterator iterator
typename NodeListTy::const_iterator const_iterator
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
static NodeRef getEntryNode(NodeRef N)
static bool classof(const SimpleDDGNode *N)
DDGNode::iterator ChildEdgeIteratorType
static ChildIteratorType child_end(NodeRef N)
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
PiBlockDDGNode & operator=(const PiBlockDDGNode &N)
DependenceGraphInfo(DependenceGraphInfo &&G)
Subclass of DDGNode representing single or multi-instruction nodes.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
typename NodeListTy::iterator iterator
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
DataDependenceGraph::iterator nodes_iterator
A container for analyses that lazily runs them and caches their results.
DDGEdge & createDefUseEdge(DDGNode &Src, DDGNode &Tgt) final override
DDGNode(const DDGNode &N)
static bool classof(const DDGNode *N)
Define classof to be able to use isa<>, cast<>, dyn_cast<>, etc.
static bool classof(const DDGNode *N)
Define classof to be able to use isa<>, cast<>, dyn_cast<>, etc.
const_iterator begin() const
A special type used by analysis passes to provide an address that identifies that particular analysis...
bool collectInstructions(llvm::function_ref< bool(Instruction *)> const &Pred, InstructionListType &IList) const
Collect a list of instructions, in IList, for which predicate Pred evaluates to true when iterating o...
DDGEdge(DDGNode &N, EdgeKind K)