22#define DEBUG_TYPE "si-post-ra-bundler"
36 return "SI post-RA bundler";
45class SIPostRABundler {
67char SIPostRABundlerLegacy::ID = 0;
78 Register Reg = Op.getReg();
79 for (Register Def : Defs)
80 if (TRI->regsOverlap(Reg, Def))
89 if (
MI.isDebugInstr())
92 for (
const MachineOperand &
Op :
MI.operands()) {
93 if (!
Op.isReg() || !
Op.readsReg())
98 "subregister indexes should not be present after RA");
100 for (MCRegUnit Unit :
TRI->regunits(
Reg))
101 UsedRegUnits.
set(
static_cast<unsigned>(Unit));
123bool SIPostRABundler::isBundleCandidate(
const MachineInstr &
MI)
const {
127bool SIPostRABundler::canBundle(
const MachineInstr &
MI,
128 const MachineInstr &NextMI)
const {
132 !isDependentLoad(NextMI);
138 return SIPostRABundler().run(MF);
143 SIPostRABundler().run(MF);
156 unsigned Opc = MI.getOpcode();
157 return Opc == AMDGPU::SCHED_GROUP_BARRIER || Opc == AMDGPU::IGLP_OPT;
168 for (
auto I =
B;
I != E;
I =
Next) {
170 if (!isBundleCandidate(*
I))
175 if (
I->getNumExplicitDefs() != 0)
176 Defs.
insert(
I->defs().begin()->getReg());
180 unsigned ClauseLength = 1;
185 if (canBundle(*BundleEnd, *
I)) {
187 if (
I->getNumExplicitDefs() != 0)
188 Defs.
insert(
I->defs().begin()->getReg());
190 }
else if (!
I->isMetaInstruction() ||
191 I->getOpcode() == AMDGPU::SCHED_BARRIER) {
203 Next = std::next(BundleEnd);
204 if (ClauseLength > 1) {
213 for (
const MachineInstr &BundleMI :
make_range(BundleStart,
Next))
214 collectUsedRegUnits(BundleMI, BundleUsedRegUnits);
216 BundleUsedRegUnits.flip();
220 collectUsedRegUnits(
Kill, KillUsedRegUnits);
222 KillUsedRegUnits &= BundleUsedRegUnits;
228 if (KillUsedRegUnits.none()) {
230 Kill.eraseFromParent();
234 KillUsedRegUnits.reset();
237 BundleUsedRegUnits.reset();
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
AMD GCN specific subclass of TargetSubtarget.
Register const TargetRegisterInfo * TRI
Promote Memory to Register
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool hasSameMemFormat(const MachineInstr &A, const MachineInstr &B)
static bool isMemoryInst(const MachineInstr &MI)
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
BitVector & set()
Set all bits in the bitvector.
Instructions::iterator instr_iterator
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.
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.
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.
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.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
Represent a constant reference to a string, i.e.
constexpr bool isFLAT(const T &...O)
constexpr bool isMTBUF(const T &...O)
constexpr bool isVIMAGE(const T &...O)
constexpr bool isSMRD(const T &...O)
constexpr bool isMIMG(const T &...O)
constexpr bool isMUBUF(const T &...O)
constexpr bool isVSAMPLE(const T &...O)
constexpr bool isDS(const T &...O)
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...
@ Kill
The last use of a register.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
char & SIPostRABundlerLegacyID
DWARFExpression::Operation Op
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next