LLVM  4.0.0
MachineBlockFrequencyInfo.h
Go to the documentation of this file.
1 //===- MachineBlockFrequencyInfo.h - MBB Frequency Analysis -*- C++ -*-----===//
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_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
15 #define LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
16 
17 #include "llvm/ADT/Optional.h"
20 #include <climits>
21 
22 namespace llvm {
23 
24 class MachineBasicBlock;
25 class MachineBranchProbabilityInfo;
26 template <class BlockT> class BlockFrequencyInfoImpl;
27 
28 /// MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation
29 /// to estimate machine basic block frequencies.
32  std::unique_ptr<ImplType> MBFI;
33 
34 public:
35  static char ID;
36 
38 
39  ~MachineBlockFrequencyInfo() override;
40 
41  void getAnalysisUsage(AnalysisUsage &AU) const override;
42 
43  bool runOnMachineFunction(MachineFunction &F) override;
44 
45  void releaseMemory() override;
46 
47  /// getblockFreq - Return block frequency. Return 0 if we don't have the
48  /// information. Please note that initial frequency is equal to 1024. It means
49  /// that we should not rely on the value itself, but only on the comparison to
50  /// the other block frequencies. We do this to avoid using of floating points.
51  ///
53 
55  Optional<uint64_t> getProfileCountFromFreq(uint64_t Freq) const;
56 
57  const MachineFunction *getFunction() const;
59  void view() const;
60 
61  // Print the block frequency Freq to OS using the current functions entry
62  // frequency to convert freq into a relative decimal form.
63  raw_ostream &printBlockFreq(raw_ostream &OS, const BlockFrequency Freq) const;
64 
65  // Convenience method that attempts to look up the frequency associated with
66  // BB and print it to OS.
68  const MachineBasicBlock *MBB) const;
69 
70  uint64_t getEntryFreq() const;
71 
72 };
73 
74 }
75 
76 #endif
void view() const
Pop up a ghostview window with the current block frequency propagation rendered using dot...
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
getblockFreq - Return block frequency.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
#define F(x, y, z)
Definition: MD5.cpp:51
MachineBasicBlock * MBB
raw_ostream & printBlockFreq(raw_ostream &OS, const BlockFrequency Freq) const
Represent the analysis usage information of a pass.
Optional< uint64_t > getProfileCountFromFreq(uint64_t Freq) const
Optional< uint64_t > getBlockProfileCount(const MachineBasicBlock *MBB) const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
const MachineBranchProbabilityInfo * getMBPI() const
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
bool runOnMachineFunction(MachineFunction &F) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
Shared implementation for block frequency analysis.
const MachineFunction * getFunction() const