LLVM  5.0.0
GCNIterativeScheduler.h
Go to the documentation of this file.
1 //===--------- GCNIterativeScheduler.h - GCN Scheduler -*- C++ -*----------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// \file
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_AMDGPU_GCNITERATIVESCHEDULER_H
15 #define LLVM_LIB_TARGET_AMDGPU_GCNITERATIVESCHEDULER_H
16 
17 #include "GCNRegPressure.h"
18 
20 
21 namespace llvm {
22 
25 public:
26  enum StrategyKind {
30  };
31 
33  StrategyKind S);
34 
35  void schedule() override;
36 
40  unsigned RegionInstrs) override;
41 
42  void finalizeSchedule() override;
43 
44 protected:
45 
47 
49  std::vector<MachineInstr*> Schedule;
51  };
52 
53  struct Region {
54  // Fields except for BestSchedule are supposed to reflect current IR state
55  // `const` fields are to emphasize they shouldn't change for any schedule.
57  // End is either a boundary instruction or end of basic block
59  const unsigned NumRegionInstrs;
61 
62  // best schedule for the region so far (not scheduled yet)
63  std::unique_ptr<TentativeSchedule> BestSchedule;
64  };
65 
67  std::vector<Region*> Regions;
68 
72 
73  class BuildDAG;
75 
76  template <typename Range>
78  Range &&Schedule) const;
79 
82 
84  return getRegionPressure(R.Begin, R.End);
85  }
86 
87  void setBestSchedule(Region &R,
88  ScheduleRef Schedule,
89  const GCNRegPressure &MaxRP = GCNRegPressure());
90 
91  void scheduleBest(Region &R);
92 
93  std::vector<MachineInstr*> detachSchedule(ScheduleRef Schedule) const;
94 
95  void sortRegionsByPressure(unsigned TargetOcc);
96 
97  template <typename Range>
98  void scheduleRegion(Region &R, Range &&Schedule,
99  const GCNRegPressure &MaxRP = GCNRegPressure());
100 
101  unsigned tryMaximizeOccupancy(unsigned TargetOcc =
103 
104  void scheduleLegacyMaxOccupancy(bool TryMaximizeOccupancy = true);
105  void scheduleMinReg(bool force = false);
106 
107  void printRegions(raw_ostream &OS) const;
108  void printSchedResult(raw_ostream &OS,
109  const Region *R,
110  const GCNRegPressure &RP) const;
111  void printSchedRP(raw_ostream &OS,
112  const GCNRegPressure &Before,
113  const GCNRegPressure &After) const;
114 };
115 
116 } // End namespace llvm
117 
118 #endif // LLVM_LIB_TARGET_AMDGPU_GCNITERATIVESCHEDULER_H
unsigned tryMaximizeOccupancy(unsigned TargetOcc=std::numeric_limits< unsigned >::max())
void enterRegion(MachineBasicBlock *BB, MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End, unsigned RegionInstrs) override
Implement the ScheduleDAGInstrs interface for handling the next scheduling region.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
void sortRegionsByPressure(unsigned TargetOcc)
SpecificBumpPtrAllocator< Region > Alloc
std::vector< MachineInstr * > detachSchedule(ScheduleRef Schedule) const
void printRegions(raw_ostream &OS) const
GCNRegPressure getRegionPressure(MachineBasicBlock::iterator Begin, MachineBasicBlock::iterator End) const
std::vector< Region * > Regions
ArrayRef< const SUnit * > ScheduleRef
ScheduleDAGMILive is an implementation of ScheduleDAGInstrs that schedules machine instructions while...
void finalizeSchedule() override
Allow targets to perform final scheduling actions at the level of the whole MachineFunction.
void printSchedResult(raw_ostream &OS, const Region *R, const GCNRegPressure &RP) const
void scheduleLegacyMaxOccupancy(bool TryMaximizeOccupancy=true)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
void setBestSchedule(Region &R, ScheduleRef Schedule, const GCNRegPressure &MaxRP=GCNRegPressure())
GCNRegPressure getSchedulePressure(const Region &R, Range &&Schedule) const
static const unsigned End
void schedule() override
Implement ScheduleDAGInstrs interface for scheduling a sequence of reorderable instructions.
A BumpPtrAllocator that allows only elements of a specific type to be allocated.
Definition: Allocator.h:382
const MachineBasicBlock::iterator End
#define C
Definition: LargeTest.cpp:25
GCNRegPressure getRegionPressure(const Region &R) const
GCNIterativeScheduler(MachineSchedContext *C, StrategyKind S)
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
void scheduleRegion(Region &R, Range &&Schedule, const GCNRegPressure &MaxRP=GCNRegPressure())
void printSchedRP(raw_ostream &OS, const GCNRegPressure &Before, const GCNRegPressure &After) const
void scheduleMinReg(bool force=false)
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
MachineBasicBlock * BB
The block in which to insert instructions.
std::unique_ptr< TentativeSchedule > BestSchedule