Go to the documentation of this file.
21 #include "llvm/Config/llvm-config.h"
32 SmallVectorImpl<std::pair<MCPhysReg, const MachineOperand*>> *Clobbers) {
34 while (LRI != LiveRegs.
end()) {
37 Clobbers->push_back(std::make_pair(*LRI, &MO));
38 LRI = LiveRegs.
erase(LRI);
47 if (MOP.isRegMask()) {
60 if (!MOP.isReg() || !MOP.readsReg())
81 SmallVectorImpl<std::pair<MCPhysReg, const MachineOperand*>> &Clobbers) {
88 if (!
Reg.isPhysical())
93 Clobbers.push_back(std::make_pair(
Reg, &*
O));
99 }
else if (
O->isRegMask()) {
105 for (
auto Reg : Clobbers) {
108 if (
Reg.second->isReg() &&
Reg.second->isDead())
110 if (
Reg.second->isRegMask() &&
119 OS <<
"Live Registers:";
121 OS <<
" (uninitialized)\n";
135 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
137 dbgs() <<
" " << *
this;
148 if (LiveRegs.
count(*R))
161 if (
Mask.all() || !
S.isValid()) {
165 for (;
S.isValid(); ++
S) {
166 unsigned SI =
S.getSubRegIndex();
204 Pristine.removeReg(
Info.getReg());
212 addBlockLiveIns(*Succ);
226 if (
Info.isRestored())
241 addBlockLiveIns(
MBB);
245 addBlockLiveIns(
MBB);
268 bool ContainsSuperReg =
false;
271 ContainsSuperReg =
true;
275 if (ContainsSuperReg)
295 if (!MO->isReg() || !MO->isDef() || MO->isDebug())
310 IsNotLive = !
Info.isRestored();
316 MO->setIsDead(IsNotLive);
324 if (!MO->isReg() || !MO->readsReg() || MO->isDebug())
333 MO->setIsKill(IsNotLive);
typename DenseT::iterator iterator
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
void removeDefs(const MachineInstr &MI)
Remove defined registers and regmask kills from the set.
This is an optimization pass for GlobalISel generic memory operations.
void removeReg(MCPhysReg Reg)
Removes a physical register, all its sub-registers, and all its super-registers from the set.
void computeLiveIns(LivePhysRegs &LiveRegs, const MachineBasicBlock &MBB)
Computes registers live-in to MBB assuming all of its successors live-in lists are up-to-date.
Iterator that enumerates the sub-registers of a Reg and the associated sub-register indices.
void addReg(MCPhysReg Reg)
Adds a physical register and all its sub-registers to the set.
void dump() const
Dumps the currently live registers to the debug output.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
void recomputeLivenessFlags(MachineBasicBlock &MBB)
Recomputes dead and kill flags in MBB.
void addLiveInsNoPristines(const MachineBasicBlock &MBB)
Adds all live-in registers of basic block MBB but skips pristine registers.
Reg
All possible values of the reg field in the ModR/M byte.
const TargetRegisterInfo * getTargetRegisterInfo() const
const_iterator begin() const
void removeRegsInMask(const MachineOperand &MO, SmallVectorImpl< std::pair< MCPhysReg, const MachineOperand * >> *Clobbers=nullptr)
Removes physical registers clobbered by the regmask operand MO.
A set of physical registers with utility functions to track liveness when walking backward/forward th...
bool isReturnBlock() const
Convenience function that returns true if the block ends in a return instruction.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
iterator_range< livein_iterator > liveins() const
auto reverse(ContainerTy &&C, std::enable_if_t< has_rbegin< ContainerTy >::value > *=nullptr)
void addLiveIns(MachineBasicBlock &MBB, const LivePhysRegs &LiveRegs)
Adds registers contained in LiveRegs to the block live-in list of MBB.
bool empty() const
Returns true if the set is empty.
unsigned const TargetRegisterInfo * TRI
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static void addCalleeSavedRegs(LivePhysRegs &LiveRegs, const MachineFunction &MF)
Adds all callee saved registers to LiveRegs.
LaneBitmask getSubRegIndexLaneMask(unsigned SubIdx) const
Return a bitmask representing the parts of a register that are covered by SubIdx.
void addLiveIns(const MachineBasicBlock &MBB)
Adds all live-in registers of basic block MBB.
const_iterator end() const
bool isReserved(MCRegister PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.
void addLiveOuts(const MachineBasicBlock &MBB)
Adds all live-out registers of basic block MBB.
iterator_range< filter_iterator< ConstMIBundleOperands, std::function< bool(const MachineOperand &)> > > phys_regs_and_masks(const MachineInstr &MI)
Returns an iterator range over all physical register and mask operands for MI and bundled instruction...
MachineOperand class - Representation of each machine instruction operand.
This class implements an extremely fast bulk output stream that can only output to a stream.
MIBundleOperands - Iterate over all operands in a bundle of machine instructions.
void computeAndAddLiveIns(LivePhysRegs &LiveRegs, MachineBasicBlock &MBB)
Convenience function combining computeLiveIns() and addLiveIns().
Analysis containing CSE Info
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
static bool clobbersPhysReg(const uint32_t *RegMask, MCRegister PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
void stepBackward(const MachineInstr &MI)
Simulates liveness when stepping backwards over an instruction(bundle).
Representation of each machine instruction.
void addUses(const MachineInstr &MI)
Add uses to the set.
bool available(const MachineRegisterInfo &MRI, MCPhysReg Reg) const
Returns true if register Reg and no aliasing register is in the set.
const MCPhysReg * getCalleeSavedRegs() const
Returns list of callee saved registers.
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
bool isValid() const
isValid - Returns true until all the operands have been visited.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void print(raw_ostream &OS) const
Prints the currently live registers to OS.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
StandardInstrumentations SI(Debug, VerifyEach)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MCSuperRegIterator enumerates all super-registers of Reg.
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
iterator_range< succ_iterator > successors()
void init(const TargetRegisterInfo &TRI)
(re-)initializes and clears the set.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
void stepForward(const MachineInstr &MI, SmallVectorImpl< std::pair< MCPhysReg, const MachineOperand * >> &Clobbers)
Simulates liveness when stepping forward over an instruction(bundle).
unsigned const MachineRegisterInfo * MRI
Wrapper class representing virtual and physical registers.
void addLiveIn(MCRegister PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
void addLiveOutsNoPristines(const MachineBasicBlock &MBB)
Adds all live-out registers of basic block MBB but skips pristine registers.
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
ConstMIBundleOperands - Iterate over all operands in a const bundle of machine instructions.
size_type count(const KeyT &Key) const
count - Returns 1 if this set contains an element identified by Key, 0 otherwise.
iterator erase(iterator I)
erase - Erases an existing element identified by a valid iterator.
bool livein_empty() const
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
MCRegAliasIterator enumerates all registers aliasing Reg.