22#define DEBUG_TYPE "si-post-ra-bundler"
38 return "SI post-RA bundler";
67char SIPostRABundler::
ID = 0;
72 return new SIPostRABundler();
75bool SIPostRABundler::isDependentLoad(
const MachineInstr &
MI)
const {
84 if (
TRI->regsOverlap(Reg, Def))
93 if (
MI.isDebugInstr())
97 if (!
Op.isReg() || !
Op.readsReg())
102 "subregister indexes should not be present after RA");
105 UsedRegUnits.
set(Unit);
109bool SIPostRABundler::isBundleCandidate(
const MachineInstr &
MI)
const {
110 const uint64_t IMemFlags =
MI.getDesc().TSFlags & MemFlags;
111 return IMemFlags != 0 &&
MI.mayLoadOrStore() && !
MI.isBundled();
116 const uint64_t IMemFlags =
MI.getDesc().TSFlags & MemFlags;
118 return (IMemFlags != 0 &&
MI.mayLoadOrStore() && !NextMI.
isBundled() &&
121 !isDependentLoad(NextMI));
132 bool Changed =
false;
135 unsigned Opc = MI.getOpcode();
136 return Opc == AMDGPU::SCHED_GROUP_BARRIER || Opc == AMDGPU::IGLP_OPT;
147 for (
auto I =
B;
I != E;
I = Next) {
149 if (!isBundleCandidate(*
I))
154 if (
I->getNumExplicitDefs() != 0)
155 Defs.insert(
I->defs().begin()->getReg());
159 unsigned ClauseLength = 1;
160 for (
I = Next;
I != E;
I = Next) {
164 if (canBundle(*BundleEnd, *
I)) {
166 if (
I->getNumExplicitDefs() != 0)
167 Defs.insert(
I->defs().begin()->getReg());
169 }
else if (!
I->isMetaInstruction()) {
180 Next = std::next(BundleEnd);
181 if (ClauseLength > 1) {
187 if (Next != E && Next->isKill()) {
191 collectUsedRegUnits(BundleMI, BundleUsedRegUnits);
193 BundleUsedRegUnits.flip();
195 while (Next != E && Next->isKill()) {
197 collectUsedRegUnits(Kill, KillUsedRegUnits);
199 KillUsedRegUnits &= BundleUsedRegUnits;
205 if (KillUsedRegUnits.none()) {
207 Kill.eraseFromParent();
211 KillUsedRegUnits.reset();
214 BundleUsedRegUnits.reset();
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
AMD GCN specific subclass of TargetSubtarget.
unsigned const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallSet class.
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
This class represents an Operation in the Expression.
FunctionPass class - This class is used to implement most global optimizations.
instr_iterator instr_begin()
Instructions::iterator instr_iterator
instr_iterator instr_end()
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
bool isBundled() const
Return true if this instruction part of a bundle.
MachineOperand class - Representation of each machine instruction operand.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Wrapper class representing virtual and physical registers.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
StringRef - Represent a constant reference to a string, i.e.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ Kill
The last use of a register.
Reg
All possible values of the reg field in the ModR/M byte.
This is an optimization pass for GlobalISel generic memory operations.
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...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
void initializeSIPostRABundlerPass(PassRegistry &)
FunctionPass * createSIPostRABundlerPass()