| Lang Hames | 60f422f | 2010-07-17 07:34:01 +0000 | [diff] [blame] | 1 | //===-- llvm/CodeGen/Splitter.h - Splitter -*- C++ -*----------------------===// | 
 | 2 | // | 
 | 3 | //                     The LLVM Compiler Infrastructure | 
 | 4 | // | 
 | 5 | // This file is distributed under the University of Illinois Open Source | 
 | 6 | // License. See LICENSE.TXT for details. | 
 | 7 | // | 
 | 8 | //===----------------------------------------------------------------------===// | 
 | 9 |  | 
 | 10 | #ifndef LLVM_CODEGEN_SPLITTER_H | 
 | 11 | #define LLVM_CODEGEN_SPLITTER_H | 
 | 12 |  | 
 | 13 | #include "llvm/CodeGen/MachineFunctionPass.h" | 
 | 14 | #include "llvm/CodeGen/MachineLoopInfo.h" | 
 | 15 | #include "llvm/CodeGen/SlotIndexes.h" | 
 | 16 |  | 
 | 17 | #include <deque> | 
 | 18 | #include <map> | 
 | 19 | #include <string> | 
 | 20 | #include <vector> | 
 | 21 |  | 
 | 22 | namespace llvm { | 
 | 23 |  | 
 | 24 |   class LiveInterval; | 
 | 25 |   class LiveIntervals; | 
| Douglas Gregor | 806de35 | 2010-07-18 11:47:56 +0000 | [diff] [blame] | 26 |   struct LiveRange; | 
| Lang Hames | 60f422f | 2010-07-17 07:34:01 +0000 | [diff] [blame] | 27 |   class LoopSplit; | 
 | 28 |   class MachineDominatorTree; | 
 | 29 |   class MachineRegisterInfo; | 
 | 30 |   class SlotIndexes; | 
 | 31 |   class TargetInstrInfo; | 
 | 32 |   class VNInfo; | 
 | 33 |  | 
 | 34 |   class LoopSplitter : public MachineFunctionPass { | 
 | 35 |     friend class LoopSplit; | 
 | 36 |   public: | 
 | 37 |     static char ID; | 
 | 38 |  | 
| Owen Anderson | 081c34b | 2010-10-19 17:21:58 +0000 | [diff] [blame] | 39 |     LoopSplitter() : MachineFunctionPass(ID) { | 
 | 40 |       initializeLoopSplitterPass(*PassRegistry::getPassRegistry()); | 
 | 41 |     } | 
| Lang Hames | 60f422f | 2010-07-17 07:34:01 +0000 | [diff] [blame] | 42 |  | 
 | 43 |     virtual void getAnalysisUsage(AnalysisUsage &au) const; | 
 | 44 |  | 
 | 45 |     virtual bool runOnMachineFunction(MachineFunction &fn); | 
 | 46 |  | 
 | 47 |     virtual void releaseMemory(); | 
 | 48 |  | 
 | 49 |  | 
 | 50 |   private: | 
 | 51 |  | 
 | 52 |     MachineFunction *mf; | 
 | 53 |     LiveIntervals *lis; | 
 | 54 |     MachineLoopInfo *mli; | 
 | 55 |     MachineRegisterInfo *mri; | 
 | 56 |     MachineDominatorTree *mdt; | 
 | 57 |     SlotIndexes *sis; | 
 | 58 |     const TargetInstrInfo *tii; | 
 | 59 |     const TargetRegisterInfo *tri; | 
 | 60 |  | 
 | 61 |     std::string fqn; | 
 | 62 |     std::deque<LiveInterval*> intervals; | 
 | 63 |  | 
 | 64 |     typedef std::pair<SlotIndex, SlotIndex> SlotPair; | 
 | 65 |     typedef std::vector<SlotPair> LoopRanges; | 
 | 66 |     typedef std::map<MachineLoop*, LoopRanges> LoopRangeMap; | 
 | 67 |     LoopRangeMap loopRangeMap; | 
 | 68 |  | 
 | 69 |     void dumpLoopInfo(MachineLoop &loop); | 
 | 70 |  | 
 | 71 |     void dumpOddTerminators(); | 
 | 72 |  | 
 | 73 |     void updateTerminators(MachineBasicBlock &mbb); | 
 | 74 |  | 
 | 75 |     bool canInsertPreHeader(MachineLoop &loop); | 
 | 76 |     MachineBasicBlock& insertPreHeader(MachineLoop &loop); | 
 | 77 |  | 
 | 78 |     bool isCriticalEdge(MachineLoop::Edge &edge); | 
 | 79 |     bool canSplitEdge(MachineLoop::Edge &edge); | 
 | 80 |     MachineBasicBlock& splitEdge(MachineLoop::Edge &edge, MachineLoop &loop); | 
 | 81 |  | 
 | 82 |     LoopRanges& getLoopRanges(MachineLoop &loop); | 
 | 83 |     std::pair<bool, SlotPair> getLoopSubRange(const LiveRange &lr, | 
 | 84 |                                               MachineLoop &loop); | 
 | 85 |  | 
 | 86 |     void dumpLoopRanges(MachineLoop &loop); | 
 | 87 |  | 
 | 88 |     void processHeader(LoopSplit &split); | 
 | 89 |     void processLoopExits(LoopSplit &split); | 
 | 90 |     void processLoopUses(LoopSplit &split); | 
 | 91 |  | 
 | 92 |     bool splitOverLoop(LiveInterval &li, MachineLoop &loop); | 
 | 93 |  | 
 | 94 |     void processInterval(LiveInterval &li); | 
 | 95 |  | 
 | 96 |     void processIntervals(); | 
 | 97 |   }; | 
 | 98 |  | 
 | 99 | } | 
 | 100 |  | 
 | 101 | #endif |