14 #ifndef LLVM_LIB_TRANSFORMS_INSTRUMENTATION_MAXIMUMSPANNINGTREE_H 15 #define LLVM_LIB_TRANSFORMS_INSTRUMENTATION_MAXIMUMSPANNINGTREE_H 29 typedef std::pair<const T*, const T*>
Edge;
39 struct EdgeWeightCompare {
40 static bool getBlockSize(
const T *
X) {
41 const BasicBlock *BB = dyn_cast_or_null<BasicBlock>(
X);
42 return BB ? BB->
size() : 0;
45 bool operator()(EdgeWeight X, EdgeWeight
Y)
const {
46 if (X.second > Y.second)
return true;
47 if (X.second < Y.second)
return false;
50 size_t XSizeA = getBlockSize(X.first.first);
51 size_t YSizeA = getBlockSize(Y.first.first);
52 if (XSizeA > YSizeA)
return true;
53 if (XSizeA < YSizeA)
return false;
55 size_t XSizeB = getBlockSize(X.first.second);
56 size_t YSizeB = getBlockSize(Y.first.second);
57 if (XSizeB > YSizeB)
return true;
58 if (XSizeB < YSizeB)
return false;
76 for (
typename EdgeWeights::iterator EWi = EdgeVector.begin(),
77 EWe = EdgeVector.end(); EWi != EWe; ++EWi) {
78 Edge
e = (*EWi).first;
85 for (
typename EdgeWeights::iterator EWi = EdgeVector.begin(),
86 EWe = EdgeVector.end(); EWi != EWe; ++EWi) {
87 Edge
e = (*EWi).first;
98 typename MaxSpanTree::iterator
begin() {
102 typename MaxSpanTree::iterator
end() {
109 #endif // LLVM_LIB_TRANSFORMS_INSTRUMENTATION_MAXIMUMSPANNINGTREE_H static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This class represents lattice values for constants.
std::vector< Edge > MaxSpanTree
member_iterator unionSets(const ElemTy &V1, const ElemTy &V2)
union - Merge the two equivalence sets for the specified values, inserting them if they do not alread...
std::pair< const T *, const T * > Edge
MaximumSpanningTree - A MST implementation.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
iterator insert(const ElemTy &Data)
insert - Insert a new value into the union/find set, ignoring the request if the value already exists...
member_iterator findLeader(iterator I) const
findLeader - Given a value in the set, return a member iterator for the equivalence class it is in...
MaxSpanTree::iterator end()
MaxSpanTree::iterator begin()
LLVM Basic Block Representation.
EquivalenceClasses - This represents a collection of equivalence classes and supports three efficient...
MaximumSpanningTree(EdgeWeights &EdgeVector)
MaximumSpanningTree() - Takes a vector of weighted edges and returns a spanning tree.
std::pair< Edge, double > EdgeWeight
void stable_sort(R &&Range)
std::vector< EdgeWeight > EdgeWeights