17#ifndef LLVM_CODEGEN_REGISTERSCAVENGING_H
18#define LLVM_CODEGEN_REGISTERSCAVENGING_H
31class TargetRegisterClass;
32class TargetRegisterInfo;
40 unsigned NumRegUnits = 0;
43 bool Tracking =
false;
46 struct ScavengedInfo {
47 ScavengedInfo(
int FI = -1) : FrameIndex(FI) {}
81 for (ScavengedInfo &Slot : Scavenged) {
82 if (Slot.FrameIndex == FI) {
85 Slot.Restore = Restore;
149 for (
const ScavengedInfo &
SI : Scavenged)
150 if (
SI.FrameIndex == FI)
158 for (
const ScavengedInfo &
I : Scavenged)
159 if (
I.FrameIndex >= 0)
160 A.push_back(
I.FrameIndex);
174 bool AllowSpill =
true);
176 bool AllowSpill =
true) {
191 bool RestoreAfter,
int SPAdj,
192 bool AllowSpill =
true);
203 void setUsed(
const BitVector &RegUnits) {
206 void setUnused(
const BitVector &RegUnits) {
212 void determineKillsAndDefs();
215 void addRegUnits(BitVector &BV, MCRegister
Reg);
218 void removeRegUnits(BitVector &BV, MCRegister
Reg);
225 BitVector &Candidates,
230 void init(MachineBasicBlock &MBB);
234 ScavengedInfo &spill(Register
Reg,
const TargetRegisterClass &RC,
int SPAdj,
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineBasicBlock MachineBasicBlock::iterator MBBI
This file implements the BitVector class.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static cl::opt< unsigned > InstrLimit("dfa-instr-limit", cl::Hidden, cl::init(0), cl::desc("If present, stops packetizing after N instructions"))
A common definition of LaneBitmask for use in TableGen and CodeGen.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
A set of register units used to track register liveness.
void addUnits(const BitVector &RegUnits)
Adds all register units marked in the bitvector RegUnits.
void removeUnits(const BitVector &RegUnits)
Removes all register units marked in the bitvector RegUnits.
MachineInstrBundleIterator< MachineInstr > iterator
Representation of each machine instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
void backward(MachineBasicBlock::iterator I)
Call backward() as long as the internal iterator does not point to I.
void enterBasicBlockEnd(MachineBasicBlock &MBB)
Start tracking liveness from the end of basic block MBB.
bool isRegUsed(Register Reg, bool includeReserved=true) const
Return if a specific register is currently used.
Register FindUnusedReg(const TargetRegisterClass *RC) const
Find an unused register of the specified register class.
Register scavengeRegister(const TargetRegisterClass *RC, MachineBasicBlock::iterator I, int SPAdj, bool AllowSpill=true)
Make a register of the specific register class available and do the appropriate bookkeeping.
void setRegUsed(Register Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Tell the scavenger a register is used.
void assignRegToScavengingIndex(int FI, Register Reg, MachineInstr *Restore=nullptr)
Record that Reg is in use at scavenging index FI.
void backward()
Update internal register state and move MBB iterator backwards.
MachineBasicBlock::iterator getCurrentPosition() const
void enterBasicBlock(MachineBasicBlock &MBB)
Start tracking liveness from the begin of basic block MBB.
void skipTo(MachineBasicBlock::iterator I)
Move the internal MBB iterator but do not update register states.
Register scavengeRegisterBackwards(const TargetRegisterClass &RC, MachineBasicBlock::iterator To, bool RestoreAfter, int SPAdj, bool AllowSpill=true)
Make a register of the specific register class available from the current position backwards to the p...
void forward(MachineBasicBlock::iterator I)
Move the internal MBB iterator and update register states until it has processed the specific iterato...
void getScavengingFrameIndices(SmallVectorImpl< int > &A) const
Get an array of scavenging frame indices.
bool isScavengingFrameIndex(int FI) const
Query whether a frame index is a scavenging frame index.
Register scavengeRegister(const TargetRegisterClass *RegClass, int SPAdj, bool AllowSpill=true)
void addScavengingFrameIndex(int FI)
Add a scavenging frame index.
BitVector getRegsAvailable(const TargetRegisterClass *RC)
Return all available registers in the register class in Mask.
void forward()
Move the internal MBB iterator and update register states.
Wrapper class representing virtual and physical registers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
void scavengeFrameVirtualRegs(MachineFunction &MF, RegScavenger &RS)
Replaces all frame index virtual registers with physical registers.
static constexpr LaneBitmask getAll()