BlockFrequencyInfo.h revision 9a24f1f070f7a9e18f7fc46214c2f2d0a38ab0f9
1//========-------- BlockFrequencyInfo.h - Block Frequency Analysis -------========//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Loops should be simplified before this analysis.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_ANALYSIS_BLOCKFREQUENCYINFO_H
15#define LLVM_ANALYSIS_BLOCKFREQUENCYINFO_H
16
17#include "llvm/Pass.h"
18#include "llvm/Support/BlockFrequency.h"
19#include <climits>
20
21namespace llvm {
22
23class BranchProbabilityInfo;
24template<class BlockT, class FunctionT, class BranchProbInfoT>
25class BlockFrequencyImpl;
26
27/// BlockFrequencyInfo pass uses BlockFrequencyImpl implementation to estimate
28/// IR basic block frequencies.
29class BlockFrequencyInfo : public FunctionPass {
30
31  BlockFrequencyImpl<BasicBlock, Function, BranchProbabilityInfo> *BFI;
32
33public:
34  static char ID;
35
36  BlockFrequencyInfo();
37
38  ~BlockFrequencyInfo();
39
40  void getAnalysisUsage(AnalysisUsage &AU) const;
41
42  bool runOnFunction(Function &F);
43
44  /// getblockFreq - Return block frequency. Return 0 if we don't have the
45  /// information. Please note that initial frequency is equal to 1024. It means
46  /// that we should not rely on the value itself, but only on the comparison to
47  /// the other block frequencies. We do this to avoid using of floating points.
48  ///
49  BlockFrequency getBlockFreq(BasicBlock *BB);
50};
51
52}
53
54#endif
55