Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
5.1 KiB

  1. //==-- llvm/MC/MCSubtargetInfo.h - Subtarget Information ---------*- 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 describes the subtarget options of a Target machine.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_MC_MCSUBTARGET_H
  14. #define LLVM_MC_MCSUBTARGET_H
  15. #include "llvm/MC/MCInstrItineraries.h"
  16. #include "llvm/MC/SubtargetFeature.h"
  17. #include <string>
  18. namespace llvm {
  19. class StringRef;
  20. //===----------------------------------------------------------------------===//
  21. ///
  22. /// MCSubtargetInfo - Generic base class for all target subtargets.
  23. ///
  24. class MCSubtargetInfo {
  25. std::string TargetTriple; // Target triple
  26. const SubtargetFeatureKV *ProcFeatures; // Processor feature list
  27. const SubtargetFeatureKV *ProcDesc; // Processor descriptions
  28. // Scheduler machine model
  29. const SubtargetInfoKV *ProcSchedModels;
  30. const MCWriteProcResEntry *WriteProcResTable;
  31. const MCWriteLatencyEntry *WriteLatencyTable;
  32. const MCReadAdvanceEntry *ReadAdvanceTable;
  33. const MCSchedModel *CPUSchedModel;
  34. const InstrStage *Stages; // Instruction itinerary stages
  35. const unsigned *OperandCycles; // Itinerary operand cycles
  36. const unsigned *ForwardingPaths; // Forwarding paths
  37. unsigned NumFeatures; // Number of processor features
  38. unsigned NumProcs; // Number of processors
  39. uint64_t FeatureBits; // Feature bits for current CPU + FS
  40. public:
  41. void InitMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS,
  42. const SubtargetFeatureKV *PF,
  43. const SubtargetFeatureKV *PD,
  44. const SubtargetInfoKV *ProcSched,
  45. const MCWriteProcResEntry *WPR,
  46. const MCWriteLatencyEntry *WL,
  47. const MCReadAdvanceEntry *RA,
  48. const InstrStage *IS,
  49. const unsigned *OC, const unsigned *FP,
  50. unsigned NF, unsigned NP);
  51. /// getTargetTriple - Return the target triple string.
  52. StringRef getTargetTriple() const {
  53. return TargetTriple;
  54. }
  55. /// getFeatureBits - Return the feature bits.
  56. ///
  57. uint64_t getFeatureBits() const {
  58. return FeatureBits;
  59. }
  60. /// InitMCProcessorInfo - Set or change the CPU (optionally supplemented with
  61. /// feature string). Recompute feature bits and scheduling model.
  62. void InitMCProcessorInfo(StringRef CPU, StringRef FS);
  63. /// ToggleFeature - Toggle a feature and returns the re-computed feature
  64. /// bits. This version does not change the implied bits.
  65. uint64_t ToggleFeature(uint64_t FB);
  66. /// ToggleFeature - Toggle a feature and returns the re-computed feature
  67. /// bits. This version will also change all implied bits.
  68. uint64_t ToggleFeature(StringRef FS);
  69. /// getSchedModelForCPU - Get the machine model of a CPU.
  70. ///
  71. const MCSchedModel *getSchedModelForCPU(StringRef CPU) const;
  72. /// getSchedModel - Get the machine model for this subtarget's CPU.
  73. ///
  74. const MCSchedModel *getSchedModel() const { return CPUSchedModel; }
  75. /// Return an iterator at the first process resource consumed by the given
  76. /// scheduling class.
  77. const MCWriteProcResEntry *getWriteProcResBegin(
  78. const MCSchedClassDesc *SC) const {
  79. return &WriteProcResTable[SC->WriteProcResIdx];
  80. }
  81. const MCWriteProcResEntry *getWriteProcResEnd(
  82. const MCSchedClassDesc *SC) const {
  83. return getWriteProcResBegin(SC) + SC->NumWriteProcResEntries;
  84. }
  85. const MCWriteLatencyEntry *getWriteLatencyEntry(const MCSchedClassDesc *SC,
  86. unsigned DefIdx) const {
  87. assert(DefIdx < SC->NumWriteLatencyEntries &&
  88. "MachineModel does not specify a WriteResource for DefIdx");
  89. return &WriteLatencyTable[SC->WriteLatencyIdx + DefIdx];
  90. }
  91. int getReadAdvanceCycles(const MCSchedClassDesc *SC, unsigned UseIdx,
  92. unsigned WriteResID) const {
  93. // TODO: The number of read advance entries in a class can be significant
  94. // (~50). Consider compressing the WriteID into a dense ID of those that are
  95. // used by ReadAdvance and representing them as a bitset.
  96. for (const MCReadAdvanceEntry *I = &ReadAdvanceTable[SC->ReadAdvanceIdx],
  97. *E = I + SC->NumReadAdvanceEntries; I != E; ++I) {
  98. if (I->UseIdx < UseIdx)
  99. continue;
  100. if (I->UseIdx > UseIdx)
  101. break;
  102. // Find the first WriteResIdx match, which has the highest cycle count.
  103. if (!I->WriteResourceID || I->WriteResourceID == WriteResID) {
  104. return I->Cycles;
  105. }
  106. }
  107. return 0;
  108. }
  109. /// getInstrItineraryForCPU - Get scheduling itinerary of a CPU.
  110. ///
  111. InstrItineraryData getInstrItineraryForCPU(StringRef CPU) const;
  112. /// Initialize an InstrItineraryData instance.
  113. void initInstrItins(InstrItineraryData &InstrItins) const;
  114. };
  115. } // End llvm namespace
  116. #endif