Add a new SDTCisIntVectorOfSameSize type constraint

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26890 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2006-03-20 05:39:48 +00:00
parent 08e25de4d3
commit 697f88456c
2 changed files with 23 additions and 3 deletions

View 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;
}

View 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