forked from OSchip/llvm-project
Tablegen support for insert & extract element matching
llvm-svn: 46901
This commit is contained in:
parent
7f5c2553c7
commit
17bedbc500
|
@ -60,6 +60,13 @@ class SDTCisIntVectorOfSameSize<int ThisOp, int OtherOp>
|
||||||
int OtherOpNum = OtherOp;
|
int OtherOpNum = OtherOp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// SDTCisEltOfVec - This indicates that ThisOp is a scalar type of the same
|
||||||
|
/// type as the element type of OtherOp, which is a vector type.
|
||||||
|
class SDTCisEltOfVec<int ThisOp, int OtherOp>
|
||||||
|
: SDTypeConstraint<ThisOp> {
|
||||||
|
int OtherOpNum = OtherOp;
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Selection DAG Type Profile definitions.
|
// Selection DAG Type Profile definitions.
|
||||||
//
|
//
|
||||||
|
@ -171,6 +178,12 @@ def SDTIStore : SDTypeProfile<1, 3, [ // indexed store
|
||||||
def SDTVecShuffle : SDTypeProfile<1, 3, [
|
def SDTVecShuffle : SDTypeProfile<1, 3, [
|
||||||
SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisIntVectorOfSameSize<3, 0>
|
SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisIntVectorOfSameSize<3, 0>
|
||||||
]>;
|
]>;
|
||||||
|
def SDTVecExtract : SDTypeProfile<1, 2, [ // vector extract
|
||||||
|
SDTCisEltOfVec<0, 1>, SDTCisPtrTy<2>
|
||||||
|
]>;
|
||||||
|
def SDTVecInsert : SDTypeProfile<1, 2, [ // vector insert
|
||||||
|
SDTCisEltOfVec<1, 0>, SDTCisPtrTy<2>
|
||||||
|
]>;
|
||||||
|
|
||||||
class SDCallSeqStart<list<SDTypeConstraint> constraints> :
|
class SDCallSeqStart<list<SDTypeConstraint> constraints> :
|
||||||
SDTypeProfile<0, 1, constraints>;
|
SDTypeProfile<0, 1, constraints>;
|
||||||
|
@ -283,6 +296,9 @@ def zext : SDNode<"ISD::ZERO_EXTEND", SDTIntExtendOp>;
|
||||||
def anyext : SDNode<"ISD::ANY_EXTEND" , SDTIntExtendOp>;
|
def anyext : SDNode<"ISD::ANY_EXTEND" , SDTIntExtendOp>;
|
||||||
def trunc : SDNode<"ISD::TRUNCATE" , SDTIntTruncOp>;
|
def trunc : SDNode<"ISD::TRUNCATE" , SDTIntTruncOp>;
|
||||||
def bitconvert : SDNode<"ISD::BIT_CONVERT", SDTUnaryOp>;
|
def bitconvert : SDNode<"ISD::BIT_CONVERT", SDTUnaryOp>;
|
||||||
|
def extractelt : SDNode<"ISD::EXTRACT_VECTOR_ELT", SDTVecExtract>;
|
||||||
|
def insertelt : SDNode<"ISD::INSERT_VECTOR_ELT", SDTVecInsert>;
|
||||||
|
|
||||||
|
|
||||||
def fadd : SDNode<"ISD::FADD" , SDTFPBinOp, [SDNPCommutative]>;
|
def fadd : SDNode<"ISD::FADD" , SDTFPBinOp, [SDNPCommutative]>;
|
||||||
def fsub : SDNode<"ISD::FSUB" , SDTFPBinOp>;
|
def fsub : SDNode<"ISD::FSUB" , SDTFPBinOp>;
|
||||||
|
|
|
@ -112,6 +112,10 @@ SDTypeConstraint::SDTypeConstraint(Record *R) {
|
||||||
ConstraintType = SDTCisIntVectorOfSameSize;
|
ConstraintType = SDTCisIntVectorOfSameSize;
|
||||||
x.SDTCisIntVectorOfSameSize_Info.OtherOperandNum =
|
x.SDTCisIntVectorOfSameSize_Info.OtherOperandNum =
|
||||||
R->getValueAsInt("OtherOpNum");
|
R->getValueAsInt("OtherOpNum");
|
||||||
|
} else if (R->isSubClassOf("SDTCisEltOfVec")) {
|
||||||
|
ConstraintType = SDTCisEltOfVec;
|
||||||
|
x.SDTCisEltOfVec_Info.OtherOperandNum =
|
||||||
|
R->getValueAsInt("OtherOpNum");
|
||||||
} else {
|
} else {
|
||||||
cerr << "Unrecognized SDTypeConstraint '" << R->getName() << "'!\n";
|
cerr << "Unrecognized SDTypeConstraint '" << R->getName() << "'!\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -288,6 +292,19 @@ bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case SDTCisEltOfVec: {
|
||||||
|
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::getVectorElementType(IVT);
|
||||||
|
return NodeToApply->UpdateNodeType(IVT, TP);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,8 @@ 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, SDTCisSameAs,
|
||||||
SDTCisVTSmallerThanOp, SDTCisOpSmallerThanOp, SDTCisIntVectorOfSameSize
|
SDTCisVTSmallerThanOp, SDTCisOpSmallerThanOp, SDTCisIntVectorOfSameSize,
|
||||||
|
SDTCisEltOfVec
|
||||||
} ConstraintType;
|
} ConstraintType;
|
||||||
|
|
||||||
union { // The discriminated union.
|
union { // The discriminated union.
|
||||||
|
@ -75,6 +76,9 @@ struct SDTypeConstraint {
|
||||||
struct {
|
struct {
|
||||||
unsigned OtherOperandNum;
|
unsigned OtherOperandNum;
|
||||||
} SDTCisIntVectorOfSameSize_Info;
|
} SDTCisIntVectorOfSameSize_Info;
|
||||||
|
struct {
|
||||||
|
unsigned OtherOperandNum;
|
||||||
|
} SDTCisEltOfVec_Info;
|
||||||
} x;
|
} x;
|
||||||
|
|
||||||
/// ApplyTypeConstraint - Given a node in a pattern, apply this type
|
/// ApplyTypeConstraint - Given a node in a pattern, apply this type
|
||||||
|
|
Loading…
Reference in New Issue