| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 1 | //===---------- SplitKit.cpp - Toolkit for splitting live ranges ----------===// | 
 | 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 | // This file contains the SplitAnalysis class as well as mutator functions for | 
 | 11 | // live range splitting. | 
 | 12 | // | 
 | 13 | //===----------------------------------------------------------------------===// | 
 | 14 |  | 
 | 15 | #include "llvm/ADT/SmallPtrSet.h" | 
 | 16 | #include "llvm/ADT/DenseMap.h" | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/SlotIndexes.h" | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 18 |  | 
 | 19 | namespace llvm { | 
 | 20 |  | 
 | 21 | class LiveInterval; | 
 | 22 | class LiveIntervals; | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 23 | class MachineInstr; | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 24 | class MachineLoop; | 
 | 25 | class MachineLoopInfo; | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 26 | class MachineRegisterInfo; | 
| Jakob Stoklund Olesen | 6a0dc07 | 2010-07-20 21:46:58 +0000 | [diff] [blame] | 27 | class TargetInstrInfo; | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 28 | class VirtRegMap; | 
 | 29 | class VNInfo; | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 30 |  | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 31 | /// SplitAnalysis - Analyze a LiveInterval, looking for live range splitting | 
 | 32 | /// opportunities. | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 33 | class SplitAnalysis { | 
| Jakob Stoklund Olesen | 08e93b1 | 2010-08-10 17:07:22 +0000 | [diff] [blame] | 34 | public: | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 35 |   const MachineFunction &mf_; | 
 | 36 |   const LiveIntervals &lis_; | 
 | 37 |   const MachineLoopInfo &loops_; | 
| Jakob Stoklund Olesen | 6a0dc07 | 2010-07-20 21:46:58 +0000 | [diff] [blame] | 38 |   const TargetInstrInfo &tii_; | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 39 |  | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 40 |   // Instructions using the the current register. | 
 | 41 |   typedef SmallPtrSet<const MachineInstr*, 16> InstrPtrSet; | 
 | 42 |   InstrPtrSet usingInstrs_; | 
 | 43 |  | 
 | 44 |   // The number of instructions using curli in each basic block. | 
 | 45 |   typedef DenseMap<const MachineBasicBlock*, unsigned> BlockCountMap; | 
 | 46 |   BlockCountMap usingBlocks_; | 
 | 47 |  | 
| Jakob Stoklund Olesen | 2dee7a5 | 2010-08-12 23:02:55 +0000 | [diff] [blame] | 48 |   // The number of basic block using curli in each loop. | 
 | 49 |   typedef DenseMap<const MachineLoop*, unsigned> LoopCountMap; | 
 | 50 |   LoopCountMap usingLoops_; | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 51 |  | 
| Jakob Stoklund Olesen | f1b05f2 | 2010-08-12 17:07:14 +0000 | [diff] [blame] | 52 | private: | 
 | 53 |   // Current live interval. | 
 | 54 |   const LiveInterval *curli_; | 
 | 55 |  | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 56 |   // Sumarize statistics by counting instructions using curli_. | 
| Jakob Stoklund Olesen | abff280 | 2010-07-20 16:12:37 +0000 | [diff] [blame] | 57 |   void analyzeUses(); | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 58 |  | 
| Jakob Stoklund Olesen | 6a0dc07 | 2010-07-20 21:46:58 +0000 | [diff] [blame] | 59 |   /// canAnalyzeBranch - Return true if MBB ends in a branch that can be | 
 | 60 |   /// analyzed. | 
 | 61 |   bool canAnalyzeBranch(const MachineBasicBlock *MBB); | 
 | 62 |  | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 63 | public: | 
| Jakob Stoklund Olesen | f2c6e36 | 2010-07-20 23:50:15 +0000 | [diff] [blame] | 64 |   SplitAnalysis(const MachineFunction &mf, const LiveIntervals &lis, | 
 | 65 |                 const MachineLoopInfo &mli); | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 66 |  | 
 | 67 |   /// analyze - set curli to the specified interval, and analyze how it may be | 
 | 68 |   /// split. | 
 | 69 |   void analyze(const LiveInterval *li); | 
 | 70 |  | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 71 |   const LiveInterval *getCurLI() { return curli_; } | 
 | 72 |  | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 73 |   /// clear - clear all data structures so SplitAnalysis is ready to analyze a | 
 | 74 |   /// new interval. | 
 | 75 |   void clear(); | 
 | 76 |  | 
| Jakob Stoklund Olesen | 6a0dc07 | 2010-07-20 21:46:58 +0000 | [diff] [blame] | 77 |   typedef SmallPtrSet<const MachineBasicBlock*, 16> BlockPtrSet; | 
| Jakob Stoklund Olesen | 2dee7a5 | 2010-08-12 23:02:55 +0000 | [diff] [blame] | 78 |   typedef SmallPtrSet<const MachineLoop*, 16> LoopPtrSet; | 
| Jakob Stoklund Olesen | 6a0dc07 | 2010-07-20 21:46:58 +0000 | [diff] [blame] | 79 |  | 
 | 80 |   // Sets of basic blocks surrounding a machine loop. | 
 | 81 |   struct LoopBlocks { | 
 | 82 |     BlockPtrSet Loop;  // Blocks in the loop. | 
 | 83 |     BlockPtrSet Preds; // Loop predecessor blocks. | 
 | 84 |     BlockPtrSet Exits; // Loop exit blocks. | 
 | 85 |  | 
 | 86 |     void clear() { | 
 | 87 |       Loop.clear(); | 
 | 88 |       Preds.clear(); | 
 | 89 |       Exits.clear(); | 
 | 90 |     } | 
 | 91 |   }; | 
 | 92 |  | 
 | 93 |   // Calculate the block sets surrounding the loop. | 
 | 94 |   void getLoopBlocks(const MachineLoop *Loop, LoopBlocks &Blocks); | 
 | 95 |  | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 96 |   /// LoopPeripheralUse - how is a variable used in and around a loop? | 
 | 97 |   /// Peripheral blocks are the loop predecessors and exit blocks. | 
 | 98 |   enum LoopPeripheralUse { | 
 | 99 |     ContainedInLoop,  // All uses are inside the loop. | 
 | 100 |     SinglePeripheral, // At most one instruction per peripheral block. | 
 | 101 |     MultiPeripheral,  // Multiple instructions in some peripheral blocks. | 
 | 102 |     OutsideLoop       // Uses outside loop periphery. | 
 | 103 |   }; | 
 | 104 |  | 
 | 105 |   /// analyzeLoopPeripheralUse - Return an enum describing how curli_ is used in | 
 | 106 |   /// and around the Loop. | 
| Jakob Stoklund Olesen | 6a0dc07 | 2010-07-20 21:46:58 +0000 | [diff] [blame] | 107 |   LoopPeripheralUse analyzeLoopPeripheralUse(const LoopBlocks&); | 
 | 108 |  | 
 | 109 |   /// getCriticalExits - It may be necessary to partially break critical edges | 
 | 110 |   /// leaving the loop if an exit block has phi uses of curli. Collect the exit | 
 | 111 |   /// blocks that need special treatment into CriticalExits. | 
 | 112 |   void getCriticalExits(const LoopBlocks &Blocks, BlockPtrSet &CriticalExits); | 
 | 113 |  | 
 | 114 |   /// canSplitCriticalExits - Return true if it is possible to insert new exit | 
 | 115 |   /// blocks before the blocks in CriticalExits. | 
 | 116 |   bool canSplitCriticalExits(const LoopBlocks &Blocks, | 
 | 117 |                              BlockPtrSet &CriticalExits); | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 118 |  | 
 | 119 |   /// getBestSplitLoop - Return the loop where curli may best be split to a | 
 | 120 |   /// separate register, or NULL. | 
 | 121 |   const MachineLoop *getBestSplitLoop(); | 
| Jakob Stoklund Olesen | f1b05f2 | 2010-08-12 17:07:14 +0000 | [diff] [blame] | 122 |  | 
 | 123 |   /// getMultiUseBlocks - Add basic blocks to Blocks that may benefit from | 
 | 124 |   /// having curli split to a new live interval. Return true if Blocks can be | 
 | 125 |   /// passed to SplitEditor::splitSingleBlocks. | 
 | 126 |   bool getMultiUseBlocks(BlockPtrSet &Blocks); | 
| Jakob Stoklund Olesen | fc412d8 | 2010-08-13 21:18:48 +0000 | [diff] [blame] | 127 |  | 
 | 128 |   /// getBlockForInsideSplit - If curli is contained inside a single basic block, | 
 | 129 |   /// and it wou pay to subdivide the interval inside that block, return it. | 
 | 130 |   /// Otherwise return NULL. The returned block can be passed to | 
 | 131 |   /// SplitEditor::splitInsideBlock. | 
 | 132 |   const MachineBasicBlock *getBlockForInsideSplit(); | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 133 | }; | 
 | 134 |  | 
