|
LLVM
10.0.0
|
This abstract builder class defines a set of high-level steps for creating DDG-like graphs. More...
#include "llvm/Analysis/DependenceGraphBuilder.h"
Public Types | |
| using | ClassesType = EquivalenceClasses< BasicBlock * > |
| using | NodeListType = SmallVector< NodeType *, 4 > |
Public Member Functions | |
| AbstractDependenceGraphBuilder (GraphType &G, DependenceInfo &D, const BasicBlockListType &BBs) | |
| virtual | ~AbstractDependenceGraphBuilder () |
| void | populate () |
| The main entry to the graph construction algorithm. More... | |
| void | computeInstructionOrdinals () |
| Compute ordinal numbers for each instruction and store them in a map for future look up. More... | |
| void | createFineGrainedNodes () |
| Create fine grained nodes. More... | |
| void | createDefUseEdges () |
| Analyze the def-use chains and create edges from the nodes containing definitions to the nodes containing the uses. More... | |
| void | createMemoryDependencyEdges () |
| Analyze data dependencies that exist between memory loads or stores, in the graph nodes and create edges between them. More... | |
| void | createAndConnectRootNode () |
| Create a root node and add edges such that each node in the graph is reachable from the root. More... | |
| void | createPiBlocks () |
| Apply graph abstraction to groups of nodes that belong to a strongly connected component of the graph to create larger compound nodes called pi-blocks. More... | |
| void | sortNodesTopologically () |
| Topologically sort the graph nodes. More... | |
Protected Types | |
| using | BasicBlockListType = SmallVectorImpl< BasicBlock * > |
| using | InstToNodeMap = DenseMap< Instruction *, NodeType * > |
| Map types to map instructions to nodes used when populating the graph. More... | |
| using | InstToOrdinalMap = DenseMap< Instruction *, size_t > |
| Map Types to map instruction/nodes to an ordinal number. More... | |
| using | NodeToOrdinalMap = DenseMap< NodeType *, size_t > |
Protected Member Functions | |
| virtual NodeType & | createRootNode ()=0 |
| Create the root node of the graph. More... | |
| virtual NodeType & | createFineGrainedNode (Instruction &I)=0 |
| Create an atomic node in the graph given a single instruction. More... | |
| virtual NodeType & | createPiBlock (const NodeListType &L)=0 |
| Create a pi-block node in the graph representing a group of nodes in an SCC of the graph. More... | |
| virtual EdgeType & | createDefUseEdge (NodeType &Src, NodeType &Tgt)=0 |
Create a def-use edge going from Src to Tgt. More... | |
| virtual EdgeType & | createMemoryEdge (NodeType &Src, NodeType &Tgt)=0 |
Create a memory dependence edge going from Src to Tgt. More... | |
| virtual EdgeType & | createRootedEdge (NodeType &Src, NodeType &Tgt)=0 |
Create a rooted edge going from Src to Tgt . More... | |
| virtual const NodeListType & | getNodesInPiBlock (const NodeType &N)=0 |
| Given a pi-block node, return a vector of all the nodes contained within it. More... | |
| virtual void | destroyEdge (EdgeType &E) |
Deallocate memory of edge E. More... | |
| virtual void | destroyNode (NodeType &N) |
Deallocate memory of node N. More... | |
| virtual bool | shouldCreatePiBlocks () const |
| Return true if creation of pi-blocks are supported and desired, and false otherwise. More... | |
| size_t | getOrdinal (Instruction &I) |
Given an instruction I return its associated ordinal number. More... | |
| size_t | getOrdinal (NodeType &N) |
Given a node N return its associated ordinal number. More... | |
Protected Attributes | |
| GraphType & | Graph |
| Reference to the graph that gets built by a concrete implementation of this builder. More... | |
| DependenceInfo & | DI |
| Dependence information used to create memory dependence edges in the graph. More... | |
| const BasicBlockListType & | BBList |
| The list of basic blocks to consider when building the graph. More... | |
| InstToNodeMap | IMap |
| A mapping from instructions to the corresponding nodes in the graph. More... | |
| InstToOrdinalMap | InstOrdinalMap |
| A mapping from each instruction to an ordinal number. More... | |
| NodeToOrdinalMap | NodeOrdinalMap |
| A mapping from nodes to an ordinal number. More... | |
This abstract builder class defines a set of high-level steps for creating DDG-like graphs.
The client code is expected to inherit from this class and define concrete implementation for each of the pure virtual functions used in the high-level algorithm.
Definition at line 28 of file DependenceGraphBuilder.h.
|
protected |
Definition at line 30 of file DependenceGraphBuilder.h.
| using llvm::AbstractDependenceGraphBuilder< GraphType >::ClassesType = EquivalenceClasses<BasicBlock *> |
Definition at line 37 of file DependenceGraphBuilder.h.
|
protected |
Map types to map instructions to nodes used when populating the graph.
Definition at line 147 of file DependenceGraphBuilder.h.
|
protected |
Map Types to map instruction/nodes to an ordinal number.
Definition at line 150 of file DependenceGraphBuilder.h.
| using llvm::AbstractDependenceGraphBuilder< GraphType >::NodeListType = SmallVector<NodeType *, 4> |
Definition at line 38 of file DependenceGraphBuilder.h.
|
protected |
Definition at line 151 of file DependenceGraphBuilder.h.
|
inline |
Definition at line 40 of file DependenceGraphBuilder.h.
|
inlinevirtual |
Definition at line 43 of file DependenceGraphBuilder.h.
| void AbstractDependenceGraphBuilder::computeInstructionOrdinals | ( | ) |
Compute ordinal numbers for each instruction and store them in a map for future look up.
These ordinals are used to compute node ordinals which are in turn used to order nodes that are part of a cycle. Instruction ordinals are assigned based on lexical program order.
Definition at line 40 of file DependenceGraphBuilder.cpp.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
| void AbstractDependenceGraphBuilder::createAndConnectRootNode | ( | ) |
Create a root node and add edges such that each node in the graph is reachable from the root.
Definition at line 62 of file DependenceGraphBuilder.cpp.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
|
protectedpure virtual |
Create a def-use edge going from Src to Tgt.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
| void AbstractDependenceGraphBuilder::createDefUseEdges | ( | ) |
Analyze the def-use chains and create edges from the nodes containing definitions to the nodes containing the uses.
Definition at line 227 of file DependenceGraphBuilder.cpp.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
|
protectedpure virtual |
Create an atomic node in the graph given a single instruction.
Implemented in llvm::DDGBuilder.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
| void AbstractDependenceGraphBuilder::createFineGrainedNodes | ( | ) |
Create fine grained nodes.
These are typically atomic nodes that consist of a single instruction.
Definition at line 49 of file DependenceGraphBuilder.cpp.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
| void AbstractDependenceGraphBuilder::createMemoryDependencyEdges | ( | ) |
Analyze data dependencies that exist between memory loads or stores, in the graph nodes and create edges between them.
Definition at line 277 of file DependenceGraphBuilder.cpp.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
|
protectedpure virtual |
Create a memory dependence edge going from Src to Tgt.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
|
protectedpure virtual |
Create a pi-block node in the graph representing a group of nodes in an SCC of the graph.
Implemented in llvm::DDGBuilder.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
| void AbstractDependenceGraphBuilder::createPiBlocks | ( | ) |
Apply graph abstraction to groups of nodes that belong to a strongly connected component of the graph to create larger compound nodes called pi-blocks.
The purpose of this abstraction is to isolate sets of program elements that need to stay together during codegen and turn the dependence graph into an acyclic graph.
Definition at line 89 of file DependenceGraphBuilder.cpp.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
|
protectedpure virtual |
Create a rooted edge going from Src to Tgt .
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
|
protectedpure virtual |
Create the root node of the graph.
Implemented in llvm::DDGBuilder.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
|
inlineprotectedvirtual |
Deallocate memory of edge E.
Definition at line 123 of file DependenceGraphBuilder.h.
|
inlineprotectedvirtual |
Deallocate memory of node N.
Definition at line 126 of file DependenceGraphBuilder.h.
|
protectedpure virtual |
Given a pi-block node, return a vector of all the nodes contained within it.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
|
inlineprotected |
Given an instruction I return its associated ordinal number.
Definition at line 133 of file DependenceGraphBuilder.h.
|
inlineprotected |
Given a node N return its associated ordinal number.
Definition at line 140 of file DependenceGraphBuilder.h.
|
inline |
The main entry to the graph construction algorithm.
It starts by creating nodes in increasing order of granularity and then adds def-use and memory edges. As one of the final stages, it also creates pi-block nodes to facilitate codegen in transformations that use dependence graphs.
The algorithmic complexity of this implementation is O(V^2 * I^2), where V is the number of vertecies (nodes) and I is the number of instructions in each node. The total number of instructions, N, is equal to V * I, therefore the worst-case time complexity is O(N^2). The average time complexity is O((N^2)/2).
Definition at line 56 of file DependenceGraphBuilder.h.
|
inlineprotectedvirtual |
Return true if creation of pi-blocks are supported and desired, and false otherwise.
Reimplemented in llvm::DDGBuilder.
Definition at line 130 of file DependenceGraphBuilder.h.
| void AbstractDependenceGraphBuilder::sortNodesTopologically | ( | ) |
Topologically sort the graph nodes.
Definition at line 378 of file DependenceGraphBuilder.cpp.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::populate().
|
protected |
The list of basic blocks to consider when building the graph.
Definition at line 162 of file DependenceGraphBuilder.h.
|
protected |
Dependence information used to create memory dependence edges in the graph.
Definition at line 159 of file DependenceGraphBuilder.h.
|
protected |
Reference to the graph that gets built by a concrete implementation of this builder.
Definition at line 155 of file DependenceGraphBuilder.h.
|
protected |
A mapping from instructions to the corresponding nodes in the graph.
Definition at line 165 of file DependenceGraphBuilder.h.
|
protected |
A mapping from each instruction to an ordinal number.
This map is used to populate the NodeOrdinalMap.
Definition at line 169 of file DependenceGraphBuilder.h.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::getOrdinal().
|
protected |
A mapping from nodes to an ordinal number.
This map is used to sort nodes in a pi-block based on program order.
Definition at line 173 of file DependenceGraphBuilder.h.
Referenced by llvm::AbstractDependenceGraphBuilder< DataDependenceGraph >::getOrdinal().
1.8.13