[llvm-branch-commits] [llvm-branch] r119209 - /llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp

Daniel Dunbar daniel at zuster.org
Mon Nov 15 13:43:42 PST 2010


Author: ddunbar
Date: Mon Nov 15 15:43:42 2010
New Revision: 119209

URL: http://llvm.org/viewvc/llvm-project?rev=119209&view=rev
Log:
Merge r117845:
--
Author: Chris Lattner <clattner at apple.com>
Date:   Sat Oct 30 20:15:02 2010 +0000

    have GetAliasRequiredFeatures get its features from
    AsmMatcherInfo so we don't have two places that know the
    feature -> enum mapping.  No functionality change.

Modified:
    llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp

Modified: llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp?rev=119209&r1=119208&r2=119209&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp Mon Nov 15 15:43:42 2010
@@ -565,7 +565,7 @@
 
   /// Map of Predicate records to their subtarget information.
   std::map<Record*, SubtargetFeatureInfo*> SubtargetFeatures;
-
+  
 private:
   /// Map of token to class information which has already been constructed.
   std::map<std::string, ClassInfo*> TokenClasses;
@@ -584,13 +584,6 @@
   ClassInfo *getOperandClass(StringRef Token,
                              const CodeGenInstruction::OperandInfo &OI);
 
-  /// getSubtargetFeature - Lookup or create the subtarget feature info for the
-  /// given operand.
-  SubtargetFeatureInfo *getSubtargetFeature(Record *Def) {
-    assert(Def->isSubClassOf("Predicate") && "Invalid predicate type!");
-    return SubtargetFeatures[Def];
-  }
-
   /// BuildRegisterClasses - Build the ClassInfo* instances for register
   /// classes.
   void BuildRegisterClasses(CodeGenTarget &Target,
@@ -605,6 +598,15 @@
 
   /// BuildInfo - Construct the various tables used during matching.
   void BuildInfo(CodeGenTarget &Target);
+  
+  /// getSubtargetFeature - Lookup or create the subtarget feature info for the
+  /// given operand.
+  SubtargetFeatureInfo *getSubtargetFeature(Record *Def) const {
+    assert(Def->isSubClassOf("Predicate") && "Invalid predicate type!");
+    std::map<Record*, SubtargetFeatureInfo*>::const_iterator I =
+      SubtargetFeatures.find(Def);
+    return I == SubtargetFeatures.end() ? 0 : I->second;
+  }
 };
 
 }
@@ -979,14 +981,9 @@
     // Compute the require features.
     std::vector<Record*> Predicates =
       CGI.TheDef->getValueAsListOfDefs("Predicates");
-    for (unsigned i = 0, e = Predicates.size(); i != e; ++i) {
-      Record *Pred = Predicates[i];
-      // Ignore predicates that are not intended for the assembler.
-      if (!Pred->getValueAsBit("AssemblerMatcherPredicate"))
-        continue;
-        
-      II->RequiredFeatures.push_back(getSubtargetFeature(Pred));
-    }
+    for (unsigned i = 0, e = Predicates.size(); i != e; ++i)
+      if (SubtargetFeatureInfo *Feature = getSubtargetFeature(Predicates[i]))
+        II->RequiredFeatures.push_back(Feature);
 
     Instructions.push_back(II.take());
   }
@@ -1516,24 +1513,19 @@
   OS << "}\n\n";
 }
 
-static std::string GetAliasRequiredFeatures(Record *R) {
-  // FIXME: This is a total hack.
+static std::string GetAliasRequiredFeatures(Record *R,
+                                            const AsmMatcherInfo &Info) {
   std::vector<Record*> ReqFeatures = R->getValueAsListOfDefs("Predicates");
-  
   std::string Result;
   unsigned NumFeatures = 0;
   for (unsigned i = 0, e = ReqFeatures.size(); i != e; ++i) {
-    Record *Pred = ReqFeatures[i];
-  
-    // Ignore predicates that are not intended for the assembler.
-    if (!Pred->getValueAsBit("AssemblerMatcherPredicate"))
-      continue;
- 
-    if (NumFeatures)
-      Result += '|';
+    if (SubtargetFeatureInfo *F = Info.getSubtargetFeature(ReqFeatures[i])) {
+      if (NumFeatures)
+        Result += '|';
     
-    Result += "Feature_" + Pred->getName();
-    ++NumFeatures;
+      Result += F->getEnumName();
+      ++NumFeatures;
+    }
   }
   
   if (NumFeatures > 1)
@@ -1576,7 +1568,7 @@
     
     for (unsigned i = 0, e = ToVec.size(); i != e; ++i) {
       Record *R = ToVec[i];
-      std::string FeatureMask = GetAliasRequiredFeatures(R);
+      std::string FeatureMask = GetAliasRequiredFeatures(R, Info);
     
       // If this unconditionally matches, remember it for later and diagnose
       // duplicates.





More information about the llvm-branch-commits mailing list