Propagate CPU string out of SubtargetFeatures
authorAnton Korobeynikov <asl@math.spbu.ru>
Sat, 23 May 2009 19:50:50 +0000 (19:50 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Sat, 23 May 2009 19:50:50 +0000 (19:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72335 91177308-0d34-0410-b5e6-96231b3b80d8

14 files changed:
include/llvm/Target/SubtargetFeature.h
lib/Target/ARM/ARMSubtarget.cpp
lib/Target/ARM/ARMSubtarget.h
lib/Target/Alpha/AlphaSubtarget.h
lib/Target/CellSPU/SPUSubtarget.h
lib/Target/MSP430/MSP430Subtarget.h
lib/Target/Mips/MipsSubtarget.h
lib/Target/PIC16/PIC16Subtarget.h
lib/Target/PowerPC/PPCSubtarget.h
lib/Target/Sparc/SparcSubtarget.h
lib/Target/SubtargetFeature.cpp
lib/Target/X86/X86Subtarget.h
lib/Target/XCore/XCoreSubtarget.h
utils/TableGen/SubtargetEmitter.cpp

index d187daac0c89c71d926c3a42c6745639be9d1940..5cfdc023d43990dcb9cc48f81b45e32bfce599dc 100644 (file)
@@ -82,10 +82,13 @@ public:
 
   /// Set the CPU string.  Replaces previous setting.  Setting to "" clears CPU.
   void setCPU(const std::string &String);
-  
+
   /// Setting CPU string only if no string is set.
   void setCPUIfNone(const std::string &String);
-  
+
+  /// Returns current CPU string.
+  const std::string & getCPU() const;
+
   /// Adding Features.
   void AddFeature(const std::string &String, bool IsEnabled = true);
            
index 2415a85051aa47cb416b7e17bf786a03b9861463..7379f1c39d8970a856f5af735ea36d00cea493d7 100644 (file)
@@ -23,14 +23,13 @@ ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS, bool thumb)
   , UseThumbBacktraces(false)
   , IsR9Reserved(false)
   , stackAlignment(4)
+  , CPUString("generic")
   , TargetType(isELF) // Default to ELF unless otherwise specified.
   , TargetABI(ARM_ABI_APCS) {
-
   // Determine default and user specified characteristics
-  std::string CPU = "generic";
 
   // Parse features string.
-  ParseSubtargetFeatures(FS, CPU);
+  CPUString = ParseSubtargetFeatures(FS, CPUString);
 
   // Set the boolean corresponding to the current target triple, or the default
   // if one cannot be determined, to true.
index fbc9e579df1c133da3ef7285f3bd06685b2fadd6..870a8c7fbcdaf1b7f035db1d3619ca57bbf983d8 100644 (file)
@@ -47,6 +47,9 @@ protected:
   /// entry to the function and which must be maintained by every function.
   unsigned stackAlignment;
 
+  /// CPUString - String name of used CPU.
+  std::string CPUString;
+
  public:
   enum {
     isELF, isDarwin
@@ -71,7 +74,8 @@ 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);
+  std::string ParseSubtargetFeatures(const std::string &FS,
+                                     const std::string &CPU);
 
   bool hasV4TOps()  const { return ARMArchVersion >= V4T; }
   bool hasV5TOps()  const { return ARMArchVersion >= V5T; }
@@ -79,7 +83,7 @@ protected:
   bool hasV6Ops()   const { return ARMArchVersion >= V6; }
 
   bool hasVFP2() const { return HasVFP2; }
-  
+
   bool isTargetDarwin() const { return TargetType == isDarwin; }
   bool isTargetELF() const { return TargetType == isELF; }
 
@@ -91,6 +95,8 @@ protected:
   bool useThumbBacktraces() const { return UseThumbBacktraces; }
   bool isR9Reserved() const { return IsR9Reserved; }
 
+  const std::string & getCPUString() const { return CPUString; }
+
   /// getStackAlignment - Returns the minimum alignment known to hold of the
   /// stack frame on entry to the function and which must be maintained by every
   /// function for this subtarget.
index bcbb62813e499ada2381049a24b92365203aa4a4..0a944cb0a634b96c36865d5c992af4635581ddd6 100644 (file)
@@ -37,7 +37,8 @@ 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);
+  std::string ParseSubtargetFeatures(const std::string &FS,
+                                     const std::string &CPU);
 
   bool hasCT() const { return HasCT; }
 };
index 695ec94fee2a401b28a8dbaad7d843c235c4d587..b6a34099b2f7df832ba6dc2b1e3dc7ccebf551dc 100644 (file)
@@ -59,8 +59,9 @@ 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);
-    
+    std::string ParseSubtargetFeatures(const std::string &FS,
+                                       const std::string &CPU);
+
     /// SetJITMode - This is called to inform the subtarget info that we are
     /// producing code for the JIT.
     void SetJITMode();
