1 //===- PathProfileInfo.h --------------------------------------*- C++ -*---===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file outlines the interface used by optimizers to load path profiles.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_PATHPROFILEINFO_H
15 #define LLVM_PATHPROFILEINFO_H
17 #include "llvm/BasicBlock.h"
18 #include "llvm/Analysis/PathNumbering.h"
23 class ProfilePathEdge;
24 class PathProfileInfo;
26 typedef std::vector<ProfilePathEdge> ProfilePathEdgeVector;
27 typedef std::vector<ProfilePathEdge>::iterator ProfilePathEdgeIterator;
29 typedef std::vector<BasicBlock*> ProfilePathBlockVector;
30 typedef std::vector<BasicBlock*>::iterator ProfilePathBlockIterator;
32 typedef std::map<unsigned int,ProfilePath*> ProfilePathMap;
33 typedef std::map<unsigned int,ProfilePath*>::iterator ProfilePathIterator;
35 typedef std::map<Function*,unsigned int> FunctionPathCountMap;
36 typedef std::map<Function*,ProfilePathMap> FunctionPathMap;
37 typedef std::map<Function*,ProfilePathMap>::iterator FunctionPathIterator;
39 class ProfilePathEdge {
41 ProfilePathEdge(BasicBlock* source, BasicBlock* target,
42 unsigned duplicateNumber);
44 inline unsigned getDuplicateNumber() { return _duplicateNumber; }
45 inline BasicBlock* getSource() { return _source; }
46 inline BasicBlock* getTarget() { return _target; }
51 unsigned _duplicateNumber;
56 ProfilePath(unsigned int number, unsigned int count,
57 double countStdDev, PathProfileInfo* ppi);
59 double getFrequency() const;
61 inline unsigned int getNumber() const { return _number; }
62 inline unsigned int getCount() const { return _count; }
63 inline double getCountStdDev() const { return _countStdDev; }
65 ProfilePathEdgeVector* getPathEdges() const;
66 ProfilePathBlockVector* getPathBlocks() const;
68 BasicBlock* getFirstBlockInPath() const;
75 // double pointer back to the profiling info
76 PathProfileInfo* _ppi;
79 // TODO: overload [] operator for getting path
80 // Add: getFunctionCallCount()
81 class PathProfileInfo {
86 void setCurrentFunction(Function* F);
87 Function* getCurrentFunction() const;
88 BasicBlock* getCurrentFunctionEntry();
90 ProfilePath* getPath(unsigned int number);
91 unsigned int getPotentialPathCount();
93 ProfilePathIterator pathBegin();
94 ProfilePathIterator pathEnd();
95 unsigned int pathsRun();
97 static char ID; // Pass identification
101 FunctionPathMap _functionPaths;
102 FunctionPathCountMap _functionPathCounts;
105 BallLarusDag* _currentDag;
106 Function* _currentFunction;
108 friend class ProfilePath;
110 } // end namespace llvm