Home | History | Annotate | Download | only in CodeGen
      1 //====----- MachineBlockFrequency.h - MachineBlock 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_CODEGEN_MACHINEBLOCKFREQUENCY_H
     15 #define LLVM_CODEGEN_MACHINEBLOCKFREQUENCY_H
     16 
     17 #include "llvm/CodeGen/MachineFunctionPass.h"
     18 #include <climits>
     19 
     20 namespace llvm {
     21 
     22 class MachineBranchProbabilityInfo;
     23 template<class BlockT, class FunctionT, class BranchProbInfoT>
     24 class BlockFrequencyImpl;
     25 
     26 /// MachineBlockFrequency pass uses BlockFrequencyImpl implementation to estimate
     27 /// machine basic block frequencies.
     28 class MachineBlockFrequency : public MachineFunctionPass {
     29 
     30   BlockFrequencyImpl<MachineBasicBlock, MachineFunction, MachineBranchProbabilityInfo> *MBFI;
     31 
     32 public:
     33   static char ID;
     34 
     35   MachineBlockFrequency();
     36 
     37   ~MachineBlockFrequency();
     38 
     39   void getAnalysisUsage(AnalysisUsage &AU) const;
     40 
     41   bool runOnMachineFunction(MachineFunction &F);
     42 
     43   /// getblockFreq - Return block frequency. Never return 0, value must be
     44   /// positive. Please note that initial frequency is equal to 1024. It means
     45   /// that we should not rely on the value itself, but only on the comparison to
     46   /// the other block frequencies. We do this to avoid using of the floating
     47   /// points.
     48   uint32_t getBlockFreq(MachineBasicBlock *MBB);
     49 };
     50 
     51 }
     52 
     53 #endif
     54