LLVM 20.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
21
22namespace llvm {
23
24template <class NodeT> class DomTreeNodeBase;
25
27
29 /// Extend the live range of @p LR to reach all uses of Reg.
30 ///
31 /// If @p LR is a main range, or if @p LI is null, then all uses must be
32 /// jointly dominated by the definitions from @p LR. If @p LR is a subrange
33 /// of the live interval @p LI, corresponding to lane mask @p LaneMask,
34 /// all uses must be jointly dominated by the definitions from @p LR
35 /// together with definitions of other lanes where @p LR becomes undefined
36 /// (via <def,read-undef> operands).
37 /// If @p LR is a main range, the @p LaneMask should be set to ~0, i.e.
38 /// LaneBitmask::getAll().
39 void extendToUses(LiveRange &LR, Register Reg, LaneBitmask LaneMask,
40 LiveInterval *LI = nullptr);
41
42public:
43 LiveIntervalCalc() = default;
44
45 /// createDeadDefs - Create a dead def in LI for every def operand of Reg.
46 /// Each instruction defining Reg gets a new VNInfo with a corresponding
47 /// minimal live range.
49
50 /// Extend the live range of @p LR to reach all uses of Reg.
51 ///
52 /// All uses must be jointly dominated by existing liveness. PHI-defs are
53 /// inserted as needed to preserve SSA form.
54 void extendToUses(LiveRange &LR, MCRegister PhysReg) {
55 extendToUses(LR, PhysReg, LaneBitmask::getAll());
56 }
57
58 /// Calculates liveness for the register specified in live interval @p LI.
59 /// Creates subregister live ranges as needed if subreg liveness tracking is
60 /// enabled.
61 void calculate(LiveInterval &LI, bool TrackSubRegs);
62
63 /// For live interval \p LI with correct SubRanges construct matching
64 /// information for the main live range. Expects the main live range to not
65 /// have any segments or value numbers.
67};
68
69} // end namespace llvm
70
71#endif // LLVM_CODEGEN_LIVEINTERVALCALC_H
unsigned Reg
Base class for the actual dominator tree node.
void createDeadDefs(LiveRange &LR, Register Reg)
createDeadDefs - Create a dead def in LI for every def operand of Reg.
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.
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:687
This class represents the liveness of a register, stack slot, etc.
Definition: LiveInterval.h:157
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