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