Compute feature bits at time of MCSubtargetInfo initialization.
authorEvan Cheng <evan.cheng@apple.com>
Thu, 7 Jul 2011 07:07:08 +0000 (07:07 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 7 Jul 2011 07:07:08 +0000 (07:07 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134606 91177308-0d34-0410-b5e6-96231b3b80d8

33 files changed:
include/llvm/MC/MCSubtargetInfo.h
include/llvm/Target/TargetRegistry.h
lib/MC/MCSubtargetInfo.cpp
lib/MC/SubtargetFeature.cpp
lib/Target/ARM/ARMSubtarget.cpp
lib/Target/ARM/ARMSubtarget.h
lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
lib/Target/Alpha/AlphaSubtarget.cpp
lib/Target/Alpha/AlphaSubtarget.h
lib/Target/Blackfin/BlackfinSubtarget.cpp
lib/Target/Blackfin/BlackfinSubtarget.h
lib/Target/CellSPU/SPUSubtarget.cpp
lib/Target/CellSPU/SPUSubtarget.h
lib/Target/MBlaze/MBlazeSubtarget.cpp
lib/Target/MBlaze/MBlazeSubtarget.h
lib/Target/MSP430/MSP430Subtarget.cpp
lib/Target/MSP430/MSP430Subtarget.h
lib/Target/Mips/MipsSubtarget.cpp
lib/Target/Mips/MipsSubtarget.h
lib/Target/PTX/PTXSubtarget.cpp
lib/Target/PTX/PTXSubtarget.h
lib/Target/PowerPC/PPCSubtarget.cpp
lib/Target/PowerPC/PPCSubtarget.h
lib/Target/Sparc/SparcSubtarget.cpp
lib/Target/Sparc/SparcSubtarget.h
lib/Target/SystemZ/SystemZSubtarget.cpp
lib/Target/SystemZ/SystemZSubtarget.h
lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
lib/Target/X86/X86Subtarget.cpp
lib/Target/X86/X86Subtarget.h
lib/Target/XCore/XCoreSubtarget.cpp
lib/Target/XCore/XCoreSubtarget.h
utils/TableGen/SubtargetEmitter.cpp

index d85527122715e67e6019725f5ad2f884f48fa72b..610a4da9d24a7e637863a9b11db228f90a3aea02 100644 (file)
@@ -34,30 +34,29 @@ class MCSubtargetInfo {
   const unsigned *ForwardingPathes;    // Forwarding pathes
   unsigned NumFeatures;                // Number of processor features
   unsigned NumProcs;                   // Number of processors
-    
+  unsigned FeatureBits;                // Feature bits for current CPU
+
 public:
-  void InitMCSubtargetInfo(const SubtargetFeatureKV *PF,
+  void InitMCSubtargetInfo(StringRef CPU, StringRef FS,
+                           const SubtargetFeatureKV *PF,
                            const SubtargetFeatureKV *PD,
                            const SubtargetInfoKV *PI, const InstrStage *IS,
                            const unsigned *OC, const unsigned *FP,
-                           unsigned NF, unsigned NP) {
-    ProcFeatures = PF;
-    ProcDesc = PD;
-    ProcItins = PI;
-    Stages = IS;
-    OperandCycles = OC;
-    ForwardingPathes = FP;
-    NumFeatures = NF;
-    NumProcs = NP;
+                           unsigned NF, unsigned NP);
+
+  /// getFeatureBits - Get the feature bits.
+  ///
+  uint64_t getFeatureBits() const {
+    return FeatureBits;
   }
 
+  /// ReInitMCSubtargetInfo - Change CPU (and optionally supplemented with
+  /// feature string), recompute and return feature bits.
+  uint64_t ReInitMCSubtargetInfo(StringRef CPU, StringRef FS);
+
   /// getInstrItineraryForCPU - Get scheduling itinerary of a CPU.
   ///
   InstrItineraryData getInstrItineraryForCPU(StringRef CPU) const;
-
-  /// getFeatureBits - Get the feature bits for a CPU (optionally supplemented
-  /// with feature string).
-  uint64_t getFeatureBits(StringRef CPU, StringRef FS) const;
 };
 
 } // End llvm namespace
index 4c7783559a72e49b13958b9363e86c6103541f4b..efc4438014c5bb124498aa3dc0bab41e1898d52c 100644 (file)
@@ -70,7 +70,9 @@ namespace llvm {
                                           StringRef TT);
     typedef MCInstrInfo *(*MCInstrInfoCtorFnTy)(void);
     typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(void);
-    typedef MCSubtargetInfo *(*MCSubtargetInfoCtorFnTy)(void);
+    typedef MCSubtargetInfo *(*MCSubtargetInfoCtorFnTy)(StringRef TT,
+                                                        StringRef CPU,
+                                                        StringRef Features);
     typedef TargetMachine *(*TargetMachineCtorTy)(const Target &T,
                                                   const std::string &TT,
                                                   const std::string &CPU,
@@ -269,10 +271,18 @@ namespace llvm {
 
     /// createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
     ///
-    MCSubtargetInfo *createMCSubtargetInfo() const {
+    /// \arg Triple - This argument is used to determine the target machine
+    /// feature set; it should always be provided. Generally this should be
+    /// either the target triple from the module, or the target triple of the
+    /// host if that does not exist.
+    /// \arg CPU - This specifies the name of the target CPU.
+    /// \arg Features - This specifies the string representation of the
+    /// additional target features.
+    MCSubtargetInfo *createMCSubtargetInfo(StringRef Triple, StringRef CPU,
+                                           StringRef Features) const {
       if (!MCSubtargetInfoCtorFn)
         return 0;
-      return MCSubtargetInfoCtorFn();
+      return MCSubtargetInfoCtorFn(Triple, CPU, Features);
     }
 
     /// createTargetMachine - Create a target specific machine implementation
@@ -824,7 +834,8 @@ namespace llvm {
       TargetRegistry::RegisterMCSubtargetInfo(T, &Allocator);
     }
   private:
-    static MCSubtargetInfo *Allocator() {
+    static MCSubtargetInfo *Allocator(StringRef TT, StringRef CPU,
+                                      StringRef FS) {
       return new MCSubtargetInfoImpl();
     }
   };
index 1874bf03bd864068034d671d7c28740e23f0ec88..3bb20b07f31d1a13bcdb7a2c6cc701026637d190 100644 (file)
 
 using namespace llvm;
 
+void MCSubtargetInfo::InitMCSubtargetInfo(StringRef CPU, StringRef FS,
+                                          const SubtargetFeatureKV *PF,
+                                          const SubtargetFeatureKV *PD,
+                                          const SubtargetInfoKV *PI,
+                                          const InstrStage *IS,
+                                          const unsigned *OC,
+                                          const unsigned *FP,
+                                          unsigned NF, unsigned NP) {
+  ProcFeatures = PF;
+  ProcDesc = PD;
+  ProcItins = PI;
+  Stages = IS;
+  OperandCycles = OC;
+  ForwardingPathes = FP;
+  NumFeatures = NF;
+  NumProcs = NP;
+
+  SubtargetFeatures Features(FS);
+  FeatureBits = Features.getFeatureBits(CPU, ProcDesc, NumProcs,
+                                        ProcFeatures, NumFeatures);
+}
+
+
+/// ReInitMCSubtargetInfo - Change CPU (and optionally supplemented with
+/// feature string) and recompute feature bits.
+uint64_t MCSubtargetInfo::ReInitMCSubtargetInfo(StringRef CPU, StringRef FS) {
+  SubtargetFeatures Features(FS);
+  FeatureBits = Features.getFeatureBits(CPU, ProcDesc, NumProcs,
+                                        ProcFeatures, NumFeatures);
+  return FeatureBits;
+}
+
 InstrItineraryData
 MCSubtargetInfo::getInstrItineraryForCPU(StringRef CPU) const {
   assert(ProcItins && "Instruction itineraries information not available!");
@@ -42,11 +74,3 @@ MCSubtargetInfo::getInstrItineraryForCPU(StringRef CPU) const {
   return InstrItineraryData(Stages, OperandCycles, ForwardingPathes,
                             (InstrItinerary *)Found->Value);
 }
-
-/// getFeatureBits - Get the feature bits for a CPU (optionally supplemented
-/// with feature string).
-uint64_t MCSubtargetInfo::getFeatureBits(StringRef CPU, StringRef FS) const {
-  SubtargetFeatures Features(FS);
-  return Features.getFeatureBits(CPU, ProcDesc, NumProcs,
-                                 ProcFeatures, NumFeatures);
-}
index b9caece47499c8ded05199a9c30f02c9614c7ead..951e0aa5b604b742f00afc2d1c7470756b0030ab 100644 (file)
@@ -231,8 +231,9 @@ uint64_t SubtargetFeatures::getFeatureBits(const StringRef CPU,
                                          size_t CPUTableSize,
                                          const SubtargetFeatureKV *FeatureTable,
                                          size_t FeatureTableSize) {
-  assert(CPUTable && "missing CPU table");
-  assert(FeatureTable && "missing features table");
+  if (!FeatureTableSize || !CPUTableSize)
+    return 0;
+
 #ifndef NDEBUG
   for (size_t i = 1; i < CPUTableSize; i++) {
     assert(strcmp(CPUTable[i - 1].Key, CPUTable[i].Key) < 0 &&
@@ -249,24 +250,27 @@ uint64_t SubtargetFeatures::getFeatureBits(const StringRef CPU,
   if (CPU == "help")
     Help(CPUTable, CPUTableSize, FeatureTable, FeatureTableSize);
   
-  // Find CPU entry
-  const SubtargetFeatureKV *CPUEntry = Find(CPU, CPUTable, CPUTableSize);
-  // If there is a match
-  if (CPUEntry) {
-    // Set base feature bits
-    Bits = CPUEntry->Value;
-
-    // Set the feature implied by this CPU feature, if any.
-    for (size_t i = 0; i < FeatureTableSize; ++i) {
-      const SubtargetFeatureKV &FE = FeatureTable[i];
-      if (CPUEntry->Value & FE.Value)
-        SetImpliedBits(Bits, &FE, FeatureTable, FeatureTableSize);
+  // Find CPU entry if CPU name is specified.
+  if (!CPU.empty()) {
+    const SubtargetFeatureKV *CPUEntry = Find(CPU, CPUTable, CPUTableSize);
+    // If there is a match
+    if (CPUEntry) {
+      // Set base feature bits
+      Bits = CPUEntry->Value;
+
+      // Set the feature implied by this CPU feature, if any.
+      for (size_t i = 0; i < FeatureTableSize; ++i) {
+        const SubtargetFeatureKV &FE = FeatureTable[i];
+        if (CPUEntry->Value & FE.Value)
+          SetImpliedBits(Bits, &FE, FeatureTable, FeatureTableSize);
+      }
+    } else {
+      errs() << "'" << CPU
+             << "' is not a recognized processor for this target"
+             << " (ignoring processor)\n";
     }
-  } else {
-    errs() << "'" << CPU
-           << "' is not a recognized processor for this target"
-           << " (ignoring processor)\n";
   }
+
   // Iterate through each feature
   for (size_t i = 0, E = Features.size(); i < E; i++) {
     const StringRef Feature = Features[i];
index 4affc157152878dc8a40fe47c8c895ea693647a1..12f12ad862d3c64edb589df7a70814fb5615600a 100644 (file)
@@ -38,7 +38,7 @@ StrictAlign("arm-strict-align", cl::Hidden,
 
 ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU,
                            const std::string &FS)
-  : ARMGenSubtargetInfo()
+  : ARMGenSubtargetInfo(TT, CPU, FS)
   , ARMProcFamily(Others)
   , HasV4TOps(false)
   , HasV5TOps(false)
@@ -78,9 +78,6 @@ ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU,
   if (CPUString.empty())
     CPUString = "generic";
 
-  if (TT.find("eabi") != std::string::npos)
-    TargetABI = ARM_ABI_AAPCS;
-
   // Insert the architecture feature derived from the target triple into the
   // feature string. This is important for setting features that are implied
   // based on the architecture version.
@@ -92,7 +89,7 @@ ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU,
       ArchFS = FS;
   }
 
-  ParseSubtargetFeatures(ArchFS, CPUString);
+  ParseSubtargetFeatures(CPUString, ArchFS);
 
   // Thumb2 implies at least V6T2. FIXME: Fix tests to explicitly specify a
   // ARM version or CPU and then remove this.
@@ -105,6 +102,9 @@ ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU,
   // After parsing Itineraries, set ItinData.IssueWidth.
   computeIssueWidth();
 
+  if (TT.find("eabi") != std::string::npos)
+    TargetABI = ARM_ABI_AAPCS;
+
   if (isAAPCS_ABI())
     stackAlignment = 8;
 
index 5fad9a777d6d73f821734d92ef2ea0a38e98584c..a199f2bfe35eaf3980db0dad3612af00b18904c2 100644 (file)
@@ -25,6 +25,7 @@
 
 namespace llvm {
 class GlobalValue;
+class StringRef;
 
 class ARMSubtarget : public ARMGenSubtargetInfo {
 protected:
@@ -168,7 +169,7 @@ protected:
   }
   /// ParseSubtargetFeatures - Parses features string setting specified
   /// subtarget options.  Definition of function is auto generated by tblgen.
-  void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
+  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
 
   void computeIssueWidth();
 
index 2d5c219ae48ce2cf42c017782741fa3cc17f2c2d..402ab4e46b67ba15e250ea1c2361892c0a4d7a4b 100644 (file)
@@ -40,9 +40,10 @@ MCRegisterInfo *createARMMCRegisterInfo() {
   return X;
 }
 
-MCSubtargetInfo *createARMMCSubtargetInfo() {
+MCSubtargetInfo *createARMMCSubtargetInfo(StringRef TT, StringRef CPU,
+                                          StringRef FS) {
   MCSubtargetInfo *X = new MCSubtargetInfo();
-  InitARMMCSubtargetInfo(X);
+  InitARMMCSubtargetInfo(X, CPU, FS);
   return X;
 }
 
index fce65fc570bca8b6cdf358588229316a9479fb67..000f606acaf4571b3f0019aeee56bbcc426568fa 100644 (file)
@@ -23,13 +23,13 @@ using namespace llvm;
 
 AlphaSubtarget::AlphaSubtarget(const std::string &TT, const std::string &CPU,
                                const std::string &FS)
-  : AlphaGenSubtargetInfo(), HasCT(false) {
+  : AlphaGenSubtargetInfo(TT, CPU, FS), HasCT(false) {
   std::string CPUName = CPU;
   if (CPUName.empty())
     CPUName = "generic";
 
   // Parse features string.
-  ParseSubtargetFeatures(FS, CPUName);
+  ParseSubtargetFeatures(CPUName, FS);
 
   // Initialize scheduling itinerary for the specified CPU.
   InstrItins = getInstrItineraryForCPU(CPUName);
index 847d4956e11851532666681f60a66518b2f659e1..70b311683f8bbedc9337a77e4d6ad620a921f178 100644 (file)
@@ -22,6 +22,7 @@
 #include "AlphaGenSubtargetInfo.inc"
 
 namespace llvm {
+class StringRe;
 
 class AlphaSubtarget : public AlphaGenSubtargetInfo {
 protected:
@@ -39,7 +40,7 @@ public:
   
   /// ParseSubtargetFeatures - Parses features string setting specified 
   /// subtarget options.  Definition of function is auto generated by tblgen.
-  void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
+  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
 
   bool hasCT() const { return HasCT; }
 };
index 9d1d4816d3d54eb42594f34308ed780a6cf75282..696bb877595806abd5dc40f2e79b855d0e216472 100644 (file)
@@ -23,7 +23,7 @@ using namespace llvm;
 BlackfinSubtarget::BlackfinSubtarget(const std::string &TT,
                                      const std::string &CPU,
                                      const std::string &FS)
-  : BlackfinGenSubtargetInfo(), sdram(false),
+  : BlackfinGenSubtargetInfo(TT, CPU, FS), sdram(false),
     icplb(false),
     wa_mi_shift(false),
     wa_csync(false),
@@ -39,5 +39,5 @@ BlackfinSubtarget::BlackfinSubtarget(const std::string &TT,
   if (CPUName.empty())
     CPUName = "generic";
   // Parse features string.
-  ParseSubtargetFeatures(FS, CPUName);
+  ParseSubtargetFeatures(CPUName, FS);
 }
index a7d6c16261223da8696782387c619122ded408fe..1a01a81116d67e80c931d494d316fcfc345049c7 100644 (file)
@@ -21,6 +21,7 @@
 #include "BlackfinGenSubtargetInfo.inc"
 
 namespace llvm {
+class StringRef;
 
   class BlackfinSubtarget : public BlackfinGenSubtargetInfo {
     bool sdram;
@@ -40,8 +41,7 @@ namespace llvm {
 
     /// ParseSubtargetFeatures - Parses features string setting specified
     /// subtarget options.  Definition of function is auto generated by tblgen.
-    void ParseSubtargetFeatures(const std::string &FS,
-                                       const std::string &CPU);
+    void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
   };
 
 } // end namespace llvm
index 2481e3b9fc9ca0aa55824b7890a4afba144f5ed3..cb94d281c66e2e5824fa1c2fbaabddc39826a086 100644 (file)
@@ -25,7 +25,7 @@ using namespace llvm;
 
 SPUSubtarget::SPUSubtarget(const std::string &TT, const std::string &CPU,
                            const std::string &FS) :
-  SPUGenSubtargetInfo(),
+  SPUGenSubtargetInfo(TT, CPU, FS),
   StackAlignment(16),
   ProcDirective(SPU::DEFAULT_PROC),
   UseLargeMem(false)
@@ -35,7 +35,7 @@ SPUSubtarget::SPUSubtarget(const std::string &TT, const std::string &CPU,
   std::string default_cpu("v0");
 
   // Parse features string.
-  ParseSubtargetFeatures(FS, default_cpu);
+  ParseSubtargetFeatures(default_cpu, FS);
 
   // Initialize scheduling itinerary for the specified CPU.
   InstrItins = getInstrItineraryForCPU(default_cpu);
index 19b97d3a0c79adc4b8d20b1ad59826bfa3228a61..7c4aa143021751d263bb24e4f9eea13fd79467e9 100644 (file)
@@ -23,6 +23,7 @@
 
 namespace llvm {
   class GlobalValue;
+  class StringRef;
 
   namespace SPU {
     enum {
@@ -57,7 +58,7 @@ namespace llvm {
     
     /// ParseSubtargetFeatures - Parses features string setting specified 
     /// subtarget options.  Definition of function is auto generated by tblgen.
-    void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
+    void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
 
     /// SetJITMode - This is called to inform the subtarget info that we are
     /// producing code for the JIT.
index 81578ce07a2b7b51a217eefca5fc96f05ac231a1..8e706cd4c73c43789ea862392529bda30c2bb7b5 100644 (file)
@@ -26,7 +26,7 @@ using namespace llvm;
 MBlazeSubtarget::MBlazeSubtarget(const std::string &TT,
                                  const std::string &CPU,
                                  const std::string &FS):
-  MBlazeGenSubtargetInfo(),
+  MBlazeGenSubtargetInfo(TT, CPU, FS),
   HasBarrel(false), HasDiv(false), HasMul(false), HasPatCmp(false),
   HasFPU(false), HasMul64(false), HasSqrt(false)
 {
@@ -34,7 +34,7 @@ MBlazeSubtarget::MBlazeSubtarget(const std::string &TT,
   std::string CPUName = CPU;
   if (CPUName.empty())
     CPUName = "mblaze";
-  ParseSubtargetFeatures(FS, CPUName);
+  ParseSubtargetFeatures(CPUName, FS);
 
   // Only use instruction scheduling if the selected CPU has an instruction
   // itinerary (the default CPU is the only one that doesn't).
index 7d70040423212403f3d724e67361e558e460b586..43b0197ad5aad25dceaf1256054f015a286037b6 100644 (file)
@@ -22,6 +22,7 @@
 #include "MBlazeGenSubtargetInfo.inc"
 
 namespace llvm {
+class StringRef;
 
 class MBlazeSubtarget : public MBlazeGenSubtargetInfo {
 
@@ -46,7 +47,7 @@ public:
 
   /// ParseSubtargetFeatures - Parses features string setting specified
   /// subtarget options.  Definition of function is auto generated by tblgen.
-  void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
+  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
 
   /// Compute the number of maximum number of issues per cycle for the
   /// MBlaze scheduling itineraries.
index bd8d7cda37f14cfc5c0251510309d90379d251f1..42cc88229585cda85f1c1f4b5ee0069b17e95002 100644 (file)
 using namespace llvm;
 
 MSP430Subtarget::MSP430Subtarget(const std::string &TT,
-                                 const std::string &CPUIgnored,
-                                 const std::string &FS) {
-  std::string CPU = "generic";
+                                 const std::string &CPU,
+                                 const std::string &FS) :
+  MSP430GenSubtargetInfo(TT, CPU, FS) {
+  std::string CPUName = "generic";
 
   // Parse features string.
-  ParseSubtargetFeatures(FS, CPU);
+  ParseSubtargetFeatures(CPUName, FS);
 }
index ead213bcaedbc9ce344336a0a8c0f9daa138de70..1ce5f11fe1bb0a4a6a5e90e49424eba1240db0bb 100644 (file)
@@ -22,6 +22,7 @@
 #include <string>
 
 namespace llvm {
+class StringRef;
 
 class MSP430Subtarget : public MSP430GenSubtargetInfo {
   bool ExtendedInsts;
@@ -34,7 +35,7 @@ public:
 
   /// ParseSubtargetFeatures - Parses features string setting specified
   /// subtarget options.  Definition of function is auto generated by tblgen.
-  void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
+  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
 };
 } // End llvm namespace
 
index a96f872b7ce27efbc8e3143c8806ef6501c20650..7a5d417ce647b07e25e407f97cbfba1ff9c22b80 100644 (file)
@@ -23,7 +23,7 @@ using namespace llvm;
 
 MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU,
                              const std::string &FS, bool little) :
-  MipsGenSubtargetInfo(),
+  MipsGenSubtargetInfo(TT, CPU, FS),
   MipsArchVersion(Mips1), MipsABI(O32), IsLittle(little), IsSingleFloat(false),
   IsFP64bit(false), IsGP64bit(false), HasVFPU(false), IsLinux(true),
   HasSEInReg(false), HasCondMov(false), HasMulDivAdd(false), HasMinMax(false),
@@ -35,7 +35,7 @@ MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU,
   MipsArchVersion = Mips1;
 
   // Parse features string.
-  ParseSubtargetFeatures(FS, CPUName);
+  ParseSubtargetFeatures(CPUName, FS);
 
   // Initialize scheduling itinerary for the specified CPU.
   InstrItins = getInstrItineraryForCPU(CPUName);
index ae76470f5e3cf671884bfc413f03e16722de327b..533d4afe073ee21a8f58c42d6d52a8633a28f50a 100644 (file)
@@ -22,6 +22,7 @@
 #include "MipsGenSubtargetInfo.inc"
 
 namespace llvm {
+class StringRef;
 
 class MipsSubtarget : public MipsGenSubtargetInfo {
 
@@ -99,7 +100,7 @@ public:
 
   /// ParseSubtargetFeatures - Parses features string setting specified
   /// subtarget options.  Definition of function is auto generated by tblgen.
-  void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
+  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
 
   bool isMips1() const { return MipsArchVersion == Mips1; }
   bool isMips32() const { return MipsArchVersion >= Mips32; }
index 5eff24a2b0556e5519bb5d46a5139fd33c387e71..846eee1792d321ee91e02f188731bfe6977e11e7 100644 (file)
@@ -23,7 +23,7 @@ using namespace llvm;
 
 PTXSubtarget::PTXSubtarget(const std::string &TT, const std::string &CPU,
                            const std::string &FS, bool is64Bit)
-  : PTXGenSubtargetInfo(),
+  : PTXGenSubtargetInfo(TT, CPU, FS),
     PTXTarget(PTX_COMPUTE_1_0),
     PTXVersion(PTX_VERSION_2_0),
     SupportsDouble(false),
@@ -32,7 +32,7 @@ PTXSubtarget::PTXSubtarget(const std::string &TT, const std::string &CPU,
   std::string TARGET = CPU;
   if (TARGET.empty())
     TARGET = "generic";
-  ParseSubtargetFeatures(FS, TARGET);
+  ParseSubtargetFeatures(TARGET, FS);
 }
 
 std::string PTXSubtarget::getTargetString() const {
index 913f0a2da3979a55159347a0cf0cbaedd41aca3c..0921f1f22c49b472165aa7e55bb8a5fd6e4e8c42 100644 (file)
@@ -20,6 +20,8 @@
 #include "PTXGenSubtargetInfo.inc"
 
 namespace llvm {
+class StringRef;
+
   class PTXSubtarget : public PTXGenSubtargetInfo {
     public:
 
@@ -112,8 +114,7 @@ namespace llvm {
                (PTXTarget >= PTX_COMPUTE_2_0 && PTXTarget < PTX_LAST_COMPUTE);
       }
 
-      void ParseSubtargetFeatures(const std::string &FS,
-                                  const std::string &CPU);
+    void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
   }; // class PTXSubtarget
 } // namespace llvm
 
index 75ee1c0990aad854e7a013288f3331887eef9aa7..7eeeaf59eccccd997d76a41a8d5ed8be37f1d84f 100644 (file)
@@ -64,7 +64,7 @@ static const char *GetCurrentPowerPCCPU() {
 
 PPCSubtarget::PPCSubtarget(const std::string &TT, const std::string &CPU,
                            const std::string &FS, bool is64Bit)
-  : PPCGenSubtargetInfo()
+  : PPCGenSubtargetInfo(TT, CPU, FS)
   , StackAlignment(16)
   , DarwinDirective(PPC::DIR_NONE)
   , IsGigaProcessor(false)
@@ -88,7 +88,7 @@ PPCSubtarget::PPCSubtarget(const std::string &TT, const std::string &CPU,
 #endif
 
   // Parse features string.
-  ParseSubtargetFeatures(FS, CPUName);
+  ParseSubtargetFeatures(CPUName, FS);
 
   // Initialize scheduling itinerary for the specified CPU.
   InstrItins = getInstrItineraryForCPU(CPUName);
index c89f922a5b653247d7c2551a65c84554288d3e50..e028de6b09de3d183e7d858b959447b663e04281 100644 (file)
@@ -26,6 +26,7 @@
 #undef PPC
 
 namespace llvm {
+class StringRef;
 
 namespace PPC {
   // -m directive values.
@@ -80,8 +81,7 @@ public:
   
   /// ParseSubtargetFeatures - Parses features string setting specified 
   /// subtarget options.  Definition of function is auto generated by tblgen.
-  void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
-
+  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
   
   /// SetJITMode - This is called to inform the subtarget info that we are
   /// producing code for the JIT.
index ee3cc03f13a021618b20a47c0bec88a4c27f0226..c8281ceaaf94d29021803d44b55a6113e70f05a3 100644 (file)
@@ -22,7 +22,7 @@ using namespace llvm;
 
 SparcSubtarget::SparcSubtarget(const std::string &TT, const std::string &CPU,
                                const std::string &FS,  bool is64Bit) :
-  SparcGenSubtargetInfo(),
+  SparcGenSubtargetInfo(TT, CPU, FS),
   IsV9(false),
   V8DeprecatedInsts(false),
   IsVIS(false),
@@ -39,5 +39,5 @@ SparcSubtarget::SparcSubtarget(const std::string &TT, const std::string &CPU,
   IsV9 = CPUName == "v9";
 
   // Parse features string.
-  ParseSubtargetFeatures(FS, CPUName);
+  ParseSubtargetFeatures(CPUName, FS);
 }
index 257f22ad461be8fd5adc161cd79b7219c5dabded..00a04c3bea57e62942a7257429baaa3b7f3559a8 100644 (file)
@@ -21,6 +21,7 @@
 #include "SparcGenSubtargetInfo.inc"
 
 namespace llvm {
+class StringRef;
 
 class SparcSubtarget : public SparcGenSubtargetInfo {
   bool IsV9;
@@ -38,7 +39,7 @@ public:
   
   /// ParseSubtargetFeatures - Parses features string setting specified 
   /// subtarget options.  Definition of function is auto generated by tblgen.
-  void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
+  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
   
   bool is64Bit() const { return Is64Bit; }
   std::string getDataLayout() const {
index 4388109fb1149407f1e00e21545967da9cc9b3b2..518c09f260235083791d96bbce7dfa39879b7459 100644 (file)
@@ -26,13 +26,13 @@ using namespace llvm;
 SystemZSubtarget::SystemZSubtarget(const std::string &TT, 
                                    const std::string &CPU,
                                    const std::string &FS):
-  SystemZGenSubtargetInfo(), HasZ10Insts(false) {
+  SystemZGenSubtargetInfo(TT, CPU, FS), HasZ10Insts(false) {
   std::string CPUName = CPU;
   if (CPUName.empty())
     CPUName = "z9";
 
   // Parse features string.
-  ParseSubtargetFeatures(FS, CPUName);
+  ParseSubtargetFeatures(CPUName, FS);
 }
 
 /// True if accessing the GV requires an extra load.
index 6ac606a53cc0cc59c92b2edeb051d8609124c5fb..55cfd80002bc955ecb2de36b78f872893073c2de 100644 (file)
@@ -22,6 +22,7 @@
 
 namespace llvm {
 class GlobalValue;
+class StringRef;
 class TargetMachine;
 
 class SystemZSubtarget : public SystemZGenSubtargetInfo {
@@ -35,7 +36,7 @@ public:
 
   /// ParseSubtargetFeatures - Parses features string setting specified
   /// subtarget options.  Definition of function is auto generated by tblgen.
-  void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
+  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
 
   bool isZ10() const { return HasZ10Insts; }
 
index f24c356fc71938aad21e8c86b6ae5672b49064d5..0f6b579ace518f2b00179b94f14e27d006979067 100644 (file)
@@ -40,9 +40,10 @@ MCRegisterInfo *createX86MCRegisterInfo() {
   return X;
 }
 
-MCSubtargetInfo *createX86MCSubtargetInfo() {
+MCSubtargetInfo *createX86MCSubtargetInfo(StringRef TT, StringRef CPU,
+                                          StringRef FS) {
   MCSubtargetInfo *X = new MCSubtargetInfo();
-  InitX86MCSubtargetInfo(X);
+  InitX86MCSubtargetInfo(X, CPU, FS);
   return X;
 }
 
index a1e6d7be984800a26dd7e4499ef08ce744bf5118..1c1a10d56ffda3efaa1a1b26dc2d14c8d38be0b4 100644 (file)
@@ -292,7 +292,7 @@ void X86Subtarget::AutoDetectSubtargetFeatures() {
 X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,
                            const std::string &FS, 
                            bool is64Bit, unsigned StackAlignOverride)
-  : X86GenSubtargetInfo()
+  : X86GenSubtargetInfo(TT, CPU, FS)
   , PICStyle(PICStyles::None)
   , X86SSELevel(NoMMXSSE)
   , X863DNowLevel(NoThreeDNow)
@@ -320,7 +320,7 @@ X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,
     std::string CPUName = CPU;
     if (CPUName.empty())
       CPUName = sys::getHostCPUName();
-    ParseSubtargetFeatures(FS, CPUName);
+    ParseSubtargetFeatures(CPUName, FS);
     // All X86-64 CPUs also have SSE2, however user might request no SSE via 
     // -mattr, so don't force SSELevel here.
     if (HasAVX)
index d49b87177525e1133561711c2a710d45aa014111..f6250b6ecf16d9821a18aad9a2045c3409c103b0 100644 (file)
@@ -24,6 +24,7 @@
 
 namespace llvm {
 class GlobalValue;
+class StringRef;
 class TargetMachine;
 
 /// PICStyles - The X86 backend supports a number of different styles of PIC.
@@ -135,7 +136,7 @@ public:
 
   /// ParseSubtargetFeatures - Parses features string setting specified
   /// subtarget options.  Definition of function is auto generated by tblgen.
-  void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
+  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
 
   /// AutoDetectSubtargetFeatures - Auto-detect CPU features using CPUID
   /// instruction.
index 6485c4ee6d6470a9bd8ab3d8e55981eccb032202..c727183c9a4d3268b83831f7db6b5f9ef066637c 100644 (file)
@@ -23,6 +23,6 @@ using namespace llvm;
 
 XCoreSubtarget::XCoreSubtarget(const std::string &TT,
                                const std::string &CPU, const std::string &FS)
-  : XCoreGenSubtargetInfo()
+  : XCoreGenSubtargetInfo(TT, CPU, FS)
 {
 }
index 2e52571e2a3cf042d43d347b89e83765ca477123..7b29fa2367106d5451cf3bb259809c8fae32a483 100644 (file)
@@ -22,6 +22,7 @@
 #include "XCoreGenSubtargetInfo.inc"
 
 namespace llvm {
+class StringRef;
 
 class XCoreSubtarget : public XCoreGenSubtargetInfo {
 
@@ -34,7 +35,7 @@ public:
   
   /// ParseSubtargetFeatures - Parses features string setting specified 
   /// subtarget options.  Definition of function is auto generated by tblgen.
-  void ParseSubtargetFeatures(const std::string &FS, const std::string &CPU);
+  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
 };
 } // End llvm namespace
 
index df0425eeba35a6f2c8c765e96f7ebca4eb382cec..929b42b8d12ae59edfbb818b23495e90b2d168e5 100644 (file)
@@ -605,8 +605,7 @@ void SubtargetEmitter::ParseFeaturesFunction(raw_ostream &OS,
      << "// subtarget options.\n"
      << "void llvm::";
   OS << Target;
-  OS << "Subtarget::ParseSubtargetFeatures(const std::string &FS,\n"
-     << "                                  const std::string &CPU) {\n"
+  OS << "Subtarget::ParseSubtargetFeatures(StringRef CPU, StringRef FS) {\n"
      << "  DEBUG(dbgs() << \"\\nFeatures:\" << FS);\n"
      << "  DEBUG(dbgs() << \"\\nCPU:\" << CPU);\n";
 
@@ -615,11 +614,7 @@ void SubtargetEmitter::ParseFeaturesFunction(raw_ostream &OS,
     return;
   }
 
-  OS << "  SubtargetFeatures Features(FS);\n"
-     << "  uint64_t Bits =  Features.getFeatureBits(CPU, "
-     << Target << "SubTypeKV, " << NumProcs << ",\n"
-     << "                                    " << Target << "FeatureKV, "
-     << NumFeatures << ");\n";
+  OS << "  uint64_t Bits = ReInitMCSubtargetInfo(CPU, FS);\n";
 
   for (unsigned i = 0; i < Features.size(); i++) {
     // Next record
@@ -629,10 +624,12 @@ void SubtargetEmitter::ParseFeaturesFunction(raw_ostream &OS,
     const std::string &Attribute = R->getValueAsString("Attribute");
 
     if (Value=="true" || Value=="false")
-      OS << "  if ((Bits & " << Target << "::" << Instance << ") != 0) "
+      OS << "  if ((Bits & " << Target << "::"
+         << Instance << ") != 0) "
          << Attribute << " = " << Value << ";\n";
     else
-      OS << "  if ((Bits & " << Target << "::" << Instance << ") != 0 && "
+      OS << "  if ((Bits & " << Target << "::"
+         << Instance << ") != 0 && "
          << Attribute << " < " << Value << ") "
          << Attribute << " = " << Value << ";\n";
   }
@@ -663,8 +660,8 @@ void SubtargetEmitter::run(raw_ostream &OS) {
 
   // MCInstrInfo initialization routine.
   OS << "static inline void Init" << Target
-     << "MCSubtargetInfo(MCSubtargetInfo *II) {\n";
-  OS << "  II->InitMCSubtargetInfo(";
+     << "MCSubtargetInfo(MCSubtargetInfo *II, StringRef CPU, StringRef FS) {\n";
+  OS << "  II->InitMCSubtargetInfo(CPU, FS, ";
   if (NumFeatures)
     OS << Target << "FeatureKV, ";
   else
@@ -702,7 +699,8 @@ void SubtargetEmitter::run(raw_ostream &OS) {
   std::string ClassName = Target + "GenSubtargetInfo";
   OS << "namespace llvm {\n";
   OS << "struct " << ClassName << " : public TargetSubtargetInfo {\n"
-     << "  explicit " << ClassName << "();\n"
+     << "  explicit " << ClassName << "(StringRef TT, StringRef CPU, "
+     << "StringRef FS);\n"
      << "};\n";
   OS << "} // End llvm namespace \n";
 
@@ -712,9 +710,10 @@ void SubtargetEmitter::run(raw_ostream &OS) {
   OS << "#undef GET_SUBTARGETINFO_CTOR\n";
 
   OS << "namespace llvm {\n";
-  OS << ClassName << "::" << ClassName << "()\n"
+  OS << ClassName << "::" << ClassName << "(StringRef TT, StringRef CPU, "
+     << "StringRef FS)\n"
      << "  : TargetSubtargetInfo() {\n"
-     << "  InitMCSubtargetInfo(";
+     << "  InitMCSubtargetInfo(CPU, FS, ";
   if (NumFeatures)
     OS << Target << "FeatureKV, ";
   else