LLVM 22.0.0git
LiveIntervalCalc.h
Go to the documentation of this file.
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
22
23namespace llvm {
24
25template <class NodeT> class DomTreeNodeBase;
26
28
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
43public:
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.
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, PhysReg, 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.
68};
69
70} // end namespace llvm
71
72#endif // LLVM_CODEGEN_LIVEINTERVALCALC_H
#define LLVM_ABI
Definition: Compiler.h:213
Register Reg
Base class for the actual dominator tree node.
LLVM_ABI void createDeadDefs(LiveRange &LR, Register Reg)
createDeadDefs - Create a dead def in LI for every def operand of Reg.
LLVM_ABI void calculate(LiveInterval &LI, bool TrackSubRegs)
Calculates liveness for the register specified in live interval LI.
void extendToUses(LiveRange &LR, MCRegister PhysReg)
Extend the live range of LR to reach all uses of Reg.
LLVM_ABI void constructMainRangeFromSubranges(LiveInterval &LI)
For live interval LI with correct SubRanges construct matching information for the main live range.
LiveInterval - This class represents the liveness of a register, or stack slot.
Definition: LiveInterval.h:690
This class represents the liveness of a register, stack slot, etc.
Definition: LiveInterval.h:158
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:33
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
static constexpr LaneBitmask getAll()
Definition: LaneBitmask.h:82