2014-04-11 23:20:58 +00:00
|
|
|
//===- MachineBlockFrequencyInfo.h - MBB Frequency Analysis -*- C++ -*-----===//
|
2011-07-16 20:23:20 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Loops should be simplified before this analysis.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-07-25 20:08:00 +00:00
|
|
|
#ifndef LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
|
|
|
|
#define LLVM_CODEGEN_MACHINEBLOCKFREQUENCYINFO_H
|
2011-07-16 20:23:20 +00:00
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
2011-07-27 22:05:51 +00:00
|
|
|
#include "llvm/Support/BlockFrequency.h"
|
2011-07-16 20:23:20 +00:00
|
|
|
#include <climits>
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2011-11-14 17:45:03 +00:00
|
|
|
class MachineBasicBlock;
|
2011-07-16 20:23:20 +00:00
|
|
|
class MachineBranchProbabilityInfo;
|
2014-04-11 23:21:02 +00:00
|
|
|
template <class BlockT> class BlockFrequencyInfoImpl;
|
2011-07-16 20:23:20 +00:00
|
|
|
|
2014-04-11 23:20:58 +00:00
|
|
|
/// MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation
|
|
|
|
/// to estimate machine basic block frequencies.
|
2011-07-25 19:25:40 +00:00
|
|
|
class MachineBlockFrequencyInfo : public MachineFunctionPass {
|
2014-04-11 23:21:02 +00:00
|
|
|
typedef BlockFrequencyInfoImpl<MachineBasicBlock> ImplType;
|
2014-03-25 18:01:38 +00:00
|
|
|
std::unique_ptr<ImplType> MBFI;
|
2011-07-16 20:23:20 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
static char ID;
|
|
|
|
|
2011-07-25 19:25:40 +00:00
|
|
|
MachineBlockFrequencyInfo();
|
2011-07-16 20:23:20 +00:00
|
|
|
|
2011-07-25 19:25:40 +00:00
|
|
|
~MachineBlockFrequencyInfo();
|
2011-07-16 20:23:20 +00:00
|
|
|
|
2014-03-07 09:26:03 +00:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override;
|
2011-07-16 20:23:20 +00:00
|
|
|
|
2014-03-07 09:26:03 +00:00
|
|
|
bool runOnMachineFunction(MachineFunction &F) override;
|
2011-07-16 20:23:20 +00:00
|
|
|
|
2014-03-25 18:01:38 +00:00
|
|
|
void releaseMemory() override;
|
|
|
|
|
2011-07-22 02:24:57 +00:00
|
|
|
/// getblockFreq - Return block frequency. Return 0 if we don't have the
|
|
|
|
/// information. Please note that initial frequency is equal to 1024. It means
|
2011-07-16 20:23:20 +00:00
|
|
|
/// that we should not rely on the value itself, but only on the comparison to
|
2011-07-22 02:24:57 +00:00
|
|
|
/// the other block frequencies. We do this to avoid using of floating points.
|
|
|
|
///
|
2011-12-20 20:03:10 +00:00
|
|
|
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const;
|
2013-12-03 00:49:33 +00:00
|
|
|
|
2014-03-25 18:01:32 +00:00
|
|
|
const MachineFunction *getFunction() const;
|
2013-12-03 00:49:33 +00:00
|
|
|
void view() const;
|
2013-12-14 00:06:03 +00:00
|
|
|
|
|
|
|
// Print the block frequency Freq to OS using the current functions entry
|
|
|
|
// frequency to convert freq into a relative decimal form.
|
|
|
|
raw_ostream &printBlockFreq(raw_ostream &OS, const BlockFrequency Freq) const;
|
|
|
|
|
|
|
|
// Convenience method that attempts to look up the frequency associated with
|
|
|
|
// BB and print it to OS.
|
|
|
|
raw_ostream &printBlockFreq(raw_ostream &OS,
|
|
|
|
const MachineBasicBlock *MBB) const;
|
|
|
|
|
2013-12-14 02:37:38 +00:00
|
|
|
uint64_t getEntryFreq() const;
|
2013-12-14 00:06:03 +00:00
|
|
|
|
2011-07-16 20:23:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|