15 #ifndef LLVM_CODEGEN_SCHEDULEDAGINSTRS_H
16 #define LLVM_CODEGEN_SCHEDULEDAGINSTRS_H
39 class MachineFrameInfo;
40 class MachineFunction;
42 class MachineLoopInfo;
44 struct MCSchedClassDesc;
46 class PseudoSourceValue;
47 class RegPressureTracker;
58 :
VirtReg(VReg), LaneMask(LaneMask), SU(SU) {}
71 :
VReg2SUnit(VReg, LaneMask, SU), OperandIndex(OperandIndex) {}
211 for (
SUnit *Entry : SUs)
239 std::vector<std::pair<MachineInstr *, MachineInstr *>>;
291 unsigned regioninstrs);
365 "SUnits std::vector reallocated on the fly!");
379 #endif // LLVM_CODEGEN_SCHEDULEDAGINSTRS_H
virtual void finishBlock()
Cleans up after scheduling in the given block.
A common definition of LaneBitmask for use in TableGen and CodeGen.
const MCSchedClassDesc * resolveSchedClass(const MachineInstr *MI) const
Return the MCSchedClassDesc for this instruction.
unsigned getSparseSetIndex() const
static unsigned virtReg2Index(unsigned Reg)
Convert a virtual register number to a 0-based index.
Record a physical register access.
void addVRegDefDeps(SUnit *SU, unsigned OperIdx)
Adds register output and data dependencies from this SUnit to instructions that occur later in the sa...
LivePhysRegs LiveRegs
Set of live physical registers for updating kill flags.
bool TrackLaneMasks
Whether lane masks should get tracked.
void dumpNode(const SUnit *SU) const override
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
TargetSchedModel SchedModel
TargetSchedModel provides an interface to the machine model.
void fixupKills(MachineBasicBlock &MBB)
Fixes register kill flags that scheduling has made invalid.
bool CanHandleTerminators
The standard DAG builder does not normally include terminators as DAG nodes because it does not creat...
MachineBasicBlock::iterator begin() const
Returns an iterator to the top of the current scheduling region.
const MCSchedClassDesc * getSchedClass(SUnit *SU) const
Resolves and cache a resolved scheduling class for an SUnit.
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.
virtual void startBlock(MachineBasicBlock *BB)
Prepares to perform scheduling in the given block.
The two locations may or may not alias. This is the least precise result.
void insertBarrierChain(Value2SUsMap &map)
Inserts a barrier chain in a huge region, far below current SU.
const TargetSchedModel * getSchedModel() const
Gets the machine model for instruction scheduling.
void buildSchedGraph(AliasAnalysis *AA, RegPressureTracker *RPTracker=nullptr, PressureDiffs *PDiffs=nullptr, LiveIntervals *LIS=nullptr, bool TrackLaneMasks=false)
Builds SUnits for the current region.
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...
Provide an instruction scheduling machine model to CodeGen passes.
'undef' values are things that do not have specified contents.
An individual mapping from virtual register number to SUnit.
std::vector< std::pair< MachineInstr *, MachineInstr * >> DbgValueVector
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
DbgValueVector DbgValues
Remember instruction that precedes DBG_VALUE.
void startBlockForKills(MachineBasicBlock *BB)
Initializes register live-range state for updating kills.
ValueType getPointer() const
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 ...
~ScheduleDAGInstrs() override=default
SUnit * BarrierChain
Remember a generic side-effecting instruction as we proceed.
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.
std::list< SUnit * > SUList
A list of SUnits, used in Value2SUsMap, during DAG construction.
PointerIntPair - This class implements a pair of a pointer and small integer.
bool RemoveKillFlags
True if the DAG builder should remove kill flags (in preparation for rescheduling).
Summarize the scheduling resources required for an instruction of a particular scheduling class...
Track the current register pressure at some position in the instruction stream, and remember the high...
SparseMultiSet< PhysRegSUOper, identity< unsigned >, uint16_t > Reg2SUnitsMap
Use a SparseMultiSet to track physical registers.
virtual void exitRegion()
Called when the scheduler has finished scheduling the current region.
const MCSchedClassDesc * SchedClass
nullptr or resolved SchedClass.
const MachineFrameInfo & MFI
This file implements the LivePhysRegs utility for tracking liveness of physical registers.
std::string getDAGName() const override
Returns a label for the region of code covered by the DAG.
void addPhysRegDeps(SUnit *SU, unsigned OperIdx)
Adds register dependencies (data, anti, and output) from this SUnit to following instructions in the ...
bool hasInstrSchedModel() const
Return true if this machine model includes an instruction-level scheduling model. ...
std::string getGraphNodeLabel(const SUnit *SU) const override
Returns a label for a DAG node that points to an instruction.
PhysRegSUOper(SUnit *su, int op, unsigned R)
void reduceHugeMemNodeMaps(Value2SUsMap &stores, Value2SUsMap &loads, unsigned N)
Reduces maps in FIFO order, by N SUs.
ValueType getValue() const
UndefValue * UnknownValue
For an unanalyzable memory access, this Value is used in maps.
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...
VReg2SUnitOperIdx(unsigned VReg, LaneBitmask LaneMask, unsigned OperandIndex, SUnit *SU)
Reg2SUnitsMap Defs
Defs, Uses - Remember where defs and uses of each register are as we iterate upward through the instr...
const MachineLoopInfo * MLI
VReg2SUnitOperIdxMultiMap CurrentVRegUses
Tracks the last instructions in this region using each virtual register.
virtual void finalizeSchedule()
Allow targets to perform final scheduling actions at the level of the whole MachineFunction.
virtual void schedule()=0
Orders nodes according to selected style.
MachineBasicBlock::iterator end() const
Returns an iterator to the bottom of the current scheduling region.
VReg2SUnit(unsigned VReg, LaneBitmask LaneMask, SUnit *SU)
SUnit * getSUnit(MachineInstr *MI) const
Returns an existing SUnit for this MI, or nullptr.
A ScheduleDAG for scheduling lists of MachineInstr.
Representation of each machine instruction.
SparseSet - Fast set implmentation for objects that can be identified by small unsigned keys...
A set of physical registers with utility functions to track liveness when walking backward/forward th...
void addChainDependencies(SUnit *SU, SUList &SUs, unsigned Latency)
Adds dependencies as needed from all SUs in list to SU.
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 AliasAnalysis and Target fail to deny the dep...
unsigned getSparseSetIndex() const
ScheduleDAGInstrs(MachineFunction &mf, const MachineLoopInfo *mli, bool RemoveKillFlags=false)
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LaneBitmask getLaneMaskForMO(const MachineOperand &MO) const
Returns a mask for which lanes get read/written by the given (register) machine operand.
void initSUnits()
Creates an SUnit for each real instruction, numbered in top-down topological order.
Fast multiset implementation for objects that can be identified by small unsigned keys...
MachineInstr * FirstDbgValue
UnderlyingObject(ValueType V, bool MayAlias)
MachineBasicBlock * BB
The block in which to insert instructions.
std::vector< SUnit > SUnits
The scheduling units.
VReg2SUnitMultiMap CurrentVRegDefs
Tracks the last instruction(s) in this region defining each virtual register.
Scheduling unit. This is a node in the scheduling DAG.
void toggleKillFlag(MachineInstr &MI, MachineOperand &MO)
Toggles a register operand kill flag.