Now that we have int/fp lattice values, implement the SDTCisOpSmallerThanOp

type constraint.  This lets tblgen realize that it doesn't need any dynamic
type checks for fextend/fround on PPC (and many other targets), because there
are only two fp types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23730 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-10-14 06:25:00 +00:00
parent 3c7e18d690
commit 603d78c9de

View File

@ -169,8 +169,47 @@ bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
return false;
}
case SDTCisOpSmallerThanOp: {
// TODO
return false;
TreePatternNode *BigOperand =
getOperandNum(x.SDTCisOpSmallerThanOp_Info.BigOperandNum, N, NumResults);
// Both operands must be integer or FP, but we don't care which.
bool MadeChange = false;
if (isExtIntegerVT(NodeToApply->getExtType()))
MadeChange |= BigOperand->UpdateNodeType(MVT::isInt, TP);
else if (isExtFloatingPointVT(NodeToApply->getExtType()))
MadeChange |= BigOperand->UpdateNodeType(MVT::isFP, TP);
if (isExtIntegerVT(BigOperand->getExtType()))
MadeChange |= NodeToApply->UpdateNodeType(MVT::isInt, TP);
else if (isExtFloatingPointVT(BigOperand->getExtType()))
MadeChange |= NodeToApply->UpdateNodeType(MVT::isFP, TP);
std::vector<MVT::ValueType> VTs = CGT.getLegalValueTypes();
if (isExtIntegerVT(NodeToApply->getExtType())) {
VTs = FilterVTs(VTs, MVT::isInteger);
} else if (isExtFloatingPointVT(NodeToApply->getExtType())) {
VTs = FilterVTs(VTs, MVT::isFloatingPoint);
} else {
VTs.clear();
}
switch (VTs.size()) {
default: // Too many VT's to pick from.
case 0: break; // No info yet.
case 1:
// Only one VT of this flavor. Cannot ever satisify the constraints.
return NodeToApply->UpdateNodeType(MVT::Other, TP); // throw
case 2:
// If we have exactly two possible types, the little operand must be the
// small one, the big operand should be the big one. Common with
// float/double for example.
assert(VTs[0] < VTs[1] && "Should be sorted!");
MadeChange |= NodeToApply->UpdateNodeType(VTs[0], TP);
MadeChange |= BigOperand->UpdateNodeType(VTs[1], TP);
break;
}
return MadeChange;
}
}
return false;