[llvm-commits] CVS: llvm/utils/TableGen/DAGISelEmitter.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Jun 19 17:18:14 PDT 2006



Changes in directory llvm/utils/TableGen:

DAGISelEmitter.cpp updated: 1.213 -> 1.214
---
Log message:

Make sure to use the result of the pattern to infer the result type of the
instruction, and the result type of the instruction to refine the pattern.
This allows us to write things like this:

def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>;

as:
def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (VR128:$src)>

and fixes a ppc64 issue.


---
Diffs of the changes:  (+34 -22)

 DAGISelEmitter.cpp |   56 ++++++++++++++++++++++++++++++++---------------------
 1 files changed, 34 insertions(+), 22 deletions(-)


Index: llvm/utils/TableGen/DAGISelEmitter.cpp
diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.213 llvm/utils/TableGen/DAGISelEmitter.cpp:1.214
--- llvm/utils/TableGen/DAGISelEmitter.cpp:1.213	Fri Jun 16 13:25:06 2006
+++ llvm/utils/TableGen/DAGISelEmitter.cpp	Mon Jun 19 19:18:02 2006
@@ -1554,22 +1554,6 @@
     // Inline pattern fragments into it.
     Pattern->InlinePatternFragments();
     
-    // Infer as many types as possible.  If we cannot infer all of them, we can
-    // never do anything with this pattern: report it to the user.
-    if (!Pattern->InferAllTypes())
-      Pattern->error("Could not infer all types in pattern!");
-
-    // Validate that the input pattern is correct.
-    {
-      std::map<std::string, TreePatternNode*> InstInputs;
-      std::map<std::string, TreePatternNode*> InstResults;
-      std::vector<Record*> InstImpInputs;
-      std::vector<Record*> InstImpResults;
-      FindPatternInputsAndOutputs(Pattern, Pattern->getOnlyTree(),
-                                  InstInputs, InstResults,
-                                  InstImpInputs, InstImpResults);
-    }
-    
     ListInit *LI = Patterns[i]->getValueAsListInit("ResultInstrs");
     if (LI->getSize() == 0) continue;  // no pattern.
     
@@ -1578,15 +1562,43 @@
     
     // Inline pattern fragments into it.
     Result->InlinePatternFragments();
-    
-    // Infer as many types as possible.  If we cannot infer all of them, we can
-    // never do anything with this pattern: report it to the user.
-    if (!Result->InferAllTypes())
-      Result->error("Could not infer all types in pattern result!");
-   
+
     if (Result->getNumTrees() != 1)
       Result->error("Cannot handle instructions producing instructions "
                     "with temporaries yet!");
+    
+    bool IterateInference;
+    do {
+      // Infer as many types as possible.  If we cannot infer all of them, we
+      // can never do anything with this pattern: report it to the user.
+      if (!Pattern->InferAllTypes())
+        Pattern->error("Could not infer all types in pattern!");
+      
+      // Infer as many types as possible.  If we cannot infer all of them, we can
+      // never do anything with this pattern: report it to the user.
+      if (!Result->InferAllTypes())
+        Result->error("Could not infer all types in pattern result!");
+     
+      // Apply the type of the result to the source pattern.  This helps us
+      // resolve cases where the input type is known to be a pointer type (which
+      // is considered resolved), but the result knows it needs to be 32- or
+      // 64-bits.  Infer the other way for good measure.
+      IterateInference = Pattern->getOnlyTree()->
+        UpdateNodeType(Result->getOnlyTree()->getExtTypes(), *Result);
+      IterateInference |= Result->getOnlyTree()->
+        UpdateNodeType(Pattern->getOnlyTree()->getExtTypes(), *Result);
+    } while (IterateInference);
+    
+    // Validate that the input pattern is correct.
+    {
+      std::map<std::string, TreePatternNode*> InstInputs;
+      std::map<std::string, TreePatternNode*> InstResults;
+      std::vector<Record*> InstImpInputs;
+      std::vector<Record*> InstImpResults;
+      FindPatternInputsAndOutputs(Pattern, Pattern->getOnlyTree(),
+                                  InstInputs, InstResults,
+                                  InstImpInputs, InstImpResults);
+    }
 
     // Promote the xform function to be an explicit node if set.
     std::vector<TreePatternNode*> ResultNodeOperands;






More information about the llvm-commits mailing list