]> granicus.if.org Git - llvm/commitdiff
[MC] Make SubtargetFeatureKV only store one FeatureBitset and use an 'unsigned' to...
authorCraig Topper <craig.topper@intel.com>
Mon, 18 Feb 2019 06:46:17 +0000 (06:46 +0000)
committerCraig Topper <craig.topper@intel.com>
Mon, 18 Feb 2019 06:46:17 +0000 (06:46 +0000)
This class is used for two difference tablegen generated tables. For one of the tables the Value FeatureBitset only has one bit set. For the other usage the Implies field was unused.

This patch changes the Value field to just be an unsigned. For the usage that put a real vector in bitset, we now use the previously unused Implies field and leave the Value field unused instead.

This is good for a 16K reduction in the size of llc on my local build with all targets enabled.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354243 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/SubtargetFeature.h
lib/MC/SubtargetFeature.cpp
utils/TableGen/SubtargetEmitter.cpp

index 5f49d3894ae6e6ca9093dab4517de83f32440b87..9c0a3f6e45fed31da757dece2f5d91c22f9bd304 100644 (file)
@@ -52,7 +52,7 @@ public:
 struct SubtargetFeatureKV {
   const char *Key;                      ///< K-V key string
   const char *Desc;                     ///< Help descriptor
-  FeatureBitset Value;                  ///< K-V integer value
+  unsigned Value;                       ///< K-V integer value
   FeatureBitset Implies;                ///< K-V bit mask
 
   /// Compare routine for std::lower_bound
index 793f00d46eda9d6bcf59ae91d4f4c46959f803b4..50f979b9d118f92a5daac950dec078d905917ffb 100644 (file)
@@ -127,8 +127,8 @@ void SetImpliedBits(FeatureBitset &Bits, const SubtargetFeatureKV &FeatureEntry,
   for (const SubtargetFeatureKV &FE : FeatureTable) {
     if (FeatureEntry.Value == FE.Value) continue;
 
-    if ((FeatureEntry.Implies & FE.Value).any()) {
-      Bits |= FE.Value;
+    if (FeatureEntry.Implies.test(FE.Value)) {
+      Bits.set(FE.Value);
       SetImpliedBits(Bits, FE, FeatureTable);
     }
   }
@@ -142,8 +142,8 @@ void ClearImpliedBits(FeatureBitset &Bits,
   for (const SubtargetFeatureKV &FE : FeatureTable) {
     if (FeatureEntry.Value == FE.Value) continue;
 
-    if ((FE.Implies & FeatureEntry.Value).any()) {
-      Bits &= ~FE.Value;
+    if (FE.Implies.test(FeatureEntry.Value)) {
+      Bits.reset(FE.Value);
       ClearImpliedBits(Bits, FE, FeatureTable);
     }
   }
@@ -157,12 +157,12 @@ SubtargetFeatures::ToggleFeature(FeatureBitset &Bits, StringRef Feature,
       Find(StripFlag(Feature), FeatureTable);
   // If there is a match
   if (FeatureEntry) {
-    if ((Bits & FeatureEntry->Value) == FeatureEntry->Value) {
-      Bits &= ~FeatureEntry->Value;
+    if (Bits.test(FeatureEntry->Value)) {
+      Bits.reset(FeatureEntry->Value);
       // For each feature that implies this, clear it.
       ClearImpliedBits(Bits, *FeatureEntry, FeatureTable);
     } else {
-      Bits |=  FeatureEntry->Value;
+      Bits.set(FeatureEntry->Value);
 
       // For each feature that this implies, set it.
       SetImpliedBits(Bits, *FeatureEntry, FeatureTable);
@@ -184,12 +184,12 @@ void SubtargetFeatures::ApplyFeatureFlag(FeatureBitset &Bits, StringRef Feature,
   if (FeatureEntry) {
     // Enable/disable feature in bits
     if (isEnabled(Feature)) {
-      Bits |= FeatureEntry->Value;
+      Bits.set(FeatureEntry->Value);
 
       // For each feature that this implies, set it.
       SetImpliedBits(Bits, *FeatureEntry, FeatureTable);
     } else {
-      Bits &= ~FeatureEntry->Value;
+      Bits.reset(FeatureEntry->Value);
 
       // For each feature that implies this, clear it.
       ClearImpliedBits(Bits, *FeatureEntry, FeatureTable);
@@ -225,11 +225,11 @@ SubtargetFeatures::getFeatureBits(StringRef CPU,
     // If there is a match
     if (CPUEntry) {
       // Set base feature bits
-      Bits = CPUEntry->Value;
+      Bits = CPUEntry->Implies;
 
       // Set the feature implied by this CPU feature, if any.
       for (auto &FE : FeatureTable) {
-        if ((CPUEntry->Value & FE.Value).any())
+        if (CPUEntry->Implies.test(FE.Value))
           SetImpliedBits(Bits, FE, FeatureTable);
       }
     } else {
index 792c957ea19c2fb4a82ee71c13b1396f0a148823..92b85d88235c191ac9e8f1916d5a964e69778a73 100644 (file)
@@ -203,7 +203,7 @@ unsigned SubtargetEmitter::FeatureKeyValues(raw_ostream &OS) {
     OS << "  { "
        << "\"" << CommandLineName << "\", "
        << "\"" << Desc << "\", "
-       << "{ " << Target << "::" << Name << " }, ";
+       << Target << "::" << Name << ", ";
 
     RecVec ImpliesList = Feature->getValueAsListOfDefs("Implies");
 
@@ -242,18 +242,18 @@ unsigned SubtargetEmitter::CPUKeyValues(raw_ostream &OS) {
     StringRef Name = Processor->getValueAsString("Name");
     RecVec FeatureList = Processor->getValueAsListOfDefs("Features");
 
-    // Emit as { "cpu", "description", { f1 , f2 , ... fn } },
-    OS << "  { "
+    // Emit as { "cpu", "description", 0, { f1 , f2 , ... fn } },
+    // The 0 is for the feature id which isn't used for CPUs.
+    OS << " { "
        << "\"" << Name << "\", "
-       << "\"Select the " << Name << " processor\", ";
+       << "\"Select the " << Name << " processor\", 0, ";
 
     OS << "{";
     for (unsigned j = 0, M = FeatureList.size(); j < M;) {
       OS << " " << Target << "::" << FeatureList[j]->getName();
       if (++j < M) OS << ",";
     }
-    // The { } is for the "implies" section of this data structure.
-    OS << " }, { } },\n";
+    OS << " } },\n";
   }
 
   // End processor table