47 #define DEBUG_TYPE "packets"
50 cl::init(0),
cl::desc(
"If present, stops packetizing after N instructions"));
67 "Exceeded maximum number of DFA terms");
68 for (
auto U : InsnClass)
78 InstrItins(I), DFAStateInputTable(SIT), DFAStateEntryTable(SET) {
82 "(DFA_MAX_RESTERMS * DFA_MAX_RESOURCES) too big for DFAInput");
85 "(DFA_MAX_RESTERMS * DFA_MAX_RESOURCES) too big for DFAStateInput");
96 void DFAPacketizer::ReadTable(
unsigned int state) {
97 unsigned ThisState = DFAStateEntryTable[state];
98 unsigned NextStateInTable = DFAStateEntryTable[state+1];
101 if (CachedTable.
count(UnsignPair(state, DFAStateInputTable[ThisState][0])))
104 for (
unsigned i = ThisState; i < NextStateInTable; i++)
105 CachedTable[UnsignPair(state, DFAStateInputTable[i][0])] =
106 DFAStateInputTable[i][1];
116 *
IE = InstrItins->
endStage(InsnClass); IS !=
IE; ++IS) {
133 UnsignPair StateTrans = UnsignPair(CurrentState, InsnInput);
134 ReadTable(CurrentState);
135 return CachedTable.
count(StateTrans) != 0;
143 UnsignPair StateTrans = UnsignPair(CurrentState, InsnInput);
144 ReadTable(CurrentState);
146 CurrentState = CachedTable[StateTrans];
171 std::vector<std::unique_ptr<ScheduleDAGMutation>> Mutations;
182 Mutations.push_back(std::move(Mutation));
200 for (
auto &M : Mutations)
212 : MF(mf),
TII(mf.getSubtarget().getInstrInfo()), AA(aa) {
227 dbgs() <<
"Finalizing packet:\n";
248 std::distance(BeginItr, EndItr));
252 dbgs() <<
"Scheduling DAG of the packetize region\n";
265 for (; BeginItr != EndItr; ++BeginItr) {
287 assert(SUI &&
"Missing SUnit Info!");
290 DEBUG(
dbgs() <<
"Checking resources for adding MI to packet " << MI);
295 dbgs() <<
" Resources are available for adding MI to packet\n";
297 dbgs() <<
" Resources NOT available\n";
303 assert(SUJ &&
"Missing SUnit Info!");
305 DEBUG(
dbgs() <<
" Checking against MJ " << *MJ);
308 DEBUG(
dbgs() <<
" Not legal to add MI, try to prune\n");
312 DEBUG(
dbgs() <<
" Could not prune dependencies for adding MI\n");
316 DEBUG(
dbgs() <<
" Pruned dependence for adding MI\n");
320 DEBUG(
if (ResourceAvail)
321 dbgs() <<
"Resources are available, but instruction should not be "
322 "added to packet\n " << MI);
329 DEBUG(
dbgs() <<
"* Adding MI to packet " << MI <<
'\n');
341 std::unique_ptr<ScheduleDAGMutation>
Mutation) {
std::vector< MachineInstr * > CurrentPacketMIs
void addMutation(std::unique_ptr< ScheduleDAGMutation > Mutation)
virtual void finishBlock()
Cleans up after scheduling in the given block.
virtual void initPacketizerState()
static DFAInput addDFAFuncUnits(DFAInput Inp, unsigned FuncUnits)
DFAInput getInsnInput(unsigned InsnClass)
Describe properties that are true of each instruction in the target description file.
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
void dumpAll(const ScheduleDAG *G) const
bool CanHandleTerminators
The standard DAG builder does not normally include terminators as DAG nodes because it does not creat...
virtual bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ)
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
virtual bool ignorePseudoInstruction(const MachineInstr &I, const MachineBasicBlock *MBB)
static unsigned InstrCount
virtual void startBlock(MachineBasicBlock *BB)
Prepares to perform scheduling in the given block.
void schedule() override
Orders nodes according to selected style.
MachineFunction & MF
Machine function.
void buildSchedGraph(AliasAnalysis *AA, RegPressureTracker *RPTracker=nullptr, PressureDiffs *PDiffs=nullptr, LiveIntervals *LIS=nullptr, bool TrackLaneMasks=false)
Builds SUnits for the current region.
std::map< MachineInstr *, SUnit * > MIToSUnit
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const HexagonInstrInfo * TII
void postprocessDAG()
Apply each ScheduleDAGMutation step in order.
const InstrStage * beginStage(unsigned ItinClassIndx) const
Return the first stage of the itinerary.
virtual void endPacket(MachineBasicBlock *MBB, MachineBasicBlock::iterator MI)
DFAPacketizer * ResourceTracker
virtual MachineBasicBlock::iterator addToPacket(MachineInstr &MI)
void addMutation(std::unique_ptr< ScheduleDAGMutation > Mutation)
DefaultVLIWScheduler takes ownership of the Mutation object.
Itinerary data supplied by a subtarget to be used by a target.
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.
DefaultVLIWScheduler(MachineFunction &MF, MachineLoopInfo &MLI, AliasAnalysis *AA)
virtual DFAPacketizer * CreateTargetScheduleState(const TargetSubtargetInfo &) const
Create machine specific model for scheduling.
initializer< Ty > init(const Ty &Val)
#define DFA_MAX_RESOURCES
virtual bool shouldAddToPacket(const MachineInstr &MI)
virtual bool isSoloInstruction(const MachineInstr &MI)
virtual void exitRegion()
Called when the scheduler has finished scheduling the current region.
self_iterator getIterator()
const InstrStage * endStage(unsigned ItinClassIndx) const
Return the last+1 stage of the itinerary.
const TargetInstrInfo * TII
const MachineLoopInfo * MLI
bool canReserveResources(const MCInstrDesc *MID)
instr_iterator getInstrIterator() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static DFAInput getDFAInsnInput(const std::vector< unsigned > &InsnClass)
Return the DFAInput for an instruction class input vector.
virtual bool isLegalToPacketizeTogether(SUnit *SUI, SUnit *SUJ)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
A ScheduleDAG for scheduling lists of MachineInstr.
Representation of each machine instruction.
unsigned getSchedClass() const
Return the scheduling class for this instruction.
These values represent a non-pipelined step in the execution of an instruction.
virtual ~VLIWPacketizerList()
static cl::opt< unsigned > InstrLimit("dfa-instr-limit", cl::Hidden, cl::init(0), cl::desc("If present, stops packetizing after N instructions"))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
VLIWPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI, AliasAnalysis *AA)
DFAPacketizer(const InstrItineraryData *I, const DFAStateInput(*SIT)[2], const unsigned *SET)
std::vector< SUnit > SUnits
The scheduling units.
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...
void PacketizeMIs(MachineBasicBlock *MBB, MachineBasicBlock::iterator BeginItr, MachineBasicBlock::iterator EndItr)
DefaultVLIWScheduler * VLIWScheduler
Scheduling unit. This is a node in the scheduling DAG.
void reserveResources(const MCInstrDesc *MID)