diff options
author | Dan Gohman <gohman@apple.com> | 2009-07-13 21:51:15 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-07-13 21:51:15 +0000 |
commit | c8d76d5afb023a1c6b439941be3b62789fcc0ed3 (patch) | |
tree | 0ff6a38e33cf421026ea0232d6c47ed6f27d554d /include/llvm/CodeGen/MachineLoopInfo.h | |
parent | 92aa0bb4cab8dec9df4c51b414b5861953752a32 (diff) |
Make Loop and MachineLoop be subclasses of LoopBase, rather than typedefs,
using the Curiously Recurring Template Pattern with LoopBase.
This will help further refactoring, and future functionality for
Loop. Also, Headers can now foward-declare Loop, instead of pulling
in LoopInfo.h or doing tricks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75519 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineLoopInfo.h')
-rw-r--r-- | include/llvm/CodeGen/MachineLoopInfo.h | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/include/llvm/CodeGen/MachineLoopInfo.h b/include/llvm/CodeGen/MachineLoopInfo.h index 2d19d7a2f8..1511b40897 100644 --- a/include/llvm/CodeGen/MachineLoopInfo.h +++ b/include/llvm/CodeGen/MachineLoopInfo.h @@ -35,48 +35,62 @@ namespace llvm { +class MachineLoop; + // Provide overrides for Loop methods that don't make sense for machine loops. template<> inline -PHINode *LoopBase<MachineBasicBlock>::getCanonicalInductionVariable() const { +PHINode * +LoopBase<MachineBasicBlock, MachineLoop>::getCanonicalInductionVariable() const { assert(0 && "getCanonicalInductionVariable not supported for machine loops!"); return 0; } template<> inline Instruction* -LoopBase<MachineBasicBlock>::getCanonicalInductionVariableIncrement() const { +LoopBase<MachineBasicBlock, + MachineLoop>::getCanonicalInductionVariableIncrement() const { assert(0 && "getCanonicalInductionVariableIncrement not supported for machine loops!"); return 0; } template<> -inline bool LoopBase<MachineBasicBlock>::isLoopInvariant(Value *V) const { +inline bool +LoopBase<MachineBasicBlock, MachineLoop>::isLoopInvariant(Value *V) const { assert(0 && "isLoopInvariant not supported for machine loops!"); return false; } template<> -inline Value *LoopBase<MachineBasicBlock>::getTripCount() const { +inline Value * +LoopBase<MachineBasicBlock, MachineLoop>::getTripCount() const { assert(0 && "getTripCount not supported for machine loops!"); return 0; } template<> -inline bool LoopBase<MachineBasicBlock>::isLCSSAForm() const { +inline bool +LoopBase<MachineBasicBlock, MachineLoop>::isLCSSAForm() const { assert(0 && "isLCSSAForm not supported for machine loops"); return false; } -typedef LoopBase<MachineBasicBlock> MachineLoop; +class MachineLoop : public LoopBase<MachineBasicBlock, MachineLoop> { +public: + MachineLoop(); +private: + friend class LoopInfoBase<MachineBasicBlock, MachineLoop>; + explicit MachineLoop(MachineBasicBlock *MBB) + : LoopBase<MachineBasicBlock, MachineLoop>(MBB) {} +}; class MachineLoopInfo : public MachineFunctionPass { - LoopInfoBase<MachineBasicBlock> LI; - friend class LoopBase<MachineBasicBlock>; + LoopInfoBase<MachineBasicBlock, MachineLoop> LI; + friend class LoopBase<MachineBasicBlock, MachineLoop>; void operator=(const MachineLoopInfo &); // do not implement MachineLoopInfo(const MachineLoopInfo &); // do not implement - LoopInfoBase<MachineBasicBlock>& getBase() { return LI; } + LoopInfoBase<MachineBasicBlock, MachineLoop>& getBase() { return LI; } public: static char ID; // Pass identification, replacement for typeid @@ -86,7 +100,7 @@ public: /// iterator/begin/end - The interface to the top-level loops in the current /// function. /// - typedef LoopInfoBase<MachineBasicBlock>::iterator iterator; + typedef LoopInfoBase<MachineBasicBlock, MachineLoop>::iterator iterator; inline iterator begin() const { return LI.begin(); } inline iterator end() const { return LI.end(); } bool empty() const { return LI.empty(); } |