28 if (Ftor && !Ftor(MF))
34 MIE =
MBB.instr_end(); MII != MIE; ) {
40 while (++MII != MIE && MII->isBundledWithPred()) {
41 MII->unbundleFromPred();
43 if (MO.isReg() && MO.isInternalRead())
44 MO.setIsInternalRead(
false);
47 MI->eraseFromParent();
65 UnpackMachineBundlesLegacy(
67 : MachineFunctionPass(ID), PredicateFtor(std::
move(Ftor)) {}
84char UnpackMachineBundlesLegacy::ID = 0;
87 "Unpack machine instruction bundles",
false,
false)
95 return new UnpackMachineBundlesLegacy(std::move(Ftor));
105 for (
auto MII = FirstMI; MII != LastMI; ++MII) {
106 if (
DebugLoc MIIDL = MII->getDebugLoc()) {
107 if (MIIDL.getLine() != 0)
121 if (
Reg.isPhysical()) {
122 for (MCRegUnit Unit :
TRI->regunits(
Reg.asMCReg()))
123 if (!LocalDefsP[
static_cast<unsigned>(Unit)])
140 assert(FirstMI != LastMI &&
"Empty bundle?");
159 for (
auto MII = FirstMI; MII != LastMI; ++MII) {
161 if (MII->isDebugInstr())
170 MO.setIsInternalRead();
176 if (ExternUses.
insert(Reg)) {
184 if (MO.isTied() && Reg.isVirtual()) {
188 unsigned TiedIdx = MII->findTiedOperandIdx(MO.getOperandNo());
201 if (LocalDefs.
insert(Reg)) {
202 if (!MO.isDead() && Reg.isPhysical()) {
203 for (MCRegUnit Unit :
TRI->regunits(Reg.asMCReg()))
204 LocalDefsP.
set(
static_cast<unsigned>(Unit));
209 DeadDefSet.
erase(Reg);
223 if (MII->mayLoadOrStore())
235 bool isKill = KilledUseSet.
contains(Reg);
241 for (
auto [DefReg,
UseReg] : TiedOperands) {
264 while (LastMI != E && LastMI->isInsideBundle())
279 assert(!MII->isInsideBundle() &&
280 "First instr cannot be inside bundle before finalization!");
282 for (++MII; MII != MIE; ) {
283 if (!MII->isInsideBundle())
306 Ops->push_back(std::make_pair(MO.
getParent(), O.getOperandNo()));
325std::pair<LaneBitmask, LaneBitmask>
333 if (!MO.isReg() || MO.getReg() != Reg)
336 unsigned SubReg = MO.getSubReg();
337 if (SubReg == 0 && MO.isUse() && !MO.isUndef())
343 UseMask |= ~SubRegMask;
344 DefMask |= SubRegMask;
345 }
else if (!MO.isUndef())
346 UseMask |= SubRegMask;
349 return {UseMask, DefMask};
354 bool AllDefsDead =
true;
355 PhysRegInfo PRI = {
false,
false,
false,
false,
false,
false,
false,
false};
357 assert(Reg.isPhysical() &&
"analyzePhysReg not given a physical register!");
359 if (MO.isRegMask() && MO.clobbersPhysReg(Reg)) {
371 if (!
TRI->regsOverlap(MOReg, Reg))
374 bool Covered =
TRI->isSuperRegisterEq(Reg, MOReg);
382 }
else if (MO.isDef()) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static Register UseReg(const MachineOperand &MO)
const HexagonInstrInfo * TII
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static bool unpackBundles(MachineFunction &MF, std::function< bool(const MachineFunction &)> Ftor)
static bool containsReg(SmallSetVector< Register, 32 > LocalDefsV, const BitVector &LocalDefsP, Register Reg, const TargetRegisterInfo *TRI)
Check if target reg is contained in given lists, which are: LocalDefsV as given list for virtual regs...
static bool isUndef(const MachineInstr &MI)
Register const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
bool isDead(const MachineInstr &MI, const MachineRegisterInfo &MRI)
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallSet class.
This file defines the SmallVector class.
BitVector & set()
Set all bits in the bitvector.
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
FunctionPass class - This class is used to implement most global optimizations.
Helper class for constructing bundles of MachineInstrs.
MIBundleBuilder & prepend(MachineInstr *MI)
Insert MI into MBB by prepending it to the instructions in the bundle.
MIBundleOperands - Iterate over all operands in a bundle of machine instructions.
Instructions::iterator instr_iterator
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & setMIFlag(MachineInstr::MIFlag Flag) const
Representation of each machine instruction.
bool isRegTiedToDefOperand(unsigned UseOpIdx, unsigned *DefOpIdx=nullptr) const
Return true if the use operand of the specified index is tied to a def operand.
LLVM_ABI void cloneMergedMemRefs(MachineFunction &MF, ArrayRef< const MachineInstr * > MIs)
Clone the merge of multiple MachineInstrs' memory reference descriptors list and replace ours with it...
LLVM_ABI void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.
MachineOperand class - Representation of each machine instruction operand.
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI LaneBitmask getMaxLaneMaskForVReg(Register Reg) const
Returns a mask covering all bits that can appear in lane masks of subregisters of the virtual registe...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Wrapper class representing virtual and physical registers.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
size_type size() const
Determine the number of elements in the SetVector.
bool contains(const_arg_type key) const
Check if the SetVector contains the given key.
iterator begin()
Get an iterator to the beginning of the SetVector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
A SetVector that performs no allocations if smaller than a certain size.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
bool contains(const T &V) const
Check if the SmallSet contains the given element.
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetInstrInfo - Interface to description of machine instruction set.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetRegisterInfo * getRegisterInfo() const =0
Return the target's register information.
PreservedAnalyses LLVM_ABI run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI 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...
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr RegState getImplRegState(bool B)
constexpr RegState getKillRegState(bool B)
LLVM_ABI bool finalizeBundles(MachineFunction &MF)
finalizeBundles - Finalize instruction bundles in the specified MachineFunction.
LLVM_ABI PhysRegInfo AnalyzePhysRegInBundle(const MachineInstr &MI, Register Reg, const TargetRegisterInfo *TRI)
AnalyzePhysRegInBundle - Analyze how the current instruction or bundle uses a physical register.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
constexpr RegState getDeadRegState(bool B)
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
LLVM_ABI FunctionPass * createUnpackMachineBundlesLegacy(std::function< bool(const MachineFunction &)> Ftor)
constexpr RegState getDefRegState(bool B)
iterator_range< ConstMIBundleOperands > const_mi_bundle_ops(const MachineInstr &MI)
LLVM_ABI VirtRegInfo AnalyzeVirtRegInBundle(MachineInstr &MI, Register Reg, SmallVectorImpl< std::pair< MachineInstr *, unsigned > > *Ops=nullptr)
AnalyzeVirtRegInBundle - Analyze how the current instruction or bundle uses a virtual register.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
constexpr RegState getUndefRegState(bool B)
LLVM_ABI char & UnpackMachineBundlesID
UnpackMachineBundles - This pass unpack machine instruction bundles.
LLVM_ABI std::pair< LaneBitmask, LaneBitmask > AnalyzeVirtRegLanesInBundle(const MachineInstr &MI, Register Reg, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI)
Return a pair of lane masks (reads, writes) indicating which lanes this instruction uses with Reg.
Information about how a physical register Reg is used by a set of operands.
bool Read
Reg or one of its aliases is read.
bool Defined
Reg or one of its aliases is defined.
bool Killed
There is a use operand of reg or a super-register with kill flag set.
bool PartialDeadDef
Reg is Defined and all defs of reg or an overlapping register are dead.
bool Clobbered
There is a regmask operand indicating Reg is clobbered.
bool FullyRead
Reg or a super-register is read. The full register is read.
bool FullyDefined
Reg or a super-register is defined.
VirtRegInfo - Information about a virtual register used by a set of operands.
bool Reads
Reads - One of the operands read the virtual register.
bool Tied
Tied - Uses and defs must use the same register.
bool Writes
Writes - One of the operands writes the virtual register.