Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 1 | //===- CodeGenSchedule.h - Scheduling Machine Models ------------*- 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 | // |
Alp Toker | ae43cab6 | 2014-01-24 17:20:08 +0000 | [diff] [blame] | 10 | // This file defines structures to encapsulate the machine model as described in |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 11 | // the target description. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Benjamin Kramer | 00e08fc | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 15 | #ifndef LLVM_UTILS_TABLEGEN_CODEGENSCHEDULE_H |
| 16 | #define LLVM_UTILS_TABLEGEN_CODEGENSCHEDULE_H |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 17 | |
Andrea Di Biagio | a9c15c1 | 2018-09-19 15:57:45 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/APInt.h" |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/DenseMap.h" |
| 20 | #include "llvm/ADT/StringMap.h" |
Chandler Carruth | 4ffd89f | 2012-12-04 10:37:14 +0000 | [diff] [blame] | 21 | #include "llvm/Support/ErrorHandling.h" |
| 22 | #include "llvm/TableGen/Record.h" |
James Molloy | 3b2a256 | 2014-06-17 13:10:38 +0000 | [diff] [blame] | 23 | #include "llvm/TableGen/SetTheory.h" |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 24 | |
| 25 | namespace llvm { |
| 26 | |
| 27 | class CodeGenTarget; |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 28 | class CodeGenSchedModels; |
| 29 | class CodeGenInstruction; |
Andrea Di Biagio | ce79db6 | 2018-04-03 13:36:24 +0000 | [diff] [blame] | 30 | class CodeGenRegisterClass; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 31 | |
Javed Absar | 0a82c73 | 2017-09-13 10:31:10 +0000 | [diff] [blame] | 32 | using RecVec = std::vector<Record*>; |
| 33 | using RecIter = std::vector<Record*>::const_iterator; |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 34 | |
Javed Absar | 0a82c73 | 2017-09-13 10:31:10 +0000 | [diff] [blame] | 35 | using IdxVec = std::vector<unsigned>; |
| 36 | using IdxIter = std::vector<unsigned>::const_iterator; |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 37 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 38 | /// We have two kinds of SchedReadWrites. Explicitly defined and inferred |
| 39 | /// sequences. TheDef is nonnull for explicit SchedWrites, but Sequence may or |
| 40 | /// may not be empty. TheDef is null for inferred sequences, and Sequence must |
| 41 | /// be nonempty. |
| 42 | /// |
| 43 | /// IsVariadic controls whether the variants are expanded into multiple operands |
| 44 | /// or a sequence of writes on one operand. |
| 45 | struct CodeGenSchedRW { |
Andrew Trick | 2062b12 | 2012-10-03 23:06:28 +0000 | [diff] [blame] | 46 | unsigned Index; |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 47 | std::string Name; |
| 48 | Record *TheDef; |
Andrew Trick | 2062b12 | 2012-10-03 23:06:28 +0000 | [diff] [blame] | 49 | bool IsRead; |
Andrew Trick | 9264988 | 2012-09-22 02:24:21 +0000 | [diff] [blame] | 50 | bool IsAlias; |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 51 | bool HasVariants; |
| 52 | bool IsVariadic; |
| 53 | bool IsSequence; |
| 54 | IdxVec Sequence; |
Andrew Trick | 9264988 | 2012-09-22 02:24:21 +0000 | [diff] [blame] | 55 | RecVec Aliases; |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 56 | |
Richard Smith | 8efd0f0 | 2012-12-20 01:05:39 +0000 | [diff] [blame] | 57 | CodeGenSchedRW() |
Craig Topper | 695aa80 | 2014-04-16 04:21:27 +0000 | [diff] [blame] | 58 | : Index(0), TheDef(nullptr), IsRead(false), IsAlias(false), |
Richard Smith | 8efd0f0 | 2012-12-20 01:05:39 +0000 | [diff] [blame] | 59 | HasVariants(false), IsVariadic(false), IsSequence(false) {} |
| 60 | CodeGenSchedRW(unsigned Idx, Record *Def) |
| 61 | : Index(Idx), TheDef(Def), IsAlias(false), IsVariadic(false) { |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 62 | Name = Def->getName(); |
Andrew Trick | 2062b12 | 2012-10-03 23:06:28 +0000 | [diff] [blame] | 63 | IsRead = Def->isSubClassOf("SchedRead"); |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 64 | HasVariants = Def->isSubClassOf("SchedVariant"); |
| 65 | if (HasVariants) |
| 66 | IsVariadic = Def->getValueAsBit("Variadic"); |
| 67 | |
| 68 | // Read records don't currently have sequences, but it can be easily |
| 69 | // added. Note that implicit Reads (from ReadVariant) may have a Sequence |
| 70 | // (but no record). |
| 71 | IsSequence = Def->isSubClassOf("WriteSequence"); |
| 72 | } |
| 73 | |
Benjamin Kramer | 109f9e6 | 2015-10-24 12:46:49 +0000 | [diff] [blame] | 74 | CodeGenSchedRW(unsigned Idx, bool Read, ArrayRef<unsigned> Seq, |
Richard Smith | 8efd0f0 | 2012-12-20 01:05:39 +0000 | [diff] [blame] | 75 | const std::string &Name) |
Benjamin Kramer | 109f9e6 | 2015-10-24 12:46:49 +0000 | [diff] [blame] | 76 | : Index(Idx), Name(Name), TheDef(nullptr), IsRead(Read), IsAlias(false), |
| 77 | HasVariants(false), IsVariadic(false), IsSequence(true), Sequence(Seq) { |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 78 | assert(Sequence.size() > 1 && "implied sequence needs >1 RWs"); |
| 79 | } |
| 80 | |
| 81 | bool isValid() const { |
| 82 | assert((!HasVariants || TheDef) && "Variant write needs record def"); |
| 83 | assert((!IsVariadic || HasVariants) && "Variadic write needs variants"); |
| 84 | assert((!IsSequence || !HasVariants) && "Sequence can't have variant"); |
| 85 | assert((!IsSequence || !Sequence.empty()) && "Sequence should be nonempty"); |
Andrew Trick | 9264988 | 2012-09-22 02:24:21 +0000 | [diff] [blame] | 86 | assert((!IsAlias || Aliases.empty()) && "Alias cannot have aliases"); |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 87 | return TheDef || !Sequence.empty(); |
| 88 | } |
| 89 | |
| 90 | #ifndef NDEBUG |
| 91 | void dump() const; |
| 92 | #endif |
| 93 | }; |
| 94 | |
Andrew Trick | e076bb1 | 2012-09-18 04:03:30 +0000 | [diff] [blame] | 95 | /// Represent a transition between SchedClasses induced by SchedVariant. |
Andrew Trick | 5e613c2 | 2012-09-15 00:19:59 +0000 | [diff] [blame] | 96 | struct CodeGenSchedTransition { |
| 97 | unsigned ToClassIdx; |
| 98 | IdxVec ProcIndices; |
| 99 | RecVec PredTerm; |
| 100 | }; |
| 101 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 102 | /// Scheduling class. |
| 103 | /// |
| 104 | /// Each instruction description will be mapped to a scheduling class. There are |
| 105 | /// four types of classes: |
| 106 | /// |
| 107 | /// 1) An explicitly defined itinerary class with ItinClassDef set. |
| 108 | /// Writes and ReadDefs are empty. ProcIndices contains 0 for any processor. |
| 109 | /// |
| 110 | /// 2) An implied class with a list of SchedWrites and SchedReads that are |
| 111 | /// defined in an instruction definition and which are common across all |
| 112 | /// subtargets. ProcIndices contains 0 for any processor. |
| 113 | /// |
| 114 | /// 3) An implied class with a list of InstRW records that map instructions to |
| 115 | /// SchedWrites and SchedReads per-processor. InstrClassMap should map the same |
| 116 | /// instructions to this class. ProcIndices contains all the processors that |
| 117 | /// provided InstrRW records for this class. ItinClassDef or Writes/Reads may |
| 118 | /// still be defined for processors with no InstRW entry. |
| 119 | /// |
| 120 | /// 4) An inferred class represents a variant of another class that may be |
| 121 | /// resolved at runtime. ProcIndices contains the set of processors that may |
| 122 | /// require the class. ProcIndices are propagated through SchedClasses as |
| 123 | /// variants are expanded. Multiple SchedClasses may be inferred from an |
| 124 | /// itinerary class. Each inherits the processor index from the ItinRW record |
| 125 | /// that mapped the itinerary class to the variant Writes or Reads. |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 126 | struct CodeGenSchedClass { |
Andrew Trick | 1ab961f | 2013-03-16 18:58:55 +0000 | [diff] [blame] | 127 | unsigned Index; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 128 | std::string Name; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 129 | Record *ItinClassDef; |
| 130 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 131 | IdxVec Writes; |
| 132 | IdxVec Reads; |
| 133 | // Sorted list of ProcIdx, where ProcIdx==0 implies any processor. |
| 134 | IdxVec ProcIndices; |
| 135 | |
Andrew Trick | 5e613c2 | 2012-09-15 00:19:59 +0000 | [diff] [blame] | 136 | std::vector<CodeGenSchedTransition> Transitions; |
| 137 | |
Andrew Trick | 9264988 | 2012-09-22 02:24:21 +0000 | [diff] [blame] | 138 | // InstRW records associated with this class. These records may refer to an |
| 139 | // Instruction no longer mapped to this class by InstrClassMap. These |
| 140 | // Instructions should be ignored by this class because they have been split |
| 141 | // off to join another inferred class. |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 142 | RecVec InstRWs; |
| 143 | |
Craig Topper | d74de62 | 2018-03-22 06:15:08 +0000 | [diff] [blame] | 144 | CodeGenSchedClass(unsigned Index, std::string Name, Record *ItinClassDef) |
| 145 | : Index(Index), Name(std::move(Name)), ItinClassDef(ItinClassDef) {} |
Andrew Trick | 1ab961f | 2013-03-16 18:58:55 +0000 | [diff] [blame] | 146 | |
Simon Pilgrim | 6ee668d | 2018-03-21 17:57:21 +0000 | [diff] [blame] | 147 | bool isKeyEqual(Record *IC, ArrayRef<unsigned> W, |
| 148 | ArrayRef<unsigned> R) const { |
Benjamin Kramer | 109f9e6 | 2015-10-24 12:46:49 +0000 | [diff] [blame] | 149 | return ItinClassDef == IC && makeArrayRef(Writes) == W && |
| 150 | makeArrayRef(Reads) == R; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 151 | } |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 152 | |
Andrew Trick | 1ab961f | 2013-03-16 18:58:55 +0000 | [diff] [blame] | 153 | // Is this class generated from a variants if existing classes? Instructions |
| 154 | // are never mapped directly to inferred scheduling classes. |
| 155 | bool isInferred() const { return !ItinClassDef; } |
| 156 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 157 | #ifndef NDEBUG |
| 158 | void dump(const CodeGenSchedModels *SchedModels) const; |
| 159 | #endif |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 160 | }; |
| 161 | |
Andrea Di Biagio | ce79db6 | 2018-04-03 13:36:24 +0000 | [diff] [blame] | 162 | /// Represent the cost of allocating a register of register class RCDef. |
| 163 | /// |
| 164 | /// The cost of allocating a register is equivalent to the number of physical |
| 165 | /// registers used by the register renamer. Register costs are defined at |
| 166 | /// register class granularity. |
| 167 | struct CodeGenRegisterCost { |
| 168 | Record *RCDef; |
| 169 | unsigned Cost; |
Andrea Di Biagio | f39b0d9 | 2018-10-12 11:23:04 +0000 | [diff] [blame] | 170 | bool AllowMoveElimination; |
| 171 | CodeGenRegisterCost(Record *RC, unsigned RegisterCost, bool AllowMoveElim = false) |
| 172 | : RCDef(RC), Cost(RegisterCost), AllowMoveElimination(AllowMoveElim) {} |
Andrea Di Biagio | ce79db6 | 2018-04-03 13:36:24 +0000 | [diff] [blame] | 173 | CodeGenRegisterCost(const CodeGenRegisterCost &) = default; |
| 174 | CodeGenRegisterCost &operator=(const CodeGenRegisterCost &) = delete; |
| 175 | }; |
| 176 | |
| 177 | /// A processor register file. |
| 178 | /// |
| 179 | /// This class describes a processor register file. Register file information is |
| 180 | /// currently consumed by external tools like llvm-mca to predict dispatch |
| 181 | /// stalls due to register pressure. |
| 182 | struct CodeGenRegisterFile { |
| 183 | std::string Name; |
| 184 | Record *RegisterFileDef; |
Andrea Di Biagio | f39b0d9 | 2018-10-12 11:23:04 +0000 | [diff] [blame] | 185 | unsigned MaxMovesEliminatedPerCycle; |
| 186 | bool AllowZeroMoveEliminationOnly; |
Andrea Di Biagio | ce79db6 | 2018-04-03 13:36:24 +0000 | [diff] [blame] | 187 | |
| 188 | unsigned NumPhysRegs; |
| 189 | std::vector<CodeGenRegisterCost> Costs; |
| 190 | |
Andrea Di Biagio | f39b0d9 | 2018-10-12 11:23:04 +0000 | [diff] [blame] | 191 | CodeGenRegisterFile(StringRef name, Record *def, unsigned MaxMoveElimPerCy = 0, |
| 192 | bool AllowZeroMoveElimOnly = false) |
| 193 | : Name(name), RegisterFileDef(def), |
| 194 | MaxMovesEliminatedPerCycle(MaxMoveElimPerCy), |
| 195 | AllowZeroMoveEliminationOnly(AllowZeroMoveElimOnly), |
| 196 | NumPhysRegs(0) {} |
Andrea Di Biagio | ce79db6 | 2018-04-03 13:36:24 +0000 | [diff] [blame] | 197 | |
| 198 | bool hasDefaultCosts() const { return Costs.empty(); } |
| 199 | }; |
| 200 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 201 | // Processor model. |
| 202 | // |
| 203 | // ModelName is a unique name used to name an instantiation of MCSchedModel. |
| 204 | // |
| 205 | // ModelDef is NULL for inferred Models. This happens when a processor defines |
Alp Toker | ae43cab6 | 2014-01-24 17:20:08 +0000 | [diff] [blame] | 206 | // an itinerary but no machine model. If the processor defines neither a machine |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 207 | // model nor itinerary, then ModelDef remains pointing to NoModel. NoModel has |
| 208 | // the special "NoModel" field set to true. |
| 209 | // |
| 210 | // ItinsDef always points to a valid record definition, but may point to the |
| 211 | // default NoItineraries. NoItineraries has an empty list of InstrItinData |
| 212 | // records. |
| 213 | // |
| 214 | // ItinDefList orders this processor's InstrItinData records by SchedClass idx. |
| 215 | struct CodeGenProcModel { |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 216 | unsigned Index; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 217 | std::string ModelName; |
| 218 | Record *ModelDef; |
| 219 | Record *ItinsDef; |
| 220 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 221 | // Derived members... |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 222 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 223 | // Array of InstrItinData records indexed by a CodeGenSchedClass index. |
| 224 | // This list is empty if the Processor has no value for Itineraries. |
| 225 | // Initialized by collectProcItins(). |
| 226 | RecVec ItinDefList; |
| 227 | |
| 228 | // Map itinerary classes to per-operand resources. |
| 229 | // This list is empty if no ItinRW refers to this Processor. |
| 230 | RecVec ItinRWDefs; |
| 231 | |
Simon Dardis | 111ec25 | 2016-06-24 08:43:27 +0000 | [diff] [blame] | 232 | // List of unsupported feature. |
| 233 | // This list is empty if the Processor has no UnsupportedFeatures. |
| 234 | RecVec UnsupportedFeaturesDefs; |
| 235 | |
Andrew Trick | 3cbd178 | 2012-09-15 00:20:02 +0000 | [diff] [blame] | 236 | // All read/write resources associated with this processor. |
| 237 | RecVec WriteResDefs; |
| 238 | RecVec ReadAdvanceDefs; |
| 239 | |
| 240 | // Per-operand machine model resources associated with this processor. |
| 241 | RecVec ProcResourceDefs; |
| 242 | |
Andrea Di Biagio | ce79db6 | 2018-04-03 13:36:24 +0000 | [diff] [blame] | 243 | // List of Register Files. |
| 244 | std::vector<CodeGenRegisterFile> RegisterFiles; |
| 245 | |
Andrea Di Biagio | 8c6c516 | 2018-04-05 15:41:41 +0000 | [diff] [blame] | 246 | // Optional Retire Control Unit definition. |
| 247 | Record *RetireControlUnit; |
| 248 | |
Andrea Di Biagio | 51af6fd | 2018-11-29 12:15:56 +0000 | [diff] [blame] | 249 | // Load/Store queue descriptors. |
| 250 | Record *LoadQueue; |
| 251 | Record *StoreQueue; |
| 252 | |
Craig Topper | d74de62 | 2018-03-22 06:15:08 +0000 | [diff] [blame] | 253 | CodeGenProcModel(unsigned Idx, std::string Name, Record *MDef, |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 254 | Record *IDef) : |
Andrea Di Biagio | 8c6c516 | 2018-04-05 15:41:41 +0000 | [diff] [blame] | 255 | Index(Idx), ModelName(std::move(Name)), ModelDef(MDef), ItinsDef(IDef), |
Andrea Di Biagio | 51af6fd | 2018-11-29 12:15:56 +0000 | [diff] [blame] | 256 | RetireControlUnit(nullptr), LoadQueue(nullptr), StoreQueue(nullptr) {} |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 257 | |
Andrew Trick | 1ab961f | 2013-03-16 18:58:55 +0000 | [diff] [blame] | 258 | bool hasItineraries() const { |
| 259 | return !ItinsDef->getValueAsListOfDefs("IID").empty(); |
| 260 | } |
| 261 | |
Andrew Trick | 3cbd178 | 2012-09-15 00:20:02 +0000 | [diff] [blame] | 262 | bool hasInstrSchedModel() const { |
| 263 | return !WriteResDefs.empty() || !ItinRWDefs.empty(); |
| 264 | } |
| 265 | |
Andrea Di Biagio | ce79db6 | 2018-04-03 13:36:24 +0000 | [diff] [blame] | 266 | bool hasExtraProcessorInfo() const { |
Andrea Di Biagio | 51af6fd | 2018-11-29 12:15:56 +0000 | [diff] [blame] | 267 | return RetireControlUnit || LoadQueue || StoreQueue || |
| 268 | !RegisterFiles.empty(); |
Andrea Di Biagio | ce79db6 | 2018-04-03 13:36:24 +0000 | [diff] [blame] | 269 | } |
| 270 | |
Andrew Trick | 3cbd178 | 2012-09-15 00:20:02 +0000 | [diff] [blame] | 271 | unsigned getProcResourceIdx(Record *PRDef) const; |
| 272 | |
Simon Dardis | 111ec25 | 2016-06-24 08:43:27 +0000 | [diff] [blame] | 273 | bool isUnsupported(const CodeGenInstruction &Inst) const; |
| 274 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 275 | #ifndef NDEBUG |
| 276 | void dump() const; |
| 277 | #endif |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 278 | }; |
| 279 | |
Andrea Di Biagio | a9c15c1 | 2018-09-19 15:57:45 +0000 | [diff] [blame] | 280 | /// Used to correlate instructions to MCInstPredicates specified by |
| 281 | /// InstructionEquivalentClass tablegen definitions. |
| 282 | /// |
| 283 | /// Example: a XOR of a register with self, is a known zero-idiom for most |
| 284 | /// X86 processors. |
| 285 | /// |
| 286 | /// Each processor can use a (potentially different) InstructionEquivalenceClass |
| 287 | /// definition to classify zero-idioms. That means, XORrr is likely to appear |
| 288 | /// in more than one equivalence class (where each class definition is |
| 289 | /// contributed by a different processor). |
| 290 | /// |
| 291 | /// There is no guarantee that the same MCInstPredicate will be used to describe |
| 292 | /// equivalence classes that identify XORrr as a zero-idiom. |
| 293 | /// |
| 294 | /// To be more specific, the requirements for being a zero-idiom XORrr may be |
| 295 | /// different for different processors. |
| 296 | /// |
| 297 | /// Class PredicateInfo identifies a subset of processors that specify the same |
| 298 | /// requirements (i.e. same MCInstPredicate and OperandMask) for an instruction |
| 299 | /// opcode. |
| 300 | /// |
| 301 | /// Back to the example. Field `ProcModelMask` will have one bit set for every |
| 302 | /// processor model that sees XORrr as a zero-idiom, and that specifies the same |
| 303 | /// set of constraints. |
| 304 | /// |
| 305 | /// By construction, there can be multiple instances of PredicateInfo associated |
| 306 | /// with a same instruction opcode. For example, different processors may define |
| 307 | /// different constraints on the same opcode. |
| 308 | /// |
| 309 | /// Field OperandMask can be used as an extra constraint. |
| 310 | /// It may be used to describe conditions that appy only to a subset of the |
| 311 | /// operands of a machine instruction, and the operands subset may not be the |
| 312 | /// same for all processor models. |
| 313 | struct PredicateInfo { |
| 314 | llvm::APInt ProcModelMask; // A set of processor model indices. |
| 315 | llvm::APInt OperandMask; // An operand mask. |
| 316 | const Record *Predicate; // MCInstrPredicate definition. |
| 317 | PredicateInfo(llvm::APInt CpuMask, llvm::APInt Operands, const Record *Pred) |
| 318 | : ProcModelMask(CpuMask), OperandMask(Operands), Predicate(Pred) {} |
| 319 | |
| 320 | bool operator==(const PredicateInfo &Other) const { |
| 321 | return ProcModelMask == Other.ProcModelMask && |
| 322 | OperandMask == Other.OperandMask && Predicate == Other.Predicate; |
| 323 | } |
| 324 | }; |
| 325 | |
| 326 | /// A collection of PredicateInfo objects. |
| 327 | /// |
| 328 | /// There is at least one OpcodeInfo object for every opcode specified by a |
| 329 | /// TIPredicate definition. |
| 330 | class OpcodeInfo { |
Andrea Di Biagio | eb2ecf3 | 2018-09-19 17:54:01 +0000 | [diff] [blame] | 331 | std::vector<PredicateInfo> Predicates; |
Andrea Di Biagio | a9c15c1 | 2018-09-19 15:57:45 +0000 | [diff] [blame] | 332 | |
| 333 | OpcodeInfo(const OpcodeInfo &Other) = delete; |
| 334 | OpcodeInfo &operator=(const OpcodeInfo &Other) = delete; |
| 335 | |
| 336 | public: |
| 337 | OpcodeInfo() = default; |
| 338 | OpcodeInfo &operator=(OpcodeInfo &&Other) = default; |
| 339 | OpcodeInfo(OpcodeInfo &&Other) = default; |
| 340 | |
| 341 | ArrayRef<PredicateInfo> getPredicates() const { return Predicates; } |
| 342 | |
| 343 | void addPredicateForProcModel(const llvm::APInt &CpuMask, |
| 344 | const llvm::APInt &OperandMask, |
| 345 | const Record *Predicate); |
| 346 | }; |
| 347 | |
| 348 | /// Used to group together tablegen instruction definitions that are subject |
| 349 | /// to a same set of constraints (identified by an instance of OpcodeInfo). |
| 350 | class OpcodeGroup { |
| 351 | OpcodeInfo Info; |
| 352 | std::vector<const Record *> Opcodes; |
| 353 | |
| 354 | OpcodeGroup(const OpcodeGroup &Other) = delete; |
| 355 | OpcodeGroup &operator=(const OpcodeGroup &Other) = delete; |
| 356 | |
| 357 | public: |
| 358 | OpcodeGroup(OpcodeInfo &&OpInfo) : Info(std::move(OpInfo)) {} |
| 359 | OpcodeGroup(OpcodeGroup &&Other) = default; |
| 360 | |
| 361 | void addOpcode(const Record *Opcode) { |
| 362 | assert(std::find(Opcodes.begin(), Opcodes.end(), Opcode) == Opcodes.end() && |
| 363 | "Opcode already in set!"); |
| 364 | Opcodes.push_back(Opcode); |
| 365 | } |
| 366 | |
| 367 | ArrayRef<const Record *> getOpcodes() const { return Opcodes; } |
| 368 | const OpcodeInfo &getOpcodeInfo() const { return Info; } |
| 369 | }; |
| 370 | |
| 371 | /// An STIPredicateFunction descriptor used by tablegen backends to |
| 372 | /// auto-generate the body of a predicate function as a member of tablegen'd |
| 373 | /// class XXXGenSubtargetInfo. |
| 374 | class STIPredicateFunction { |
| 375 | const Record *FunctionDeclaration; |
| 376 | |
| 377 | std::vector<const Record *> Definitions; |
| 378 | std::vector<OpcodeGroup> Groups; |
| 379 | |
| 380 | STIPredicateFunction(const STIPredicateFunction &Other) = delete; |
| 381 | STIPredicateFunction &operator=(const STIPredicateFunction &Other) = delete; |
| 382 | |
| 383 | public: |
| 384 | STIPredicateFunction(const Record *Rec) : FunctionDeclaration(Rec) {} |
| 385 | STIPredicateFunction(STIPredicateFunction &&Other) = default; |
| 386 | |
| 387 | bool isCompatibleWith(const STIPredicateFunction &Other) const { |
| 388 | return FunctionDeclaration == Other.FunctionDeclaration; |
| 389 | } |
| 390 | |
| 391 | void addDefinition(const Record *Def) { Definitions.push_back(Def); } |
| 392 | void addOpcode(const Record *OpcodeRec, OpcodeInfo &&Info) { |
| 393 | if (Groups.empty() || |
| 394 | Groups.back().getOpcodeInfo().getPredicates() != Info.getPredicates()) |
| 395 | Groups.emplace_back(std::move(Info)); |
| 396 | Groups.back().addOpcode(OpcodeRec); |
| 397 | } |
| 398 | |
| 399 | StringRef getName() const { |
| 400 | return FunctionDeclaration->getValueAsString("Name"); |
| 401 | } |
| 402 | const Record *getDefaultReturnPredicate() const { |
| 403 | return FunctionDeclaration->getValueAsDef("DefaultReturnValue"); |
| 404 | } |
| 405 | |
| 406 | const Record *getDeclaration() const { return FunctionDeclaration; } |
| 407 | ArrayRef<const Record *> getDefinitions() const { return Definitions; } |
| 408 | ArrayRef<OpcodeGroup> getGroups() const { return Groups; } |
| 409 | }; |
| 410 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 411 | /// Top level container for machine model data. |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 412 | class CodeGenSchedModels { |
| 413 | RecordKeeper &Records; |
| 414 | const CodeGenTarget &Target; |
| 415 | |
Andrew Trick | 1374526 | 2012-10-03 23:06:32 +0000 | [diff] [blame] | 416 | // Map dag expressions to Instruction lists. |
| 417 | SetTheory Sets; |
| 418 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 419 | // List of unique processor models. |
| 420 | std::vector<CodeGenProcModel> ProcModels; |
| 421 | |
| 422 | // Map Processor's MachineModel or ProcItin to a CodeGenProcModel index. |
Javed Absar | 0a82c73 | 2017-09-13 10:31:10 +0000 | [diff] [blame] | 423 | using ProcModelMapTy = DenseMap<Record*, unsigned>; |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 424 | ProcModelMapTy ProcModelMap; |
| 425 | |
| 426 | // Per-operand SchedReadWrite types. |
| 427 | std::vector<CodeGenSchedRW> SchedWrites; |
| 428 | std::vector<CodeGenSchedRW> SchedReads; |
| 429 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 430 | // List of unique SchedClasses. |
| 431 | std::vector<CodeGenSchedClass> SchedClasses; |
| 432 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 433 | // Any inferred SchedClass has an index greater than NumInstrSchedClassses. |
| 434 | unsigned NumInstrSchedClasses; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 435 | |
Matthias Braun | 4492b0e | 2016-06-21 03:24:03 +0000 | [diff] [blame] | 436 | RecVec ProcResourceDefs; |
| 437 | RecVec ProcResGroups; |
| 438 | |
Andrew Trick | 1ab961f | 2013-03-16 18:58:55 +0000 | [diff] [blame] | 439 | // Map each instruction to its unique SchedClass index considering the |
| 440 | // combination of it's itinerary class, SchedRW list, and InstRW records. |
Javed Absar | 0a82c73 | 2017-09-13 10:31:10 +0000 | [diff] [blame] | 441 | using InstClassMapTy = DenseMap<Record*, unsigned>; |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 442 | InstClassMapTy InstrClassMap; |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 443 | |
Andrea Di Biagio | a9c15c1 | 2018-09-19 15:57:45 +0000 | [diff] [blame] | 444 | std::vector<STIPredicateFunction> STIPredicates; |
| 445 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 446 | public: |
| 447 | CodeGenSchedModels(RecordKeeper& RK, const CodeGenTarget &TGT); |
| 448 | |
Jim Grosbach | bfe74b9 | 2014-04-18 02:09:04 +0000 | [diff] [blame] | 449 | // iterator access to the scheduling classes. |
Javed Absar | 0a82c73 | 2017-09-13 10:31:10 +0000 | [diff] [blame] | 450 | using class_iterator = std::vector<CodeGenSchedClass>::iterator; |
| 451 | using const_class_iterator = std::vector<CodeGenSchedClass>::const_iterator; |
Jim Grosbach | bfe74b9 | 2014-04-18 02:09:04 +0000 | [diff] [blame] | 452 | class_iterator classes_begin() { return SchedClasses.begin(); } |
| 453 | const_class_iterator classes_begin() const { return SchedClasses.begin(); } |
| 454 | class_iterator classes_end() { return SchedClasses.end(); } |
| 455 | const_class_iterator classes_end() const { return SchedClasses.end(); } |
| 456 | iterator_range<class_iterator> classes() { |
Craig Topper | e6bc7d1 | 2015-12-06 05:08:07 +0000 | [diff] [blame] | 457 | return make_range(classes_begin(), classes_end()); |
Jim Grosbach | bfe74b9 | 2014-04-18 02:09:04 +0000 | [diff] [blame] | 458 | } |
| 459 | iterator_range<const_class_iterator> classes() const { |
Craig Topper | e6bc7d1 | 2015-12-06 05:08:07 +0000 | [diff] [blame] | 460 | return make_range(classes_begin(), classes_end()); |
Jim Grosbach | bfe74b9 | 2014-04-18 02:09:04 +0000 | [diff] [blame] | 461 | } |
| 462 | iterator_range<class_iterator> explicit_classes() { |
Craig Topper | e6bc7d1 | 2015-12-06 05:08:07 +0000 | [diff] [blame] | 463 | return make_range(classes_begin(), classes_begin() + NumInstrSchedClasses); |
Jim Grosbach | bfe74b9 | 2014-04-18 02:09:04 +0000 | [diff] [blame] | 464 | } |
| 465 | iterator_range<const_class_iterator> explicit_classes() const { |
Craig Topper | e6bc7d1 | 2015-12-06 05:08:07 +0000 | [diff] [blame] | 466 | return make_range(classes_begin(), classes_begin() + NumInstrSchedClasses); |
Jim Grosbach | bfe74b9 | 2014-04-18 02:09:04 +0000 | [diff] [blame] | 467 | } |
| 468 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 469 | Record *getModelOrItinDef(Record *ProcDef) const { |
| 470 | Record *ModelDef = ProcDef->getValueAsDef("SchedModel"); |
| 471 | Record *ItinsDef = ProcDef->getValueAsDef("ProcItin"); |
| 472 | if (!ItinsDef->getValueAsListOfDefs("IID").empty()) { |
| 473 | assert(ModelDef->getValueAsBit("NoModel") |
| 474 | && "Itineraries must be defined within SchedMachineModel"); |
| 475 | return ItinsDef; |
| 476 | } |
| 477 | return ModelDef; |
| 478 | } |
| 479 | |
| 480 | const CodeGenProcModel &getModelForProc(Record *ProcDef) const { |
| 481 | Record *ModelDef = getModelOrItinDef(ProcDef); |
| 482 | ProcModelMapTy::const_iterator I = ProcModelMap.find(ModelDef); |
| 483 | assert(I != ProcModelMap.end() && "missing machine model"); |
| 484 | return ProcModels[I->second]; |
| 485 | } |
| 486 | |
Andrew Trick | a3d82ce | 2013-06-15 04:50:06 +0000 | [diff] [blame] | 487 | CodeGenProcModel &getProcModel(Record *ModelDef) { |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 488 | ProcModelMapTy::const_iterator I = ProcModelMap.find(ModelDef); |
| 489 | assert(I != ProcModelMap.end() && "missing machine model"); |
| 490 | return ProcModels[I->second]; |
| 491 | } |
Andrew Trick | a3d82ce | 2013-06-15 04:50:06 +0000 | [diff] [blame] | 492 | const CodeGenProcModel &getProcModel(Record *ModelDef) const { |
| 493 | return const_cast<CodeGenSchedModels*>(this)->getProcModel(ModelDef); |
| 494 | } |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 495 | |
| 496 | // Iterate over the unique processor models. |
Javed Absar | 0a82c73 | 2017-09-13 10:31:10 +0000 | [diff] [blame] | 497 | using ProcIter = std::vector<CodeGenProcModel>::const_iterator; |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 498 | ProcIter procModelBegin() const { return ProcModels.begin(); } |
| 499 | ProcIter procModelEnd() const { return ProcModels.end(); } |
Craig Topper | dcbac18 | 2016-02-13 06:03:32 +0000 | [diff] [blame] | 500 | ArrayRef<CodeGenProcModel> procModels() const { return ProcModels; } |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 501 | |
Andrew Trick | 1ab961f | 2013-03-16 18:58:55 +0000 | [diff] [blame] | 502 | // Return true if any processors have itineraries. |
| 503 | bool hasItineraries() const; |
| 504 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 505 | // Get a SchedWrite from its index. |
| 506 | const CodeGenSchedRW &getSchedWrite(unsigned Idx) const { |
| 507 | assert(Idx < SchedWrites.size() && "bad SchedWrite index"); |
| 508 | assert(SchedWrites[Idx].isValid() && "invalid SchedWrite"); |
| 509 | return SchedWrites[Idx]; |
| 510 | } |
| 511 | // Get a SchedWrite from its index. |
| 512 | const CodeGenSchedRW &getSchedRead(unsigned Idx) const { |
| 513 | assert(Idx < SchedReads.size() && "bad SchedRead index"); |
| 514 | assert(SchedReads[Idx].isValid() && "invalid SchedRead"); |
| 515 | return SchedReads[Idx]; |
| 516 | } |
| 517 | |
| 518 | const CodeGenSchedRW &getSchedRW(unsigned Idx, bool IsRead) const { |
| 519 | return IsRead ? getSchedRead(Idx) : getSchedWrite(Idx); |
| 520 | } |
Andrew Trick | 2062b12 | 2012-10-03 23:06:28 +0000 | [diff] [blame] | 521 | CodeGenSchedRW &getSchedRW(Record *Def) { |
Andrew Trick | 9264988 | 2012-09-22 02:24:21 +0000 | [diff] [blame] | 522 | bool IsRead = Def->isSubClassOf("SchedRead"); |
Andrew Trick | 2062b12 | 2012-10-03 23:06:28 +0000 | [diff] [blame] | 523 | unsigned Idx = getSchedRWIdx(Def, IsRead); |
Andrew Trick | 9264988 | 2012-09-22 02:24:21 +0000 | [diff] [blame] | 524 | return const_cast<CodeGenSchedRW&>( |
| 525 | IsRead ? getSchedRead(Idx) : getSchedWrite(Idx)); |
| 526 | } |
Andrea Di Biagio | bf50bde | 2018-04-26 12:56:26 +0000 | [diff] [blame] | 527 | const CodeGenSchedRW &getSchedRW(Record *Def) const { |
Andrew Trick | 2062b12 | 2012-10-03 23:06:28 +0000 | [diff] [blame] | 528 | return const_cast<CodeGenSchedModels&>(*this).getSchedRW(Def); |
Andrew Trick | 9264988 | 2012-09-22 02:24:21 +0000 | [diff] [blame] | 529 | } |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 530 | |
Andrea Di Biagio | bf50bde | 2018-04-26 12:56:26 +0000 | [diff] [blame] | 531 | unsigned getSchedRWIdx(const Record *Def, bool IsRead) const; |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 532 | |
Andrew Trick | 3b8fb64 | 2012-09-19 04:43:19 +0000 | [diff] [blame] | 533 | // Return true if the given write record is referenced by a ReadAdvance. |
| 534 | bool hasReadOfWrite(Record *WriteDef) const; |
| 535 | |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 536 | // Get a SchedClass from its index. |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 537 | CodeGenSchedClass &getSchedClass(unsigned Idx) { |
| 538 | assert(Idx < SchedClasses.size() && "bad SchedClass index"); |
| 539 | return SchedClasses[Idx]; |
| 540 | } |
| 541 | const CodeGenSchedClass &getSchedClass(unsigned Idx) const { |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 542 | assert(Idx < SchedClasses.size() && "bad SchedClass index"); |
| 543 | return SchedClasses[Idx]; |
| 544 | } |
| 545 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 546 | // Get the SchedClass index for an instruction. Instructions with no |
| 547 | // itinerary, no SchedReadWrites, and no InstrReadWrites references return 0 |
| 548 | // for NoItinerary. |
| 549 | unsigned getSchedClassIdx(const CodeGenInstruction &Inst) const; |
| 550 | |
Javed Absar | 0a82c73 | 2017-09-13 10:31:10 +0000 | [diff] [blame] | 551 | using SchedClassIter = std::vector<CodeGenSchedClass>::const_iterator; |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 552 | SchedClassIter schedClassBegin() const { return SchedClasses.begin(); } |
| 553 | SchedClassIter schedClassEnd() const { return SchedClasses.end(); } |
Craig Topper | dcbac18 | 2016-02-13 06:03:32 +0000 | [diff] [blame] | 554 | ArrayRef<CodeGenSchedClass> schedClasses() const { return SchedClasses; } |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 555 | |
Andrew Trick | 1ab961f | 2013-03-16 18:58:55 +0000 | [diff] [blame] | 556 | unsigned numInstrSchedClasses() const { return NumInstrSchedClasses; } |
| 557 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 558 | void findRWs(const RecVec &RWDefs, IdxVec &Writes, IdxVec &Reads) const; |
| 559 | void findRWs(const RecVec &RWDefs, IdxVec &RWs, bool IsRead) const; |
Andrew Trick | 5e613c2 | 2012-09-15 00:19:59 +0000 | [diff] [blame] | 560 | void expandRWSequence(unsigned RWIdx, IdxVec &RWSeq, bool IsRead) const; |
Andrew Trick | 2062b12 | 2012-10-03 23:06:28 +0000 | [diff] [blame] | 561 | void expandRWSeqForProc(unsigned RWIdx, IdxVec &RWSeq, bool IsRead, |
| 562 | const CodeGenProcModel &ProcModel) const; |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 563 | |
Benjamin Kramer | 109f9e6 | 2015-10-24 12:46:49 +0000 | [diff] [blame] | 564 | unsigned addSchedClass(Record *ItinDef, ArrayRef<unsigned> OperWrites, |
| 565 | ArrayRef<unsigned> OperReads, |
| 566 | ArrayRef<unsigned> ProcIndices); |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 567 | |
| 568 | unsigned findOrInsertRW(ArrayRef<unsigned> Seq, bool IsRead); |
| 569 | |
Evandro Menezes | 8304ff2 | 2017-11-21 21:33:52 +0000 | [diff] [blame] | 570 | Record *findProcResUnits(Record *ProcResKind, const CodeGenProcModel &PM, |
| 571 | ArrayRef<SMLoc> Loc) const; |
Andrew Trick | 3cbd178 | 2012-09-15 00:20:02 +0000 | [diff] [blame] | 572 | |
Andrea Di Biagio | a9c15c1 | 2018-09-19 15:57:45 +0000 | [diff] [blame] | 573 | ArrayRef<STIPredicateFunction> getSTIPredicates() const { |
| 574 | return STIPredicates; |
| 575 | } |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 576 | private: |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 577 | void collectProcModels(); |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 578 | |
| 579 | // Initialize a new processor model if it is unique. |
| 580 | void addProcModel(Record *ProcDef); |
| 581 | |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 582 | void collectSchedRW(); |
| 583 | |
Benjamin Kramer | 109f9e6 | 2015-10-24 12:46:49 +0000 | [diff] [blame] | 584 | std::string genRWName(ArrayRef<unsigned> Seq, bool IsRead); |
| 585 | unsigned findRWForSequence(ArrayRef<unsigned> Seq, bool IsRead); |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 586 | |
| 587 | void collectSchedClasses(); |
| 588 | |
Andrea Di Biagio | 8c6c516 | 2018-04-05 15:41:41 +0000 | [diff] [blame] | 589 | void collectRetireControlUnits(); |
| 590 | |
Andrea Di Biagio | ce79db6 | 2018-04-03 13:36:24 +0000 | [diff] [blame] | 591 | void collectRegisterFiles(); |
| 592 | |
Andrea Di Biagio | 8c6c516 | 2018-04-05 15:41:41 +0000 | [diff] [blame] | 593 | void collectOptionalProcessorInfo(); |
| 594 | |
Andrew Trick | 1ab961f | 2013-03-16 18:58:55 +0000 | [diff] [blame] | 595 | std::string createSchedClassName(Record *ItinClassDef, |
Benjamin Kramer | 109f9e6 | 2015-10-24 12:46:49 +0000 | [diff] [blame] | 596 | ArrayRef<unsigned> OperWrites, |
| 597 | ArrayRef<unsigned> OperReads); |
Andrew Trick | 48605c3 | 2012-09-15 00:19:57 +0000 | [diff] [blame] | 598 | std::string createSchedClassName(const RecVec &InstDefs); |
| 599 | void createInstRWClass(Record *InstRWDef); |
| 600 | |
| 601 | void collectProcItins(); |
| 602 | |
| 603 | void collectProcItinRW(); |
Andrew Trick | 5e613c2 | 2012-09-15 00:19:59 +0000 | [diff] [blame] | 604 | |
Simon Dardis | 111ec25 | 2016-06-24 08:43:27 +0000 | [diff] [blame] | 605 | void collectProcUnsupportedFeatures(); |
| 606 | |
Andrew Trick | 5e613c2 | 2012-09-15 00:19:59 +0000 | [diff] [blame] | 607 | void inferSchedClasses(); |
| 608 | |
Andrea Di Biagio | e9759dd | 2018-08-14 18:36:54 +0000 | [diff] [blame] | 609 | void checkMCInstPredicates() const; |
Josh Stone | c1ddded | 2018-09-11 17:28:43 +0000 | [diff] [blame] | 610 | |
Andrea Di Biagio | a9c15c1 | 2018-09-19 15:57:45 +0000 | [diff] [blame] | 611 | void checkSTIPredicates() const; |
| 612 | |
| 613 | void collectSTIPredicates(); |
| 614 | |
Andrea Di Biagio | 51af6fd | 2018-11-29 12:15:56 +0000 | [diff] [blame] | 615 | void collectLoadStoreQueueInfo(); |
| 616 | |
Matthias Braun | eab2869 | 2016-03-01 20:03:21 +0000 | [diff] [blame] | 617 | void checkCompleteness(); |
| 618 | |
Benjamin Kramer | 109f9e6 | 2015-10-24 12:46:49 +0000 | [diff] [blame] | 619 | void inferFromRW(ArrayRef<unsigned> OperWrites, ArrayRef<unsigned> OperReads, |
| 620 | unsigned FromClassIdx, ArrayRef<unsigned> ProcIndices); |
Andrew Trick | 5e613c2 | 2012-09-15 00:19:59 +0000 | [diff] [blame] | 621 | void inferFromItinClass(Record *ItinClassDef, unsigned FromClassIdx); |
| 622 | void inferFromInstRWs(unsigned SCIdx); |
Andrew Trick | 3cbd178 | 2012-09-15 00:20:02 +0000 | [diff] [blame] | 623 | |
Andrew Trick | e30f32a | 2013-04-23 23:45:14 +0000 | [diff] [blame] | 624 | bool hasSuperGroup(RecVec &SubUnits, CodeGenProcModel &PM); |
| 625 | void verifyProcResourceGroups(CodeGenProcModel &PM); |
| 626 | |
Andrew Trick | 3cbd178 | 2012-09-15 00:20:02 +0000 | [diff] [blame] | 627 | void collectProcResources(); |
| 628 | |
| 629 | void collectItinProcResources(Record *ItinClassDef); |
| 630 | |
Andrew Trick | dbe6d43 | 2012-10-10 05:43:13 +0000 | [diff] [blame] | 631 | void collectRWResources(unsigned RWIdx, bool IsRead, |
Benjamin Kramer | 109f9e6 | 2015-10-24 12:46:49 +0000 | [diff] [blame] | 632 | ArrayRef<unsigned> ProcIndices); |
Andrew Trick | dbe6d43 | 2012-10-10 05:43:13 +0000 | [diff] [blame] | 633 | |
Benjamin Kramer | 109f9e6 | 2015-10-24 12:46:49 +0000 | [diff] [blame] | 634 | void collectRWResources(ArrayRef<unsigned> Writes, ArrayRef<unsigned> Reads, |
| 635 | ArrayRef<unsigned> ProcIndices); |
Andrew Trick | 3cbd178 | 2012-09-15 00:20:02 +0000 | [diff] [blame] | 636 | |
Evandro Menezes | 8304ff2 | 2017-11-21 21:33:52 +0000 | [diff] [blame] | 637 | void addProcResource(Record *ProcResourceKind, CodeGenProcModel &PM, |
| 638 | ArrayRef<SMLoc> Loc); |
Andrew Trick | 3cbd178 | 2012-09-15 00:20:02 +0000 | [diff] [blame] | 639 | |
| 640 | void addWriteRes(Record *ProcWriteResDef, unsigned PIdx); |
| 641 | |
| 642 | void addReadAdvance(Record *ProcReadAdvanceDef, unsigned PIdx); |
Andrew Trick | 2661b41 | 2012-07-07 04:00:00 +0000 | [diff] [blame] | 643 | }; |
| 644 | |
| 645 | } // namespace llvm |
| 646 | |
| 647 | #endif |