mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-14 15:28:20 +00:00
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
This commit is contained in:
@@ -30,12 +30,15 @@ class SDTCisVT<int OpNum, ValueType vt> : SDTypeConstraint<OpNum> {
|
|||||||
|
|
||||||
class SDTCisPtrTy<int OpNum> : SDTypeConstraint<OpNum>;
|
class SDTCisPtrTy<int OpNum> : SDTypeConstraint<OpNum>;
|
||||||
|
|
||||||
// SDTCisInt - The specified operand is has integer type.
|
// SDTCisInt - The specified operand has integer type.
|
||||||
class SDTCisInt<int OpNum> : SDTypeConstraint<OpNum>;
|
class SDTCisInt<int OpNum> : SDTypeConstraint<OpNum>;
|
||||||
|
|
||||||
// SDTCisFP - The specified operand is has floating point type.
|
// SDTCisFP - The specified operand has floating-point type.
|
||||||
class SDTCisFP<int OpNum> : SDTypeConstraint<OpNum>;
|
class SDTCisFP<int OpNum> : SDTypeConstraint<OpNum>;
|
||||||
|
|
||||||
|
// SDTCisVec - The specified operand has a vector type.
|
||||||
|
class SDTCisVec<int OpNum> : SDTypeConstraint<OpNum>;
|
||||||
|
|
||||||
// SDTCisSameAs - The two specified operands have identical types.
|
// SDTCisSameAs - The two specified operands have identical types.
|
||||||
class SDTCisSameAs<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
|
class SDTCisSameAs<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
|
||||||
int OtherOperandNum = OtherOp;
|
int OtherOperandNum = OtherOp;
|
||||||
|
@@ -95,7 +95,7 @@ bool isExtFloatingPointInVTs(const std::vector<unsigned char> &EVTs) {
|
|||||||
/// vector contains a vector value type.
|
/// vector contains a vector value type.
|
||||||
bool isExtVectorInVTs(const std::vector<unsigned char> &EVTs) {
|
bool isExtVectorInVTs(const std::vector<unsigned char> &EVTs) {
|
||||||
assert(!EVTs.empty() && "Cannot check for vector in empty ExtVT list!");
|
assert(!EVTs.empty() && "Cannot check for vector in empty ExtVT list!");
|
||||||
return !(FilterEVTs(EVTs, isVector).empty());
|
return EVTs[0] == isVec || !(FilterEVTs(EVTs, isVector).empty());
|
||||||
}
|
}
|
||||||
} // end namespace EEVT.
|
} // end namespace EEVT.
|
||||||
} // end namespace llvm.
|
} // end namespace llvm.
|
||||||
@@ -190,6 +190,8 @@ SDTypeConstraint::SDTypeConstraint(Record *R) {
|
|||||||
ConstraintType = SDTCisInt;
|
ConstraintType = SDTCisInt;
|
||||||
} else if (R->isSubClassOf("SDTCisFP")) {
|
} else if (R->isSubClassOf("SDTCisFP")) {
|
||||||
ConstraintType = SDTCisFP;
|
ConstraintType = SDTCisFP;
|
||||||
|
} else if (R->isSubClassOf("SDTCisVec")) {
|
||||||
|
ConstraintType = SDTCisVec;
|
||||||
} else if (R->isSubClassOf("SDTCisSameAs")) {
|
} else if (R->isSubClassOf("SDTCisSameAs")) {
|
||||||
ConstraintType = SDTCisSameAs;
|
ConstraintType = SDTCisSameAs;
|
||||||
x.SDTCisSameAs_Info.OtherOperandNum = R->getValueAsInt("OtherOperandNum");
|
x.SDTCisSameAs_Info.OtherOperandNum = R->getValueAsInt("OtherOperandNum");
|
||||||
@@ -283,6 +285,16 @@ bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
|
|||||||
return NodeToApply->UpdateNodeType(FPVTs[0], TP);
|
return NodeToApply->UpdateNodeType(FPVTs[0], TP);
|
||||||
return NodeToApply->UpdateNodeType(EEVT::isFP, TP);
|
return NodeToApply->UpdateNodeType(EEVT::isFP, TP);
|
||||||
}
|
}
|
||||||
|
case SDTCisVec: {
|
||||||
|
// If there is only one vector type supported, this must be it.
|
||||||
|
std::vector<MVT::SimpleValueType> VecVTs =
|
||||||
|
FilterVTs(CGT.getLegalValueTypes(), isVector);
|
||||||
|
|
||||||
|
// If we found exactly one supported vector type, apply it.
|
||||||
|
if (VecVTs.size() == 1)
|
||||||
|
return NodeToApply->UpdateNodeType(VecVTs[0], TP);
|
||||||
|
return NodeToApply->UpdateNodeType(EEVT::isVec, TP);
|
||||||
|
}
|
||||||
case SDTCisSameAs: {
|
case SDTCisSameAs: {
|
||||||
TreePatternNode *OtherNode =
|
TreePatternNode *OtherNode =
|
||||||
getOperandNum(x.SDTCisSameAs_Info.OtherOperandNum, N, NumResults);
|
getOperandNum(x.SDTCisSameAs_Info.OtherOperandNum, N, NumResults);
|
||||||
@@ -502,7 +514,8 @@ bool TreePatternNode::UpdateNodeType(const std::vector<unsigned char> &ExtVTs,
|
|||||||
setTypes(FVTs);
|
setTypes(FVTs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (ExtVTs[0] == MVT::vAny && EEVT::isExtVectorInVTs(getExtTypes())) {
|
if ((ExtVTs[0] == EEVT::isVec || ExtVTs[0] == MVT::vAny) &&
|
||||||
|
EEVT::isExtVectorInVTs(getExtTypes())) {
|
||||||
assert(hasTypeSet() && "should be handled above!");
|
assert(hasTypeSet() && "should be handled above!");
|
||||||
std::vector<unsigned char> FVTs = FilterEVTs(getExtTypes(), isVector);
|
std::vector<unsigned char> FVTs = FilterEVTs(getExtTypes(), isVector);
|
||||||
if (getExtTypes() == FVTs)
|
if (getExtTypes() == FVTs)
|
||||||
@@ -511,16 +524,16 @@ bool TreePatternNode::UpdateNodeType(const std::vector<unsigned char> &ExtVTs,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we know this is an int or fp type, and we are told it is a specific one,
|
// If we know this is an int, FP, or vector type, and we are told it is a
|
||||||
// take the advice.
|
// specific one, take the advice.
|
||||||
//
|
//
|
||||||
// Similarly, we should probably set the type here to the intersection of
|
// Similarly, we should probably set the type here to the intersection of
|
||||||
// {isInt|isFP} and ExtVTs
|
// {isInt|isFP|isVec} and ExtVTs
|
||||||
if (((getExtTypeNum(0) == EEVT::isInt || getExtTypeNum(0) == MVT::iAny) &&
|
if (((getExtTypeNum(0) == EEVT::isInt || getExtTypeNum(0) == MVT::iAny) &&
|
||||||
EEVT::isExtIntegerInVTs(ExtVTs)) ||
|
EEVT::isExtIntegerInVTs(ExtVTs)) ||
|
||||||
((getExtTypeNum(0) == EEVT::isFP || getExtTypeNum(0) == MVT::fAny) &&
|
((getExtTypeNum(0) == EEVT::isFP || getExtTypeNum(0) == MVT::fAny) &&
|
||||||
EEVT::isExtFloatingPointInVTs(ExtVTs)) ||
|
EEVT::isExtFloatingPointInVTs(ExtVTs)) ||
|
||||||
(getExtTypeNum(0) == MVT::vAny &&
|
((getExtTypeNum(0) == EEVT::isVec || getExtTypeNum(0) == MVT::vAny) &&
|
||||||
EEVT::isExtVectorInVTs(ExtVTs))) {
|
EEVT::isExtVectorInVTs(ExtVTs))) {
|
||||||
setTypes(ExtVTs);
|
setTypes(ExtVTs);
|
||||||
return true;
|
return true;
|
||||||
@@ -556,6 +569,7 @@ void TreePatternNode::print(raw_ostream &OS) const {
|
|||||||
case MVT::Other: OS << ":Other"; break;
|
case MVT::Other: OS << ":Other"; break;
|
||||||
case EEVT::isInt: OS << ":isInt"; break;
|
case EEVT::isInt: OS << ":isInt"; break;
|
||||||
case EEVT::isFP : OS << ":isFP"; break;
|
case EEVT::isFP : OS << ":isFP"; break;
|
||||||
|
case EEVT::isVec: OS << ":isVec"; break;
|
||||||
case EEVT::isUnknown: ; /*OS << ":?";*/ break;
|
case EEVT::isUnknown: ; /*OS << ":?";*/ break;
|
||||||
case MVT::iPTR: OS << ":iPTR"; break;
|
case MVT::iPTR: OS << ":iPTR"; break;
|
||||||
case MVT::iPTRAny: OS << ":iPTRAny"; break;
|
case MVT::iPTRAny: OS << ":iPTRAny"; break;
|
||||||
|
@@ -39,16 +39,21 @@ namespace EEVT {
|
|||||||
enum DAGISelGenValueType {
|
enum DAGISelGenValueType {
|
||||||
isFP = MVT::LAST_VALUETYPE,
|
isFP = MVT::LAST_VALUETYPE,
|
||||||
isInt,
|
isInt,
|
||||||
|
isVec,
|
||||||
isUnknown
|
isUnknown
|
||||||
};
|
};
|
||||||
|
|
||||||
/// isExtIntegerVT - Return true if the specified extended value type vector
|
/// isExtIntegerInVTs - Return true if the specified extended value type
|
||||||
/// contains isInt or an integer value type.
|
/// vector contains isInt or an integer value type.
|
||||||
bool isExtIntegerInVTs(const std::vector<unsigned char> &EVTs);
|
bool isExtIntegerInVTs(const std::vector<unsigned char> &EVTs);
|
||||||
|
|
||||||
/// isExtFloatingPointVT - Return true if the specified extended value type
|
/// isExtFloatingPointInVTs - Return true if the specified extended value
|
||||||
/// vector contains isFP or a FP value type.
|
/// type vector contains isFP or a FP value type.
|
||||||
bool isExtFloatingPointInVTs(const std::vector<unsigned char> &EVTs);
|
bool isExtFloatingPointInVTs(const std::vector<unsigned char> &EVTs);
|
||||||
|
|
||||||
|
/// isExtVectorinVTs - Return true if the specified extended value type
|
||||||
|
/// vector contains isVec or a vector value type.
|
||||||
|
bool isExtVectorInVTs(const std::vector<unsigned char> &EVTs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set type used to track multiply used variables in patterns
|
/// Set type used to track multiply used variables in patterns
|
||||||
@@ -61,7 +66,7 @@ struct SDTypeConstraint {
|
|||||||
|
|
||||||
unsigned OperandNo; // The operand # this constraint applies to.
|
unsigned OperandNo; // The operand # this constraint applies to.
|
||||||
enum {
|
enum {
|
||||||
SDTCisVT, SDTCisPtrTy, SDTCisInt, SDTCisFP, SDTCisSameAs,
|
SDTCisVT, SDTCisPtrTy, SDTCisInt, SDTCisFP, SDTCisVec, SDTCisSameAs,
|
||||||
SDTCisVTSmallerThanOp, SDTCisOpSmallerThanOp, SDTCisEltOfVec
|
SDTCisVTSmallerThanOp, SDTCisOpSmallerThanOp, SDTCisEltOfVec
|
||||||
} ConstraintType;
|
} ConstraintType;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user