index c7b8101671b314e831799f9d9268d0e4f6968c91..96c8108b71bc83fd78f197d0a130feefcfb391a8 100644 (file)
@@ -33,7 +33,8 @@ 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);
+  std::string ParseSubtargetFeatures(const std::string &FS,
+                                     const std::string &CPU);
 };
 } // End llvm namespace
 
index 656199a69ac3e560ae3a6d9c3a2581983592d089..62d5e969ee2bdcf22252ec7da199af833b2cad82 100644 (file)
@@ -109,7 +109,8 @@ 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);
+  std::string ParseSubtargetFeatures(const std::string &FS,
+                                     const std::string &CPU);
 
   bool hasMips2Ops() const { return MipsArchVersion >= Mips2; }
 
index c6eb7119d9575d2a2f1016cd5c5fe4c7900e1bdb..e5147a0cf892871ca63a24ffea124ef29ba174bc 100644 (file)
@@ -37,7 +37,8 @@ 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);
+  std::string ParseSubtargetFeatures(const std::string &FS,
+                                     const std::string &CPU);
 };
 } // End llvm namespace
 
index d268a7d9b73a019ee12835da334ac297c301a8ee..176f3e19477a31f36403bd7dd7c52ce16061176a 100644 (file)
@@ -86,7 +86,9 @@ 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);
+  std::string ParseSubtargetFeatures(const std::string &FS,
+                                     const std::string &CPU);
+
   
   /// SetJITMode - This is called to inform the subtarget info that we are
   /// producing code for the JIT.
index dcb8c89fd12781f1b5f8317826be13b486be79a6..e5a5ba47f1064e3b8ba83ee1c2d328056fbbf957 100644 (file)
@@ -33,8 +33,9 @@ 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);
-  
+  std::string ParseSubtargetFeatures(const std::string &FS,
+                                     const std::string &CPU);
+
 };
 
 } // end namespace llvm
index 66ffb57e785dcda414f04828e7c2434bf63a2619..f9370256c602fc0039d6be883efcfabb5c8174a7 100644 (file)
@@ -186,7 +186,7 @@ void SubtargetFeatures::setString(const std::string &Initial) {
 }
 
 
-/// setCPU - Set the CPU string.  Replaces previous setting.  Setting to "" 
+/// setCPU - Set the CPU string.  Replaces previous setting.  Setting to ""
 /// clears CPU.
 void SubtargetFeatures::setCPU(const std::string &String) {
   Features[0] = LowercaseString(String);
@@ -199,9 +199,16 @@ void SubtargetFeatures::setCPUIfNone(const std::string &String) {
   if (Features[0].empty()) setCPU(String);
 }
 
+/// getCPU - Returns current CPU.
+///
+const std::string & SubtargetFeatures::getCPU() const {
+  return Features[0];
+}
+
+
 /// SetImpliedBits - For each feature that is (transitively) implied by this
 /// feature, set it.
-/// 
+///
 static
 void SetImpliedBits(uint32_t &Bits, const SubtargetFeatureKV *FeatureEntry,
                     const SubtargetFeatureKV *FeatureTable,
index abf1e814175f4ff5c25cf02cb4cd8e63191c9b1f..a5ca61704f633ef539b4f0bbba6a7fb0a52f8630 100644 (file)
@@ -108,7 +108,8 @@ 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);
+  std::string ParseSubtargetFeatures(const std::string &FS,
+                                     const std::string &CPU);
 
   /// AutoDetectSubtargetFeatures - Auto-detect CPU features using CPUID
   /// instruction.
index 779018f3fce18021e4944a75a19335d4ecaf7ec7..ff6475baa81046a12f36603191ab8070ab0dbe92 100644 (file)
@@ -38,7 +38,8 @@ 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);
+  std::string ParseSubtargetFeatures(const std::string &FS,
+                                     const std::string &CPU);
 };
 } // End llvm namespace
 
index cb36a76f432a059ede9679778cdf7b1b1c0f90eb..a28e8bc3a4634697941bd03e1045c636f613883c 100644 (file)
@@ -451,7 +451,7 @@ void SubtargetEmitter::ParseFeaturesFunction(std::ostream &OS) {
 
   OS << "// ParseSubtargetFeatures - Parses features string setting specified\n" 
      << "// subtarget options.\n" 
-     << "void llvm::";
+     << "std::string llvm::";
   OS << Target;
   OS << "Subtarget::ParseSubtargetFeatures(const std::string &FS,\n"
      << "                                  const std::string &CPU) {\n"
@@ -481,11 +481,12 @@ void SubtargetEmitter::ParseFeaturesFunction(std::ostream &OS) {
        <<              "Features.getInfo(ProcItinKV, ProcItinKVSize);\n"
        << "  InstrItins = InstrItineraryData(Stages, Itinerary);\n";
   }
-  
-  OS << "}\n";
+
+  OS << "  return Features.getCPU();\n"
+     << "}\n";
 }
 
-// 
+//
 // SubtargetEmitter::run - Main subtarget enumeration emitter.
 //
 void SubtargetEmitter::run(std::ostream &OS) {