1 | //===- LiveIntervalCalc.h - Calculate live intervals -----------*- 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 | // The LiveIntervalCalc class is an extension of LiveRangeCalc targeted to the |
10 | // computation and modification of the LiveInterval variants of LiveRanges. |
11 | // LiveIntervals are meant to track liveness of registers and stack slots and |
12 | // LiveIntervalCalc adds to LiveRangeCalc all the machinery required to |
13 | // construct the liveness of virtual registers tracked by a LiveInterval. |
14 | // |
15 | //===----------------------------------------------------------------------===// |
16 | |
17 | #ifndef LLVM_CODEGEN_LIVEINTERVALCALC_H |
18 | #define LLVM_CODEGEN_LIVEINTERVALCALC_H |
19 | |
20 | #include "llvm/CodeGen/LiveRangeCalc.h" |
21 | #include "llvm/Support/Compiler.h" |
22 | |
23 | namespace llvm { |
24 | |
25 | template <class NodeT> class DomTreeNodeBase; |
26 | |
27 | using MachineDomTreeNode = DomTreeNodeBase<MachineBasicBlock>; |
28 | |
29 | class LiveIntervalCalc : public LiveRangeCalc { |
30 | /// Extend the live range of @p LR to reach all uses of Reg. |
31 | /// |
32 | /// If @p LR is a main range, or if @p LI is null, then all uses must be |
33 | /// jointly dominated by the definitions from @p LR. If @p LR is a subrange |
34 | /// of the live interval @p LI, corresponding to lane mask @p LaneMask, |
35 | /// all uses must be jointly dominated by the definitions from @p LR |
36 | /// together with definitions of other lanes where @p LR becomes undefined |
37 | /// (via <def,read-undef> operands). |
38 | /// If @p LR is a main range, the @p LaneMask should be set to ~0, i.e. |
39 | /// LaneBitmask::getAll(). |
40 | LLVM_ABI void extendToUses(LiveRange &LR, Register Reg, LaneBitmask LaneMask, |
41 | LiveInterval *LI = nullptr); |
42 | |
43 | public: |
44 | LiveIntervalCalc() = default; |
45 | |
46 | /// createDeadDefs - Create a dead def in LI for every def operand of Reg. |
47 | /// Each instruction defining Reg gets a new VNInfo with a corresponding |
48 | /// minimal live range. |
49 | LLVM_ABI void createDeadDefs(LiveRange &LR, Register Reg); |
50 | |
51 | /// Extend the live range of @p LR to reach all uses of Reg. |
52 | /// |
53 | /// All uses must be jointly dominated by existing liveness. PHI-defs are |
54 | /// inserted as needed to preserve SSA form. |
55 | void extendToUses(LiveRange &LR, MCRegister PhysReg) { |
56 | extendToUses(LR, Reg: PhysReg, LaneMask: LaneBitmask::getAll()); |
57 | } |
58 | |
59 | /// Calculates liveness for the register specified in live interval @p LI. |
60 | /// Creates subregister live ranges as needed if subreg liveness tracking is |
61 | /// enabled. |
62 | LLVM_ABI void calculate(LiveInterval &LI, bool TrackSubRegs); |
63 | |
64 | /// For live interval \p LI with correct SubRanges construct matching |
65 | /// information for the main live range. Expects the main live range to not |
66 | /// have any segments or value numbers. |
67 | LLVM_ABI void constructMainRangeFromSubranges(LiveInterval &LI); |
68 | }; |
69 | |
70 | } // end namespace llvm |
71 | |
72 | #endif // LLVM_CODEGEN_LIVEINTERVALCALC_H |
73 | |