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