#ifndef LLVM_CODEGEN_MACHINE_LOOP_INFO_H
#define LLVM_CODEGEN_MACHINE_LOOP_INFO_H
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Analysis/LoopInfo.h"
namespace llvm {
template<> inline
PHINode *LoopBase<MachineBasicBlock>::getCanonicalInductionVariable() const {
assert(0 && "getCanonicalInductionVariable not supported for machine loops!");
return 0;
}
template<> inline Instruction*
LoopBase<MachineBasicBlock>::getCanonicalInductionVariableIncrement() const {
assert(0 &&
"getCanonicalInductionVariableIncrement not supported for machine loops!");
return 0;
}
template<>
inline bool LoopBase<MachineBasicBlock>::isLoopInvariant(Value *V) const {
assert(0 && "isLoopInvariant not supported for machine loops!");
return false;
}
template<>
inline Value *LoopBase<MachineBasicBlock>::getTripCount() const {
assert(0 && "getTripCount not supported for machine loops!");
return 0;
}
template<>
inline bool LoopBase<MachineBasicBlock>::isLCSSAForm() const {
assert(0 && "isLCSSAForm not supported for machine loops");
return false;
}
typedef LoopBase<MachineBasicBlock> MachineLoop;
class MachineLoopInfo : public MachineFunctionPass {
LoopInfoBase<MachineBasicBlock>* LI;
friend class LoopBase<MachineBasicBlock>;
LoopInfoBase<MachineBasicBlock>& getBase() { return *LI; }
public:
static char ID;
MachineLoopInfo() : MachineFunctionPass(&ID) {
LI = new LoopInfoBase<MachineBasicBlock>();
}
~MachineLoopInfo() { delete LI; }
typedef std::vector<MachineLoop*>::const_iterator iterator;
inline iterator begin() const { return LI->begin(); }
inline iterator end() const { return LI->end(); }
bool empty() const { return LI->empty(); }
inline MachineLoop *getLoopFor(const MachineBasicBlock *BB) const {
return LI->getLoopFor(BB);
}
inline const MachineLoop *operator[](const MachineBasicBlock *BB) const {
return LI->getLoopFor(BB);
}
inline unsigned getLoopDepth(const MachineBasicBlock *BB) const {
return LI->getLoopDepth(BB);
}
inline bool isLoopHeader(MachineBasicBlock *BB) const {
return LI->isLoopHeader(BB);
}
virtual bool runOnMachineFunction(MachineFunction &F);
virtual void releaseMemory() { LI->releaseMemory(); }
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
inline MachineLoop *removeLoop(iterator I) { return LI->removeLoop(I); }
inline void changeLoopFor(MachineBasicBlock *BB, MachineLoop *L) {
LI->changeLoopFor(BB, L);
}
inline void changeTopLevelLoop(MachineLoop *OldLoop, MachineLoop *NewLoop) {
LI->changeTopLevelLoop(OldLoop, NewLoop);
}
inline void addTopLevelLoop(MachineLoop *New) {
LI->addTopLevelLoop(New);
}
void removeBlock(MachineBasicBlock *BB) {
LI->removeBlock(BB);
}
};
template <> struct GraphTraits<const MachineLoop*> {
typedef const MachineLoop NodeType;
typedef std::vector<MachineLoop*>::const_iterator ChildIteratorType;
static NodeType *getEntryNode(const MachineLoop *L) { return L; }
static inline ChildIteratorType child_begin(NodeType *N) {
return N->begin();
}
static inline ChildIteratorType child_end(NodeType *N) {
return N->end();
}
};
template <> struct GraphTraits<MachineLoop*> {
typedef MachineLoop NodeType;
typedef std::vector<MachineLoop*>::const_iterator ChildIteratorType;
static NodeType *getEntryNode(MachineLoop *L) { return L; }
static inline ChildIteratorType child_begin(NodeType *N) {
return N->begin();
}
static inline ChildIteratorType child_end(NodeType *N) {
return N->end();
}
};
}
#endif