| Jakob Stoklund Olesen | 1407c84 | 2010-08-18 19:00:08 +0000 | [diff] [blame] | 135 |  | 
 | 136 | /// LiveIntervalMap - Map values from a large LiveInterval into a small | 
 | 137 | /// interval that is a subset. Insert phi-def values as needed. This class is | 
 | 138 | /// used by SplitEditor to create new smaller LiveIntervals. | 
 | 139 | /// | 
 | 140 | /// parentli_ is the larger interval, li_ is the subset interval. Every value | 
 | 141 | /// in li_ corresponds to exactly one value in parentli_, and the live range | 
 | 142 | /// of the value is contained within the live range of the parentli_ value. | 
 | 143 | /// Values in parentli_ may map to any number of openli_ values, including 0. | 
 | 144 | class LiveIntervalMap { | 
 | 145 |   LiveIntervals &lis_; | 
| Jakob Stoklund Olesen | 1407c84 | 2010-08-18 19:00:08 +0000 | [diff] [blame] | 146 |  | 
 | 147 |   // The parent interval is never changed. | 
 | 148 |   const LiveInterval &parentli_; | 
 | 149 |  | 
 | 150 |   // The child interval's values are fully contained inside parentli_ values. | 
| Jakob Stoklund Olesen | 9ca2aeb | 2010-09-13 23:29:09 +0000 | [diff] [blame] | 151 |   LiveInterval *li_; | 
| Jakob Stoklund Olesen | 1407c84 | 2010-08-18 19:00:08 +0000 | [diff] [blame] | 152 |  | 
 | 153 |   typedef DenseMap<const VNInfo*, VNInfo*> ValueMap; | 
 | 154 |  | 
 | 155 |   // Map parentli_ values to simple values in li_ that are defined at the same | 
 | 156 |   // SlotIndex, or NULL for parentli_ values that have complex li_ defs. | 
 | 157 |   // Note there is a difference between values mapping to NULL (complex), and | 
 | 158 |   // values not present (unknown/unmapped). | 
 | 159 |   ValueMap valueMap_; | 
 | 160 |  | 
| Jakob Stoklund Olesen | 1407c84 | 2010-08-18 19:00:08 +0000 | [diff] [blame] | 161 | public: | 
 | 162 |   LiveIntervalMap(LiveIntervals &lis, | 
| Jakob Stoklund Olesen | 9ca2aeb | 2010-09-13 23:29:09 +0000 | [diff] [blame] | 163 |                   const LiveInterval &parentli) | 
 | 164 |     : lis_(lis), parentli_(parentli), li_(0) {} | 
 | 165 |  | 
 | 166 |   /// reset - clear all data structures and start a new live interval. | 
 | 167 |   void reset(LiveInterval *); | 
 | 168 |  | 
 | 169 |   /// getLI - return the current live interval. | 
 | 170 |   LiveInterval *getLI() const { return li_; } | 
| Jakob Stoklund Olesen | 1407c84 | 2010-08-18 19:00:08 +0000 | [diff] [blame] | 171 |  | 
 | 172 |   /// defValue - define a value in li_ from the parentli_ value VNI and Idx. | 
 | 173 |   /// Idx does not have to be ParentVNI->def, but it must be contained within | 
 | 174 |   /// ParentVNI's live range in parentli_. | 
 | 175 |   /// Return the new li_ value. | 
 | 176 |   VNInfo *defValue(const VNInfo *ParentVNI, SlotIndex Idx); | 
 | 177 |  | 
 | 178 |   /// mapValue - map ParentVNI to the corresponding li_ value at Idx. It is | 
 | 179 |   /// assumed that ParentVNI is live at Idx. | 
 | 180 |   /// If ParentVNI has not been defined by defValue, it is assumed that | 
 | 181 |   /// ParentVNI->def dominates Idx. | 
 | 182 |   /// If ParentVNI has been defined by defValue one or more times, a value that | 
 | 183 |   /// dominates Idx will be returned. This may require creating extra phi-def | 
 | 184 |   /// values and adding live ranges to li_. | 
| Jakob Stoklund Olesen | 5fa42a4 | 2010-09-21 22:32:21 +0000 | [diff] [blame] | 185 |   /// If simple is not NULL, *simple will indicate if ParentVNI is a simply | 
 | 186 |   /// mapped value. | 
 | 187 |   VNInfo *mapValue(const VNInfo *ParentVNI, SlotIndex Idx, bool *simple = 0); | 
 | 188 |  | 
| Jakob Stoklund Olesen | fc60d77 | 2010-10-05 20:36:25 +0000 | [diff] [blame] | 189 |   // extendTo - Find the last li_ value defined in MBB at or before Idx. The | 
 | 190 |   // parentli is assumed to be live at Idx. Extend the live range to include | 
 | 191 |   // Idx. Return the found VNInfo, or NULL. | 
 | 192 |   VNInfo *extendTo(MachineBasicBlock *MBB, SlotIndex Idx); | 
 | 193 |  | 
| Jakob Stoklund Olesen | 5fa42a4 | 2010-09-21 22:32:21 +0000 | [diff] [blame] | 194 |   /// isMapped - Return true is ParentVNI is a known mapped value. It may be a | 
 | 195 |   /// simple 1-1 mapping or a complex mapping to later defs. | 
 | 196 |   bool isMapped(const VNInfo *ParentVNI) const { | 
 | 197 |     return valueMap_.count(ParentVNI); | 
 | 198 |   } | 
 | 199 |  | 
 | 200 |   /// isComplexMapped - Return true if ParentVNI has received new definitions | 
 | 201 |   /// with defValue. | 
 | 202 |   bool isComplexMapped(const VNInfo *ParentVNI) const; | 
 | 203 |  | 
 | 204 |   // addSimpleRange - Add a simple range from parentli_ to li_. | 
 | 205 |   // ParentVNI must be live in the [Start;End) interval. | 
 | 206 |   void addSimpleRange(SlotIndex Start, SlotIndex End, const VNInfo *ParentVNI); | 
| Jakob Stoklund Olesen | 1407c84 | 2010-08-18 19:00:08 +0000 | [diff] [blame] | 207 |  | 
 | 208 |   /// addRange - Add live ranges to li_ where [Start;End) intersects parentli_. | 
 | 209 |   /// All needed values whose def is not inside [Start;End) must be defined | 
 | 210 |   /// beforehand so mapValue will work. | 
 | 211 |   void addRange(SlotIndex Start, SlotIndex End); | 
| Jakob Stoklund Olesen | f6a129a | 2010-09-16 00:01:36 +0000 | [diff] [blame] | 212 |  | 
 | 213 |   /// defByCopyFrom - Insert a copy from Reg to li, assuming that Reg carries | 
 | 214 |   /// ParentVNI. Add a minimal live range for the new value and return it. | 
 | 215 |   VNInfo *defByCopyFrom(unsigned Reg, | 
 | 216 |                         const VNInfo *ParentVNI, | 
 | 217 |                         MachineBasicBlock &MBB, | 
 | 218 |                         MachineBasicBlock::iterator I); | 
 | 219 |  | 
| Jakob Stoklund Olesen | 1407c84 | 2010-08-18 19:00:08 +0000 | [diff] [blame] | 220 | }; | 
 | 221 |  | 
 | 222 |  | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 223 | /// SplitEditor - Edit machine code and LiveIntervals for live range | 
 | 224 | /// splitting. | 
 | 225 | /// | 
