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 14 #ifndef LLVM_MC_MCSUBTARGET_H 15 #define LLVM_MC_MCSUBTARGET_H 16 17 #include "llvm/MC/SubtargetFeature.h" 18 #include "llvm/MC/MCInstrItineraries.h" 19 #include <string> 20 21 namespace llvm { 22 23 class StringRef; 24 25 //===----------------------------------------------------------------------===// 26 /// 27 /// MCSubtargetInfo - Generic base class for all target subtargets. 28 /// 29 class MCSubtargetInfo { 30 std::string TargetTriple; // Target triple 31 const SubtargetFeatureKV *ProcFeatures; // Processor feature list 32 const SubtargetFeatureKV *ProcDesc; // Processor descriptions 33 const SubtargetInfoKV *ProcItins; // Scheduling itineraries 34 const InstrStage *Stages; // Instruction stages 35 const unsigned *OperandCycles; // Operand cycles 36 const unsigned *ForwardingPathes; // Forwarding pathes 37 unsigned NumFeatures; // Number of processor features 38 unsigned NumProcs; // Number of processors 39 uint64_t FeatureBits; // Feature bits for current CPU + FS 40 41 public: 42 void InitMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS, 43 const SubtargetFeatureKV *PF, 44 const SubtargetFeatureKV *PD, 45 const SubtargetInfoKV *PI, const InstrStage *IS, 46 const unsigned *OC, const unsigned *FP, 47 unsigned NF, unsigned NP); 48 49 /// getTargetTriple - Return the target triple string. getTargetTriple()50 StringRef getTargetTriple() const { 51 return TargetTriple; 52 } 53 54 /// getFeatureBits - Return the feature bits. 55 /// getFeatureBits()56 uint64_t getFeatureBits() const { 57 return FeatureBits; 58 } 59 60 /// ReInitMCSubtargetInfo - Change CPU (and optionally supplemented with 61 /// feature string), recompute and return feature bits. 62 uint64_t ReInitMCSubtargetInfo(StringRef CPU, StringRef FS); 63 64 /// ToggleFeature - Toggle a feature and returns the re-computed feature 65 /// bits. This version does not change the implied bits. 66 uint64_t ToggleFeature(uint64_t FB); 67 68 /// ToggleFeature - Toggle a feature and returns the re-computed feature 69 /// bits. This version will also change all implied bits. 70 uint64_t ToggleFeature(StringRef FS); 71 72 /// getInstrItineraryForCPU - Get scheduling itinerary of a CPU. 73 /// 74 InstrItineraryData getInstrItineraryForCPU(StringRef CPU) const; 75 }; 76 77 } // End llvm namespace 78 79 #endif 80