39 #include "llvm/Config/llvm-config.h" 65 #define DEBUG_TYPE "machine-scheduler" 69 cl::desc(
"Enable use of AA during MI DAG construction"));
82 "prior to scheduling, at which point a trade-off " 83 "is made to avoid excessive compile time."));
87 cl::desc(
"A huge scheduling region will have maps reduced by this many " 88 "nodes at a time. Defaults to HugeRegion / 2."));
99 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 101 for (
const SUnit *su : L) {
102 dbgs() <<
"SU(" << su->NodeNum <<
")";
112 bool RemoveKillFlags)
113 :
ScheduleDAG(mf), MLI(mli), MFI(mf.getFrameInfo()),
114 RemoveKillFlags(RemoveKillFlags),
116 Type::getVoidTy(mf.
getFunction().getContext()))), Topo(SUnits, &ExitSU) {
131 auto allMMOsOkay = [&]() {
134 if (MMO->isVolatile() || MMO->isAtomic())
149 if (PSV->isAliased(&MFI))
152 bool MayAlias = PSV->mayAlias(&MFI);
154 }
else if (
const Value *V = MMO->getValue()) {
159 for (
Value *V : Objs) {
169 if (!allMMOsOkay()) {
189 unsigned regioninstrs) {
190 assert(bb ==
BB &&
"startBlock should set BB");
206 if (!MO.isReg() || MO.isDef())
continue;
219 for (
const auto &LI : Succ->liveins()) {
239 bool ImplicitPseudoDef = (OperIdx >= DefMIDesc->
getNumOperands() &&
252 int UseOp =
I->OpIdx;
266 bool ImplicitPseudoUse =
269 if (!ImplicitPseudoDef && !ImplicitPseudoUse) {
272 ST.adjustSchedDependency(SU, UseSU, Dep);
278 ST.adjustSchedDependency(SU, UseSU, Dep);
317 SDep Dep(SU, Kind, *Alias);
353 for (
bool isBegin = I == B; !isBegin; ) {
354 isBegin = (--
I) == B;
436 if ((LaneMask & KillLaneMask).none()) {
441 if ((LaneMask & DefLaneMask).any()) {
451 LaneMask &= ~KillLaneMask;
453 if (LaneMask.
any()) {
454 I->LaneMask = LaneMask;
476 if ((V2SU.LaneMask & LaneMask).none())
479 SUnit *DefSU = V2SU.SU;
495 LaneBitmask OverlapMask = V2SU.LaneMask & LaneMask;
496 LaneBitmask NonOverlapMask = V2SU.LaneMask & ~LaneMask;
498 V2SU.LaneMask = OverlapMask;
499 if (NonOverlapMask.
any())
528 if ((PrevDefLaneMask & LaneMask).none())
571 if (
MI.isDebugInstr())
613 unsigned NumNodes = 0;
616 unsigned TrueMemOrderLatency;
637 assert(NumNodes >= Itr->second.size());
638 NumNodes -= Itr->second.size();
650 unsigned inline size()
const {
return NumNodes; }
655 for (
auto &
I : *
this)
656 NumNodes +=
I.second.size();
660 return TrueMemOrderLatency;
668 for (
auto &
I : Val2SUsMap)
670 Val2SUsMap.getTrueMemOrderLatency());
677 if (Itr != Val2SUsMap.
end())
685 for (
auto &
I : map) {
699 SUList &sus = CurrItr->second;
700 SUList::iterator SUItr = sus.begin(), SUEE = sus.end();
701 for (; SUItr != SUEE; ++SUItr) {
714 if (SUItr != sus.begin())
715 sus.erase(sus.begin(), SUItr);
719 map.
remove_if([&](std::pair<ValueType, SUList> &mapEntry) {
720 return (mapEntry.second.empty()); });
782 "Only BuildGraph should update Defs/Uses");
802 DbgValues.push_back(std::make_pair(DbgMI, &MI));
814 assert(SU &&
"No SUnit mapped to this MI");
819 if (TrackLaneMasks) {
823 if (PDiffs !=
nullptr)
828 assert(&*RPTracker->
getPos() == &MI &&
"RPTracker in sync");
829 RPTracker->
recede(RegOpers);
834 "Cannot schedule terminators or labels!");
841 bool HasVRegDef =
false;
895 LLVM_DEBUG(
dbgs() <<
"Global memory object and new barrier chain: SU(" 954 bool ThisMayAlias = UnderlObj.mayAlias();
964 bool ThisMayAlias = UnderlObj.mayAlias();
967 (ThisMayAlias ? Stores : NonAliasStores).insert(SU, V);
984 bool ThisMayAlias = UnderlObj.mayAlias();
991 (ThisMayAlias ? Loads : NonAliasLoads).insert(SU, V);
1005 dbgs() <<
"Reducing NonAliasStores and NonAliasLoads maps.\n";);
1022 PSV->printCustom(OS);
1027 for (
auto &Itr : *
this) {
1028 if (Itr.first.is<
const Value*>()) {
1029 const Value *V = Itr.first.get<
const Value*>();
1030 if (isa<UndefValue>(V))
1031 dbgs() <<
"Unknown";
1048 dbgs() <<
"Loading SUnits:\n"; loads.
dump());
1051 std::vector<unsigned> NodeNums;
1052 NodeNums.reserve(stores.
size() + loads.
size());
1053 for (
auto &
I : stores)
1054 for (
auto *SU :
I.second)
1055 NodeNums.push_back(SU->NodeNum);
1056 for (
auto &
I : loads)
1057 for (
auto *SU :
I.second)
1058 NodeNums.push_back(SU->NodeNum);
1064 assert(N <= NodeNums.size());
1065 SUnit *newBarrierChain = &
SUnits[*(NodeNums.end() -
N)];
1087 LLVM_DEBUG(
dbgs() <<
"After reduction:\nStoring SUnits:\n"; stores.dump();
1088 dbgs() <<
"Loading SUnits:\n"; loads.dump());
1094 if (!MO.isReg() || !MO.readsReg())
1101 bool IsKill = LiveRegs.
available(MRI, Reg);
1102 MO.setIsKill(IsKill);
1116 if (
MI.isDebugInstr())
1137 if (!
MI.isBundled()) {
1148 while (I->isBundledWithSucc())
1151 if (!I->isDebugInstr())
1154 }
while (I != Bundle);
1160 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 1168 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 1226 std::vector<std::pair<const SUnit *, const SUnit*>> ConnectionPairs;
1230 unsigned ParentNodeID;
1231 unsigned SubInstrCount = 0;
1234 RootData(
unsigned id): NodeID(
id),
1235 ParentNodeID(SchedDFSResult::InvalidSubtreeID) {}
1237 unsigned getSparseSetIndex()
const {
return NodeID; }
1252 return R.DFSNodeData[SU->
NodeNum].SubtreeID
1253 != SchedDFSResult::InvalidSubtreeID;
1259 R.DFSNodeData[SU->
NodeNum].InstrCount =
1283 if ((InstrCount - R.DFSNodeData[PredNum].InstrCount) < R.SubtreeLimit)
1284 joinPredSubtree(PredDep, SU,
false);
1287 if (R.DFSNodeData[PredNum].SubtreeID == PredNum) {
1290 if (RootSet[PredNum].ParentNodeID == SchedDFSResult::InvalidSubtreeID)
1291 RootSet[PredNum].ParentNodeID = SU->
NodeNum;
1293 else if (RootSet.
count(PredNum)) {
1298 RData.SubInstrCount += RootSet[PredNum].SubInstrCount;
1299 RootSet.
erase(PredNum);
1309 R.DFSNodeData[Succ->
NodeNum].InstrCount
1311 joinPredSubtree(PredDep, Succ);
1316 ConnectionPairs.push_back(std::make_pair(PredDep.
getSUnit(), Succ));
1325 &&
"number of roots should match trees");
1326 for (
const RootData &Root : RootSet) {
1327 unsigned TreeID = SubtreeClasses[Root.NodeID];
1328 if (Root.ParentNodeID != SchedDFSResult::InvalidSubtreeID)
1329 R.DFSTreeData[TreeID].ParentTreeID = SubtreeClasses[Root.ParentNodeID];
1330 R.DFSTreeData[TreeID].SubInstrCount = Root.SubInstrCount;
1336 R.SubtreeConnections.resize(SubtreeClasses.
getNumClasses());
1337 R.SubtreeConnectLevels.resize(SubtreeClasses.
getNumClasses());
1339 for (
unsigned Idx = 0, End = R.DFSNodeData.size(); Idx != End; ++Idx) {
1340 R.DFSNodeData[Idx].SubtreeID = SubtreeClasses[Idx];
1342 << R.DFSNodeData[Idx].SubtreeID <<
'\n');
1344 for (
const std::pair<const SUnit*, const SUnit*> &
P : ConnectionPairs) {
1345 unsigned PredTree = SubtreeClasses[
P.first->NodeNum];
1346 unsigned SuccTree = SubtreeClasses[
P.second->NodeNum];
1347 if (PredTree == SuccTree)
1349 unsigned Depth =
P.first->getDepth();
1350 addConnection(PredTree, SuccTree, Depth);
1351 addConnection(SuccTree, PredTree, Depth);
1359 bool CheckLimit =
true) {
1364 unsigned PredNum = PredSU->
NodeNum;
1365 if (R.DFSNodeData[PredNum].SubtreeID != PredNum)
1370 unsigned NumDataSucs = 0;
1371 for (
const SDep &SuccDep : PredSU->Succs) {
1373 if (++NumDataSucs >= 4)
1377 if (CheckLimit && R.DFSNodeData[PredNum].InstrCount > R.SubtreeLimit)
1379 R.DFSNodeData[PredNum].SubtreeID = Succ->
NodeNum;
1391 R.SubtreeConnections[FromTree];
1392 for (SchedDFSResult::Connection &
C : Connections) {
1393 if (
C.TreeID == ToTree) {
1398 Connections.push_back(SchedDFSResult::Connection(ToTree, Depth));
1399 FromTree = R.DFSTreeData[FromTree].ParentTreeID;
1400 }
while (FromTree != SchedDFSResult::InvalidSubtreeID);
1409 class SchedDAGReverseDFS {
1410 std::vector<std::pair<const SUnit *, SUnit::const_pred_iterator>> DFSStack;
1413 bool isComplete()
const {
return DFSStack.
empty(); }
1415 void follow(
const SUnit *SU) {
1416 DFSStack.push_back(std::make_pair(SU, SU->
Preds.begin()));
1418 void advance() { ++DFSStack.back().second; }
1420 const SDep *backtrack() {
1421 DFSStack.pop_back();
1422 return DFSStack.empty() ? nullptr : std::prev(DFSStack.back().second);
1425 const SUnit *getCurr()
const {
return DFSStack.back().first; }
1430 return getCurr()->
Preds.end();
1452 for (
const SUnit &SU : SUnits) {
1456 SchedDAGReverseDFS
DFS;
1461 while (DFS.getPred() != DFS.getPredEnd()) {
1462 const SDep &PredDep = *DFS.getPred();
1478 const SUnit *Child = DFS.getCurr();
1479 const SDep *PredDep = DFS.backtrack();
1483 if (DFS.isComplete())
1494 for (
const Connection &
C : SubtreeConnections[SubtreeID]) {
1495 SubtreeConnectLevels[
C.TreeID] =
1496 std::max(SubtreeConnectLevels[
C.TreeID],
C.Level);
1498 << SubtreeConnectLevels[
C.TreeID] <<
'\n');
1502 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 1504 OS <<
InstrCount <<
" / " << Length <<
" = ";
1512 dbgs() << *
this <<
'\n';
static bool getUnderlyingObjectsForInstr(const MachineInstr *MI, const MachineFrameInfo &MFI, UnderlyingObjectsVector &Objects, const DataLayout &DL)
If this machine instr has memory reference information and it can be tracked to a normal reference to...
iterator end()
Returns an iterator past this container.
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
void addInstruction(unsigned Idx, const RegisterOperands &RegOpers, const MachineRegisterInfo &MRI)
Record pressure difference induced by the given operand list to node with index Idx.
ScheduleDAGTopologicalSort Topo
Topo - A topological ordering for SUnits which permits fast IsReachable and similar queries...
A parsed version of the target data layout string in and methods for querying it. ...
virtual void finishBlock()
Cleans up after scheduling in the given block.
bool joinPredSubtree(const SDep &PredDep, const SUnit *Succ, bool CheckLimit=true)
Joins the predecessor subtree with the successor that is its DFS parent.
bool isDebugLabel() const
A common definition of LaneBitmask for use in TableGen and CodeGen.
ValueType & operator[](const SUList &Key)
To keep NumNodes up to date, insert() is used instead of this operator w/ push_back().
bool deadDefHasNoUse(const MachineOperand &MO)
Returns true if the def register in MO has no uses.
bool isCall(QueryType Type=AnyInBundle) const
iterator_base< SparseMultiSet *> iterator
ProcResIter getWriteProcResBegin(const MCSchedClassDesc *SC) const
iterator insert(const ValueT &Val)
Insert a new element at the tail of the subset list.
void dump() const override
void insert(SUnit *SU, ValueType V)
Adds SU to the SUList of V.
This class represents lattice values for constants.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds...
void init(unsigned N)
Initialize an array of N PressureDiffs.
Record a physical register access.
bool contains(const KeyT &Key) const
Returns true if this set contains an element identified by Key.
void addVRegDefDeps(SUnit *SU, unsigned OperIdx)
Adds register output and data dependencies from this SUnit to instructions that occur later in the sa...
static cl::opt< unsigned > HugeRegion("dag-maps-huge-region", cl::Hidden, cl::init(1000), cl::desc("The limit to use while constructing the DAG " "prior to scheduling, at which point a trade-off " "is made to avoid excessive compile time."))
LivePhysRegs LiveRegs
Set of live physical registers for updating kill flags.
bool TrackLaneMasks
Whether lane masks should get tracked.
const MCSchedClassDesc * getSchedClass(SUnit *SU) const
Resolves and cache a resolved scheduling class for an SUnit.
void push_back(const T &Elt)
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Describe properties that are true of each instruction in the target description file.
unsigned getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
void setIsUndef(bool Val=true)
Represent the ILP of the subDAG rooted at a DAG node.
static cl::opt< unsigned > ReductionSize("dag-maps-reduction-size", cl::Hidden, cl::desc("A huge scheduling region will have maps reduced by this many " "nodes at a time. Defaults to HugeRegion / 2."))
TargetSchedModel SchedModel
TargetSchedModel provides an interface to the machine model.
void fixupKills(MachineBasicBlock &MBB)
Fixes register kill flags that scheduling has made invalid.
unsigned getSubReg() const
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
void compress()
compress - Compress equivalence classes by numbering them 0 .
bool CanHandleTerminators
The standard DAG builder does not normally include terminators as DAG nodes because it does not creat...
unsigned computeOperandLatency(const MachineInstr *DefMI, unsigned DefOperIdx, const MachineInstr *UseMI, unsigned UseOperIdx) const
Compute operand latency based on the available machine model.
ProcResIter getWriteProcResEnd(const MCSchedClassDesc *SC) const
bool isTransient() const
Return true if this is a transient instruction that is either very likely to be eliminated during reg...
This class implements a map that also provides access to all stored values in a deterministic order...
bool mayAlias(AAResults *AA, const MachineInstr &Other, bool UseTBAA) const
Returns true if this instruction's memory access aliases the memory access of Other.
bool hasOneDef(unsigned RegNo) const
Return true if there is exactly one operand defining the specified register.
static cl::opt< bool > EnableAASchedMI("enable-aa-sched-mi", cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::desc("Enable use of AA during MI DAG construction"))
static unsigned InstrCount
Kind
These are the different kinds of scheduling dependencies.
iterator_range< mop_iterator > operands()
unsigned NumRegionInstrs
Instructions in this region (distance(RegionBegin, RegionEnd)).
void addPhysRegDataDeps(SUnit *SU, unsigned OperIdx)
MO is an operand of SU's instruction that defines a physical register.
RangePair equal_range(const KeyT &K)
The bounds of the range of items sharing Key K.
SmallVector< SDep, 4 > Preds
All sunit predecessors.
virtual void startBlock(MachineBasicBlock *BB)
Prepares to perform scheduling in the given block.
virtual void adjustSchedDependency(SUnit *def, SUnit *use, SDep &dep) const
void clearList(ValueType V)
Clears the list of SUs mapped to V.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
iterator_range< succ_iterator > successors()
A register anti-dependence (aka WAR).
void insertBarrierChain(Value2SUsMap &map)
Inserts a barrier chain in a huge region, far below current SU.
void recede(SmallVectorImpl< RegisterMaskPair > *LiveUses=nullptr)
Recede across the previous instruction.
MachineFunction & MF
Machine function.
A description of a memory reference used in the backend.
unsigned NumSuccs
of SDep::Data sucss.
MachineBasicBlock::iterator RegionEnd
The end of the range to be scheduled.
DenseMap< MachineInstr *, SUnit * > MISUnitMap
After calling BuildSchedGraph, each machine instruction in the current scheduling region is mapped to...
void addSchedBarrierDeps()
Adds dependencies from instructions in the current list of instructions being scheduled to scheduling...
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
'undef' values are things that do not have specified contents.
An individual mapping from virtual register number to SUnit.
unsigned getNumOperands() const
Retuns the total number of operands.
void setInstr(MachineInstr *MI)
Assigns the instruction for the SUnit.
A Use represents the edge between a Value definition and its users.
SmallVectorImpl< SDep >::const_iterator const_pred_iterator
size_type count(const KeyT &Key) const
count - Returns 1 if this set contains an element identified by Key, 0 otherwise. ...
static bool hasDataSucc(const SUnit *SU)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Regular data dependence (aka true-dependence).
bool hasPhysRegUses
Has physreg uses.
static constexpr LaneBitmask getAll()
bool isTerminator(QueryType Type=AnyInBundle) const
Returns true if this instruction part of the terminator for a basic block.
ValueT & operator[](const KeyT &Key)
bool hasPhysRegDefs
Has physreg defs that are being used.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
DbgValueVector DbgValues
Remember instruction that precedes DBG_VALUE.
void buildSchedGraph(AAResults *AA, RegPressureTracker *RPTracker=nullptr, PressureDiffs *PDiffs=nullptr, LiveIntervals *LIS=nullptr, bool TrackLaneMasks=false)
Builds SUnits for the current region.
bool hasInstrSchedModel() const
Return true if this machine model includes an instruction-level scheduling model. ...
MachineBasicBlock::const_iterator getPos() const
Get the MI position corresponding to this register pressure.
bool isIdentifiedObject(const Value *V)
Return true if this pointer refers to a distinct and identifiable object.
Compute the values of each DAG node for various metrics during DFS.
Value2SUsMap(unsigned lat=0)
A register output-dependence (aka WAW).
bool readsReg() const
readsReg - Returns true if this operand reads the previous value of its register. ...
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
bool hasReservedResource
Uses a reserved resource.
bool mayRaiseFPException() const
Return true if this instruction could possibly raise a floating-point exception.
MachineBasicBlock::iterator RegionBegin
The beginning of the range to be scheduled.
void addVRegUseDeps(SUnit *SU, unsigned OperIdx)
Adds a register data dependency if the instruction that defines the virtual register used at OperIdx ...
void print(raw_ostream &OS) const
size_type size() const
size - Returns the number of elements in the set.
SUnit * BarrierChain
Remember a generic side-effecting instruction as we proceed.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool canAddEdge(SUnit *SuccSU, SUnit *PredSU)
True if an edge can be added from PredSU to SuccSU without creating a cycle.
MachineBasicBlock::iterator begin() const
Returns an iterator to the top of the current scheduling region.
static void toggleKills(const MachineRegisterInfo &MRI, LivePhysRegs &LiveRegs, MachineInstr &MI, bool addToLiveRegs)
void collect(const MachineInstr &MI, const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, bool TrackLaneMasks, bool IgnoreDead)
Analyze the given instruction MI and fill in the Uses, Defs and DeadDefs list based on the MachineOpe...
List of registers defined and used by a machine instruction.
LaneBitmask getLaneMask() const
Returns the combination of all lane masks of register in this class.
static Function * getFunction(Constant *C)
virtual void enterRegion(MachineBasicBlock *bb, MachineBasicBlock::iterator begin, MachineBasicBlock::iterator end, unsigned regioninstrs)
Initialize the DAG and common scheduler state for a new scheduling region.
void visitPostorderNode(const SUnit *SU)
Called once for each node after all predecessors are visited.
iterator find(const KeyT &Key)
unsigned getTrueMemOrderLatency() const
void visitPreorder(const SUnit *SU)
Initializes this node's instruction count.
std::list< SUnit * > SUList
A list of SUnits, used in Value2SUsMap, during DAG construction.
reverse_iterator rbegin()
bool isBoundaryNode() const
Boundary nodes are placeholders for the boundary of the scheduling region.
unsigned getNumSubtrees() const
The number of subtrees detected in this DAG.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
iterator erase(iterator I)
erase - Erases an existing element identified by a valid iterator.
void dumpNodeAll(const SUnit &SU) const
void recedeSkipDebugValues()
Recede until we find an instruction which is not a DebugValue.
bool isUnbuffered
Uses an unbuffered resource.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
void remove_if(Predicate Pred)
Remove the elements that match the predicate.
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
initializer< Ty > init(const Ty &Val)
bool isCall
Is a function call.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
bool isArtificial() const
Tests if this is an Order dependence that is marked as "artificial", meaning it isn't necessary for c...
void clearDAG()
Clears the DAG state (between regions).
ArrayRef< MachineMemOperand * > memoperands() const
Access to memory operands of the instruction.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
static unsigned getReductionSize()
unsigned short Latency
Node latency.
Identify one of the processor resource kinds consumed by a particular scheduling class for the specif...
bool RemoveKillFlags
True if the DAG builder should remove kill flags (in preparation for rescheduling).
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void visitCrossEdge(const SDep &PredDep, const SUnit *Succ)
Adds a connection for cross edges.
Internal state used to compute SchedDFSResult.
void addLiveOuts(const MachineBasicBlock &MBB)
Adds all live-out registers of basic block MBB.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
void reComputeSize()
Counts the number of SUs in this map after a reduction.
Summarize the scheduling resources required for an instruction of a particular scheduling class...
unsigned getNumClasses() const
getNumClasses - Return the number of equivalence classes after compress() was called.
void addConnection(unsigned FromTree, unsigned ToTree, unsigned Depth)
Called by finalize() to record a connection between trees.
bool getUnderlyingObjectsForCodeGen(const Value *V, SmallVectorImpl< Value *> &Objects, const DataLayout &DL)
This is a wrapper around GetUnderlyingObjects and adds support for basic ptrtoint+arithmetic+inttoptr...
void init(const TargetRegisterInfo &TRI)
(re-)initializes and clears the set.
void setUniverse(unsigned U)
Set the universe size which determines the largest key the set can hold.
MCRegAliasIterator enumerates all registers aliasing Reg.
Track the current register pressure at some position in the instruction stream, and remember the high...
virtual void exitRegion()
Called when the scheduler has finished scheduling the current region.
void setUniverse(unsigned U)
setUniverse - Set the universe size which determines the largest key the set can hold.
void print(raw_ostream &OS, bool IsStandalone=true, bool SkipOpers=false, bool SkipDebugLoc=false, bool AddNewLine=true, const TargetInstrInfo *TII=nullptr) const
Print this MI to OS.
const MachineFrameInfo & MFI
unsigned getNumVirtRegs() const
getNumVirtRegs - Return the number of virtual registers created.
void init(const TargetSubtargetInfo *TSInfo)
Initialize the machine model for instruction scheduling.
void clear()
Clears the set.
void dumpNodeName(const SUnit &SU) const
LaneBitmask getLaneMaskForMO(const MachineOperand &MO) const
Returns a mask for which lanes get read/written by the given (register) machine operand.
bool isVisited(const SUnit *SU) const
Returns true if this node been visited by the DFS traversal.
MCSubRegIterator enumerates all sub-registers of Reg.
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
std::string & str()
Flushes the stream contents to the target string and returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::string getDAGName() const override
Returns a label for the region of code covered by the DAG.
bool isConstantPhysReg(unsigned PhysReg) const
Returns true if PhysReg is unallocatable and constant throughout the function.
void setIsKill(bool Val=true)
iterator find(const KeyT &Key)
Find an element by its key.
void sort(IteratorTy Start, IteratorTy End)
const bool HasDisjunctSubRegs
Whether the class supports two (or more) disjunct subregister indices.
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
The two locations may or may not alias. This is the least precise result.
void addPhysRegDeps(SUnit *SU, unsigned OperIdx)
Adds register dependencies (data, anti, and output) from this SUnit to following instructions in the ...
bool addEdge(SUnit *SuccSU, const SDep &PredDep)
Add a DAG edge to the given SU with the given predecessor dependence data.
unsigned join(unsigned a, unsigned b)
Join the equivalence classes of a and b.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void adjustLaneLiveness(const LiveIntervals &LIS, const MachineRegisterInfo &MRI, SlotIndex Pos, MachineInstr *AddFlagsMI=nullptr)
Use liveness information to find out which uses/defs are partially undefined/dead and adjust the Regi...
std::string getGraphNodeLabel(const SUnit *SU) const override
Returns a label for a DAG node that points to an instruction.
void reduceHugeMemNodeMaps(Value2SUsMap &stores, Value2SUsMap &loads, unsigned N)
Reduces maps in FIFO order, by N SUs.
bool isCommutable
Is a commutable instruction.
Iterator for intrusive lists based on ilist_node.
ConstMIBundleOperands - Iterate over all operands in a const bundle of machine instructions.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
Align max(MaybeAlign Lhs, Align Rhs)
void compute(ArrayRef< SUnit > SUnits)
Compute various metrics for the DAG with given roots.
bool isDereferenceableInvariantLoad(AAResults *AA) const
Return true if this load instruction never traps and points to a memory location whose value doesn't ...
UndefValue * UnknownValue
For an unanalyzable memory access, this Value is used in maps.
bool available(const MachineRegisterInfo &MRI, MCPhysReg Reg) const
Returns true if register Reg and no aliasing register is in the set.
bool isDebugValue() const
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void AddPredQueued(SUnit *Y, SUnit *X)
Queues an update to the topological ordering to accommodate an edge to be added from SUnit X to SUnit...
Reg2SUnitsMap Defs
Defs, Uses - Remember where defs and uses of each register are as we iterate upward through the instr...
void eraseAll(const KeyT &K)
Erase all elements with the given key.
CHAIN = SC CHAIN, Imm128 - System call.
bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
LaneBitmask getSubRegIndexLaneMask(unsigned SubIdx) const
Return a bitmask representing the parts of a register that are covered by SubIdx. ...
Nonvolatile load/Store instructions that may alias.
typename std::vector< std::pair< ValueType, SUList >> ::iterator iterator
bool addPredBarrier(SUnit *SU)
Adds a barrier edge to SU by calling addPred(), with latency 0 generally or latency 1 for a store fol...
void MarkDirty()
Mark the ordering as temporarily broken, after a new node has been added.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
VReg2SUnitOperIdxMultiMap CurrentVRegUses
Tracks the last instructions in this region using each virtual register.
bool IsReachable(const SUnit *SU, const SUnit *TargetSU)
Checks if SU is reachable from TargetSU.
Special value supplied for machine level alias analysis.
unsigned computeOutputLatency(const MachineInstr *DefMI, unsigned DefOperIdx, const MachineInstr *DepMI) const
Output dependency latency of a pair of defs of the same register.
void dumpNode(const SUnit &SU) const override
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
void visitPostorderEdge(const SDep &PredDep, const SUnit *Succ)
Called once for each tree edge after calling visitPostOrderNode on the predecessor.
void setLatency(unsigned Lat)
Sets the latency for this edge.
**iterator erase(iterator I)
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
TargetSubtargetInfo - Generic base class for all target subtargets.
SUnit EntrySU
Special node for the region entry.
Representation of each machine instruction.
SUnit ExitSU
Special node for the region exit.
void finalize()
Sets each node's subtree ID to the representative ID and record connections between trees...
const TargetRegisterInfo * TRI
Target processor register info.
static cl::opt< bool > UseTBAA("use-tbaa-in-sched-mi", cl::Hidden, cl::init(true), cl::desc("Enable use of TBAA during MI DAG construction"))
A set of physical registers with utility functions to track liveness when walking backward/forward th...
LLVM_NODISCARD bool empty() const
std::pair< iterator, iterator > RangePair
void addChainDependencies(SUnit *SU, SUList &SUs, unsigned Latency)
Adds dependencies as needed from all SUs in list to SU.
constexpr bool any() const
bool empty() const
Returns true if the set is empty.
Mapping from virtual register to SUnit including an operand index.
void addChainDependency(SUnit *SUa, SUnit *SUb, unsigned Latency=0)
Adds a chain edge between SUa and SUb, but only if both AAResults and Target fail to deny the depende...
Kind getKind() const
Returns an enum value representing the kind of the dependence.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
ScheduleDAGInstrs(MachineFunction &mf, const MachineLoopInfo *mli, bool RemoveKillFlags=false)
unsigned NodeNum
Entry # of node in the node vector.
MachineBasicBlock::iterator end() const
Returns an iterator to the bottom of the current scheduling region.
bool registerDefIsDead(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Returns true if the register is dead in this machine instruction.
SUnit * newSUnit(MachineInstr *MI)
Creates a new SUnit and return a ptr to it.
void addBarrierChain(Value2SUsMap &map)
Adds barrier chain edges from all SUs in map, and then clear the map.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const MCProcResourceDesc * getProcResource(unsigned PIdx) const
Get a processor resource by ID for convenience.
bool addPred(const SDep &D, bool Required=true)
Adds the specified edge as a pred of the current node if not already.
bool hasImplicitUseOfPhysReg(unsigned Reg) const
Return true if this instruction implicitly uses the specified physical register.
A raw_ostream that writes to an std::string.
std::string getFullName() const
Return a formatted string to identify this block and its parent function.
LLVM Value Representation.
void removeRegsInMask(const MachineOperand &MO, SmallVectorImpl< std::pair< MCPhysReg, const MachineOperand *>> *Clobbers=nullptr)
Removes physical registers clobbered by the regmask operand MO.
void clear()
Clears map from all contents.
void initSUnits()
Creates an SUnit for each real instruction, numbered in top-down topological order.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
SmallVector< SDep, 4 > Succs
All sunit successors.
void addReg(MCPhysReg Reg)
Adds a physical register and all its sub-registers to the set.
Arbitrary strong DAG edge (no real dependence).
void scheduleTree(unsigned SubtreeID)
Scheduler callback to update SubtreeConnectLevels when a tree is initially scheduled.
This class implements an extremely fast bulk output stream that can only output to a stream...
MachineInstr * FirstDbgValue
bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore...
MachineBasicBlock * BB
The block in which to insert instructions.
virtual bool useAA() const
Enable use of alias analysis during code generation (during MI scheduling, DAGCombine, etc.).
bool isBarrier(QueryType Type=AnyInBundle) const
Returns true if the specified instruction stops control flow from executing the instruction immediate...
void removeReg(MCPhysReg Reg)
Removes a physical register, all its sub-registers, and all its super-registers from the set...
Register getReg() const
getReg - Returns the register number.
static void dumpSUList(ScheduleDAGInstrs::SUList &L)
MachineRegisterInfo & MRI
Virtual/real register map.
std::vector< SUnit > SUnits
The scheduling units.
SchedDFSImpl(SchedDFSResult &r)
bool hasImplicitDefOfPhysReg(unsigned Reg, const MCRegisterInfo *MRI=nullptr) const
Return true if this instruction implicitly defines the specified physical register.
const MachineOperand & getOperand(unsigned i) const
SlotIndex - An opaque wrapper around machine indexes.
static bool isGlobalMemoryObject(AAResults *AA, MachineInstr *MI)
Returns true if MI is an instruction we are unable to reason about (like a call or something with unm...
VReg2SUnitMultiMap CurrentVRegDefs
Tracks the last instruction(s) in this region defining each virtual register.
bool hasTailCall() const
Returns true if the function contains a tail call.
Scheduling unit. This is a node in the scheduling DAG.
Wrapper class representing virtual and physical registers.
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...