Reapply 50867: A small refactoring (extract method) + some comment fixes.
[oota-llvm.git] / utils / TableGen / CodeGenDAGPatterns.h
index d62b2798adfde48d14aa0400132967bb8a8ccaab..0d29eb51658d63d4c2c7cbefb1f08ba667cda898 100644 (file)
@@ -15,7 +15,8 @@
 #ifndef CODEGEN_DAGPATTERNS_H
 #define CODEGEN_DAGPATTERNS_H
 
-#include "TableGenBackend.h"
+#include <set>
+
 #include "CodeGenTarget.h"
 #include "CodeGenIntrinsics.h"
 
@@ -48,6 +49,9 @@ namespace MVT {
   bool isExtFloatingPointInVTs(const std::vector<unsigned char> &EVTs);
 }
 
+/// Set type used to track multiply used variables in patterns
+typedef std::set<std::string> MultipleUseVarSet;
+
 /// SDTypeConstraint - This is a discriminated union of constraints,
 /// corresponding to the SDTypeConstraint tablegen class in Target.td.
 struct SDTypeConstraint {
@@ -56,7 +60,8 @@ struct SDTypeConstraint {
   unsigned OperandNo;   // The operand # this constraint applies to.
   enum { 
     SDTCisVT, SDTCisPtrTy, SDTCisInt, SDTCisFP, SDTCisSameAs, 
-    SDTCisVTSmallerThanOp, SDTCisOpSmallerThanOp, SDTCisIntVectorOfSameSize
+    SDTCisVTSmallerThanOp, SDTCisOpSmallerThanOp, SDTCisIntVectorOfSameSize,
+    SDTCisEltOfVec
   } ConstraintType;
   
   union {   // The discriminated union.
@@ -75,6 +80,9 @@ struct SDTypeConstraint {
     struct {
       unsigned OtherOperandNum;
     } SDTCisIntVectorOfSameSize_Info;
+    struct {
+      unsigned OtherOperandNum;
+    } SDTCisEltOfVec_Info;
   } x;
 
   /// ApplyTypeConstraint - Given a node in a pattern, apply this type
@@ -227,7 +235,8 @@ public:   // Higher level manipulation routines.
   /// the specified node.  For this comparison, all of the state of the node
   /// is considered, except for the assigned name.  Nodes with differing names
   /// that are otherwise identical are considered isomorphic.
-  bool isIsomorphicTo(const TreePatternNode *N) const;
+  bool isIsomorphicTo(const TreePatternNode *N,
+                      const MultipleUseVarSet &DepVars) const;
   
   /// SubstituteFormalArguments - Replace the formal arguments in this tree
   /// with actual values specified by ArgMap.
@@ -267,7 +276,7 @@ public:   // Higher level manipulation routines.
   
   /// canPatternMatch - If it is impossible for this pattern to match on this
   /// target, fill in Reason and return false.  Otherwise, return true.
-  bool canPatternMatch(std::string &Reason, CodeGenDAGPatterns &CDP);
+  bool canPatternMatch(std::string &Reason, const CodeGenDAGPatterns &CDP);
 };
 
 
@@ -457,6 +466,7 @@ public:
   CodeGenDAGPatterns(RecordKeeper &R); 
   ~CodeGenDAGPatterns();
   
+  CodeGenTarget &getTargetInfo() { return Target; }
   const CodeGenTarget &getTargetInfo() const { return Target; }
   
   Record *getSDNodeNamed(const std::string &Name) const;
@@ -546,6 +556,7 @@ private:
   void ParseDefaultOperands();
   void ParseInstructions();
   void ParsePatterns();
+  void InferInstructionFlags();
   void GenerateVariants();
   
   void FindPatternInputsAndOutputs(TreePattern *I, TreePatternNode *Pat,