| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#ifndef LLVM_CODEGEN_RESOURCEPRIORITYQUEUE_H |
| 17 |
#define LLVM_CODEGEN_RESOURCEPRIORITYQUEUE_H |
| 18 |
|
| 19 |
#include "llvm/CodeGen/ScheduleDAG.h" |
| 20 |
|
| 21 |
namespace llvm { |
| 22 |
class DFAPacketizer; |
| 23 |
class InstrItineraryData; |
| 24 |
class ResourcePriorityQueue; |
| 25 |
class SelectionDAGISel; |
| 26 |
class TargetInstrInfo; |
| 27 |
class TargetRegisterInfo; |
| 28 |
|
| 29 |
|
| 30 |
struct resource_sort { |
| 31 |
ResourcePriorityQueue *PQ; |
| 32 |
explicit resource_sort(ResourcePriorityQueue *pq) : PQ(pq) {} |
| 33 |
|
| 34 |
bool operator()(const SUnit* LHS, const SUnit* RHS) const; |
| 35 |
}; |
| 36 |
|
| 37 |
class ResourcePriorityQueue : public SchedulingPriorityQueue { |
| 38 |
|
| 39 |
std::vector<SUnit> *SUnits; |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
std::vector<unsigned> NumNodesSolelyBlocking; |
| 46 |
|
| 47 |
|
| 48 |
std::vector<SUnit*> Queue; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
std::vector<unsigned> RegPressure; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
std::vector<unsigned> RegLimit; |
| 57 |
|
| 58 |
resource_sort Picker; |
| 59 |
const TargetRegisterInfo *TRI; |
| 60 |
const TargetLowering *TLI; |
| 61 |
const TargetInstrInfo *TII; |
| 62 |
const InstrItineraryData* InstrItins; |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
std::unique_ptr<DFAPacketizer> ResourcesModel; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
std::vector<SUnit*> Packet; |
| 71 |
|
| 72 |
|
| 73 |
unsigned ParallelLiveRanges; |
| 74 |
int HorizontalVerticalBalance; |
| 75 |
|
| 76 |
public: |
| 77 |
ResourcePriorityQueue(SelectionDAGISel *IS); |
| 78 |
|
| 79 |
bool isBottomUp() const override { return false; } |
| 80 |
|
| 81 |
void initNodes(std::vector<SUnit> &sunits) override; |
| 82 |
|
| 83 |
void addNode(const SUnit *SU) override { |
| 84 |
NumNodesSolelyBlocking.resize(SUnits->size(), 0); |
| 85 |
} |
| 86 |
|
| 87 |
void updateNode(const SUnit *SU) override {} |
| 88 |
|
| 89 |
void releaseState() override { |
| 90 |
SUnits = nullptr; |
| 91 |
} |
| 92 |
|
| 93 |
unsigned getLatency(unsigned NodeNum) const { |
| 94 |
assert(NodeNum < (*SUnits).size()); |
| 95 |
return (*SUnits)[NodeNum].getHeight(); |
| 96 |
} |
| 97 |
|
| 98 |
unsigned getNumSolelyBlockNodes(unsigned NodeNum) const { |
| 99 |
assert(NodeNum < NumNodesSolelyBlocking.size()); |
| 100 |
return NumNodesSolelyBlocking[NodeNum]; |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
int SUSchedulingCost (SUnit *SU); |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
void initNumRegDefsLeft(SUnit *SU); |
| 110 |
int regPressureDelta(SUnit *SU, bool RawPressure = false); |
| 111 |
int rawRegPressureDelta (SUnit *SU, unsigned RCId); |
| 112 |
|
| 113 |
bool empty() const override { return Queue.empty(); } |
| 114 |
|
| 115 |
void push(SUnit *U) override; |
| 116 |
|
| 117 |
SUnit *pop() override; |
| 118 |
|
| 119 |
void remove(SUnit *SU) override; |
| 120 |
|
| 121 |
|
| 122 |
void scheduledNode(SUnit *SU) override; |
| 123 |
bool isResourceAvailable(SUnit *SU); |
| 124 |
void reserveResources(SUnit *SU); |
| 125 |
|
| 126 |
private: |
| 127 |
void adjustPriorityOfUnscheduledPreds(SUnit *SU); |
| 128 |
SUnit *getSingleUnscheduledPred(SUnit *SU); |
| 129 |
unsigned numberRCValPredInSU (SUnit *SU, unsigned RCId); |
| 130 |
unsigned numberRCValSuccInSU (SUnit *SU, unsigned RCId); |
| 131 |
}; |
| 132 |
} |
| 133 |
|
| 134 |
#endif |