Add a new SDTCisIntVectorOfSameSize type constraint
authorChris Lattner <sabre@nondot.org>
Mon, 20 Mar 2006 05:39:48 +0000 (05:39 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 20 Mar 2006 05:39:48 +0000 (05:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26890 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/DAGISelEmitter.cpp
utils/TableGen/DAGISelEmitter.h

index e04463cbb527a37348bf4f0d5b2d10922aa79deb..4b8ea20e27282a9a7af787e2758d48d487f5459b 100644 (file)
@@ -63,14 +63,14 @@ static bool LHSIsSubsetOfRHS(const std::vector<unsigned char> &LHS,
 
 /// isExtIntegerVT - Return true if the specified extended value type vector
 /// contains isInt or an integer value type.
-static bool isExtIntegerInVTs(std::vector<unsigned char> EVTs) {
+static bool isExtIntegerInVTs(const std::vector<unsigned char> &EVTs) {
   assert(!EVTs.empty() && "Cannot check for integer in empty ExtVT list!");
   return EVTs[0] == MVT::isInt || !(FilterEVTs(EVTs, MVT::isInteger).empty());
 }
 
 /// isExtFloatingPointVT - Return true if the specified extended value type 
 /// vector contains isFP or a FP value type.
-static bool isExtFloatingPointInVTs(std::vector<unsigned char> EVTs) {
+static bool isExtFloatingPointInVTs(const std::vector<unsigned char> &EVTs) {
   assert(!EVTs.empty() && "Cannot check for integer in empty ExtVT list!");
   return EVTs[0] == MVT::isFP ||
          !(FilterEVTs(EVTs, MVT::isFloatingPoint).empty());
@@ -103,6 +103,10 @@ SDTypeConstraint::SDTypeConstraint(Record *R) {
     ConstraintType = SDTCisOpSmallerThanOp;
     x.SDTCisOpSmallerThanOp_Info.BigOperandNum = 
       R->getValueAsInt("BigOperandNum");
+  } else if (R->isSubClassOf("SDTCisIntVectorOfSameSize")) {
+    ConstraintType = SDTCisIntVectorOfSameSize;
+    x.SDTCisIntVectorOfSameSize_Info.OtherOperandNum =
+      R->getValueAsInt("OtherOpNum");
   } else {
     std::cerr << "Unrecognized SDTypeConstraint '" << R->getName() << "'!\n";
     exit(1);
@@ -259,6 +263,19 @@ bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
     }    
     return MadeChange;
   }
+  case SDTCisIntVectorOfSameSize: {
+    TreePatternNode *OtherOperand =
+      getOperandNum(x.SDTCisIntVectorOfSameSize_Info.OtherOperandNum,
+                    N, NumResults);
+    if (OtherOperand->hasTypeSet()) {
+      if (!MVT::isVector(OtherOperand->getTypeNum(0)))
+        TP.error(N->getOperator()->getName() + " VT operand must be a vector!");
+      MVT::ValueType IVT = OtherOperand->getTypeNum(0);
+      IVT = MVT::getIntVectorWithNumElements(MVT::getVectorNumElements(IVT));
+      return NodeToApply->UpdateNodeType(IVT, TP);
+    }
+    return false;
+  }
   }  
   return false;
 }
index 1552462b3771d5326598817d0d0f03b857c18be5..6add8b28e4147ebd307a524e25585e371815c8b2 100644 (file)
@@ -47,7 +47,7 @@ namespace llvm {
     unsigned OperandNo;   // The operand # this constraint applies to.
     enum { 
       SDTCisVT, SDTCisPtrTy, SDTCisInt, SDTCisFP, SDTCisSameAs, 
-      SDTCisVTSmallerThanOp, SDTCisOpSmallerThanOp
+      SDTCisVTSmallerThanOp, SDTCisOpSmallerThanOp, SDTCisIntVectorOfSameSize
     } ConstraintType;
     
     union {   // The discriminated union.
@@ -63,6 +63,9 @@ namespace llvm {
       struct {
         unsigned BigOperandNum;
       } SDTCisOpSmallerThanOp_Info;
+      struct {
+        unsigned OtherOperandNum;
+      } SDTCisIntVectorOfSameSize_Info;
     } x;
 
     /// ApplyTypeConstraint - Given a node in a pattern, apply this type