Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:29

0001 //===- LiveIntervalCalc.h - Calculate live intervals -----------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // The LiveIntervalCalc class is an extension of LiveRangeCalc targeted to the
0010 // computation and modification of the LiveInterval variants of LiveRanges.
0011 // LiveIntervals are meant to track liveness of registers and stack slots and
0012 // LiveIntervalCalc adds to LiveRangeCalc all the machinery required to
0013 // construct the liveness of virtual registers tracked by a LiveInterval.
0014 //
0015 //===----------------------------------------------------------------------===//
0016 
0017 #ifndef LLVM_CODEGEN_LIVEINTERVALCALC_H
0018 #define LLVM_CODEGEN_LIVEINTERVALCALC_H
0019 
0020 #include "llvm/CodeGen/LiveRangeCalc.h"
0021 
0022 namespace llvm {
0023 
0024 template <class NodeT> class DomTreeNodeBase;
0025 
0026 using MachineDomTreeNode = DomTreeNodeBase<MachineBasicBlock>;
0027 
0028 class LiveIntervalCalc : public LiveRangeCalc {
0029   /// Extend the live range of @p LR to reach all uses of Reg.
0030   ///
0031   /// If @p LR is a main range, or if @p LI is null, then all uses must be
0032   /// jointly dominated by the definitions from @p LR. If @p LR is a subrange
0033   /// of the live interval @p LI, corresponding to lane mask @p LaneMask,
0034   /// all uses must be jointly dominated by the definitions from @p LR
0035   /// together with definitions of other lanes where @p LR becomes undefined
0036   /// (via <def,read-undef> operands).
0037   /// If @p LR is a main range, the @p LaneMask should be set to ~0, i.e.
0038   /// LaneBitmask::getAll().
0039   void extendToUses(LiveRange &LR, Register Reg, LaneBitmask LaneMask,
0040                     LiveInterval *LI = nullptr);
0041 
0042 public:
0043   LiveIntervalCalc() = default;
0044 
0045   /// createDeadDefs - Create a dead def in LI for every def operand of Reg.
0046   /// Each instruction defining Reg gets a new VNInfo with a corresponding
0047   /// minimal live range.
0048   void createDeadDefs(LiveRange &LR, Register Reg);
0049 
0050   /// Extend the live range of @p LR to reach all uses of Reg.
0051   ///
0052   /// All uses must be jointly dominated by existing liveness.  PHI-defs are
0053   /// inserted as needed to preserve SSA form.
0054   void extendToUses(LiveRange &LR, MCRegister PhysReg) {
0055     extendToUses(LR, PhysReg, LaneBitmask::getAll());
0056   }
0057 
0058   /// Calculates liveness for the register specified in live interval @p LI.
0059   /// Creates subregister live ranges as needed if subreg liveness tracking is
0060   /// enabled.
0061   void calculate(LiveInterval &LI, bool TrackSubRegs);
0062 
0063   /// For live interval \p LI with correct SubRanges construct matching
0064   /// information for the main live range. Expects the main live range to not
0065   /// have any segments or value numbers.
0066   void constructMainRangeFromSubranges(LiveInterval &LI);
0067 };
0068 
0069 } // end namespace llvm
0070 
0071 #endif // LLVM_CODEGEN_LIVEINTERVALCALC_H