blockfreq: Remove unnecessary template parameters

Moves redundant template parameters into an implementation detail of
BlockFrequencyInfoImpl.

No functionality change.

<rdar://problem/14292693>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206084 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2014-04-11 23:21:02 +00:00
parent e9139c68d4
commit 3c371e995a
3 changed files with 24 additions and 9 deletions

View File

@ -21,14 +21,12 @@
namespace llvm {
class BranchProbabilityInfo;
template <class BlockT, class FunctionT, class BranchProbInfoT>
class BlockFrequencyInfoImpl;
template <class BlockT> class BlockFrequencyInfoImpl;
/// BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to
/// estimate IR basic block frequencies.
class BlockFrequencyInfo : public FunctionPass {
typedef BlockFrequencyInfoImpl<BasicBlock, Function, BranchProbabilityInfo>
ImplType;
typedef BlockFrequencyInfoImpl<BasicBlock> ImplType;
std::unique_ptr<ImplType> BFI;
public:

View File

@ -29,16 +29,35 @@
namespace llvm {
class BranchProbabilityInfo;
class BlockFrequencyInfo;
class MachineBranchProbabilityInfo;
class MachineBlockFrequencyInfo;
namespace bfi_detail {
template <class BlockT> struct TypeMap {};
template <> struct TypeMap<BasicBlock> {
typedef BasicBlock BlockT;
typedef Function FunctionT;
typedef BranchProbabilityInfo BlockProbInfoT;
};
template <> struct TypeMap<MachineBasicBlock> {
typedef MachineBasicBlock BlockT;
typedef MachineFunction FunctionT;
typedef MachineBranchProbabilityInfo BlockProbInfoT;
};
}
/// BlockFrequencyInfoImpl implements block frequency algorithm for IR and
/// Machine Instructions. Algorithm starts with value ENTRY_FREQ
/// for the entry block and then propagates frequencies using branch weights
/// from (Machine)BranchProbabilityInfo. LoopInfo is not required because
/// algorithm can find "backedges" by itself.
template<class BlockT, class FunctionT, class BlockProbInfoT>
template <class BT>
class BlockFrequencyInfoImpl {
typedef typename bfi_detail::TypeMap<BT>::BlockT BlockT;
typedef typename bfi_detail::TypeMap<BT>::FunctionT FunctionT;
typedef typename bfi_detail::TypeMap<BT>::BlockProbInfoT BlockProbInfoT;
DenseMap<const BlockT *, BlockFrequency> Freqs;

View File

@ -22,14 +22,12 @@ namespace llvm {
class MachineBasicBlock;
class MachineBranchProbabilityInfo;
template <class BlockT, class FunctionT, class BranchProbInfoT>
class BlockFrequencyInfoImpl;
template <class BlockT> class BlockFrequencyInfoImpl;
/// MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation
/// to estimate machine basic block frequencies.
class MachineBlockFrequencyInfo : public MachineFunctionPass {
typedef BlockFrequencyInfoImpl<MachineBasicBlock, MachineFunction,
MachineBranchProbabilityInfo> ImplType;
typedef BlockFrequencyInfoImpl<MachineBasicBlock> ImplType;
std::unique_ptr<ImplType> MBFI;
public: