SplitKit.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. //===- SplitKit.h - Toolkit for splitting live ranges -----------*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file contains the SplitAnalysis class as well as mutator functions for
  10. // live range splitting.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_LIB_CODEGEN_SPLITKIT_H
  14. #define LLVM_LIB_CODEGEN_SPLITKIT_H
  15. #include "llvm/ADT/ArrayRef.h"
  16. #include "llvm/ADT/BitVector.h"
  17. #include "llvm/ADT/DenseMap.h"
  18. #include "llvm/ADT/DenseSet.h"
  19. #include "llvm/ADT/IntervalMap.h"
  20. #include "llvm/ADT/PointerIntPair.h"
  21. #include "llvm/ADT/SmallPtrSet.h"
  22. #include "llvm/ADT/SmallVector.h"
  23. #include "llvm/CodeGen/LiveIntervalCalc.h"
  24. #include "llvm/CodeGen/LiveIntervals.h"
  25. #include "llvm/CodeGen/MachineBasicBlock.h"
  26. #include "llvm/CodeGen/MachineFunction.h"
  27. #include "llvm/CodeGen/SlotIndexes.h"
  28. #include "llvm/Support/Compiler.h"
  29. #include <utility>
  30. namespace llvm {
  31. class LiveInterval;
  32. class LiveRange;
  33. class LiveIntervals;
  34. class LiveRangeEdit;
  35. class MachineBlockFrequencyInfo;
  36. class MachineDominatorTree;
  37. class MachineLoopInfo;
  38. class MachineRegisterInfo;
  39. class TargetInstrInfo;
  40. class TargetRegisterInfo;
  41. class VirtRegMap;
  42. class VirtRegAuxInfo;
  43. /// Determines the latest safe point in a block in which we can insert a split,
  44. /// spill or other instruction related with CurLI.
  45. class LLVM_LIBRARY_VISIBILITY InsertPointAnalysis {
  46. private:
  47. const LiveIntervals &LIS;
  48. /// Last legal insert point in each basic block in the current function.
  49. /// The first entry is the first terminator, the second entry is the
  50. /// last valid point to insert a split or spill for a variable that is
  51. /// live into a landing pad or inlineasm_br successor.
  52. SmallVector<std::pair<SlotIndex, SlotIndex>, 8> LastInsertPoint;
  53. SlotIndex computeLastInsertPoint(const LiveInterval &CurLI,
  54. const MachineBasicBlock &MBB);
  55. public:
  56. InsertPointAnalysis(const LiveIntervals &lis, unsigned BBNum);
  57. /// Return the base index of the last valid insert point for \pCurLI in \pMBB.
  58. SlotIndex getLastInsertPoint(const LiveInterval &CurLI,
  59. const MachineBasicBlock &MBB) {
  60. unsigned Num = MBB.getNumber();
  61. // Inline the common simple case.
  62. if (LastInsertPoint[Num].first.isValid() &&
  63. !LastInsertPoint[Num].second.isValid())
  64. return LastInsertPoint[Num].first;
  65. return computeLastInsertPoint(CurLI, MBB);
  66. }
  67. /// Returns the last insert point as an iterator for \pCurLI in \pMBB.
  68. MachineBasicBlock::iterator getLastInsertPointIter(const LiveInterval &CurLI,
  69. MachineBasicBlock &MBB);
  70. /// Return the base index of the first insert point in \pMBB.
  71. SlotIndex getFirstInsertPoint(MachineBasicBlock &MBB) {
  72. SlotIndex Res = LIS.getMBBStartIdx(&MBB);
  73. if (!MBB.empty()) {
  74. MachineBasicBlock::iterator MII = MBB.SkipPHIsLabelsAndDebug(MBB.begin());
  75. if (MII != MBB.end())
  76. Res = LIS.getInstructionIndex(*MII);
  77. }
  78. return Res;
  79. }
  80. };
  81. /// SplitAnalysis - Analyze a LiveInterval, looking for live range splitting
  82. /// opportunities.
  83. class LLVM_LIBRARY_VISIBILITY SplitAnalysis {
  84. public:
  85. const MachineFunction &MF;
  86. const VirtRegMap &VRM;
  87. const LiveIntervals &LIS;
  88. const MachineLoopInfo &Loops;
  89. const TargetInstrInfo &TII;
  90. /// Additional information about basic blocks where the current variable is
  91. /// live. Such a block will look like one of these templates:
  92. ///
  93. /// 1. | o---x | Internal to block. Variable is only live in this block.
  94. /// 2. |---x | Live-in, kill.
  95. /// 3. | o---| Def, live-out.
  96. /// 4. |---x o---| Live-in, kill, def, live-out. Counted by NumGapBlocks.
  97. /// 5. |---o---o---| Live-through with uses or defs.
  98. /// 6. |-----------| Live-through without uses. Counted by NumThroughBlocks.
  99. ///
  100. /// Two BlockInfo entries are created for template 4. One for the live-in
  101. /// segment, and one for the live-out segment. These entries look as if the
  102. /// block were split in the middle where the live range isn't live.
  103. ///
  104. /// Live-through blocks without any uses don't get BlockInfo entries. They
  105. /// are simply listed in ThroughBlocks instead.
  106. ///
  107. struct BlockInfo {
  108. MachineBasicBlock *MBB;
  109. SlotIndex FirstInstr; ///< First instr accessing current reg.
  110. SlotIndex LastInstr; ///< Last instr accessing current reg.
  111. SlotIndex FirstDef; ///< First non-phi valno->def, or SlotIndex().
  112. bool LiveIn; ///< Current reg is live in.
  113. bool LiveOut; ///< Current reg is live out.
  114. /// isOneInstr - Returns true when this BlockInfo describes a single
  115. /// instruction.
  116. bool isOneInstr() const {
  117. return SlotIndex::isSameInstr(FirstInstr, LastInstr);
  118. }
  119. void print(raw_ostream &OS) const;
  120. void dump() const;
  121. };
  122. private:
  123. // Current live interval.
  124. const LiveInterval *CurLI = nullptr;
  125. /// Insert Point Analysis.
  126. InsertPointAnalysis IPA;
  127. // Sorted slot indexes of using instructions.
  128. SmallVector<SlotIndex, 8> UseSlots;
  129. /// UseBlocks - Blocks where CurLI has uses.
  130. SmallVector<BlockInfo, 8> UseBlocks;
  131. /// NumGapBlocks - Number of duplicate entries in UseBlocks for blocks where
  132. /// the live range has a gap.
  133. unsigned NumGapBlocks;
  134. /// ThroughBlocks - Block numbers where CurLI is live through without uses.
  135. BitVector ThroughBlocks;
  136. /// NumThroughBlocks - Number of live-through blocks.
  137. unsigned NumThroughBlocks;
  138. // Sumarize statistics by counting instructions using CurLI.
  139. void analyzeUses();
  140. /// calcLiveBlockInfo - Compute per-block information about CurLI.
  141. void calcLiveBlockInfo();
  142. public:
  143. SplitAnalysis(const VirtRegMap &vrm, const LiveIntervals &lis,
  144. const MachineLoopInfo &mli);
  145. /// analyze - set CurLI to the specified interval, and analyze how it may be
  146. /// split.
  147. void analyze(const LiveInterval *li);
  148. /// clear - clear all data structures so SplitAnalysis is ready to analyze a
  149. /// new interval.
  150. void clear();
  151. /// getParent - Return the last analyzed interval.
  152. const LiveInterval &getParent() const { return *CurLI; }
  153. /// isOriginalEndpoint - Return true if the original live range was killed or
  154. /// (re-)defined at Idx. Idx should be the 'def' slot for a normal kill/def,
  155. /// and 'use' for an early-clobber def.
  156. /// This can be used to recognize code inserted by earlier live range
  157. /// splitting.
  158. bool isOriginalEndpoint(SlotIndex Idx) const;
  159. /// getUseSlots - Return an array of SlotIndexes of instructions using CurLI.
  160. /// This include both use and def operands, at most one entry per instruction.
  161. ArrayRef<SlotIndex> getUseSlots() const { return UseSlots; }
  162. /// getUseBlocks - Return an array of BlockInfo objects for the basic blocks
  163. /// where CurLI has uses.
  164. ArrayRef<BlockInfo> getUseBlocks() const { return UseBlocks; }
  165. /// getNumThroughBlocks - Return the number of through blocks.
  166. unsigned getNumThroughBlocks() const { return NumThroughBlocks; }
  167. /// isThroughBlock - Return true if CurLI is live through MBB without uses.
  168. bool isThroughBlock(unsigned MBB) const { return ThroughBlocks.test(MBB); }
  169. /// getThroughBlocks - Return the set of through blocks.
  170. const BitVector &getThroughBlocks() const { return ThroughBlocks; }
  171. /// getNumLiveBlocks - Return the number of blocks where CurLI is live.
  172. unsigned getNumLiveBlocks() const {
  173. return getUseBlocks().size() - NumGapBlocks + getNumThroughBlocks();
  174. }
  175. /// countLiveBlocks - Return the number of blocks where li is live. This is
  176. /// guaranteed to return the same number as getNumLiveBlocks() after calling
  177. /// analyze(li).
  178. unsigned countLiveBlocks(const LiveInterval *li) const;
  179. using BlockPtrSet = SmallPtrSet<const MachineBasicBlock *, 16>;
  180. /// shouldSplitSingleBlock - Returns true if it would help to create a local
  181. /// live range for the instructions in BI. There is normally no benefit to
  182. /// creating a live range for a single instruction, but it does enable
  183. /// register class inflation if the instruction has a restricted register
  184. /// class.
  185. ///
  186. /// @param BI The block to be isolated.
  187. /// @param SingleInstrs True when single instructions should be isolated.
  188. bool shouldSplitSingleBlock(const BlockInfo &BI, bool SingleInstrs) const;
  189. SlotIndex getLastSplitPoint(unsigned Num) {
  190. return IPA.getLastInsertPoint(*CurLI, *MF.getBlockNumbered(Num));
  191. }
  192. SlotIndex getLastSplitPoint(MachineBasicBlock *BB) {
  193. return IPA.getLastInsertPoint(*CurLI, *BB);
  194. }
  195. MachineBasicBlock::iterator getLastSplitPointIter(MachineBasicBlock *BB) {
  196. return IPA.getLastInsertPointIter(*CurLI, *BB);
  197. }
  198. SlotIndex getFirstSplitPoint(unsigned Num) {
  199. return IPA.getFirstInsertPoint(*MF.getBlockNumbered(Num));
  200. }
  201. };
  202. /// SplitEditor - Edit machine code and LiveIntervals for live range
  203. /// splitting.
  204. ///
  205. /// - Create a SplitEditor from a SplitAnalysis.
  206. /// - Start a new live interval with openIntv.
  207. /// - Mark the places where the new interval is entered using enterIntv*
  208. /// - Mark the ranges where the new interval is used with useIntv*
  209. /// - Mark the places where the interval is exited with exitIntv*.
  210. /// - Finish the current interval with closeIntv and repeat from 2.
  211. /// - Rewrite instructions with finish().
  212. ///
  213. class LLVM_LIBRARY_VISIBILITY SplitEditor {
  214. SplitAnalysis &SA;
  215. LiveIntervals &LIS;
  216. VirtRegMap &VRM;
  217. MachineRegisterInfo &MRI;
  218. MachineDominatorTree &MDT;
  219. const TargetInstrInfo &TII;
  220. const TargetRegisterInfo &TRI;
  221. const MachineBlockFrequencyInfo &MBFI;
  222. VirtRegAuxInfo &VRAI;
  223. public:
  224. /// ComplementSpillMode - Select how the complement live range should be
  225. /// created. SplitEditor automatically creates interval 0 to contain
  226. /// anything that isn't added to another interval. This complement interval
  227. /// can get quite complicated, and it can sometimes be an advantage to allow
  228. /// it to overlap the other intervals. If it is going to spill anyway, no
  229. /// registers are wasted by keeping a value in two places at the same time.
  230. enum ComplementSpillMode {
  231. /// SM_Partition(Default) - Try to create the complement interval so it
  232. /// doesn't overlap any other intervals, and the original interval is
  233. /// partitioned. This may require a large number of back copies and extra
  234. /// PHI-defs. Only segments marked with overlapIntv will be overlapping.
  235. SM_Partition,
  236. /// SM_Size - Overlap intervals to minimize the number of inserted COPY
  237. /// instructions. Copies to the complement interval are hoisted to their
  238. /// common dominator, so only one COPY is required per value in the
  239. /// complement interval. This also means that no extra PHI-defs need to be
  240. /// inserted in the complement interval.
  241. SM_Size,
  242. /// SM_Speed - Overlap intervals to minimize the expected execution
  243. /// frequency of the inserted copies. This is very similar to SM_Size, but
  244. /// the complement interval may get some extra PHI-defs.
  245. SM_Speed
  246. };
  247. private:
  248. /// Edit - The current parent register and new intervals created.
  249. LiveRangeEdit *Edit = nullptr;
  250. /// Index into Edit of the currently open interval.
  251. /// The index 0 is used for the complement, so the first interval started by
  252. /// openIntv will be 1.
  253. unsigned OpenIdx = 0;
  254. /// The current spill mode, selected by reset().
  255. ComplementSpillMode SpillMode = SM_Partition;
  256. using RegAssignMap = IntervalMap<SlotIndex, unsigned>;
  257. /// Allocator for the interval map. This will eventually be shared with
  258. /// SlotIndexes and LiveIntervals.
  259. RegAssignMap::Allocator Allocator;
  260. /// RegAssign - Map of the assigned register indexes.
  261. /// Edit.get(RegAssign.lookup(Idx)) is the register that should be live at
  262. /// Idx.
  263. RegAssignMap RegAssign;
  264. using ValueForcePair = PointerIntPair<VNInfo *, 1>;
  265. using ValueMap = DenseMap<std::pair<unsigned, unsigned>, ValueForcePair>;
  266. /// Values - keep track of the mapping from parent values to values in the new
  267. /// intervals. Given a pair (RegIdx, ParentVNI->id), Values contains:
  268. ///
  269. /// 1. No entry - the value is not mapped to Edit.get(RegIdx).
  270. /// 2. (Null, false) - the value is mapped to multiple values in
  271. /// Edit.get(RegIdx). Each value is represented by a minimal live range at
  272. /// its def. The full live range can be inferred exactly from the range
  273. /// of RegIdx in RegAssign.
  274. /// 3. (Null, true). As above, but the ranges in RegAssign are too large, and
  275. /// the live range must be recomputed using ::extend().
  276. /// 4. (VNI, false) The value is mapped to a single new value.
  277. /// The new value has no live ranges anywhere.
  278. ValueMap Values;
  279. /// LICalc - Cache for computing live ranges and SSA update. Each instance
  280. /// can only handle non-overlapping live ranges, so use a separate
  281. /// LiveIntervalCalc instance for the complement interval when in spill mode.
  282. LiveIntervalCalc LICalc[2];
  283. /// getLICalc - Return the LICalc to use for RegIdx. In spill mode, the
  284. /// complement interval can overlap the other intervals, so it gets its own
  285. /// LICalc instance. When not in spill mode, all intervals can share one.
  286. LiveIntervalCalc &getLICalc(unsigned RegIdx) {
  287. return LICalc[SpillMode != SM_Partition && RegIdx != 0];
  288. }
  289. /// Add a segment to the interval LI for the value number VNI. If LI has
  290. /// subranges, corresponding segments will be added to them as well, but
  291. /// with newly created value numbers. If Original is true, dead def will
  292. /// only be added a subrange of LI if the corresponding subrange of the
  293. /// original interval has a def at this index. Otherwise, all subranges
  294. /// of LI will be updated.
  295. void addDeadDef(LiveInterval &LI, VNInfo *VNI, bool Original);
  296. /// defValue - define a value in RegIdx from ParentVNI at Idx.
  297. /// Idx does not have to be ParentVNI->def, but it must be contained within
  298. /// ParentVNI's live range in ParentLI. The new value is added to the value
  299. /// map. The value being defined may either come from rematerialization
  300. /// (or an inserted copy), or it may be coming from the original interval.
  301. /// The parameter Original should be true in the latter case, otherwise
  302. /// it should be false.
  303. /// Return the new LI value.
  304. VNInfo *defValue(unsigned RegIdx, const VNInfo *ParentVNI, SlotIndex Idx,
  305. bool Original);
  306. /// forceRecompute - Force the live range of ParentVNI in RegIdx to be
  307. /// recomputed by LiveRangeCalc::extend regardless of the number of defs.
  308. /// This is used for values whose live range doesn't match RegAssign exactly.
  309. /// They could have rematerialized, or back-copies may have been moved.
  310. void forceRecompute(unsigned RegIdx, const VNInfo &ParentVNI);
  311. /// Calls forceRecompute() on any affected regidx and on ParentVNI
  312. /// predecessors in case of a phi definition.
  313. void forceRecomputeVNI(const VNInfo &ParentVNI);
  314. /// defFromParent - Define Reg from ParentVNI at UseIdx using either
  315. /// rematerialization or a COPY from parent. Return the new value.
  316. VNInfo *defFromParent(unsigned RegIdx, const VNInfo *ParentVNI,
  317. SlotIndex UseIdx, MachineBasicBlock &MBB,
  318. MachineBasicBlock::iterator I);
  319. /// removeBackCopies - Remove the copy instructions that defines the values
  320. /// in the vector in the complement interval.
  321. void removeBackCopies(SmallVectorImpl<VNInfo*> &Copies);
  322. /// getShallowDominator - Returns the least busy dominator of MBB that is
  323. /// also dominated by DefMBB. Busy is measured by loop depth.
  324. MachineBasicBlock *findShallowDominator(MachineBasicBlock *MBB,
  325. MachineBasicBlock *DefMBB);
  326. /// Find out all the backCopies dominated by others.
  327. void computeRedundantBackCopies(DenseSet<unsigned> &NotToHoistSet,
  328. SmallVectorImpl<VNInfo *> &BackCopies);
  329. /// Hoist back-copies to the complement interval. It tries to hoist all
  330. /// the back-copies to one BB if it is beneficial, or else simply remove
  331. /// redundant backcopies dominated by others.
  332. void hoistCopies();
  333. /// transferValues - Transfer values to the new ranges.
  334. /// Return true if any ranges were skipped.
  335. bool transferValues();
  336. /// Live range @p LR corresponding to the lane Mask @p LM has a live
  337. /// PHI def at the beginning of block @p B. Extend the range @p LR of
  338. /// all predecessor values that reach this def. If @p LR is a subrange,
  339. /// the array @p Undefs is the set of all locations where it is undefined
  340. /// via <def,read-undef> in other subranges for the same register.
  341. void extendPHIRange(MachineBasicBlock &B, LiveIntervalCalc &LIC,
  342. LiveRange &LR, LaneBitmask LM,
  343. ArrayRef<SlotIndex> Undefs);
  344. /// extendPHIKillRanges - Extend the ranges of all values killed by original
  345. /// parent PHIDefs.
  346. void extendPHIKillRanges();
  347. /// rewriteAssigned - Rewrite all uses of Edit.getReg() to assigned registers.
  348. void rewriteAssigned(bool ExtendRanges);
  349. /// deleteRematVictims - Delete defs that are dead after rematerializing.
  350. void deleteRematVictims();
  351. /// Add a copy instruction copying \p FromReg to \p ToReg before
  352. /// \p InsertBefore. This can be invoked with a \p LaneMask which may make it
  353. /// necessary to construct a sequence of copies to cover it exactly.
  354. SlotIndex buildCopy(Register FromReg, Register ToReg, LaneBitmask LaneMask,
  355. MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore,
  356. bool Late, unsigned RegIdx);
  357. SlotIndex buildSingleSubRegCopy(Register FromReg, Register ToReg,
  358. MachineBasicBlock &MB, MachineBasicBlock::iterator InsertBefore,
  359. unsigned SubIdx, LiveInterval &DestLI, bool Late, SlotIndex Def);
  360. public:
  361. /// Create a new SplitEditor for editing the LiveInterval analyzed by SA.
  362. /// Newly created intervals will be appended to newIntervals.
  363. SplitEditor(SplitAnalysis &SA, LiveIntervals &LIS, VirtRegMap &VRM,
  364. MachineDominatorTree &MDT, MachineBlockFrequencyInfo &MBFI,
  365. VirtRegAuxInfo &VRAI);
  366. /// reset - Prepare for a new split.
  367. void reset(LiveRangeEdit&, ComplementSpillMode = SM_Partition);
  368. /// Create a new virtual register and live interval.
  369. /// Return the interval index, starting from 1. Interval index 0 is the
  370. /// implicit complement interval.
  371. unsigned openIntv();
  372. /// currentIntv - Return the current interval index.
  373. unsigned currentIntv() const { return OpenIdx; }
  374. /// selectIntv - Select a previously opened interval index.
  375. void selectIntv(unsigned Idx);
  376. /// enterIntvBefore - Enter the open interval before the instruction at Idx.
  377. /// If the parent interval is not live before Idx, a COPY is not inserted.
  378. /// Return the beginning of the new live range.
  379. SlotIndex enterIntvBefore(SlotIndex Idx);
  380. /// enterIntvAfter - Enter the open interval after the instruction at Idx.
  381. /// Return the beginning of the new live range.
  382. SlotIndex enterIntvAfter(SlotIndex Idx);
  383. /// enterIntvAtEnd - Enter the open interval at the end of MBB.
  384. /// Use the open interval from the inserted copy to the MBB end.
  385. /// Return the beginning of the new live range.
  386. SlotIndex enterIntvAtEnd(MachineBasicBlock &MBB);
  387. /// useIntv - indicate that all instructions in MBB should use OpenLI.
  388. void useIntv(const MachineBasicBlock &MBB);
  389. /// useIntv - indicate that all instructions in range should use OpenLI.
  390. void useIntv(SlotIndex Start, SlotIndex End);
  391. /// leaveIntvAfter - Leave the open interval after the instruction at Idx.
  392. /// Return the end of the live range.
  393. SlotIndex leaveIntvAfter(SlotIndex Idx);
  394. /// leaveIntvBefore - Leave the open interval before the instruction at Idx.
  395. /// Return the end of the live range.
  396. SlotIndex leaveIntvBefore(SlotIndex Idx);
  397. /// leaveIntvAtTop - Leave the interval at the top of MBB.
  398. /// Add liveness from the MBB top to the copy.
  399. /// Return the end of the live range.
  400. SlotIndex leaveIntvAtTop(MachineBasicBlock &MBB);
  401. /// overlapIntv - Indicate that all instructions in range should use the open
  402. /// interval if End does not have tied-def usage of the register and in this
  403. /// case complement interval is used. Let the complement interval be live.
  404. ///
  405. /// This doubles the register pressure, but is sometimes required to deal with
  406. /// register uses after the last valid split point.
  407. ///
  408. /// The Start index should be a return value from a leaveIntv* call, and End
  409. /// should be in the same basic block. The parent interval must have the same
  410. /// value across the range.
  411. ///
  412. void overlapIntv(SlotIndex Start, SlotIndex End);
  413. /// finish - after all the new live ranges have been created, compute the
  414. /// remaining live range, and rewrite instructions to use the new registers.
  415. /// @param LRMap When not null, this vector will map each live range in Edit
  416. /// back to the indices returned by openIntv.
  417. /// There may be extra indices created by dead code elimination.
  418. void finish(SmallVectorImpl<unsigned> *LRMap = nullptr);
  419. /// dump - print the current interval mapping to dbgs().
  420. void dump() const;
  421. // ===--- High level methods ---===
  422. /// splitSingleBlock - Split CurLI into a separate live interval around the
  423. /// uses in a single block. This is intended to be used as part of a larger
  424. /// split, and doesn't call finish().
  425. void splitSingleBlock(const SplitAnalysis::BlockInfo &BI);
  426. /// splitLiveThroughBlock - Split CurLI in the given block such that it
  427. /// enters the block in IntvIn and leaves it in IntvOut. There may be uses in
  428. /// the block, but they will be ignored when placing split points.
  429. ///
  430. /// @param MBBNum Block number.
  431. /// @param IntvIn Interval index entering the block.
  432. /// @param LeaveBefore When set, leave IntvIn before this point.
  433. /// @param IntvOut Interval index leaving the block.
  434. /// @param EnterAfter When set, enter IntvOut after this point.
  435. void splitLiveThroughBlock(unsigned MBBNum,
  436. unsigned IntvIn, SlotIndex LeaveBefore,
  437. unsigned IntvOut, SlotIndex EnterAfter);
  438. /// splitRegInBlock - Split CurLI in the given block such that it enters the
  439. /// block in IntvIn and leaves it on the stack (or not at all). Split points
  440. /// are placed in a way that avoids putting uses in the stack interval. This
  441. /// may require creating a local interval when there is interference.
  442. ///
  443. /// @param BI Block descriptor.
  444. /// @param IntvIn Interval index entering the block. Not 0.
  445. /// @param LeaveBefore When set, leave IntvIn before this point.
  446. void splitRegInBlock(const SplitAnalysis::BlockInfo &BI,
  447. unsigned IntvIn, SlotIndex LeaveBefore);
  448. /// splitRegOutBlock - Split CurLI in the given block such that it enters the
  449. /// block on the stack (or isn't live-in at all) and leaves it in IntvOut.
  450. /// Split points are placed to avoid interference and such that the uses are
  451. /// not in the stack interval. This may require creating a local interval
  452. /// when there is interference.
  453. ///
  454. /// @param BI Block descriptor.
  455. /// @param IntvOut Interval index leaving the block.
  456. /// @param EnterAfter When set, enter IntvOut after this point.
  457. void splitRegOutBlock(const SplitAnalysis::BlockInfo &BI,
  458. unsigned IntvOut, SlotIndex EnterAfter);
  459. };
  460. } // end namespace llvm
  461. #endif // LLVM_LIB_CODEGEN_SPLITKIT_H