llvm.org GIT mirror llvm / 36e3e66
Add a new "SDTCisVec" SDTypeConstraint. This complements the vAny type. There have been a few times where I've wanted this but ended up leaving the operand type unconstrained. It is easy to add this now and should help catch errors in the future. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78849 91177308-0d34-0410-b5e6-96231b3b80d8 Bob Wilson 10 years ago
3 changed file(s) with 35 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
2929
3030 class SDTCisPtrTy : SDTypeConstraint;
3131
32 // SDTCisInt - The specified operand is has integer type.
32 // SDTCisInt - The specified operand has integer type.
3333 class SDTCisInt : SDTypeConstraint;
3434
35 // SDTCisFP - The specified operand is has floating point type.
35 // SDTCisFP - The specified operand has floating-point type.
3636 class SDTCisFP : SDTypeConstraint;
37
38 // SDTCisVec - The specified operand has a vector type.
39 class SDTCisVec : SDTypeConstraint;
3740
3841 // SDTCisSameAs - The two specified operands have identical types.
3942 class SDTCisSameAs : SDTypeConstraint {
9494 /// vector contains a vector value type.
9595 bool isExtVectorInVTs(const std::vector &EVTs) {
9696 assert(!EVTs.empty() && "Cannot check for vector in empty ExtVT list!");
97 return !(FilterEVTs(EVTs, isVector).empty());
97 return EVTs[0] == isVec || !(FilterEVTs(EVTs, isVector).empty());
9898 }
9999 } // end namespace EEVT.
100100 } // end namespace llvm.
189189 ConstraintType = SDTCisInt;
190190 } else if (R->isSubClassOf("SDTCisFP")) {
191191 ConstraintType = SDTCisFP;
192 } else if (R->isSubClassOf("SDTCisVec")) {
193 ConstraintType = SDTCisVec;
192194 } else if (R->isSubClassOf("SDTCisSameAs")) {
193195 ConstraintType = SDTCisSameAs;
194196 x.SDTCisSameAs_Info.OtherOperandNum = R->getValueAsInt("OtherOperandNum");
281283 if (FPVTs.size() == 1)
282284 return NodeToApply->UpdateNodeType(FPVTs[0], TP);
283285 return NodeToApply->UpdateNodeType(EEVT::isFP, TP);
286 }
287 case SDTCisVec: {
288 // If there is only one vector type supported, this must be it.
289 std::vector VecVTs =
290 FilterVTs(CGT.getLegalValueTypes(), isVector);
291
292 // If we found exactly one supported vector type, apply it.
293 if (VecVTs.size() == 1)
294 return NodeToApply->UpdateNodeType(VecVTs[0], TP);
295 return NodeToApply->UpdateNodeType(EEVT::isVec, TP);
284296 }
285297 case SDTCisSameAs: {
286298 TreePatternNode *OtherNode =
501513 setTypes(FVTs);
502514 return true;
503515 }
504 if (ExtVTs[0] == MVT::vAny && EEVT::isExtVectorInVTs(getExtTypes())) {
516 if ((ExtVTs[0] == EEVT::isVec || ExtVTs[0] == MVT::vAny) &&
517 EEVT::isExtVectorInVTs(getExtTypes())) {
505518 assert(hasTypeSet() && "should be handled above!");
506519 std::vector FVTs = FilterEVTs(getExtTypes(), isVector);
507520 if (getExtTypes() == FVTs)
510523 return true;
511524 }
512525
513 // If we know this is an int or fp type, and we are told it is a specific one,
514 // take the advice.
526 // If we know this is an int, FP, or vector type, and we are told it is a
527 // specific one, take the advice.
515528 //
516529 // Similarly, we should probably set the type here to the intersection of
517 // {isInt|isFP} and ExtVTs
530 // {isInt|isFP|isVec} and ExtVTs
518531 if (((getExtTypeNum(0) == EEVT::isInt || getExtTypeNum(0) == MVT::iAny) &&
519532 EEVT::isExtIntegerInVTs(ExtVTs)) ||
520533 ((getExtTypeNum(0) == EEVT::isFP || getExtTypeNum(0) == MVT::fAny) &&
521534 EEVT::isExtFloatingPointInVTs(ExtVTs)) ||
522 (getExtTypeNum(0) == MVT::vAny &&
535 ((getExtTypeNum(0) == EEVT::isVec || getExtTypeNum(0) == MVT::vAny) &&
523536 EEVT::isExtVectorInVTs(ExtVTs))) {
524537 setTypes(ExtVTs);
525538 return true;
555568 case MVT::Other: OS << ":Other"; break;
556569 case EEVT::isInt: OS << ":isInt"; break;
557570 case EEVT::isFP : OS << ":isFP"; break;
571 case EEVT::isVec: OS << ":isVec"; break;
558572 case EEVT::isUnknown: ; /*OS << ":?";*/ break;
559573 case MVT::iPTR: OS << ":iPTR"; break;
560574 case MVT::iPTRAny: OS << ":iPTRAny"; break;
3838 enum DAGISelGenValueType {
3939 isFP = MVT::LAST_VALUETYPE,
4040 isInt,
41 isVec,
4142 isUnknown
4243 };
4344
44 /// isExtIntegerVT - Return true if the specified extended value type vector
45 /// contains isInt or an integer value type.
45 /// isExtIntegerInVTs - Return true if the specified extended value type
46 /// vector contains isInt or an integer value type.
4647 bool isExtIntegerInVTs(const std::vector &EVTs);
4748
48 /// isExtFloatingPointVT - Return true if the specified extended value type
49 /// vector contains isFP or a FP value type.
49 /// isExtFloatingPointInVTs - Return true if the specified extended value
50 /// type vector contains isFP or a FP value type.
5051 bool isExtFloatingPointInVTs(const std::vector &EVTs);
52
53 /// isExtVectorinVTs - Return true if the specified extended value type
54 /// vector contains isVec or a vector value type.
55 bool isExtVectorInVTs(const std::vector &EVTs);
5156 }
5257
5358 /// Set type used to track multiply used variables in patterns
6065
6166 unsigned OperandNo; // The operand # this constraint applies to.
6267 enum {
63 SDTCisVT, SDTCisPtrTy, SDTCisInt, SDTCisFP, SDTCisSameAs,
68 SDTCisVT, SDTCisPtrTy, SDTCisInt, SDTCisFP, SDTCisVec, SDTCisSameAs,
6469 SDTCisVTSmallerThanOp, SDTCisOpSmallerThanOp, SDTCisEltOfVec
6570 } ConstraintType;
6671