|
LLVM 23.0.0git
|
This class represents the scheduled code. More...
#include "llvm/CodeGen/MachinePipeliner.h"
Public Types | |
| using | sched_iterator = DenseMap<int, std::deque<SUnit *>>::iterator |
| Iterators for the cycle to instruction map. | |
| using | const_sched_iterator |
Public Member Functions | |
| SMSchedule (MachineFunction *mf, SwingSchedulerDAG *DAG) | |
| void | reset () |
| void | setInitiationInterval (int ii) |
| Set the initiation interval for this schedule. | |
| int | getInitiationInterval () const |
| Return the initiation interval for this schedule. | |
| int | getFirstCycle () const |
| Return the first cycle in the completed schedule. | |
| int | getFinalCycle () const |
| Return the last cycle in the finalized schedule. | |
| LLVM_ABI void | computeStart (SUnit *SU, int *MaxEarlyStart, int *MinLateStart, int II, SwingSchedulerDAG *DAG) |
| Compute the scheduling start slot for the instruction. | |
| LLVM_ABI bool | insert (SUnit *SU, int StartCycle, int EndCycle, int II) |
| Try to schedule the node at the specified StartCycle and continue until the node is schedule or the EndCycle is reached. | |
| bool | isScheduledAtStage (SUnit *SU, unsigned StageNum) |
| Return true if the instruction is scheduled at the specified stage. | |
| int | stageScheduled (SUnit *SU) const |
| Return the stage for a scheduled instruction. | |
| unsigned | cycleScheduled (SUnit *SU) const |
| Return the cycle for a scheduled instruction. | |
| unsigned | getMaxStageCount () |
| Return the maximum stage count needed for this schedule. | |
| std::deque< SUnit * > & | getInstructions (int cycle) |
| Return the instructions that are scheduled at the specified cycle. | |
| LLVM_ABI SmallPtrSet< SUnit *, 8 > | computeUnpipelineableNodes (SwingSchedulerDAG *SSD, TargetInstrInfo::PipelinerLoopInfo *PLI) |
| Determine transitive dependences of unpipelineable instructions. | |
| LLVM_ABI std::deque< SUnit * > | reorderInstructions (const SwingSchedulerDAG *SSD, const std::deque< SUnit * > &Instrs) const |
| LLVM_ABI bool | normalizeNonPipelinedInstructions (SwingSchedulerDAG *SSD, TargetInstrInfo::PipelinerLoopInfo *PLI) |
| LLVM_ABI bool | isValidSchedule (SwingSchedulerDAG *SSD) |
| LLVM_ABI void | finalizeSchedule (SwingSchedulerDAG *SSD) |
| After the schedule has been formed, call this function to combine the instructions from the different stages/cycles. | |
| LLVM_ABI void | orderDependence (const SwingSchedulerDAG *SSD, SUnit *SU, std::deque< SUnit * > &Insts) const |
| Order the instructions within a cycle so that the definitions occur before the uses. | |
| LLVM_ABI bool | isLoopCarried (const SwingSchedulerDAG *SSD, MachineInstr &Phi) const |
| Return true if the scheduled Phi has a loop carried operand. | |
| LLVM_ABI bool | isLoopCarriedDefOfUse (const SwingSchedulerDAG *SSD, MachineInstr *Def, MachineOperand &MO) const |
| Return true if the instruction is a definition that is loop carried and defines the use on the next iteration. | |
| LLVM_ABI bool | onlyHasLoopCarriedOutputOrOrderPreds (SUnit *SU, const SwingSchedulerDDG *DDG) const |
| Return true if all scheduled predecessors are loop-carried output/order dependencies. | |
| LLVM_ABI void | print (raw_ostream &os) const |
| Print the schedule information to the given output. | |
| LLVM_ABI void | dump () const |
| Utility function used for debugging to print the schedule. | |
This class represents the scheduled code.
The main data structure is a map from scheduled cycle to instructions. During scheduling, the data structure explicitly represents all stages/iterations. When the algorithm finshes, the schedule is collapsed into a single stage, which represents instructions from different loop iterations.
The SMS algorithm allows negative values for cycles, so the first cycle in the schedule is the smallest cycle value.
Definition at line 732 of file MachinePipeliner.h.
Definition at line 793 of file MachinePipeliner.h.
| using llvm::SMSchedule::sched_iterator = DenseMap<int, std::deque<SUnit *>>::iterator |
Iterators for the cycle to instruction map.
Definition at line 792 of file MachinePipeliner.h.
|
inline |
Definition at line 759 of file MachinePipeliner.h.
| void SMSchedule::computeStart | ( | SUnit * | SU, |
| int * | MaxEarlyStart, | ||
| int * | MinLateStart, | ||
| int | II, | ||
| SwingSchedulerDAG * | DAG ) |
Compute the scheduling start slot for the instruction.
The start slot depends on any predecessor or successor nodes scheduled already.
Definition at line 3296 of file MachinePipeliner.cpp.
References llvm::SwingSchedulerDAG::getDDG(), getFirstCycle(), llvm::SwingSchedulerDDG::getInEdges(), llvm::SUnit::getInstr(), getInstructions(), llvm::SwingSchedulerDDG::getOutEdges(), I, II, llvm::MachineInstr::isPHI(), llvm::SUnit::isPred(), multipleIterations(), and llvm::SUnit::Preds.
| SmallPtrSet< SUnit *, 8 > SMSchedule::computeUnpipelineableNodes | ( | SwingSchedulerDAG * | SSD, |
| TargetInstrInfo::PipelinerLoopInfo * | PLI ) |
Determine transitive dependences of unpipelineable instructions.
Definition at line 3525 of file MachinePipeliner.cpp.
References llvm::SmallPtrSetImpl< PtrType >::count(), llvm::dbgs(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::SwingSchedulerDAG::getDDG(), llvm::SwingSchedulerDDG::getInEdges(), llvm::SUnit::getInstr(), llvm::SwingSchedulerDDG::getOutEdges(), llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SUnit::isInstr(), LLVM_DEBUG, llvm::SUnit::NodeNum, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::TargetInstrInfo::PipelinerLoopInfo::shouldIgnoreForPipelining(), and llvm::ScheduleDAG::SUnits.
Referenced by normalizeNonPipelinedInstructions().
Return the cycle for a scheduled instruction.
This function normalizes the first cycle to be 0.
Definition at line 812 of file MachinePipeliner.h.
References assert().
Referenced by llvm::SwingSchedulerDAG::applyInstrChange(), isLoopCarried(), llvm::SwingSchedulerDDG::isValidSchedule(), and orderDependence().
| LLVM_DUMP_METHOD void SMSchedule::dump | ( | ) | const |
Utility function used for debugging to print the schedule.
Definition at line 3877 of file MachinePipeliner.cpp.
References llvm::dbgs(), LLVM_DUMP_METHOD, and print().
| void SMSchedule::finalizeSchedule | ( | SwingSchedulerDAG * | SSD | ) |
After the schedule has been formed, call this function to combine the instructions from the different stages/cycles.
That is, this function creates a schedule that represents a single iteration.
Definition at line 3819 of file MachinePipeliner.cpp.
References llvm::SwingSchedulerDAG::applyInstrChange(), llvm::dump(), llvm::SwingSchedulerDAG::fixupRegisterOverlaps(), getFinalCycle(), getFirstCycle(), llvm::SUnit::getInstr(), getMaxStageCount(), LLVM_DEBUG, reorderInstructions(), llvm::reverse(), and llvm::ScheduleDAG::SUnits.
|
inline |
Return the last cycle in the finalized schedule.
Definition at line 785 of file MachinePipeliner.h.
Referenced by computeScheduledInsts(), finalizeSchedule(), print(), and llvm::SwingSchedulerDAG::schedule().
|
inline |
Return the first cycle in the completed schedule.
This can be a negative value.
Definition at line 782 of file MachinePipeliner.h.
Referenced by computeScheduledInsts(), computeStart(), finalizeSchedule(), normalizeNonPipelinedInstructions(), print(), and llvm::SwingSchedulerDAG::schedule().
|
inline |
Return the initiation interval for this schedule.
Definition at line 778 of file MachinePipeliner.h.
Referenced by computeScheduledInsts(), and llvm::SwingSchedulerDDG::isValidSchedule().
|
inline |
Return the instructions that are scheduled at the specified cycle.
Definition at line 824 of file MachinePipeliner.h.
Referenced by computeScheduledInsts(), computeStart(), normalizeNonPipelinedInstructions(), and llvm::SwingSchedulerDAG::schedule().
|
inline |
Return the maximum stage count needed for this schedule.
Definition at line 819 of file MachinePipeliner.h.
Referenced by computeScheduledInsts(), finalizeSchedule(), and llvm::SwingSchedulerDAG::schedule().
Try to schedule the node at the specified StartCycle and continue until the node is schedule or the EndCycle is reached.
This function returns true if the node is scheduled. This routine may search either forward or backward for a place to insert the instruction based upon the relative values of StartCycle and EndCycle.
Definition at line 3243 of file MachinePipeliner.cpp.
References llvm::dbgs(), llvm::MachineInstr::dump(), llvm::SUnit::getInstr(), llvm::MachineInstr::getOpcode(), II, and LLVM_DEBUG.
| bool SMSchedule::isLoopCarried | ( | const SwingSchedulerDAG * | SSD, |
| MachineInstr & | Phi ) const |
Return true if the scheduled Phi has a loop carried operand.
Definition at line 3465 of file MachinePipeliner.cpp.
References assert(), cycleScheduled(), llvm::SUnit::getInstr(), getPhiRegs(), llvm::ScheduleDAGInstrs::getSUnit(), llvm::MachineInstr::isPHI(), and stageScheduled().
Referenced by isLoopCarriedDefOfUse().
| bool SMSchedule::isLoopCarriedDefOfUse | ( | const SwingSchedulerDAG * | SSD, |
| MachineInstr * | Def, | ||
| MachineOperand & | MO ) const |
Return true if the instruction is a definition that is loop carried and defines the use on the next iteration.
v1 = phi(v2, v3) (Def) v3 = op v1 (MO) = v1 If MO appears before Def, then v1 and v3 may get assigned to the same register.
Definition at line 3494 of file MachinePipeliner.cpp.
References getLoopPhiReg(), llvm::MachineOperand::getReg(), isLoopCarried(), and llvm::MachineOperand::isReg().
Referenced by orderDependence().
Return true if the instruction is scheduled at the specified stage.
Definition at line 797 of file MachinePipeliner.h.
References stageScheduled().
| bool SMSchedule::isValidSchedule | ( | SwingSchedulerDAG * | SSD | ) |
Definition at line 3630 of file MachinePipeliner.cpp.
References assert(), llvm::SwingSchedulerDAG::getDDG(), llvm::SwingSchedulerDDG::getOutEdges(), llvm::SUnit::hasPhysRegDefs, stageScheduled(), and llvm::ScheduleDAG::SUnits.
| bool SMSchedule::normalizeNonPipelinedInstructions | ( | SwingSchedulerDAG * | SSD, |
| TargetInstrInfo::PipelinerLoopInfo * | PLI ) |
Definition at line 3555 of file MachinePipeliner.cpp.
References computeUnpipelineableNodes(), llvm::SmallPtrSetImpl< PtrType >::contains(), llvm::dbgs(), llvm::erase(), llvm::SwingSchedulerDAG::getDDG(), getFirstCycle(), llvm::SwingSchedulerDDG::getInEdges(), llvm::SUnit::getInstr(), getInstructions(), llvm::SwingSchedulerDDG::getOutEdges(), llvm::SUnit::isInstr(), LLVM_DEBUG, llvm::SUnit::NodeNum, stageScheduled(), and llvm::ScheduleDAG::SUnits.
| bool SMSchedule::onlyHasLoopCarriedOutputOrOrderPreds | ( | SUnit * | SU, |
| const SwingSchedulerDDG * | DDG ) const |
Return true if all scheduled predecessors are loop-carried output/order dependencies.
Definition at line 3516 of file MachinePipeliner.cpp.
References llvm::SwingSchedulerDDG::getInEdges().
| void SMSchedule::orderDependence | ( | const SwingSchedulerDAG * | SSD, |
| SUnit * | SU, | ||
| std::deque< SUnit * > & | Insts ) const |
Order the instructions within a cycle so that the definitions occur before the uses.
Returns true if the instruction is added to the start of the list, or false if added to the end.
Definition at line 3334 of file MachinePipeliner.cpp.
References cycleScheduled(), llvm::SwingSchedulerDAG::getDDG(), llvm::SwingSchedulerDDG::getInEdges(), llvm::SUnit::getInstr(), llvm::SwingSchedulerDAG::getInstrBaseReg(), llvm::SwingSchedulerDDG::getOutEdges(), I, isLoopCarriedDefOfUse(), MI, orderDependence(), and stageScheduled().
Referenced by orderDependence(), and reorderInstructions().
| void SMSchedule::print | ( | raw_ostream & | os | ) | const |
Print the schedule information to the given output.
Definition at line 3862 of file MachinePipeliner.cpp.
References getFinalCycle(), getFirstCycle(), llvm::SUnit::getInstr(), llvm::SUnit::NodeNum, llvm::MachineInstr::print(), and stageScheduled().
| std::deque< SUnit * > SMSchedule::reorderInstructions | ( | const SwingSchedulerDAG * | SSD, |
| const std::deque< SUnit * > & | Instrs ) const |
Definition at line 3800 of file MachinePipeliner.cpp.
References llvm::append_range(), llvm::SUnit::getInstr(), llvm::MachineInstr::isPHI(), and orderDependence().
Referenced by computeScheduledInsts(), and finalizeSchedule().
|
inline |
Definition at line 763 of file MachinePipeliner.h.
|
inline |
Set the initiation interval for this schedule.
Definition at line 772 of file MachinePipeliner.h.
|
inline |
Return the stage for a scheduled instruction.
Return -1 if the instruction has not been scheduled.
Definition at line 803 of file MachinePipeliner.h.
Referenced by llvm::SwingSchedulerDAG::applyInstrChange(), computeScheduledInsts(), isLoopCarried(), isScheduledAtStage(), isValidSchedule(), llvm::SwingSchedulerDDG::isValidSchedule(), normalizeNonPipelinedInstructions(), orderDependence(), print(), and llvm::SwingSchedulerDAG::schedule().