34 std::function<bool(const Function &)> PredicateFtor;
41 "Unpack machine instruction bundles",
false,
false)
44 if (PredicateFtor && !PredicateFtor(*MF.getFunction()))
58 while (++MII != MIE && MII->isBundledWithPred()) {
59 MII->unbundleFromPred();
60 for (
unsigned i = 0, e = MII->getNumOperands(); i != e; ++i) {
81 return new UnpackMachineBundles(Ftor);
99 "Finalize machine instruction bundles",
false,
false)
115 assert(FirstMI != LastMI &&
"Empty bundle?");
135 for (; FirstMI != LastMI; ++FirstMI) {
136 for (
unsigned i = 0, e = FirstMI->getNumOperands(); i != e; ++i) {
149 if (LocalDefSet.
count(Reg)) {
155 if (ExternUseSet.
insert(Reg).second) {
166 for (
unsigned i = 0, e = Defs.
size(); i != e; ++i) {
172 if (LocalDefSet.
insert(Reg).second) {
179 KilledDefSet.
erase(Reg);
182 DeadDefSet.
erase(Reg);
187 unsigned SubReg = *SubRegs;
188 if (LocalDefSet.
insert(SubReg).second)
198 for (
unsigned i = 0, e = LocalDefs.
size(); i != e; ++i) {
199 unsigned Reg = LocalDefs[i];
200 if (Added.
insert(Reg).second) {
202 bool isDead = DeadDefSet.
count(Reg) || KilledDefSet.
count(Reg);
208 for (
unsigned i = 0, e = ExternUses.
size(); i != e; ++i) {
209 unsigned Reg = ExternUses[i];
210 bool isKill = KilledUseSet.
count(Reg);
211 bool isUndef = UndefUseSet.
count(Reg);
227 while (LastMI != E && LastMI->isInsideBundle())
236 bool Changed =
false;
243 assert(!MII->isInsideBundle() &&
244 "First instr cannot be inside bundle before finalization!");
246 for (++MII; MII != MIE; ) {
247 if (!MII->isInsideBundle())
295 bool AllDefsDead =
true;
296 PhysRegInfo PRI = {
false,
false,
false,
false,
false,
false};
299 "analyzePhysReg not given a physical register!");
309 unsigned MOReg = MO.
getReg();
313 bool IsRegOrSuperReg = MOReg == Reg || TRI->
isSubRegister(MOReg, Reg);
314 bool IsRegOrOverlapping = MOReg == Reg || TRI->
regsOverlap(MOReg, Reg);
316 if (IsRegOrSuperReg && MO.
readsReg()) {
322 if (IsRegOrOverlapping && MO.
readsReg()) {
329 if (IsRegOrSuperReg) {
334 if (IsRegOrOverlapping)
338 if (AllDefsDead && PRI.
Defines)
void push_back(const T &Elt)
const MachineFunction * getParent() const
getParent - Return the MachineFunction containing this basic block.
INITIALIZE_PASS(UnpackMachineBundles,"unpack-mi-bundles","Unpack machine instruction bundles", false, false) bool UnpackMachineBundles
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()
bool Tied
Tied - Uses and defs must use the same register.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
MachineOperand & deref() const
void initializeFinalizeMachineBundlesPass(PassRegistry &)
bool isSubRegister(unsigned RegA, unsigned RegB) const
Returns true if RegB is a sub-register of RegA.
void initializeUnpackMachineBundlesPass(PassRegistry &)
Instructions::iterator instr_iterator
VirtRegInfo analyzeVirtReg(unsigned Reg, SmallVectorImpl< std::pair< MachineInstr *, unsigned > > *Ops=nullptr)
analyzeVirtReg - Analyze how the current instruction or bundle uses a virtual register.
bool Clobbers
Clobbers - Reg or an overlapping register is defined, or a regmask clobbers Reg.
bool DefinesDead
DefinesDead - All defs of a Reg or a super-register are dead.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
Reg
All possible values of the reg field in the ModR/M byte.
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.
MIBundleBuilder & prepend(MachineInstr *MI)
Insert MI into MBB by prepending it to the instructions in the bundle.
unsigned getUndefRegState(bool B)
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)
bool Kills
There is a kill of Reg or a super-register.
bool regsOverlap(unsigned regA, unsigned regB) const
regsOverlap - Returns true if the two registers are equal or alias each other.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
bool ReadsOverlap
ReadsOverlap - Reg or an overlapping register is read.
bool Writes
Writes - One of the operands writes the virtual register.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
FunctionPass * createUnpackMachineBundles(std::function< bool(const Function &)> Ftor)
void setIsInternalRead(bool Val=true)
FunctionPass class - This class is used to implement most global optimizations.
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.
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
BuildMI - Builder interface.
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.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
MachineOperand class - Representation of each machine instruction operand.
bool finalizeBundles(MachineFunction &MF)
finalizeBundles - Finalize instruction bundles in the specified MachineFunction.
bool Reads
Reads - Read or a super-register is read.
BUNDLE - This instruction represents an instruction bundle.
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
Representation of each machine instruction.
static bool isPhysicalRegister(unsigned Reg)
isPhysicalRegister - Return true if the specified register number is in the physical register namespa...
bool Defines
Defines - Reg or a super-register is defined.
unsigned getImplRegState(bool B)
PhysRegInfo - Information about a physical register used by a set of operands.
unsigned getReg() const
getReg - Returns the register number.
bool isValid() const
isValid - Returns true until all the operands have been visited.
virtual const TargetInstrInfo * getInstrInfo() const
BasicBlockListType::iterator iterator
bool isRegTiedToDefOperand(unsigned UseOpIdx, unsigned *DefOpIdx=nullptr) const
Return true if the use operand of the specified index is tied to a def operand.
print Print MemDeps of function
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register. ...
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
addReg - Add a new virtual register operand...
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...
unsigned getOperandNo() const
getOperandNo - Returns the number of the current operand relative to its instruction.
bool isInternalRead() const
Helper class for constructing bundles of MachineInstrs.