[llvm-commits] [llvm] r96904 - /llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp

Chris Lattner sabre at nondot.org
Mon Feb 22 23:22:28 PST 2010


Author: lattner
Date: Tue Feb 23 01:22:28 2010
New Revision: 96904

URL: http://llvm.org/viewvc/llvm-project?rev=96904&view=rev
Log:
Reject patterns that use a name multiple times in the src or result
of a pattern and where the uses have different types.


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

Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=96904&r1=96903&r2=96904&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Tue Feb 23 01:22:28 2010
@@ -2091,20 +2091,21 @@
 typedef std::pair<const TreePatternNode*, unsigned> NameRecord;
 
 static void FindNames(const TreePatternNode *P, 
-                      std::map<std::string, NameRecord> &Names) {
+                      std::map<std::string, NameRecord> &Names,
+                      const TreePattern *PatternTop) {
   if (!P->getName().empty()) {
     NameRecord &Rec = Names[P->getName()];
     // If this is the first instance of the name, remember the node.
     if (Rec.second++ == 0)
       Rec.first = P;
-//    else
-//      assert(Rec.first->getExtTypes() == P->getExtTypes() &&
-//             "Type mismatch on name repetition");
+    else if (Rec.first->getExtTypes() != P->getExtTypes())
+      PatternTop->error("repetition of value: $" + P->getName() +
+                        " where different uses have different types!");
   }
   
   if (!P->isLeaf()) {
     for (unsigned i = 0, e = P->getNumChildren(); i != e; ++i)
-      FindNames(P->getChild(i), Names);
+      FindNames(P->getChild(i), Names, PatternTop);
   }
 }
 
@@ -2118,8 +2119,8 @@
   // Find all of the named values in the input and output, ensure they have the
   // same type.
   std::map<std::string, NameRecord> SrcNames, DstNames;
-  FindNames(PTM.getSrcPattern(), SrcNames);
-  FindNames(PTM.getDstPattern(), DstNames);
+  FindNames(PTM.getSrcPattern(), SrcNames, Pattern);
+  FindNames(PTM.getDstPattern(), DstNames, Pattern);
 
   // Scan all of the named values in the destination pattern, rejecting them if
   // they don't exist in the input pattern.





More information about the llvm-commits mailing list