Reapply 50867: A small refactoring (extract method) + some comment fixes.
[oota-llvm.git] / utils / TableGen / CodeGenDAGPatterns.h
index 44c154a353792e0a8a2966a962b81ac93cfa5398..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 {
@@ -231,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.
@@ -271,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);
 };
 
 
@@ -461,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;
@@ -550,6 +556,7 @@ private:
   void ParseDefaultOperands();
   void ParseInstructions();
   void ParsePatterns();
+  void InferInstructionFlags();
   void GenerateVariants();
   
   void FindPatternInputsAndOutputs(TreePattern *I, TreePatternNode *Pat,