blob: 2ae760a58da5250f3e8668948358c17bae42b0b7 [file] [log] [blame]
Jakob Stoklund Olesen8dd070e2011-01-04 21:10:05 +00001//===-------- SplitKit.h - Toolkit for splitting live ranges ----*- C++ -*-===//
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +00002//
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
Sebastian Redl6796e4f2011-04-24 15:46:51 +000015#ifndef LLVM_CODEGEN_SPLITKIT_H
16#define LLVM_CODEGEN_SPLITKIT_H
17
Jakob Stoklund Olesendb529a82011-04-06 03:57:00 +000018#include "llvm/ADT/ArrayRef.h"
Jakob Stoklund Olesen13ba2da2011-03-04 00:15:36 +000019#include "llvm/ADT/BitVector.h"
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +000020#include "llvm/ADT/DenseMap.h"
Jakob Stoklund Olesen13ba2da2011-03-04 00:15:36 +000021#include "llvm/ADT/IndexedMap.h"
Eric Christopher0f438112011-02-03 06:18:29 +000022#include "llvm/ADT/IntervalMap.h"
Jakob Stoklund Olesen8d0963f2010-12-21 01:50:21 +000023#include "llvm/ADT/SmallPtrSet.h"
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +000024#include "llvm/CodeGen/SlotIndexes.h"
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +000025
26namespace llvm {
27
Eric Christopher0f438112011-02-03 06:18:29 +000028class ConnectedVNInfoEqClasses;
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +000029class LiveInterval;
30class LiveIntervals;
Jakob Stoklund Olesena17768f2010-10-14 23:49:52 +000031class LiveRangeEdit;
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +000032class MachineInstr;
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +000033class MachineLoopInfo;
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +000034class MachineRegisterInfo;
Jakob Stoklund Olesen6a0dc072010-07-20 21:46:58 +000035class TargetInstrInfo;
Jakob Stoklund Olesencfa71342010-11-10 19:31:50 +000036class TargetRegisterInfo;
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +000037class VirtRegMap;
38class VNInfo;
Jakob Stoklund Olesen532de3d2010-10-22 20:28:21 +000039class raw_ostream;
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +000040
Jakob Stoklund Olesene1dde7b2010-10-28 20:34:52 +000041/// At some point we should just include MachineDominators.h:
42class MachineDominatorTree;
43template <class NodeT> class DomTreeNodeBase;
44typedef DomTreeNodeBase<MachineBasicBlock> MachineDomTreeNode;
45
Jakob Stoklund Olesen8d0963f2010-12-21 01:50:21 +000046
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +000047/// SplitAnalysis - Analyze a LiveInterval, looking for live range splitting
48/// opportunities.
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +000049class SplitAnalysis {
Jakob Stoklund Olesen08e93b12010-08-10 17:07:22 +000050public:
Jakob Stoklund Olesen07862842011-01-26 00:50:53 +000051 const MachineFunction &MF;
Jakob Stoklund Olesen1b847de2011-02-19 00:53:42 +000052 const VirtRegMap &VRM;
Jakob Stoklund Olesen07862842011-01-26 00:50:53 +000053 const LiveIntervals &LIS;
54 const MachineLoopInfo &Loops;
55 const TargetInstrInfo &TII;
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +000056
Jakob Stoklund Olesenb5fa9332011-01-18 21:13:27 +000057 // Sorted slot indexes of using instructions.
58 SmallVector<SlotIndex, 8> UseSlots;
59
Jakob Stoklund Olesenf0ac26c2011-02-09 22:50:26 +000060 /// Additional information about basic blocks where the current variable is
61 /// live. Such a block will look like one of these templates:
62 ///
63 /// 1. | o---x | Internal to block. Variable is only live in this block.
64 /// 2. |---x | Live-in, kill.
65 /// 3. | o---| Def, live-out.
66 /// 4. |---x o---| Live-in, kill, def, live-out.
67 /// 5. |---o---o---| Live-through with uses or defs.
68 /// 6. |-----------| Live-through without uses. Transparent.
69 ///
70 struct BlockInfo {
71 MachineBasicBlock *MBB;
72 SlotIndex FirstUse; ///< First instr using current reg.
73 SlotIndex LastUse; ///< Last instr using current reg.
74 SlotIndex Kill; ///< Interval end point inside block.
75 SlotIndex Def; ///< Interval start point inside block.
Jakob Stoklund Olesenf0ac26c2011-02-09 22:50:26 +000076 bool LiveThrough; ///< Live in whole block (Templ 5. or 6. above).
77 bool LiveIn; ///< Current reg is live in.
78 bool LiveOut; ///< Current reg is live out.
Jakob Stoklund Olesenf0ac26c2011-02-09 22:50:26 +000079 };
80
Jakob Stoklund Olesenf1b05f22010-08-12 17:07:14 +000081private:
82 // Current live interval.
Jakob Stoklund Olesen07862842011-01-26 00:50:53 +000083 const LiveInterval *CurLI;
Jakob Stoklund Olesenf1b05f22010-08-12 17:07:14 +000084
Jakob Stoklund Olesen1a774452011-04-05 04:20:27 +000085 /// LastSplitPoint - Last legal split point in each basic block in the current
86 /// function. The first entry is the first terminator, the second entry is the
87 /// last valid split point for a variable that is live in to a landing pad
88 /// successor.
89 SmallVector<std::pair<SlotIndex, SlotIndex>, 8> LastSplitPoint;
90
Jakob Stoklund Olesendb529a82011-04-06 03:57:00 +000091 /// UseBlocks - Blocks where CurLI has uses.
92 SmallVector<BlockInfo, 8> UseBlocks;
93
94 /// ThroughBlocks - Block numbers where CurLI is live through without uses.
Jakob Stoklund Olesenf4afdfc2011-04-09 02:59:09 +000095 BitVector ThroughBlocks;
96
97 /// NumThroughBlocks - Number of live-through blocks.
98 unsigned NumThroughBlocks;
Jakob Stoklund Olesendb529a82011-04-06 03:57:00 +000099
Jakob Stoklund Olesen1a774452011-04-05 04:20:27 +0000100 SlotIndex computeLastSplitPoint(unsigned Num);
101
Jakob Stoklund Olesen07862842011-01-26 00:50:53 +0000102 // Sumarize statistics by counting instructions using CurLI.
Jakob Stoklund Olesenabff2802010-07-20 16:12:37 +0000103 void analyzeUses();
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +0000104
Jakob Stoklund Olesenf0ac26c2011-02-09 22:50:26 +0000105 /// calcLiveBlockInfo - Compute per-block information about CurLI.
Jakob Stoklund Olesen2b0f9e72011-03-05 18:33:49 +0000106 bool calcLiveBlockInfo();
Jakob Stoklund Olesenf0ac26c2011-02-09 22:50:26 +0000107
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +0000108public:
Jakob Stoklund Olesen1b847de2011-02-19 00:53:42 +0000109 SplitAnalysis(const VirtRegMap &vrm, const LiveIntervals &lis,
Jakob Stoklund Olesenf2c6e362010-07-20 23:50:15 +0000110 const MachineLoopInfo &mli);
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +0000111
Jakob Stoklund Olesen07862842011-01-26 00:50:53 +0000112 /// analyze - set CurLI to the specified interval, and analyze how it may be
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +0000113 /// split.
114 void analyze(const LiveInterval *li);
115
116 /// clear - clear all data structures so SplitAnalysis is ready to analyze a
117 /// new interval.
118 void clear();
119
Jakob Stoklund Olesen034a80d2011-02-17 19:13:53 +0000120 /// getParent - Return the last analyzed interval.
121 const LiveInterval &getParent() const { return *CurLI; }
122
Jakob Stoklund Olesen1a774452011-04-05 04:20:27 +0000123 /// getLastSplitPoint - Return that base index of the last valid split point
124 /// in the basic block numbered Num.
125 SlotIndex getLastSplitPoint(unsigned Num) {
126 // Inline the common simple case.
127 if (LastSplitPoint[Num].first.isValid() &&
128 !LastSplitPoint[Num].second.isValid())
129 return LastSplitPoint[Num].first;
130 return computeLastSplitPoint(Num);
131 }
132
Jakob Stoklund Olesen06c0f252011-02-21 23:09:46 +0000133 /// isOriginalEndpoint - Return true if the original live range was killed or
134 /// (re-)defined at Idx. Idx should be the 'def' slot for a normal kill/def,
135 /// and 'use' for an early-clobber def.
136 /// This can be used to recognize code inserted by earlier live range
137 /// splitting.
138 bool isOriginalEndpoint(SlotIndex Idx) const;
139
Jakob Stoklund Olesendb529a82011-04-06 03:57:00 +0000140 /// getUseBlocks - Return an array of BlockInfo objects for the basic blocks
141 /// where CurLI has uses.
142 ArrayRef<BlockInfo> getUseBlocks() { return UseBlocks; }
143
Jakob Stoklund Olesenf4afdfc2011-04-09 02:59:09 +0000144 /// getNumThroughBlocks - Return the number of through blocks.
145 unsigned getNumThroughBlocks() const { return NumThroughBlocks; }
146
147 /// isThroughBlock - Return true if CurLI is live through MBB without uses.
148 bool isThroughBlock(unsigned MBB) const { return ThroughBlocks.test(MBB); }
Jakob Stoklund Olesendb529a82011-04-06 03:57:00 +0000149
Jakob Stoklund Olesen5db42892011-04-12 21:30:53 +0000150 /// getThroughBlocks - Return the set of through blocks.
151 const BitVector &getThroughBlocks() const { return ThroughBlocks; }
152
Jakob Stoklund Olesen9f4b8932011-04-26 22:33:12 +0000153 /// countLiveBlocks - Return the number of blocks where li is live.
154 /// This is guaranteed to return the same number as getNumThroughBlocks() +
155 /// getUseBlocks().size() after calling analyze(li).
156 unsigned countLiveBlocks(const LiveInterval *li) const;
157
Jakob Stoklund Olesen6a0dc072010-07-20 21:46:58 +0000158 typedef SmallPtrSet<const MachineBasicBlock*, 16> BlockPtrSet;
159
Jakob Stoklund Olesenf1b05f22010-08-12 17:07:14 +0000160 /// getMultiUseBlocks - Add basic blocks to Blocks that may benefit from
Jakob Stoklund Olesen07862842011-01-26 00:50:53 +0000161 /// having CurLI split to a new live interval. Return true if Blocks can be
Jakob Stoklund Olesenf1b05f22010-08-12 17:07:14 +0000162 /// passed to SplitEditor::splitSingleBlocks.
163 bool getMultiUseBlocks(BlockPtrSet &Blocks);
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +0000164};
165
Jakob Stoklund Olesen1407c842010-08-18 19:00:08 +0000166
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000167/// SplitEditor - Edit machine code and LiveIntervals for live range
168/// splitting.
169///
Jakob Stoklund Olesen5eb308b2010-08-06 22:17:33 +0000170/// - Create a SplitEditor from a SplitAnalysis.
Jakob Stoklund Olesen7536f722010-08-04 22:08:39 +0000171/// - Start a new live interval with openIntv.
172/// - Mark the places where the new interval is entered using enterIntv*
173/// - Mark the ranges where the new interval is used with useIntv*
174/// - Mark the places where the interval is exited with exitIntv*.
175/// - Finish the current interval with closeIntv and repeat from 2.
Jakob Stoklund Olesen74669272010-10-08 23:42:21 +0000176/// - Rewrite instructions with finish().
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000177///
178class SplitEditor {
Jakob Stoklund Olesen0eeca442011-02-19 00:42:33 +0000179 SplitAnalysis &SA;
Jakob Stoklund Olesen07862842011-01-26 00:50:53 +0000180 LiveIntervals &LIS;
181 VirtRegMap &VRM;
182 MachineRegisterInfo &MRI;
Eric Christopher0f438112011-02-03 06:18:29 +0000183 MachineDominatorTree &MDT;
Jakob Stoklund Olesen07862842011-01-26 00:50:53 +0000184 const TargetInstrInfo &TII;
185 const TargetRegisterInfo &TRI;
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000186
Jakob Stoklund Olesen07862842011-01-26 00:50:53 +0000187 /// Edit - The current parent register and new intervals created.
Jakob Stoklund Olesena2cae582011-03-02 23:31:50 +0000188 LiveRangeEdit *Edit;
Jakob Stoklund Olesena17768f2010-10-14 23:49:52 +0000189
Eric Christopher0f438112011-02-03 06:18:29 +0000190 /// Index into Edit of the currently open interval.
191 /// The index 0 is used for the complement, so the first interval started by
192 /// openIntv will be 1.
193 unsigned OpenIdx;
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000194
Eric Christopher0f438112011-02-03 06:18:29 +0000195 typedef IntervalMap<SlotIndex, unsigned> RegAssignMap;
196
197 /// Allocator for the interval map. This will eventually be shared with
198 /// SlotIndexes and LiveIntervals.
199 RegAssignMap::Allocator Allocator;
200
201 /// RegAssign - Map of the assigned register indexes.
202 /// Edit.get(RegAssign.lookup(Idx)) is the register that should be live at
203 /// Idx.
204 RegAssignMap RegAssign;
205
Jakob Stoklund Olesen670ccd12011-03-01 23:14:53 +0000206 typedef DenseMap<std::pair<unsigned, unsigned>, VNInfo*> ValueMap;
207
208 /// Values - keep track of the mapping from parent values to values in the new
209 /// intervals. Given a pair (RegIdx, ParentVNI->id), Values contains:
210 ///
211 /// 1. No entry - the value is not mapped to Edit.get(RegIdx).
212 /// 2. Null - the value is mapped to multiple values in Edit.get(RegIdx).
213 /// Each value is represented by a minimal live range at its def.
214 /// 3. A non-null VNInfo - the value is mapped to a single new value.
215 /// The new value has no live ranges anywhere.
216 ValueMap Values;
217
Jakob Stoklund Olesen1c38ba62011-03-02 01:59:34 +0000218 typedef std::pair<VNInfo*, MachineDomTreeNode*> LiveOutPair;
Jakob Stoklund Olesen13ba2da2011-03-04 00:15:36 +0000219 typedef IndexedMap<LiveOutPair, MBB2NumberFunctor> LiveOutMap;
Jakob Stoklund Olesen1c38ba62011-03-02 01:59:34 +0000220
221 // LiveOutCache - Map each basic block where a new register is live out to the
222 // live-out value and its defining block.
223 // One of these conditions shall be true:
224 //
225 // 1. !LiveOutCache.count(MBB)
226 // 2. LiveOutCache[MBB].second.getNode() == MBB
227 // 3. forall P in preds(MBB): LiveOutCache[P] == LiveOutCache[MBB]
228 //
229 // This is only a cache, the values can be computed as:
230 //
231 // VNI = Edit.get(RegIdx)->getVNInfoAt(LIS.getMBBEndIdx(MBB))
232 // Node = mbt_[LIS.getMBBFromIndex(VNI->def)]
233 //
234 // The cache is also used as a visited set by extendRange(). It can be shared
235 // by all the new registers because at most one is live out of each block.
236 LiveOutMap LiveOutCache;
237
Jakob Stoklund Olesen13ba2da2011-03-04 00:15:36 +0000238 // LiveOutSeen - Indexed by MBB->getNumber(), a bit is set for each valid
239 // entry in LiveOutCache.
240 BitVector LiveOutSeen;
241
Jakob Stoklund Olesen44b7ae22011-04-15 17:24:49 +0000242 /// LiveInBlock - Info for updateSSA() about a block where a register is
243 /// live-in.
244 /// The updateSSA caller provides DomNode and Kill inside MBB, updateSSA()
245 /// adds the computed live-in value.
246 struct LiveInBlock {
247 // Dominator tree node for the block.
248 // Cleared by updateSSA when the final value has been determined.
249 MachineDomTreeNode *DomNode;
250
251 // Live-in value filled in by updateSSA once it is known.
252 VNInfo *Value;
253
254 // Position in block where the live-in range ends, or SlotIndex() if the
255 // range passes through the block.
256 SlotIndex Kill;
257
258 LiveInBlock(MachineDomTreeNode *node) : DomNode(node), Value(0) {}
259 };
260
261 /// LiveInBlocks - List of live-in blocks used by findReachingDefs() and
262 /// updateSSA(). This list is usually empty, it exists here to avoid frequent
263 /// reallocations.
264 SmallVector<LiveInBlock, 16> LiveInBlocks;
265
Jakob Stoklund Olesen670ccd12011-03-01 23:14:53 +0000266 /// defValue - define a value in RegIdx from ParentVNI at Idx.
267 /// Idx does not have to be ParentVNI->def, but it must be contained within
268 /// ParentVNI's live range in ParentLI. The new value is added to the value
269 /// map.
270 /// Return the new LI value.
271 VNInfo *defValue(unsigned RegIdx, const VNInfo *ParentVNI, SlotIndex Idx);
272
273 /// markComplexMapped - Mark ParentVNI as complex mapped in RegIdx regardless
274 /// of the number of defs.
275 void markComplexMapped(unsigned RegIdx, const VNInfo *ParentVNI);
276
Jakob Stoklund Olesencfa71342010-11-10 19:31:50 +0000277 /// defFromParent - Define Reg from ParentVNI at UseIdx using either
278 /// rematerialization or a COPY from parent. Return the new value.
Eric Christopher0f438112011-02-03 06:18:29 +0000279 VNInfo *defFromParent(unsigned RegIdx,
Jakob Stoklund Olesencfa71342010-11-10 19:31:50 +0000280 VNInfo *ParentVNI,
281 SlotIndex UseIdx,
282 MachineBasicBlock &MBB,
283 MachineBasicBlock::iterator I);
284
Jakob Stoklund Olesen1c38ba62011-03-02 01:59:34 +0000285 /// extendRange - Extend the live range of Edit.get(RegIdx) so it reaches Idx.
286 /// Insert PHIDefs as needed to preserve SSA form.
287 void extendRange(unsigned RegIdx, SlotIndex Idx);
288
Jakob Stoklund Olesen44b7ae22011-04-15 17:24:49 +0000289 /// findReachingDefs - Starting from MBB, add blocks to LiveInBlocks until all
290 /// reaching defs for LI are found.
291 /// @param LI Live interval whose value is needed.
292 /// @param MBB Block where LI should be live-in.
293 /// @param Kill Kill point in MBB.
294 /// @return Unique value seen, or NULL.
295 VNInfo *findReachingDefs(LiveInterval *LI, MachineBasicBlock *MBB,
296 SlotIndex Kill);
Jakob Stoklund Olesen1c38ba62011-03-02 01:59:34 +0000297
Jakob Stoklund Olesen44b7ae22011-04-15 17:24:49 +0000298 /// updateSSA - Compute and insert PHIDefs such that all blocks in
299 // LiveInBlocks get a known live-in value. Add live ranges to the blocks.
300 void updateSSA();
301
302 /// transferValues - Transfer values to the new ranges.
303 /// Return true if any ranges were skipped.
304 bool transferValues();
Jakob Stoklund Olesen46703532011-03-02 23:05:19 +0000305
Jakob Stoklund Olesene2dc0c92011-03-02 23:05:16 +0000306 /// extendPHIKillRanges - Extend the ranges of all values killed by original
307 /// parent PHIDefs.
308 void extendPHIKillRanges();
309
Eric Christopher0f438112011-02-03 06:18:29 +0000310 /// rewriteAssigned - Rewrite all uses of Edit.getReg() to assigned registers.
Jakob Stoklund Olesen46703532011-03-02 23:05:19 +0000311 void rewriteAssigned(bool ExtendRanges);
Jakob Stoklund Olesen5fa42a42010-09-21 22:32:21 +0000312
Jakob Stoklund Olesen58817992011-03-08 22:46:11 +0000313 /// deleteRematVictims - Delete defs that are dead after rematerializing.
314 void deleteRematVictims();
315
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000316public:
317 /// Create a new SplitEditor for editing the LiveInterval analyzed by SA.
Jakob Stoklund Olesen7536f722010-08-04 22:08:39 +0000318 /// Newly created intervals will be appended to newIntervals.
Jakob Stoklund Olesend68f4582010-10-28 20:34:50 +0000319 SplitEditor(SplitAnalysis &SA, LiveIntervals&, VirtRegMap&,
Jakob Stoklund Olesenbece06f2011-03-03 01:29:13 +0000320 MachineDominatorTree&);
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000321
Jakob Stoklund Olesenbece06f2011-03-03 01:29:13 +0000322 /// reset - Prepare for a new split.
323 void reset(LiveRangeEdit&);
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000324
Jakob Stoklund Olesen7536f722010-08-04 22:08:39 +0000325 /// Create a new virtual register and live interval.
Jakob Stoklund Olesene1b43c32011-04-12 18:11:31 +0000326 /// Return the interval index, starting from 1. Interval index 0 is the
327 /// implicit complement interval.
328 unsigned openIntv();
329
330 /// currentIntv - Return the current interval index.
331 unsigned currentIntv() const { return OpenIdx; }
332
333 /// selectIntv - Select a previously opened interval index.
334 void selectIntv(unsigned Idx);
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000335
Jakob Stoklund Olesen207c8682011-02-03 17:04:16 +0000336 /// enterIntvBefore - Enter the open interval before the instruction at Idx.
337 /// If the parent interval is not live before Idx, a COPY is not inserted.
338 /// Return the beginning of the new live range.
339 SlotIndex enterIntvBefore(SlotIndex Idx);
Jakob Stoklund Olesenf1b05f22010-08-12 17:07:14 +0000340
Jakob Stoklund Olesen207c8682011-02-03 17:04:16 +0000341 /// enterIntvAtEnd - Enter the open interval at the end of MBB.
342 /// Use the open interval from he inserted copy to the MBB end.
343 /// Return the beginning of the new live range.
344 SlotIndex enterIntvAtEnd(MachineBasicBlock &MBB);
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000345
Jakob Stoklund Olesen07862842011-01-26 00:50:53 +0000346 /// useIntv - indicate that all instructions in MBB should use OpenLI.
Jakob Stoklund Olesen7536f722010-08-04 22:08:39 +0000347 void useIntv(const MachineBasicBlock &MBB);
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000348
Jakob Stoklund Olesen07862842011-01-26 00:50:53 +0000349 /// useIntv - indicate that all instructions in range should use OpenLI.
Jakob Stoklund Olesen7536f722010-08-04 22:08:39 +0000350 void useIntv(SlotIndex Start, SlotIndex End);
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000351
Jakob Stoklund Olesen207c8682011-02-03 17:04:16 +0000352 /// leaveIntvAfter - Leave the open interval after the instruction at Idx.
353 /// Return the end of the live range.
354 SlotIndex leaveIntvAfter(SlotIndex Idx);
Jakob Stoklund Olesenf1b05f22010-08-12 17:07:14 +0000355
Jakob Stoklund Olesen9b057772011-02-09 23:30:25 +0000356 /// leaveIntvBefore - Leave the open interval before the instruction at Idx.
357 /// Return the end of the live range.
358 SlotIndex leaveIntvBefore(SlotIndex Idx);
359
Jakob Stoklund Olesen7536f722010-08-04 22:08:39 +0000360 /// leaveIntvAtTop - Leave the interval at the top of MBB.
Jakob Stoklund Olesen207c8682011-02-03 17:04:16 +0000361 /// Add liveness from the MBB top to the copy.
362 /// Return the end of the live range.
363 SlotIndex leaveIntvAtTop(MachineBasicBlock &MBB);
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000364
Jakob Stoklund Olesen5c716bd2011-02-08 18:50:21 +0000365 /// overlapIntv - Indicate that all instructions in range should use the open
366 /// interval, but also let the complement interval be live.
367 ///
368 /// This doubles the register pressure, but is sometimes required to deal with
369 /// register uses after the last valid split point.
370 ///
371 /// The Start index should be a return value from a leaveIntv* call, and End
372 /// should be in the same basic block. The parent interval must have the same
373 /// value across the range.
374 ///
375 void overlapIntv(SlotIndex Start, SlotIndex End);
376
Jakob Stoklund Olesen74669272010-10-08 23:42:21 +0000377 /// finish - after all the new live ranges have been created, compute the
378 /// remaining live range, and rewrite instructions to use the new registers.
Jakob Stoklund Olesen59280462011-04-21 18:38:15 +0000379 /// @param LRMap When not null, this vector will map each live range in Edit
380 /// back to the indices returned by openIntv.
381 /// There may be extra indices created by dead code elimination.
382 void finish(SmallVectorImpl<unsigned> *LRMap = 0);
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000383
Eric Christopher0f438112011-02-03 06:18:29 +0000384 /// dump - print the current interval maping to dbgs().
385 void dump() const;
386
Jakob Stoklund Olesenf0179002010-07-26 23:44:11 +0000387 // ===--- High level methods ---===
388
Jakob Stoklund Olesenfd5c5132011-04-12 19:32:53 +0000389 /// splitSingleBlock - Split CurLI into a separate live interval around the
390 /// uses in a single block. This is intended to be used as part of a larger
391 /// split, and doesn't call finish().
392 void splitSingleBlock(const SplitAnalysis::BlockInfo &BI);
393
Jakob Stoklund Olesen07862842011-01-26 00:50:53 +0000394 /// splitSingleBlocks - Split CurLI into a separate live interval inside each
Jakob Stoklund Olesen57d0f2d2010-10-05 22:19:33 +0000395 /// basic block in Blocks.
396 void splitSingleBlocks(const SplitAnalysis::BlockPtrSet &Blocks);
Jakob Stoklund Olesenfc412d82010-08-13 21:18:48 +0000397};
Jakob Stoklund Olesen8ae02632010-07-20 15:41:07 +0000398
399}
Sebastian Redl6796e4f2011-04-24 15:46:51 +0000400
401#endif