LiveIntervalCalc.h 3.1 KB

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