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);
48 if (!
O->isDef() ||
O->isDebug())
50 unsigned Reg =
O->getReg();
54 }
else if (
O->isRegMask())
62 if (!
O->isReg() || !
O->readsReg() ||
O->isDebug())
64 unsigned Reg =
O->getReg();
86 SmallVectorImpl<std::pair<MCPhysReg, const MachineOperand*>> &Clobbers) {
89 if (
O->isReg() && !
O->isDebug()) {
90 unsigned Reg =
O->getReg();
96 Clobbers.push_back(std::make_pair(Reg, &*
O));
103 }
else if (
O->isRegMask())
108 for (
auto Reg : Clobbers) {
111 if (
Reg.second->isReg() &&
Reg.second->isDead())
113 if (
Reg.second->isRegMask() &&
122 OS <<
"Live Registers:";
124 OS <<
" (uninitialized)\n";
138 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 140 dbgs() <<
" " << *
this;
146 if (LiveRegs.
count(Reg))
151 if (LiveRegs.
count(*R))
159 for (
const auto &LI : MBB.
liveins()) {
163 assert(Mask.
any() &&
"Invalid livein mask");
215 addBlockLiveIns(*Succ);
229 if (
Info.isRestored())
244 addBlockLiveIns(MBB);
267 bool ContainsSuperReg =
false;
269 if (LiveRegs.contains(*SReg) && !MRI.
isReserved(*SReg)) {
270 ContainsSuperReg =
true;
274 if (ContainsSuperReg)
293 if (!MO->isReg() || !MO->isDef() || MO->isDebug())
296 unsigned Reg = MO->getReg();
301 bool IsNotLive = LiveRegs.
available(MRI, Reg);
302 MO->setIsDead(IsNotLive);
310 if (!MO->isReg() || !MO->readsReg() || MO->isDebug())
313 unsigned Reg = MO->getReg();
318 bool IsNotLive = LiveRegs.
available(MRI, Reg);
319 MO->setIsKill(IsNotLive);
bool isCalleeSavedInfoValid() const
Has the callee saved info been calculated yet?
This class represents lattice values for constants.
void dump() const
Dumps the currently live registers to the debug output.
MIBundleOperands - Iterate over all operands in a bundle of machine instructions. ...
static void addCalleeSavedRegs(LivePhysRegs &LiveRegs, const MachineFunction &MF)
Adds all callee saved registers to LiveRegs.
const_iterator begin() const
iterator_range< succ_iterator > successors()
bool empty() const
Returns true if the set is empty.
bool isReturnBlock() const
Convenience function that returns true if the block ends in a return instruction. ...
MCSuperRegIterator enumerates all super-registers of Reg.
Printable printReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
size_type count(const KeyT &Key) const
count - Returns 1 if this set contains an element identified by Key, 0 otherwise. ...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
bool isValid() const
isValid - Returns true until all the operands have been visited.
void addLiveIns(MachineBasicBlock &MBB, const LivePhysRegs &LiveRegs)
Adds registers contained in LiveRegs to the block live-in list of MBB.
unsigned getSubRegIndex() const
Returns sub-register index of the current sub-register.
reverse_iterator rbegin()
Analysis containing CSE Info
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
iterator erase(iterator I)
erase - Erases an existing element identified by a valid iterator.
void addLiveIn(MCPhysReg PhysReg, LaneBitmask LaneMask=LaneBitmask::getAll())
Adds the specified register as a live in.
const TargetRegisterInfo * getTargetRegisterInfo() const
unsigned const MachineRegisterInfo * MRI
unsigned getSubReg() const
Returns current sub-register.
typename DenseT::iterator iterator
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Iterator that enumerates the sub-registers of a Reg and the associated sub-register indices...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void addLiveOuts(const MachineBasicBlock &MBB)
Adds all live-out registers of basic block MBB.
void addLiveIns(const MachineBasicBlock &MBB)
Adds all live-in registers of basic block MBB.
void addUses(const MachineInstr &MI)
Add uses to the set.
void init(const TargetRegisterInfo &TRI)
(re-)initializes and clears the set.
MCRegAliasIterator enumerates all registers aliasing Reg.
void stepBackward(const MachineInstr &MI)
Simulates liveness when stepping backwards over an instruction(bundle).
bool livein_empty() const
constexpr bool all() const
RegisterSet::const_iterator const_iterator
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
void addLiveOutsNoPristines(const MachineBasicBlock &MBB)
Adds all live-out registers of basic block MBB but skips pristine registers.
const_iterator end() const
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_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
ConstMIBundleOperands - Iterate over all operands in a const bundle of machine instructions.
bool isValid() const
Returns true if this iterator is not yet at the end.
bool available(const MachineRegisterInfo &MRI, MCPhysReg Reg) const
Returns true if register Reg and no aliasing register is in the set.
MachineOperand class - Representation of each machine instruction operand.
const_iterator begin() const
LaneBitmask getSubRegIndexLaneMask(unsigned SubIdx) const
Return a bitmask representing the parts of a register that are covered by SubIdx. ...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
The CalleeSavedInfo class tracks the information need to locate where a callee saved register is in t...
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
void computeAndAddLiveIns(LivePhysRegs &LiveRegs, MachineBasicBlock &MBB)
Convenience function combining computeLiveIns() and addLiveIns().
void print(raw_ostream &OS) const
Prints the currently live registers to OS.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void removeDefs(const MachineInstr &MI)
Remove defined registers and regmask kills from the set.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
A set of physical registers with utility functions to track liveness when walking backward/forward th...
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
Returns a reference to call saved info vector for the current function.
constexpr bool any() const
const_iterator end() const
iterator_range< livein_iterator > liveins() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void removeRegsInMask(const MachineOperand &MO, SmallVectorImpl< std::pair< MCPhysReg, const MachineOperand *>> *Clobbers=nullptr)
Removes physical registers clobbered by the regmask operand MO.
const MCPhysReg * getCalleeSavedRegs() const
Returns list of callee saved registers.
void addReg(MCPhysReg Reg)
Adds a physical register and all its sub-registers to the set.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
This class implements an extremely fast bulk output stream that can only output to a stream...
void removeReg(MCPhysReg Reg)
Removes a physical register, all its sub-registers, and all its super-registers from the set...
void stepForward(const MachineInstr &MI, SmallVectorImpl< std::pair< MCPhysReg, const MachineOperand *>> &Clobbers)
Simulates liveness when stepping forward over an instruction(bundle).
void recomputeLivenessFlags(MachineBasicBlock &MBB)
Recomputes dead and kill flags in MBB.
bool isReserved(unsigned PhysReg) const
isReserved - Returns true when PhysReg is a reserved register.