From 697f88456ce41ca425eaf7f882cc910bbac3100b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 20 Mar 2006 05:39:48 +0000 Subject: [PATCH] Add a new SDTCisIntVectorOfSameSize type constraint git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26890 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/DAGISelEmitter.cpp | 21 +++++++++++++++++++-- utils/TableGen/DAGISelEmitter.h | 5 ++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp index e04463cbb52..4b8ea20e272 100644 --- a/utils/TableGen/DAGISelEmitter.cpp +++ b/utils/TableGen/DAGISelEmitter.cpp @@ -63,14 +63,14 @@ static bool LHSIsSubsetOfRHS(const std::vector &LHS, /// isExtIntegerVT - Return true if the specified extended value type vector /// contains isInt or an integer value type. -static bool isExtIntegerInVTs(std::vector EVTs) { +static bool isExtIntegerInVTs(const std::vector &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 EVTs) { +static bool isExtFloatingPointInVTs(const std::vector &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; } diff --git a/utils/TableGen/DAGISelEmitter.h b/utils/TableGen/DAGISelEmitter.h index 1552462b377..6add8b28e41 100644 --- a/utils/TableGen/DAGISelEmitter.h +++ b/utils/TableGen/DAGISelEmitter.h @@ -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