[llvm-commits] [llvm] r78706 - /llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp

Daniel Dunbar daniel at zuster.org
Tue Aug 11 13:10:07 PDT 2009


Author: ddunbar
Date: Tue Aug 11 15:10:07 2009
New Revision: 78706

URL: http://llvm.org/viewvc/llvm-project?rev=78706&view=rev
Log:
llvm-mc/AsmMatcher: Fix two thinkos in determining whether two classes are
related.

Modified:
    llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp

Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=78706&r1=78705&r2=78706&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Tue Aug 11 15:10:07 2009
@@ -325,6 +325,10 @@
   /// MCInst; this is not valid for Token or register kinds.
   std::string RenderMethod;
 
+  /// For register classes, the records for all the registers in this class.
+  std::set<Record*> Registers;
+
+public:
   /// isRegisterClass() - Check if this is a register class.
   bool isRegisterClass() const {
     return Kind >= RegisterClass0 && Kind < UserClass0;
@@ -342,18 +346,32 @@
     if (Kind == Token || RHS.Kind == Token)
       return Kind == Token && RHS.Kind == Token;
 
-    // Registers are only related to registers.
-    if (isRegisterClass() || RHS.isRegisterClass())
-      return isRegisterClass() && RHS.isRegisterClass();
+    // Registers classes are only related to registers classes, and only if
+    // their intersection is non-empty.
+    if (isRegisterClass() || RHS.isRegisterClass()) {
+      if (!isRegisterClass() || !RHS.isRegisterClass())
+        return false;
+
+      std::set<Record*> Tmp;
+      std::insert_iterator< std::set<Record*> > II(Tmp, Tmp.begin());
+      std::set_intersection(Registers.begin(), Registers.end(), 
+                            RHS.Registers.begin(), RHS.Registers.end(),
+                            II);
+
+      return !Tmp.empty();
+    }
 
     // Otherwise we have two users operands; they are related if they are in the
     // same class hierarchy.
+    //
+    // FIXME: This is an oversimplification, they should only be related if they
+    // intersect, however we don't have that information.
     assert(isUserClass() && RHS.isUserClass() && "Unexpected class!");
     const ClassInfo *Root = this;
     while (!Root->SuperClasses.empty())
       Root = Root->SuperClasses.front();
 
-    const ClassInfo *RHSRoot = this;
+    const ClassInfo *RHSRoot = &RHS;
     while (!RHSRoot->SuperClasses.empty())
       RHSRoot = RHSRoot->SuperClasses.front();
     
@@ -674,6 +692,7 @@
     CI->ValueName = "";
     CI->PredicateMethod = ""; // unused
     CI->RenderMethod = "addRegOperands";
+    CI->Registers = *it;
     Classes.push_back(CI);
     RegisterSetClasses.insert(std::make_pair(*it, CI));
   }





More information about the llvm-commits mailing list