|
15 | 15 | #ifndef LLVM_CODEGEN_SCHEDULEDAGINSTRS_H
|
16 | 16 | #define LLVM_CODEGEN_SCHEDULEDAGINSTRS_H
|
17 | 17 |
|
| 18 | +#include "llvm/ADT/MapVector.h" |
18 | 19 | #include "llvm/ADT/SparseMultiSet.h"
|
19 | 20 | #include "llvm/ADT/SparseSet.h"
|
20 | 21 | #include "llvm/CodeGen/ScheduleDAG.h"
|
21 | 22 | #include "llvm/CodeGen/TargetSchedule.h"
|
22 | 23 | #include "llvm/Support/Compiler.h"
|
23 | 24 | #include "llvm/Target/TargetRegisterInfo.h"
|
| 25 | +#include <list> |
24 | 26 |
|
25 | 27 | namespace llvm {
|
26 | 28 | class MachineFrameInfo;
|
@@ -84,6 +86,10 @@ namespace llvm {
|
84 | 86 | typedef SparseMultiSet<VReg2SUnitOperIdx, VirtReg2IndexFunctor>
|
85 | 87 | VReg2SUnitOperIdxMultiMap;
|
86 | 88 |
|
| 89 | + typedef PointerUnion<const Value *, const PseudoSourceValue *> ValueType; |
| 90 | + typedef SmallVector<PointerIntPair<ValueType, 1, bool>, 4> |
| 91 | + UnderlyingObjectsVector; |
| 92 | + |
87 | 93 | /// ScheduleDAGInstrs - A ScheduleDAG subclass for scheduling lists of
|
88 | 94 | /// MachineInstrs.
|
89 | 95 | class ScheduleDAGInstrs : public ScheduleDAG {
|
@@ -149,10 +155,66 @@ namespace llvm {
|
149 | 155 | /// Tracks the last instructions in this region using each virtual register.
|
150 | 156 | VReg2SUnitOperIdxMultiMap CurrentVRegUses;
|
151 | 157 |
|
152 |
| - /// PendingLoads - Remember where unknown loads are after the most recent |
153 |
| - /// unknown store, as we iterate. As with Defs and Uses, this is here |
154 |
| - /// to minimize construction/destruction. |
155 |
| - std::vector<SUnit *> PendingLoads; |
| 158 | + AliasAnalysis *AAForDep; |
| 159 | + |
| 160 | + /// Remember a generic side-effecting instruction as we proceed. |
| 161 | + /// No other SU ever gets scheduled around it (except in the special |
| 162 | + /// case of a huge region that gets reduced). |
| 163 | + SUnit *BarrierChain; |
| 164 | + |
| 165 | + public: |
| 166 | + |
| 167 | + /// A list of SUnits, used in Value2SUsMap, during DAG construction. |
| 168 | + /// Note: to gain speed it might be worth investigating an optimized |
| 169 | + /// implementation of this data structure, such as a singly linked list |
| 170 | + /// with a memory pool (SmallVector was tried but slow and SparseSet is not |
| 171 | + /// applicable). |
| 172 | + typedef std::list<SUnit *> SUList; |
| 173 | + protected: |
| 174 | + /// A map from ValueType to SUList, used during DAG construction, |
| 175 | + /// as a means of remembering which SUs depend on which memory |
| 176 | + /// locations. |
| 177 | + class Value2SUsMap; |
| 178 | + |
| 179 | + /// Remove in FIFO order some SUs from huge maps. |
| 180 | + void reduceHugeMemNodeMaps(Value2SUsMap &stores, |
| 181 | + Value2SUsMap &loads, unsigned N); |
| 182 | + |
| 183 | + /// Add a chain edge between SUa and SUb, but only if both AliasAnalysis |
| 184 | + /// and Target fail to deny the dependency. |
| 185 | + void addChainDependency(SUnit *SUa, SUnit *SUb, |
| 186 | + unsigned Latency = 0); |
| 187 | + |
| 188 | + /// Add dependencies as needed from all SUs in list to SU. |
| 189 | + void addChainDependencies(SUnit *SU, SUList &sus, unsigned Latency) { |
| 190 | + for (auto *su : sus) |
| 191 | + addChainDependency(SU, su, Latency); |
| 192 | + } |
| 193 | + |
| 194 | + /// Add dependencies as needed from all SUs in map, to SU. |
| 195 | + void addChainDependencies(SUnit *SU, Value2SUsMap &Val2SUsMap); |
| 196 | + |
| 197 | + /// Add dependencies as needed to SU, from all SUs mapped to V. |
| 198 | + void addChainDependencies(SUnit *SU, Value2SUsMap &Val2SUsMap, |
| 199 | + ValueType V); |
| 200 | + |
| 201 | + /// Add barrier chain edges from all SUs in map, and then clear |
| 202 | + /// the map. This is equivalent to insertBarrierChain(), but |
| 203 | + /// optimized for the common case where the new BarrierChain (a |
| 204 | + /// global memory object) has a higher NodeNum than all SUs in |
| 205 | + /// map. It is assumed BarrierChain has been set before calling |
| 206 | + /// this. |
| 207 | + void addBarrierChain(Value2SUsMap &map); |
| 208 | + |
| 209 | + /// Insert a barrier chain in a huge region, far below current |
| 210 | + /// SU. Add barrier chain edges from all SUs in map with higher |
| 211 | + /// NodeNums than this new BarrierChain, and remove them from |
| 212 | + /// map. It is assumed BarrierChain has been set before calling |
| 213 | + /// this. |
| 214 | + void insertBarrierChain(Value2SUsMap &map); |
| 215 | + |
| 216 | + /// For an unanalyzable memory access, this Value is used in maps. |
| 217 | + UndefValue *UnknownValue; |
156 | 218 |
|
157 | 219 | /// DbgValues - Remember instruction that precedes DBG_VALUE.
|
158 | 220 | /// These are generated by buildSchedGraph but persist so they can be
|
|
0 commit comments