Don't build tblgen with -pedantic or -Wno-long-long
[oota-llvm.git] / utils / TableGen / DAGISelEmitter.h
index 35606f7787c2319387600a7c75d20fb19ca87983..8a8bf3d6c58036aa35912f80be28b025121d2cde 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "TableGenBackend.h"
 #include "CodeGenTarget.h"
+#include "CodeGenIntrinsics.h"
 #include <set>
 
 namespace llvm {
@@ -168,10 +169,15 @@ namespace llvm {
     void setName(const std::string &N) { Name = N; }
     
     bool isLeaf() const { return Val != 0; }
-    bool hasTypeSet() const { return Types[0] < MVT::LAST_VALUETYPE; }
+    bool hasTypeSet() const {
+      return (Types[0] < MVT::LAST_VALUETYPE) || (Types[0] == MVT::iPTR);
+    }
     bool isTypeCompletelyUnknown() const {
       return Types[0] == MVT::isUnknown;
     }
+    bool isTypeDynamicallyResolved() const {
+      return Types[0] == MVT::iPTR;
+    }
     MVT::ValueType getTypeNum(unsigned Num) const {
       assert(hasTypeSet() && "Doesn't have a type yet!");
       assert(Types.size() > Num && "Type num out of range!");
@@ -246,7 +252,7 @@ namespace llvm {
     /// ContainsUnresolvedType - Return true if this tree contains any
     /// unresolved types.
     bool ContainsUnresolvedType() const {
-      if (!hasTypeSet()) return true;
+      if (!hasTypeSet() && !isTypeDynamicallyResolved()) return true;
       for (unsigned i = 0, e = getNumChildren(); i != e; ++i)
         if (getChild(i)->ContainsUnresolvedType()) return true;
       return false;
@@ -393,16 +399,21 @@ namespace llvm {
 /// PatternToMatch - Used by DAGISelEmitter to keep tab of patterns processed
 /// to produce isel.
 struct PatternToMatch {
-  PatternToMatch(ListInit *preds, TreePatternNode *src, TreePatternNode *dst):
-    Predicates(preds), SrcPattern(src), DstPattern(dst) {};
+  PatternToMatch(ListInit *preds,
+                 TreePatternNode *src, TreePatternNode *dst,
+                 unsigned complexity):
+    Predicates(preds), SrcPattern(src), DstPattern(dst),
+    AddedComplexity(complexity) {};
 
   ListInit        *Predicates;  // Top level predicate conditions to match.
   TreePatternNode *SrcPattern;  // Source pattern to match.
   TreePatternNode *DstPattern;  // Resulting pattern.
+  unsigned         AddedComplexity; // Add to matching pattern complexity.
 
   ListInit        *getPredicates() const { return Predicates; }
   TreePatternNode *getSrcPattern() const { return SrcPattern; }
   TreePatternNode *getDstPattern() const { return DstPattern; }
+  unsigned         getAddedComplexity() const { return AddedComplexity; }
 };
 
 /// DAGISelEmitter - The top-level class which coordinates construction
@@ -412,6 +423,7 @@ class DAGISelEmitter : public TableGenBackend {
 private:
   RecordKeeper &Records;
   CodeGenTarget Target;
+  std::vector<CodeGenIntrinsic> Intrinsics;
   
   std::map<Record*, SDNodeInfo> SDNodes;
   std::map<Record*, std::pair<Record*, std::string> > SDNodeXForms;
@@ -419,6 +431,10 @@ private:
   std::map<Record*, TreePattern*> PatternFragments;
   std::map<Record*, DAGInstruction> Instructions;
   
+  // Specific SDNode definitions:
+  Record *intrinsic_void_sdnode;
+  Record *intrinsic_w_chain_sdnode, *intrinsic_wo_chain_sdnode;
+  
   /// PatternsToMatch - All of the things we are matching on the DAG.  The first
   /// value is the pattern to match, the second pattern is the result to
   /// emit.
@@ -448,6 +464,25 @@ public:
     return ComplexPatterns.find(R)->second;
   }
   
+  const CodeGenIntrinsic &getIntrinsic(Record *R) const {
+    for (unsigned i = 0, e = Intrinsics.size(); i != e; ++i)
+      if (Intrinsics[i].TheDef == R) return Intrinsics[i];
+    assert(0 && "Unknown intrinsic!");
+    abort();
+  }
+  
+  const CodeGenIntrinsic &getIntrinsicInfo(unsigned IID) const {
+    assert(IID-1 < Intrinsics.size() && "Bad intrinsic ID!");
+    return Intrinsics[IID-1];
+  }
+  
+  unsigned getIntrinsicID(Record *R) const {
+    for (unsigned i = 0, e = Intrinsics.size(); i != e; ++i)
+      if (Intrinsics[i].TheDef == R) return i;
+    assert(0 && "Unknown intrinsic!");
+    abort();
+  }
+  
   TreePattern *getPatternFragment(Record *R) const {
     assert(PatternFragments.count(R) && "Invalid pattern fragment request!");
     return PatternFragments.find(R)->second;
@@ -458,6 +493,17 @@ public:
     return Instructions.find(R)->second;
   }
   
+  Record *get_intrinsic_void_sdnode() const {
+    return intrinsic_void_sdnode;
+  }
+  Record *get_intrinsic_w_chain_sdnode() const {
+    return intrinsic_w_chain_sdnode;
+  }
+  Record *get_intrinsic_wo_chain_sdnode() const {
+    return intrinsic_wo_chain_sdnode;
+  }
+
+  
 private:
   void ParseNodeInfo();
   void ParseNodeTransforms(std::ostream &OS);