1218893Sdim//===-------- SplitKit.h - Toolkit for splitting live ranges ----*- C++ -*-===//
2212793Sdim//
3212793Sdim//                     The LLVM Compiler Infrastructure
4212793Sdim//
5212793Sdim// This file is distributed under the University of Illinois Open Source
6212793Sdim// License. See LICENSE.TXT for details.
7212793Sdim//
8212793Sdim//===----------------------------------------------------------------------===//
9212793Sdim//
10212793Sdim// This file contains the SplitAnalysis class as well as mutator functions for
11212793Sdim// live range splitting.
12212793Sdim//
13212793Sdim//===----------------------------------------------------------------------===//
14212793Sdim
15221345Sdim#ifndef LLVM_CODEGEN_SPLITKIT_H
16221345Sdim#define LLVM_CODEGEN_SPLITKIT_H
17221345Sdim
18226633Sdim#include "LiveRangeCalc.h"
19221345Sdim#include "llvm/ADT/ArrayRef.h"
20218893Sdim#include "llvm/ADT/DenseMap.h"
21218893Sdim#include "llvm/ADT/IntervalMap.h"
22212793Sdim#include "llvm/ADT/SmallPtrSet.h"
23212793Sdim
24212793Sdimnamespace llvm {
25212793Sdim
26218893Sdimclass ConnectedVNInfoEqClasses;
27212793Sdimclass LiveInterval;
28212793Sdimclass LiveIntervals;
29218893Sdimclass LiveRangeEdit;
30263508Sdimclass MachineBlockFrequencyInfo;
31212793Sdimclass MachineInstr;
32212793Sdimclass MachineLoopInfo;
33212793Sdimclass MachineRegisterInfo;
34212793Sdimclass TargetInstrInfo;
35218893Sdimclass TargetRegisterInfo;
36212793Sdimclass VirtRegMap;
37212793Sdimclass VNInfo;
38218893Sdimclass raw_ostream;
39212793Sdim
40212793Sdim/// SplitAnalysis - Analyze a LiveInterval, looking for live range splitting
41212793Sdim/// opportunities.
42212793Sdimclass SplitAnalysis {
43212793Sdimpublic:
44218893Sdim  const MachineFunction &MF;
45218893Sdim  const VirtRegMap &VRM;
46218893Sdim  const LiveIntervals &LIS;
47218893Sdim  const MachineLoopInfo &Loops;
48218893Sdim  const TargetInstrInfo &TII;
49212793Sdim
50218893Sdim  /// Additional information about basic blocks where the current variable is
51218893Sdim  /// live. Such a block will look like one of these templates:
52218893Sdim  ///
53218893Sdim  ///  1. |   o---x   | Internal to block. Variable is only live in this block.
54218893Sdim  ///  2. |---x       | Live-in, kill.
55218893Sdim  ///  3. |       o---| Def, live-out.
56223017Sdim  ///  4. |---x   o---| Live-in, kill, def, live-out. Counted by NumGapBlocks.
57218893Sdim  ///  5. |---o---o---| Live-through with uses or defs.
58223017Sdim  ///  6. |-----------| Live-through without uses. Counted by NumThroughBlocks.
59218893Sdim  ///
60223017Sdim  /// Two BlockInfo entries are created for template 4. One for the live-in
61223017Sdim  /// segment, and one for the live-out segment. These entries look as if the
62223017Sdim  /// block were split in the middle where the live range isn't live.
63223017Sdim  ///
64223017Sdim  /// Live-through blocks without any uses don't get BlockInfo entries. They
65223017Sdim  /// are simply listed in ThroughBlocks instead.
66223017Sdim  ///
67218893Sdim  struct BlockInfo {
68218893Sdim    MachineBasicBlock *MBB;
69226633Sdim    SlotIndex FirstInstr; ///< First instr accessing current reg.
70226633Sdim    SlotIndex LastInstr;  ///< Last instr accessing current reg.
71226633Sdim    SlotIndex FirstDef;   ///< First non-phi valno->def, or SlotIndex().
72218893Sdim    bool LiveIn;          ///< Current reg is live in.
73218893Sdim    bool LiveOut;         ///< Current reg is live out.
74224145Sdim
75224145Sdim    /// isOneInstr - Returns true when this BlockInfo describes a single
76224145Sdim    /// instruction.
77224145Sdim    bool isOneInstr() const {
78226633Sdim      return SlotIndex::isSameInstr(FirstInstr, LastInstr);
79224145Sdim    }
80218893Sdim  };
81218893Sdim
82212793Sdimprivate:
83212793Sdim  // Current live interval.
84218893Sdim  const LiveInterval *CurLI;
85212793Sdim
86234353Sdim  // Sorted slot indexes of using instructions.
87234353Sdim  SmallVector<SlotIndex, 8> UseSlots;
88234353Sdim
89221345Sdim  /// LastSplitPoint - Last legal split point in each basic block in the current
90221345Sdim  /// function. The first entry is the first terminator, the second entry is the
91221345Sdim  /// last valid split point for a variable that is live in to a landing pad
92221345Sdim  /// successor.
93221345Sdim  SmallVector<std::pair<SlotIndex, SlotIndex>, 8> LastSplitPoint;
94221345Sdim
95221345Sdim  /// UseBlocks - Blocks where CurLI has uses.
96221345Sdim  SmallVector<BlockInfo, 8> UseBlocks;
97221345Sdim
98223017Sdim  /// NumGapBlocks - Number of duplicate entries in UseBlocks for blocks where
99223017Sdim  /// the live range has a gap.
100223017Sdim  unsigned NumGapBlocks;
101223017Sdim
102221345Sdim  /// ThroughBlocks - Block numbers where CurLI is live through without uses.
103221345Sdim  BitVector ThroughBlocks;
104221345Sdim
105221345Sdim  /// NumThroughBlocks - Number of live-through blocks.
106221345Sdim  unsigned NumThroughBlocks;
107221345Sdim
108223017Sdim  /// DidRepairRange - analyze was forced to shrinkToUses().
109223017Sdim  bool DidRepairRange;
110223017Sdim
111221345Sdim  SlotIndex computeLastSplitPoint(unsigned Num);
112221345Sdim
113218893Sdim  // Sumarize statistics by counting instructions using CurLI.
114212793Sdim  void analyzeUses();
115212793Sdim
116218893Sdim  /// calcLiveBlockInfo - Compute per-block information about CurLI.
117221345Sdim  bool calcLiveBlockInfo();
118218893Sdim
119212793Sdimpublic:
120218893Sdim  SplitAnalysis(const VirtRegMap &vrm, const LiveIntervals &lis,
121212793Sdim                const MachineLoopInfo &mli);
122212793Sdim
123218893Sdim  /// analyze - set CurLI to the specified interval, and analyze how it may be
124212793Sdim  /// split.
125212793Sdim  void analyze(const LiveInterval *li);
126212793Sdim
127223017Sdim  /// didRepairRange() - Returns true if CurLI was invalid and has been repaired
128223017Sdim  /// by analyze(). This really shouldn't happen, but sometimes the coalescer
129223017Sdim  /// can create live ranges that end in mid-air.
130223017Sdim  bool didRepairRange() const { return DidRepairRange; }
131223017Sdim
132212793Sdim  /// clear - clear all data structures so SplitAnalysis is ready to analyze a
133212793Sdim  /// new interval.
134212793Sdim  void clear();
135212793Sdim
136218893Sdim  /// getParent - Return the last analyzed interval.
137218893Sdim  const LiveInterval &getParent() const { return *CurLI; }
138212793Sdim
139234353Sdim  /// getLastSplitPoint - Return the base index of the last valid split point
140221345Sdim  /// in the basic block numbered Num.
141221345Sdim  SlotIndex getLastSplitPoint(unsigned Num) {
142221345Sdim    // Inline the common simple case.
143221345Sdim    if (LastSplitPoint[Num].first.isValid() &&
144221345Sdim        !LastSplitPoint[Num].second.isValid())
145221345Sdim      return LastSplitPoint[Num].first;
146221345Sdim    return computeLastSplitPoint(Num);
147218893Sdim  }
148212793Sdim
149234353Sdim  /// getLastSplitPointIter - Returns the last split point as an iterator.
150234353Sdim  MachineBasicBlock::iterator getLastSplitPointIter(MachineBasicBlock*);
151234353Sdim
152219077Sdim  /// isOriginalEndpoint - Return true if the original live range was killed or
153219077Sdim  /// (re-)defined at Idx. Idx should be the 'def' slot for a normal kill/def,
154219077Sdim  /// and 'use' for an early-clobber def.
155219077Sdim  /// This can be used to recognize code inserted by earlier live range
156219077Sdim  /// splitting.
157219077Sdim  bool isOriginalEndpoint(SlotIndex Idx) const;
158219077Sdim
159234353Sdim  /// getUseSlots - Return an array of SlotIndexes of instructions using CurLI.
160234353Sdim  /// This include both use and def operands, at most one entry per instruction.
161234353Sdim  ArrayRef<SlotIndex> getUseSlots() const { return UseSlots; }
162234353Sdim
163221345Sdim  /// getUseBlocks - Return an array of BlockInfo objects for the basic blocks
164221345Sdim  /// where CurLI has uses.
165223017Sdim  ArrayRef<BlockInfo> getUseBlocks() const { return UseBlocks; }
166221345Sdim
167221345Sdim  /// getNumThroughBlocks - Return the number of through blocks.
168221345Sdim  unsigned getNumThroughBlocks() const { return NumThroughBlocks; }
169221345Sdim
170221345Sdim  /// isThroughBlock - Return true if CurLI is live through MBB without uses.
171221345Sdim  bool isThroughBlock(unsigned MBB) const { return ThroughBlocks.test(MBB); }
172221345Sdim
173221345Sdim  /// getThroughBlocks - Return the set of through blocks.
174221345Sdim  const BitVector &getThroughBlocks() const { return ThroughBlocks; }
175221345Sdim
176223017Sdim  /// getNumLiveBlocks - Return the number of blocks where CurLI is live.
177223017Sdim  unsigned getNumLiveBlocks() const {
178223017Sdim    return getUseBlocks().size() - NumGapBlocks + getNumThroughBlocks();
179223017Sdim  }
180223017Sdim
181223017Sdim  /// countLiveBlocks - Return the number of blocks where li is live. This is
182223017Sdim  /// guaranteed to return the same number as getNumLiveBlocks() after calling
183223017Sdim  /// analyze(li).
184221345Sdim  unsigned countLiveBlocks(const LiveInterval *li) const;
185221345Sdim
186218893Sdim  typedef SmallPtrSet<const MachineBasicBlock*, 16> BlockPtrSet;
187212793Sdim
188226633Sdim  /// shouldSplitSingleBlock - Returns true if it would help to create a local
189226633Sdim  /// live range for the instructions in BI. There is normally no benefit to
190226633Sdim  /// creating a live range for a single instruction, but it does enable
191226633Sdim  /// register class inflation if the instruction has a restricted register
192226633Sdim  /// class.
193226633Sdim  ///
194226633Sdim  /// @param BI           The block to be isolated.
195226633Sdim  /// @param SingleInstrs True when single instructions should be isolated.
196226633Sdim  bool shouldSplitSingleBlock(const BlockInfo &BI, bool SingleInstrs) const;
197212793Sdim};
198212793Sdim
199212793Sdim
200212793Sdim/// SplitEditor - Edit machine code and LiveIntervals for live range
201212793Sdim/// splitting.
202212793Sdim///
203212793Sdim/// - Create a SplitEditor from a SplitAnalysis.
204212793Sdim/// - Start a new live interval with openIntv.
205212793Sdim/// - Mark the places where the new interval is entered using enterIntv*
206212793Sdim/// - Mark the ranges where the new interval is used with useIntv*
207212793Sdim/// - Mark the places where the interval is exited with exitIntv*.
208212793Sdim/// - Finish the current interval with closeIntv and repeat from 2.
209218893Sdim/// - Rewrite instructions with finish().
210212793Sdim///
211212793Sdimclass SplitEditor {
212218893Sdim  SplitAnalysis &SA;
213218893Sdim  LiveIntervals &LIS;
214218893Sdim  VirtRegMap &VRM;
215218893Sdim  MachineRegisterInfo &MRI;
216218893Sdim  MachineDominatorTree &MDT;
217218893Sdim  const TargetInstrInfo &TII;
218218893Sdim  const TargetRegisterInfo &TRI;
219263508Sdim  const MachineBlockFrequencyInfo &MBFI;
220212793Sdim
221226633Sdimpublic:
222226633Sdim
223226633Sdim  /// ComplementSpillMode - Select how the complement live range should be
224226633Sdim  /// created.  SplitEditor automatically creates interval 0 to contain
225226633Sdim  /// anything that isn't added to another interval.  This complement interval
226226633Sdim  /// can get quite complicated, and it can sometimes be an advantage to allow
227226633Sdim  /// it to overlap the other intervals.  If it is going to spill anyway, no
228226633Sdim  /// registers are wasted by keeping a value in two places at the same time.
229226633Sdim  enum ComplementSpillMode {
230226633Sdim    /// SM_Partition(Default) - Try to create the complement interval so it
231226633Sdim    /// doesn't overlap any other intervals, and the original interval is
232226633Sdim    /// partitioned.  This may require a large number of back copies and extra
233226633Sdim    /// PHI-defs.  Only segments marked with overlapIntv will be overlapping.
234226633Sdim    SM_Partition,
235226633Sdim
236226633Sdim    /// SM_Size - Overlap intervals to minimize the number of inserted COPY
237226633Sdim    /// instructions.  Copies to the complement interval are hoisted to their
238226633Sdim    /// common dominator, so only one COPY is required per value in the
239226633Sdim    /// complement interval.  This also means that no extra PHI-defs need to be
240226633Sdim    /// inserted in the complement interval.
241226633Sdim    SM_Size,
242226633Sdim
243226633Sdim    /// SM_Speed - Overlap intervals to minimize the expected execution
244226633Sdim    /// frequency of the inserted copies.  This is very similar to SM_Size, but
245226633Sdim    /// the complement interval may get some extra PHI-defs.
246226633Sdim    SM_Speed
247226633Sdim  };
248226633Sdim
249226633Sdimprivate:
250226633Sdim
251218893Sdim  /// Edit - The current parent register and new intervals created.
252221345Sdim  LiveRangeEdit *Edit;
253212793Sdim
254218893Sdim  /// Index into Edit of the currently open interval.
255218893Sdim  /// The index 0 is used for the complement, so the first interval started by
256218893Sdim  /// openIntv will be 1.
257218893Sdim  unsigned OpenIdx;
258212793Sdim
259226633Sdim  /// The current spill mode, selected by reset().
260226633Sdim  ComplementSpillMode SpillMode;
261226633Sdim
262218893Sdim  typedef IntervalMap<SlotIndex, unsigned> RegAssignMap;
263212793Sdim
264218893Sdim  /// Allocator for the interval map. This will eventually be shared with
265218893Sdim  /// SlotIndexes and LiveIntervals.
266218893Sdim  RegAssignMap::Allocator Allocator;
267212793Sdim
268218893Sdim  /// RegAssign - Map of the assigned register indexes.
269218893Sdim  /// Edit.get(RegAssign.lookup(Idx)) is the register that should be live at
270218893Sdim  /// Idx.
271218893Sdim  RegAssignMap RegAssign;
272212793Sdim
273226633Sdim  typedef PointerIntPair<VNInfo*, 1> ValueForcePair;
274226633Sdim  typedef DenseMap<std::pair<unsigned, unsigned>, ValueForcePair> ValueMap;
275212793Sdim
276221345Sdim  /// Values - keep track of the mapping from parent values to values in the new
277221345Sdim  /// intervals. Given a pair (RegIdx, ParentVNI->id), Values contains:
278221345Sdim  ///
279221345Sdim  /// 1. No entry - the value is not mapped to Edit.get(RegIdx).
280226633Sdim  /// 2. (Null, false) - the value is mapped to multiple values in
281226633Sdim  ///    Edit.get(RegIdx).  Each value is represented by a minimal live range at
282226633Sdim  ///    its def.  The full live range can be inferred exactly from the range
283226633Sdim  ///    of RegIdx in RegAssign.
284226633Sdim  /// 3. (Null, true).  As above, but the ranges in RegAssign are too large, and
285226633Sdim  ///    the live range must be recomputed using LiveRangeCalc::extend().
286226633Sdim  /// 4. (VNI, false) The value is mapped to a single new value.
287221345Sdim  ///    The new value has no live ranges anywhere.
288221345Sdim  ValueMap Values;
289221345Sdim
290226633Sdim  /// LRCalc - Cache for computing live ranges and SSA update.  Each instance
291226633Sdim  /// can only handle non-overlapping live ranges, so use a separate
292226633Sdim  /// LiveRangeCalc instance for the complement interval when in spill mode.
293226633Sdim  LiveRangeCalc LRCalc[2];
294221345Sdim
295226633Sdim  /// getLRCalc - Return the LRCalc to use for RegIdx.  In spill mode, the
296226633Sdim  /// complement interval can overlap the other intervals, so it gets its own
297226633Sdim  /// LRCalc instance.  When not in spill mode, all intervals can share one.
298226633Sdim  LiveRangeCalc &getLRCalc(unsigned RegIdx) {
299226633Sdim    return LRCalc[SpillMode != SM_Partition && RegIdx != 0];
300226633Sdim  }
301221345Sdim
302221345Sdim  /// defValue - define a value in RegIdx from ParentVNI at Idx.
303221345Sdim  /// Idx does not have to be ParentVNI->def, but it must be contained within
304221345Sdim  /// ParentVNI's live range in ParentLI. The new value is added to the value
305221345Sdim  /// map.
306221345Sdim  /// Return the new LI value.
307221345Sdim  VNInfo *defValue(unsigned RegIdx, const VNInfo *ParentVNI, SlotIndex Idx);
308221345Sdim
309226633Sdim  /// forceRecompute - Force the live range of ParentVNI in RegIdx to be
310226633Sdim  /// recomputed by LiveRangeCalc::extend regardless of the number of defs.
311226633Sdim  /// This is used for values whose live range doesn't match RegAssign exactly.
312226633Sdim  /// They could have rematerialized, or back-copies may have been moved.
313226633Sdim  void forceRecompute(unsigned RegIdx, const VNInfo *ParentVNI);
314221345Sdim
315218893Sdim  /// defFromParent - Define Reg from ParentVNI at UseIdx using either
316218893Sdim  /// rematerialization or a COPY from parent. Return the new value.
317218893Sdim  VNInfo *defFromParent(unsigned RegIdx,
318218893Sdim                        VNInfo *ParentVNI,
319218893Sdim                        SlotIndex UseIdx,
320218893Sdim                        MachineBasicBlock &MBB,
321218893Sdim                        MachineBasicBlock::iterator I);
322212793Sdim
323226633Sdim  /// removeBackCopies - Remove the copy instructions that defines the values
324226633Sdim  /// in the vector in the complement interval.
325226633Sdim  void removeBackCopies(SmallVectorImpl<VNInfo*> &Copies);
326221345Sdim
327226633Sdim  /// getShallowDominator - Returns the least busy dominator of MBB that is
328226633Sdim  /// also dominated by DefMBB.  Busy is measured by loop depth.
329226633Sdim  MachineBasicBlock *findShallowDominator(MachineBasicBlock *MBB,
330226633Sdim                                          MachineBasicBlock *DefMBB);
331221345Sdim
332226633Sdim  /// hoistCopiesForSize - Hoist back-copies to the complement interval in a
333226633Sdim  /// way that minimizes code size. This implements the SM_Size spill mode.
334226633Sdim  void hoistCopiesForSize();
335221345Sdim
336221345Sdim  /// transferValues - Transfer values to the new ranges.
337221345Sdim  /// Return true if any ranges were skipped.
338221345Sdim  bool transferValues();
339221345Sdim
340221345Sdim  /// extendPHIKillRanges - Extend the ranges of all values killed by original
341221345Sdim  /// parent PHIDefs.
342221345Sdim  void extendPHIKillRanges();
343221345Sdim
344218893Sdim  /// rewriteAssigned - Rewrite all uses of Edit.getReg() to assigned registers.
345221345Sdim  void rewriteAssigned(bool ExtendRanges);
346212793Sdim
347221345Sdim  /// deleteRematVictims - Delete defs that are dead after rematerializing.
348221345Sdim  void deleteRematVictims();
349212793Sdim
350212793Sdimpublic:
351212793Sdim  /// Create a new SplitEditor for editing the LiveInterval analyzed by SA.
352212793Sdim  /// Newly created intervals will be appended to newIntervals.
353212793Sdim  SplitEditor(SplitAnalysis &SA, LiveIntervals&, VirtRegMap&,
354263508Sdim              MachineDominatorTree&, MachineBlockFrequencyInfo &);
355212793Sdim
356221345Sdim  /// reset - Prepare for a new split.
357226633Sdim  void reset(LiveRangeEdit&, ComplementSpillMode = SM_Partition);
358212793Sdim
359212793Sdim  /// Create a new virtual register and live interval.
360221345Sdim  /// Return the interval index, starting from 1. Interval index 0 is the
361221345Sdim  /// implicit complement interval.
362221345Sdim  unsigned openIntv();
363212793Sdim
364221345Sdim  /// currentIntv - Return the current interval index.
365221345Sdim  unsigned currentIntv() const { return OpenIdx; }
366221345Sdim
367221345Sdim  /// selectIntv - Select a previously opened interval index.
368221345Sdim  void selectIntv(unsigned Idx);
369221345Sdim
370218893Sdim  /// enterIntvBefore - Enter the open interval before the instruction at Idx.
371218893Sdim  /// If the parent interval is not live before Idx, a COPY is not inserted.
372218893Sdim  /// Return the beginning of the new live range.
373218893Sdim  SlotIndex enterIntvBefore(SlotIndex Idx);
374212793Sdim
375224145Sdim  /// enterIntvAfter - Enter the open interval after the instruction at Idx.
376224145Sdim  /// Return the beginning of the new live range.
377224145Sdim  SlotIndex enterIntvAfter(SlotIndex Idx);
378224145Sdim
379218893Sdim  /// enterIntvAtEnd - Enter the open interval at the end of MBB.
380218893Sdim  /// Use the open interval from he inserted copy to the MBB end.
381218893Sdim  /// Return the beginning of the new live range.
382218893Sdim  SlotIndex enterIntvAtEnd(MachineBasicBlock &MBB);
383212793Sdim
384218893Sdim  /// useIntv - indicate that all instructions in MBB should use OpenLI.
385212793Sdim  void useIntv(const MachineBasicBlock &MBB);
386212793Sdim
387218893Sdim  /// useIntv - indicate that all instructions in range should use OpenLI.
388212793Sdim  void useIntv(SlotIndex Start, SlotIndex End);
389212793Sdim
390218893Sdim  /// leaveIntvAfter - Leave the open interval after the instruction at Idx.
391218893Sdim  /// Return the end of the live range.
392218893Sdim  SlotIndex leaveIntvAfter(SlotIndex Idx);
393212793Sdim
394218893Sdim  /// leaveIntvBefore - Leave the open interval before the instruction at Idx.
395218893Sdim  /// Return the end of the live range.
396218893Sdim  SlotIndex leaveIntvBefore(SlotIndex Idx);
397218893Sdim
398212793Sdim  /// leaveIntvAtTop - Leave the interval at the top of MBB.
399218893Sdim  /// Add liveness from the MBB top to the copy.
400218893Sdim  /// Return the end of the live range.
401218893Sdim  SlotIndex leaveIntvAtTop(MachineBasicBlock &MBB);
402212793Sdim
403218893Sdim  /// overlapIntv - Indicate that all instructions in range should use the open
404218893Sdim  /// interval, but also let the complement interval be live.
405218893Sdim  ///
406218893Sdim  /// This doubles the register pressure, but is sometimes required to deal with
407218893Sdim  /// register uses after the last valid split point.
408218893Sdim  ///
409218893Sdim  /// The Start index should be a return value from a leaveIntv* call, and End
410218893Sdim  /// should be in the same basic block. The parent interval must have the same
411218893Sdim  /// value across the range.
412218893Sdim  ///
413218893Sdim  void overlapIntv(SlotIndex Start, SlotIndex End);
414218893Sdim
415218893Sdim  /// finish - after all the new live ranges have been created, compute the
416218893Sdim  /// remaining live range, and rewrite instructions to use the new registers.
417221345Sdim  /// @param LRMap When not null, this vector will map each live range in Edit
418221345Sdim  ///              back to the indices returned by openIntv.
419221345Sdim  ///              There may be extra indices created by dead code elimination.
420221345Sdim  void finish(SmallVectorImpl<unsigned> *LRMap = 0);
421212793Sdim
422218893Sdim  /// dump - print the current interval maping to dbgs().
423218893Sdim  void dump() const;
424218893Sdim
425212793Sdim  // ===--- High level methods ---===
426212793Sdim
427221345Sdim  /// splitSingleBlock - Split CurLI into a separate live interval around the
428221345Sdim  /// uses in a single block. This is intended to be used as part of a larger
429221345Sdim  /// split, and doesn't call finish().
430221345Sdim  void splitSingleBlock(const SplitAnalysis::BlockInfo &BI);
431221345Sdim
432224145Sdim  /// splitLiveThroughBlock - Split CurLI in the given block such that it
433224145Sdim  /// enters the block in IntvIn and leaves it in IntvOut. There may be uses in
434224145Sdim  /// the block, but they will be ignored when placing split points.
435224145Sdim  ///
436224145Sdim  /// @param MBBNum      Block number.
437224145Sdim  /// @param IntvIn      Interval index entering the block.
438224145Sdim  /// @param LeaveBefore When set, leave IntvIn before this point.
439224145Sdim  /// @param IntvOut     Interval index leaving the block.
440224145Sdim  /// @param EnterAfter  When set, enter IntvOut after this point.
441224145Sdim  void splitLiveThroughBlock(unsigned MBBNum,
442224145Sdim                             unsigned IntvIn, SlotIndex LeaveBefore,
443224145Sdim                             unsigned IntvOut, SlotIndex EnterAfter);
444224145Sdim
445224145Sdim  /// splitRegInBlock - Split CurLI in the given block such that it enters the
446224145Sdim  /// block in IntvIn and leaves it on the stack (or not at all). Split points
447224145Sdim  /// are placed in a way that avoids putting uses in the stack interval. This
448224145Sdim  /// may require creating a local interval when there is interference.
449224145Sdim  ///
450224145Sdim  /// @param BI          Block descriptor.
451224145Sdim  /// @param IntvIn      Interval index entering the block. Not 0.
452224145Sdim  /// @param LeaveBefore When set, leave IntvIn before this point.
453224145Sdim  void splitRegInBlock(const SplitAnalysis::BlockInfo &BI,
454224145Sdim                       unsigned IntvIn, SlotIndex LeaveBefore);
455224145Sdim
456224145Sdim  /// splitRegOutBlock - Split CurLI in the given block such that it enters the
457224145Sdim  /// block on the stack (or isn't live-in at all) and leaves it in IntvOut.
458224145Sdim  /// Split points are placed to avoid interference and such that the uses are
459224145Sdim  /// not in the stack interval. This may require creating a local interval
460224145Sdim  /// when there is interference.
461224145Sdim  ///
462224145Sdim  /// @param BI          Block descriptor.
463224145Sdim  /// @param IntvOut     Interval index leaving the block.
464224145Sdim  /// @param EnterAfter  When set, enter IntvOut after this point.
465224145Sdim  void splitRegOutBlock(const SplitAnalysis::BlockInfo &BI,
466224145Sdim                        unsigned IntvOut, SlotIndex EnterAfter);
467212793Sdim};
468212793Sdim
469212793Sdim}
470221345Sdim
471221345Sdim#endif
472