23#define DEBUG_TYPE "si-post-ra-bundler"
39 return "SI post-RA bundler";
48class SIPostRABundler {
75char SIPostRABundlerLegacy::
ID = 0;
80 return new SIPostRABundlerLegacy();
83bool SIPostRABundler::isDependentLoad(
const MachineInstr &
MI)
const {
92 if (
TRI->regsOverlap(Reg, Def))
101 if (
MI.isDebugInstr())
105 if (!
Op.isReg() || !
Op.readsReg())
110 "subregister indexes should not be present after RA");
113 UsedRegUnits.
set(Unit);
117bool SIPostRABundler::isBundleCandidate(
const MachineInstr &
MI)
const {
118 const uint64_t IMemFlags =
MI.getDesc().TSFlags & MemFlags;
119 return IMemFlags != 0 &&
MI.mayLoadOrStore() && !
MI.isBundled();
124 const uint64_t IMemFlags =
MI.getDesc().TSFlags & MemFlags;
126 return (IMemFlags != 0 &&
MI.mayLoadOrStore() && !NextMI.
isBundled() &&
129 !isDependentLoad(NextMI));
135 return SIPostRABundler().run(MF);
140 SIPostRABundler().run(MF);
150 bool Changed =
false;
153 unsigned Opc = MI.getOpcode();
154 return Opc == AMDGPU::SCHED_GROUP_BARRIER || Opc == AMDGPU::IGLP_OPT;
165 for (
auto I =
B;
I != E;
I = Next) {
167 if (!isBundleCandidate(*
I))
172 if (
I->getNumExplicitDefs() != 0)
173 Defs.insert(
I->defs().begin()->getReg());
177 unsigned ClauseLength = 1;
178 for (
I = Next;
I != E;
I = Next) {
182 if (canBundle(*BundleEnd, *
I)) {
184 if (
I->getNumExplicitDefs() != 0)
185 Defs.insert(
I->defs().begin()->getReg());
187 }
else if (!
I->isMetaInstruction() ||
188 I->getOpcode() == AMDGPU::SCHED_BARRIER) {
200 Next = std::next(BundleEnd);
201 if (ClauseLength > 1) {
207 if (Next != E && Next->isKill()) {
211 collectUsedRegUnits(BundleMI, BundleUsedRegUnits);
213 BundleUsedRegUnits.flip();
215 while (Next != E && Next->isKill()) {
217 collectUsedRegUnits(Kill, KillUsedRegUnits);
219 KillUsedRegUnits &= BundleUsedRegUnits;
225 if (KillUsedRegUnits.none()) {
227 Kill.eraseFromParent();
231 KillUsedRegUnits.reset();
234 BundleUsedRegUnits.reset();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
AMD GCN specific subclass of TargetSubtarget.
Register const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the SmallSet class.
A container for analyses that lazily runs them and caches their results.
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 LLVM_ABI 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.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Wrapper class representing virtual and physical registers.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
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.
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...
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.
FunctionPass * createSIPostRABundlerPass()
char & SIPostRABundlerLegacyID
void initializeSIPostRABundlerLegacyPass(PassRegistry &)