Go to the documentation of this file.
22 #define DEBUG_TYPE "si-post-ra-bundler"
38 return "SI post-RA bundler";
67 char SIPostRABundler::
ID = 0;
72 return new SIPostRABundler();
75 bool SIPostRABundler::isDependentLoad(
const MachineInstr &
MI)
const {
93 if (
MI.isDebugInstr())
97 if (!
Op.isReg() || !
Op.readsReg())
102 "subregister indexes should not be present after RA");
105 UsedRegUnits.
set(*Units);
109 bool 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;
138 for (
auto I =
B;
I !=
E;
I = Next) {
140 if (!isBundleCandidate(*
I))
145 if (
I->getNumExplicitDefs() != 0)
146 Defs.insert(
I->defs().begin()->getReg());
150 unsigned ClauseLength = 1;
151 for (
I = Next;
I !=
E;
I = Next) {
155 if (canBundle(*BundleEnd, *
I)) {
157 if (
I->getNumExplicitDefs() != 0)
158 Defs.insert(
I->defs().begin()->getReg());
160 }
else if (!
I->isMetaInstruction()) {
171 Next = std::next(BundleEnd);
172 if (ClauseLength > 1) {
178 if (Next !=
E && Next->isKill()) {
182 collectUsedRegUnits(BundleMI, BundleUsedRegUnits);
184 BundleUsedRegUnits.flip();
186 while (Next !=
E && Next->isKill()) {
188 collectUsedRegUnits(
Kill, KillUsedRegUnits);
190 KillUsedRegUnits &= BundleUsedRegUnits;
196 if (KillUsedRegUnits.none()) {
198 Kill.eraseFromParent();
202 KillUsedRegUnits.reset();
205 BundleUsedRegUnits.reset();
FunctionPass * createSIPostRABundlerPass()
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
Reg
All possible values of the reg field in the ModR/M byte.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
bool isBundled() const
Return true if this instruction part of a bundle.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
unsigned getNumRegUnits() const
Return the number of (native) register units in the target.
unsigned const TargetRegisterInfo * TRI
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
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...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Represent the analysis usage information of a pass.
@ Kill
The last use of a register.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
MachineOperand class - Representation of each machine instruction operand.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool regsOverlap(Register RegA, Register RegB) const
Returns true if the two registers are equal or alias each other.
Representation of each machine instruction.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void initializeSIPostRABundlerPass(PassRegistry &)
instr_iterator instr_begin()
instr_iterator instr_end()
StringRef - Represent a constant reference to a string, i.e.
Wrapper class representing virtual and physical registers.
Function & getFunction()
Return the LLVM function that this machine code represents.
void setPreservesAll()
Set by analyses that do not transform their input at all.
Iterator for intrusive lists based on ilist_node.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
FunctionPass class - This class is used to implement most global optimizations.