2011-07-25 19:25:40 +00:00
|
|
|
//====----- MachineBlockFrequencyInfo.h - MachineBlock Frequency Analysis ----====//
|
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;
|
|
|
|
template<class BlockT, class FunctionT, class BranchProbInfoT>
|
|
|
|
class BlockFrequencyImpl;
|
|
|
|
|
2011-07-25 19:25:40 +00:00
|
|
|
/// MachineBlockFrequencyInfo pass uses BlockFrequencyImpl implementation to estimate
|
2011-07-16 20:23:20 +00:00
|
|
|
/// machine basic block frequencies.
|
2011-07-25 19:25:40 +00:00
|
|
|
class MachineBlockFrequencyInfo : public MachineFunctionPass {
|
2011-07-16 20:23:20 +00:00
|
|
|
|
2011-11-14 17:45:03 +00:00
|
|
|
BlockFrequencyImpl<MachineBasicBlock, MachineFunction,
|
|
|
|
MachineBranchProbabilityInfo> *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
|
|
|
|
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const;
|
|
|
|
|
|
|
|
bool runOnMachineFunction(MachineFunction &F);
|
|
|
|
|
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-08-03 21:30:57 +00:00
|
|
|
BlockFrequency getBlockFreq(MachineBasicBlock *MBB) const;
|
2011-07-16 20:23:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|