LLVM 24.0.0git
llvm::GCNRematStrategy Class Reference

Rematerializes registers across code regions to achieve register pressure targets. More...

#include "Target/AMDGPU/GCNRematStrategy.h"

Public Member Functions

 GCNRematStrategy (MachineFunction &MF, MutableArrayRef< RegionBoundaries > Regions, MutableArrayRef< GCNRPTracker::LiveRegSet > LiveIns, MutableArrayRef< GCNRPTracker::LiveRegSet > LiveOuts, LiveIntervals &LIS, const MachineBlockFrequencyInfo &MBFI)
 Creates a strategy that can rematerialize across Regions whose live-ins LiveIns and live-outs LiveOuts are provided.
void rematerializeFor (unsigned MaxSGPRs, unsigned MaxVGPRs, bool SpillReduction, BitVector &AffectedRegions, MutableArrayRef< GCNRegPressure > *MaxPressure=nullptr)
 Rematerializes with the goal of reducing the maximum pressure in all Regions to MaxSGPRs SGPRs and MaxVGPRs VGPRs.
void startRecordingRemats ()
 Starts recording rematerializations for eventual rollback.
void clearRecordedRemats ()
 Stops recording rematerializations and clears all recorded ones.
void rollbackRecordedRemats ()
 Rolls back all recorded rematerializations.

Detailed Description

Rematerializes registers across code regions to achieve register pressure targets.

The strategy updates region boundaries and live-ins/live-outs as it rematerializes. It uses the target independent rematerializers to expose rematerializable registers and perform rematerializations.

The strategy only supports rematerializing registers that meet all of the following constraints.

  1. The register is virtual and has a single defining instruction.
  2. The single defining instruction is either deemed rematerializable by the target-independent logic, or if not, has no non-constant and non-ignorable physical register use. 3 The register has no virtual register use whose live range would be extended by the rematerialization.
  3. The register has at least one user outside its defining region. If rematerialized, one copy is made per using region and the original register stays if the defining region has users.
  4. The register is not used by or using another register that is going to be rematerialized.

Definition at line 42 of file GCNRematStrategy.h.

Constructor & Destructor Documentation

◆ GCNRematStrategy()

llvm::GCNRematStrategy::GCNRematStrategy ( MachineFunction & MF,
MutableArrayRef< RegionBoundaries > Regions,
MutableArrayRef< GCNRPTracker::LiveRegSet > LiveIns,
MutableArrayRef< GCNRPTracker::LiveRegSet > LiveOuts,
LiveIntervals & LIS,
const MachineBlockFrequencyInfo & MBFI )
inline

Creates a strategy that can rematerialize across Regions whose live-ins LiveIns and live-outs LiveOuts are provided.

The underlying rematerializer is created and initialized.

Definition at line 50 of file GCNRematStrategy.h.

Member Function Documentation

◆ clearRecordedRemats()

void llvm::GCNRematStrategy::clearRecordedRemats ( )
inline

Stops recording rematerializations and clears all recorded ones.

Definition at line 77 of file GCNRematStrategy.h.

References assert().

◆ rematerializeFor()

void GCNRematStrategy::rematerializeFor ( unsigned MaxSGPRs,
unsigned MaxVGPRs,
bool SpillReduction,
BitVector & AffectedRegions,
MutableArrayRef< GCNRegPressure > * MaxPressure = nullptr )

Rematerializes with the goal of reducing the maximum pressure in all Regions to MaxSGPRs SGPRs and MaxVGPRs VGPRs.

SpillReduction indicates whether that register pressure target allows to reduce spilling, which influences rematerialization decisions. Regions which are rematerialized from/into/over have their corresponding index set in AffectedRegions. When not null, MaxPressure provides initial maximum pressure for all regions and contains updated maximum pressures when the function returns.

Definition at line 239 of file GCNRematStrategy.cpp.

References _, llvm::LaneBitmask::any(), assert(), llvm::dbgs(), DefMI, llvm::enumerate(), llvm::LiveInterval::hasSubRanges(), LLVM_DEBUG, llvm::BitVector::reset(), llvm::reverse(), llvm::BitVector::set_bits(), llvm::ArrayRef< T >::size(), llvm::BitVector::size(), llvm::sort(), llvm::LiveInterval::subranges(), TRI, and UseReg().

◆ rollbackRecordedRemats()

void GCNRematStrategy::rollbackRecordedRemats ( )

Rolls back all recorded rematerializations.

Definition at line 529 of file GCNRematStrategy.cpp.

References assert().

◆ startRecordingRemats()

void llvm::GCNRematStrategy::startRecordingRemats ( )
inline

Starts recording rematerializations for eventual rollback.

Definition at line 71 of file GCNRematStrategy.h.

References assert().


The documentation for this class was generated from the following files: