15#define DEBUG_TYPE "global_sched"
25 : TII(TII), TRI(TRI) {
26 LiveIns.resize(TRI->getNumRegs());
27 LiveOuts.resize(TRI->getNumRegs());
33 for (
const auto &LI :
MBB->liveins())
40 for (
const auto &LI : Succ->liveins())
55 for (++MII; MII != MIIE && MII->isInsideBundle(); ++MII) {
58 for (
unsigned i = 0, e = MII->getNumOperands(); i != e; ++i) {
82 for (
unsigned i = 0, e =
MI->getNumOperands(); i != e; ++i) {
123 for (
unsigned i = 0; i < Set.size(); i++)
134 BitVector NewLiveOuts(TRI->getNumRegs());
147 for (
const auto &LI :
MBB->liveins())
148 setUsed(NewLiveIns, LI.PhysReg);
154 for (
const auto &LI : Succ->liveins())
155 setUsed(NewLiveOuts, LI.PhysReg);
157 LiveIns = NewLiveIns;
164 NewLiveIns = NewLiveOuts;
167 std::vector<MachineInstr *> BundleList;
170 if (!
MI->isDebugInstr())
171 BundleList.push_back(&*
MI);
173 while (!BundleList.empty()) {
175 BundleList.pop_back();
184 NewLiveIns &= NotGen;
185 NewLiveIns |= LocalUse;
197 for (
unsigned i = 0; i < LiveIns.size(); ++i) {
198 if (NewLiveIns.
test(i))
200 if (LiveIns.test(i) == NewLiveIns.
test(i))
203 MBB->removeLiveIn(i);
204 if (NewLiveIns.
test(i))
211 for (
unsigned i = 0; i < LiveIns.size(); i++)
214 for (
unsigned i = 0; i < LiveOuts.size(); i++)
215 if (LiveOuts.test(i))
225 : TII(TII), TRI(TRI) {
227 Elements.push_back(
MBB);
228 ElementIndex[
MBB] = 0;
229 LiveInfo[
MBB] = std::make_unique<LivenessInfo>(TII, TRI,
MBB);
235 ElementIndex.clear();
239 auto It = LiveInfo.find(
MBB);
240 assert(It != LiveInfo.end() &&
"Missing Liveness info");
241 assert(It->second &&
"Missing Liveness info");
242 return It->second.get();
247 if (LiveInfo.find(
MBB) != LiveInfo.end())
249 ElementIndex[
MBB] =
static_cast<unsigned>(Elements.size());
250 Elements.push_back(
MBB);
251 LiveInfo[
MBB] = std::make_unique<LivenessInfo>(TII, TRI,
MBB);
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool isPredicatedDef(MachineInstr *MI, unsigned Reg, const HexagonInstrInfo *QII)
static void dumpRI(const TargetRegisterInfo *TRI, BitVector &Set)
Register const TargetRegisterInfo * TRI
BasicBlockRegion(const TargetInstrInfo *TII, const TargetRegisterInfo *TRI, MachineBasicBlock *MBB)
BasicBlockRegion Methods.
LivenessInfo * getLivenessInfoForBB(MachineBasicBlock *MBB)
void addBBtoRegion(MachineBasicBlock *MBB)
bool test(unsigned Idx) const
bool isPredicated(const MachineInstr &MI) const override
Returns true if the instruction is already predicated.
Class to track incremental liveness update.
void UpdateLiveness(MachineBasicBlock *MBB)
void parseOperands(MachineInstr *MI, BitVector &Gen, BitVector &Kill, BitVector &Use)
Determine def/use set for MI.
LivenessInfo(const TargetInstrInfo *TII, const TargetRegisterInfo *TRI, MachineBasicBlock *MBB)
void setUsed(BitVector &Set, unsigned Reg)
setUsed - Set the register and its sub-registers as being used.
void parseOperandsWithReset(MachineInstr *MI, BitVector &Gen, BitVector &Kill, BitVector &Use)
MCSubRegIterator enumerates all sub-registers of Reg.
bool isValid() const
Returns true if this iterator is not yet at the end.
Instructions::iterator instr_iterator
instr_iterator instr_end()
MachineInstrBundleIterator< MachineInstr > iterator
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Register getReg() const
getReg - Returns the register number.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
A Use represents the edge between a Value definition and its users.
This is an optimization pass for GlobalISel generic memory operations.
@ Kill
The last use of a register.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI 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.