| Jakob Stoklund Olesen | 5eb308b | 2010-08-06 22:17:33 +0000 | [diff] [blame] | 226 | /// - Create a SplitEditor from a SplitAnalysis. | 
| Jakob Stoklund Olesen | 7536f72 | 2010-08-04 22:08:39 +0000 | [diff] [blame] | 227 | /// - Start a new live interval with openIntv. | 
 | 228 | /// - Mark the places where the new interval is entered using enterIntv* | 
 | 229 | /// - Mark the ranges where the new interval is used with useIntv*  | 
 | 230 | /// - Mark the places where the interval is exited with exitIntv*. | 
 | 231 | /// - Finish the current interval with closeIntv and repeat from 2. | 
| Jakob Stoklund Olesen | 7466927 | 2010-10-08 23:42:21 +0000 | [diff] [blame] | 232 | /// - Rewrite instructions with finish(). | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 233 | /// | 
 | 234 | class SplitEditor { | 
 | 235 |   SplitAnalysis &sa_; | 
 | 236 |   LiveIntervals &lis_; | 
 | 237 |   VirtRegMap &vrm_; | 
 | 238 |   MachineRegisterInfo &mri_; | 
 | 239 |   const TargetInstrInfo &tii_; | 
 | 240 |  | 
| Jakob Stoklund Olesen | 5eb308b | 2010-08-06 22:17:33 +0000 | [diff] [blame] | 241 |   /// curli_ - The immutable interval we are currently splitting. | 
 | 242 |   const LiveInterval *const curli_; | 
 | 243 |  | 
 | 244 |   /// dupli_ - Created as a copy of curli_, ranges are carved out as new | 
 | 245 |   /// intervals get added through openIntv / closeIntv. This is used to avoid | 
 | 246 |   /// editing curli_. | 
| Jakob Stoklund Olesen | dd9f3fd | 2010-09-13 23:29:11 +0000 | [diff] [blame] | 247 |   LiveIntervalMap dupli_; | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 248 |  | 
 | 249 |   /// Currently open LiveInterval. | 
| Jakob Stoklund Olesen | dd9f3fd | 2010-09-13 23:29:11 +0000 | [diff] [blame] | 250 |   LiveIntervalMap openli_; | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 251 |  | 
 | 252 |   /// createInterval - Create a new virtual register and LiveInterval with same | 
 | 253 |   /// register class and spill slot as curli. | 
 | 254 |   LiveInterval *createInterval(); | 
 | 255 |  | 
| Jakob Stoklund Olesen | 7536f72 | 2010-08-04 22:08:39 +0000 | [diff] [blame] | 256 |   /// All the new intervals created for this split are added to intervals_. | 
| Jakob Stoklund Olesen | 0a2b2a1 | 2010-08-13 22:56:53 +0000 | [diff] [blame] | 257 |   SmallVectorImpl<LiveInterval*> &intervals_; | 
| Jakob Stoklund Olesen | 7536f72 | 2010-08-04 22:08:39 +0000 | [diff] [blame] | 258 |  | 
 | 259 |   /// The index into intervals_ of the first interval we added. There may be | 
 | 260 |   /// others from before we got it. | 
 | 261 |   unsigned firstInterval; | 
 | 262 |  | 
| Jakob Stoklund Olesen | 5fa42a4 | 2010-09-21 22:32:21 +0000 | [diff] [blame] | 263 |   /// intervalsLiveAt - Return true if any member of intervals_ is live at Idx. | 
 | 264 |   bool intervalsLiveAt(SlotIndex Idx) const; | 
 | 265 |  | 
 | 266 |   /// Values in curli whose live range has been truncated when entering an open | 
 | 267 |   /// li. | 
 | 268 |   SmallPtrSet<const VNInfo*, 8> truncatedValues; | 
 | 269 |  | 
 | 270 |   /// addTruncSimpleRange - Add the given simple range to dupli_ after | 
 | 271 |   /// truncating any overlap with intervals_. | 
 | 272 |   void addTruncSimpleRange(SlotIndex Start, SlotIndex End, VNInfo *VNI); | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 273 |  | 
| Jakob Stoklund Olesen | 7466927 | 2010-10-08 23:42:21 +0000 | [diff] [blame] | 274 |   /// computeRemainder - Compute the dupli liveness as the complement of all the | 
 | 275 |   /// new intervals. | 
 | 276 |   void computeRemainder(); | 
 | 277 |  | 
 | 278 |   /// rewrite - Rewrite all uses of reg to use the new registers. | 
 | 279 |   void rewrite(unsigned reg); | 
 | 280 |  | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 281 | public: | 
 | 282 |   /// Create a new SplitEditor for editing the LiveInterval analyzed by SA. | 
| Jakob Stoklund Olesen | 7536f72 | 2010-08-04 22:08:39 +0000 | [diff] [blame] | 283 |   /// Newly created intervals will be appended to newIntervals. | 
 | 284 |   SplitEditor(SplitAnalysis &SA, LiveIntervals&, VirtRegMap&, | 
| Jakob Stoklund Olesen | 0a2b2a1 | 2010-08-13 22:56:53 +0000 | [diff] [blame] | 285 |               SmallVectorImpl<LiveInterval*> &newIntervals); | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 286 |  | 
| Jakob Stoklund Olesen | 5eb308b | 2010-08-06 22:17:33 +0000 | [diff] [blame] | 287 |   /// getAnalysis - Get the corresponding analysis. | 
 | 288 |   SplitAnalysis &getAnalysis() { return sa_; } | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 289 |  | 
| Jakob Stoklund Olesen | 7536f72 | 2010-08-04 22:08:39 +0000 | [diff] [blame] | 290 |   /// Create a new virtual register and live interval. | 
 | 291 |   void openIntv(); | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 292 |  | 
| Jakob Stoklund Olesen | f1b05f2 | 2010-08-12 17:07:14 +0000 | [diff] [blame] | 293 |   /// enterIntvBefore - Enter openli before the instruction at Idx. If curli is | 
 | 294 |   /// not live before Idx, a COPY is not inserted. | 
 | 295 |   void enterIntvBefore(SlotIndex Idx); | 
 | 296 |  | 
| Jakob Stoklund Olesen | 7536f72 | 2010-08-04 22:08:39 +0000 | [diff] [blame] | 297 |   /// enterIntvAtEnd - Enter openli at the end of MBB. | 
| Jakob Stoklund Olesen | f6a129a | 2010-09-16 00:01:36 +0000 | [diff] [blame] | 298 |   void enterIntvAtEnd(MachineBasicBlock &MBB); | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 299 |  | 
| Jakob Stoklund Olesen | 7536f72 | 2010-08-04 22:08:39 +0000 | [diff] [blame] | 300 |   /// useIntv - indicate that all instructions in MBB should use openli. | 
 | 301 |   void useIntv(const MachineBasicBlock &MBB); | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 302 |  | 
| Jakob Stoklund Olesen | 7536f72 | 2010-08-04 22:08:39 +0000 | [diff] [blame] | 303 |   /// useIntv - indicate that all instructions in range should use openli. | 
 | 304 |   void useIntv(SlotIndex Start, SlotIndex End); | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 305 |  | 
| Jakob Stoklund Olesen | f1b05f2 | 2010-08-12 17:07:14 +0000 | [diff] [blame] | 306 |   /// leaveIntvAfter - Leave openli after the instruction at Idx. | 
 | 307 |   void leaveIntvAfter(SlotIndex Idx); | 
 | 308 |  | 
| Jakob Stoklund Olesen | 7536f72 | 2010-08-04 22:08:39 +0000 | [diff] [blame] | 309 |   /// leaveIntvAtTop - Leave the interval at the top of MBB. | 
 | 310 |   /// Currently, only one value can leave the interval. | 
 | 311 |   void leaveIntvAtTop(MachineBasicBlock &MBB); | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 312 |  | 
| Jakob Stoklund Olesen | 7536f72 | 2010-08-04 22:08:39 +0000 | [diff] [blame] | 313 |   /// closeIntv - Indicate that we are done editing the currently open | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 314 |   /// LiveInterval, and ranges can be trimmed. | 
| Jakob Stoklund Olesen | 7536f72 | 2010-08-04 22:08:39 +0000 | [diff] [blame] | 315 |   void closeIntv(); | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 316 |  | 
| Jakob Stoklund Olesen | 7466927 | 2010-10-08 23:42:21 +0000 | [diff] [blame] | 317 |   /// finish - after all the new live ranges have been created, compute the | 
 | 318 |   /// remaining live range, and rewrite instructions to use the new registers. | 
 | 319 |   void finish(); | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 320 |  | 
 | 321 |   // ===--- High level methods ---=== | 
 | 322 |  | 
 | 323 |   /// splitAroundLoop - Split curli into a separate live interval inside | 
| Jakob Stoklund Olesen | 57d0f2d | 2010-10-05 22:19:33 +0000 | [diff] [blame] | 324 |   /// the loop. | 
 | 325 |   void splitAroundLoop(const MachineLoop*); | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 326 |  | 
| Jakob Stoklund Olesen | f1b05f2 | 2010-08-12 17:07:14 +0000 | [diff] [blame] | 327 |   /// splitSingleBlocks - Split curli into a separate live interval inside each | 
| Jakob Stoklund Olesen | 57d0f2d | 2010-10-05 22:19:33 +0000 | [diff] [blame] | 328 |   /// basic block in Blocks. | 
 | 329 |   void splitSingleBlocks(const SplitAnalysis::BlockPtrSet &Blocks); | 
| Jakob Stoklund Olesen | f017900 | 2010-07-26 23:44:11 +0000 | [diff] [blame] | 330 |  | 
| Jakob Stoklund Olesen | 57d0f2d | 2010-10-05 22:19:33 +0000 | [diff] [blame] | 331 |   /// splitInsideBlock - Split curli into multiple intervals inside MBB. | 
 | 332 |   void splitInsideBlock(const MachineBasicBlock *); | 
| Jakob Stoklund Olesen | fc412d8 | 2010-08-13 21:18:48 +0000 | [diff] [blame] | 333 | }; | 
| Jakob Stoklund Olesen | 8ae0263 | 2010-07-20 15:41:07 +0000 | [diff] [blame] | 334 |  | 
 | 335 | } |