36 std::function<bool(const MachineFunction &)> PredicateFtor;
43 "Unpack machine instruction bundles",
false,
false)
46 if (PredicateFtor && !PredicateFtor(MF))
60 while (++MII != MIE && MII->isBundledWithPred()) {
61 MII->unbundleFromPred();
62 for (
unsigned i = 0, e = MII->getNumOperands(); i != e; ++i) {
84 return new UnpackMachineBundles(std::move(Ftor));
102 "Finalize machine instruction bundles",
false,
false)
113 for (
auto MII = FirstMI; MII != LastMI; ++MII)
114 if (MII->getDebugLoc().get())
115 return MII->getDebugLoc();
128 assert(FirstMI != LastMI &&
"Empty bundle?");
148 for (
auto MII = FirstMI; MII != LastMI; ++MII) {
149 for (
unsigned i = 0, e = MII->getNumOperands(); i != e; ++i) {
162 if (LocalDefSet.
count(Reg)) {
168 if (ExternUseSet.
insert(Reg).second) {
179 for (
unsigned i = 0, e = Defs.
size(); i != e; ++i) {
185 if (LocalDefSet.
insert(Reg).second) {
192 KilledDefSet.
erase(Reg);
195 DeadDefSet.
erase(Reg);
200 unsigned SubReg = *SubRegs;
201 if (LocalDefSet.
insert(SubReg).second)
211 for (
unsigned i = 0, e = LocalDefs.
size(); i != e; ++i) {
212 unsigned Reg = LocalDefs[i];
213 if (Added.
insert(Reg).second) {
215 bool isDead = DeadDefSet.
count(Reg) || KilledDefSet.
count(Reg);
221 for (
unsigned i = 0, e = ExternUses.
size(); i != e; ++i) {
222 unsigned Reg = ExternUses[i];
223 bool isKill = KilledUseSet.
count(Reg);
231 for (
auto MII = FirstMI; MII != LastMI; ++MII) {
249 while (LastMI != E && LastMI->isInsideBundle())
258 bool Changed =
false;
265 assert(!MII->isInsideBundle() &&
266 "First instr cannot be inside bundle before finalization!");
268 for (++MII; MII != MIE; ) {
269 if (!MII->isInsideBundle())
289 for(; isValid(); ++*
this) {
296 Ops->push_back(std::make_pair(MO.
getParent(), getOperandNo()));
317 bool AllDefsDead =
true;
318 PhysRegInfo PRI = {
false,
false,
false,
false,
false,
false,
false,
false};
321 "analyzePhysReg not given a physical register!");
322 for (; isValid(); ++*
this) {
333 unsigned MOReg = MO.
getReg();
348 }
else if (MO.
isDef()) {
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
bool isSuperRegisterEq(unsigned RegA, unsigned RegB) const
Returns true if RegB is a super-register of RegA or if RegB == RegA.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
instr_iterator instr_begin()
instr_iterator instr_end()
This class represents lattice values for constants.
bool Tied
Tied - Uses and defs must use the same register.
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
void push_back(const T &Elt)
unsigned getReg() const
getReg - Returns the register number.
void initializeFinalizeMachineBundlesPass(PassRegistry &)
unsigned const TargetRegisterInfo * TRI
void initializeUnpackMachineBundlesPass(PassRegistry &)
bool isInternalRead() const
VirtRegInfo analyzeVirtReg(unsigned Reg, SmallVectorImpl< std::pair< MachineInstr *, unsigned > > *Ops=nullptr)
analyzeVirtReg - Analyze how the current instruction or bundle uses a virtual register.
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
char & FinalizeMachineBundlesID
FinalizeMachineBundles - This pass finalize machine instruction bundles (created earlier, e.g.
PhysRegInfo analyzePhysReg(unsigned Reg, const TargetRegisterInfo *TRI)
analyzePhysReg - Analyze how the current instruction or bundle uses a physical register.
INITIALIZE_PASS(UnpackMachineBundles, "unpack-mi-bundles", "Unpack machine instruction bundles", false, false) bool UnpackMachineBundles
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register. ...
MIBundleBuilder & prepend(MachineInstr *MI)
Insert MI into MBB by prepending it to the instructions in the bundle.
virtual const TargetInstrInfo * getInstrInfo() const
unsigned getUndefRegState(bool B)
bool PartialDeadDef
Reg is Defined and all defs of reg or an overlapping register are dead.
VirtRegInfo - Information about a virtual register used by a set of operands.
unsigned getKillRegState(bool B)
TargetInstrInfo - Interface to description of machine instruction set.
unsigned getDeadRegState(bool B)
unsigned getDefRegState(bool B)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool Writes
Writes - One of the operands writes the virtual register.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool Read
Reg or one of its aliases is read.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
bool Clobbered
There is a regmask operand indicating Reg is clobbered.
bool Killed
There is a use operand of reg or a super-register with kill flag set.
void setIsInternalRead(bool Val=true)
FunctionPass class - This class is used to implement most global optimizations.
bool isRegTiedToDefOperand(unsigned UseOpIdx, unsigned *DefOpIdx=nullptr) const
Return true if the use operand of the specified index is tied to a def operand.
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
bool Reads
Reads - One of the operands read the virtual register.
char & UnpackMachineBundlesID
UnpackMachineBundles - This pass unpack machine instruction bundles.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
MCSubRegIterator enumerates all sub-registers of Reg.
static bool isUndef(ArrayRef< int > Mask)
Iterator for intrusive lists based on ilist_node.
bool regsOverlap(unsigned regA, unsigned regB) const
Returns true if the two registers are equal or alias each other.
MachineOperand class - Representation of each machine instruction operand.
bool finalizeBundles(MachineFunction &MF)
finalizeBundles - Finalize instruction bundles in the specified MachineFunction.
bool FullyDefined
Reg or a super-register is defined.
FunctionPass * createUnpackMachineBundles(std::function< bool(const MachineFunction &)> Ftor)
bool FullyRead
Reg or a super-register is read. The full register is read.
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.
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.
static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
Return the first found DebugLoc that has a DILocation, given a range of instructions.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
unsigned getImplRegState(bool B)
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Information about how a physical register Reg is used by a set of operands.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Instructions::iterator instr_iterator
bool Defined
Reg or one of its aliases is defined.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
print Print MemDeps of function
Binary functor that adapts to any other binary functor after dereferencing operands.
void finalizeBundle(MachineBasicBlock &MBB, MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
finalizeBundle - Finalize a machine instruction bundle which includes a sequence of instructions star...
Helper class for constructing bundles of MachineInstrs.
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.