summaryrefslogtreecommitdiff
path: root/lib/Transforms/Instrumentation/MaximumSpanningTree.h
blob: 2343985f23d43d7d8539d804c8645acfaf3aae79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//===- llvm/Analysis/MaximumSpanningTree.h - Interface ----------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This module privides means for calculating a maximum spanning tree for the
// CFG of a function according to a given profile.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_ANALYSIS_MAXIMUMSPANNINGTREE_H
#define LLVM_ANALYSIS_MAXIMUMSPANNINGTREE_H

#include "llvm/Analysis/ProfileInfo.h"
#include "llvm/Support/raw_ostream.h"
#include <vector>

namespace llvm {
  class Function;

  class MaximumSpanningTree {
  public:
    typedef std::vector<ProfileInfo::Edge> MaxSpanTree;

  protected:
    MaxSpanTree MST;

  public:
    static char ID; // Class identification, replacement for typeinfo

    // MaxSpanTree() - Calculates a MST for a function according to a profile.
    // If inverted is true, all the edges *not* in the MST are returned. As a
    // special also all leaf edges of the MST are not included, this makes it
    // easier for the OptimalEdgeProfileInstrumentation to use this MST to do
    // an optimal profiling.
    MaximumSpanningTree(std::vector<ProfileInfo::EdgeWeight>&);
    virtual ~MaximumSpanningTree() {}

    virtual MaxSpanTree::iterator begin();
    virtual MaxSpanTree::iterator end();

    virtual void dump();
  };

} // End llvm namespace

#endif