mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
make getOperandNum a static function (since it's just used by
ApplyTypeConstraint) and make it handle multiple result nodes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99003 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6c7ed6b549
commit
2e68a02c26
@ -538,24 +538,27 @@ SDTypeConstraint::SDTypeConstraint(Record *R) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// getOperandNum - Return the node corresponding to operand #OpNo in tree
|
/// getOperandNum - Return the node corresponding to operand #OpNo in tree
|
||||||
/// N, which has NumResults results.
|
/// N, and the result number in ResNo.
|
||||||
TreePatternNode *SDTypeConstraint::getOperandNum(unsigned OpNo,
|
static TreePatternNode *getOperandNum(unsigned OpNo, TreePatternNode *N,
|
||||||
TreePatternNode *N,
|
const SDNodeInfo &NodeInfo,
|
||||||
unsigned NumResults) const {
|
unsigned &ResNo) {
|
||||||
assert(NumResults <= 1 &&
|
unsigned NumResults = NodeInfo.getNumResults();
|
||||||
"We only work with nodes with zero or one result so far!");
|
if (OpNo < NumResults) {
|
||||||
|
ResNo = OpNo;
|
||||||
|
return N;
|
||||||
|
}
|
||||||
|
|
||||||
if (OpNo >= (NumResults + N->getNumChildren())) {
|
OpNo -= NumResults;
|
||||||
errs() << "Invalid operand number " << OpNo << " ";
|
|
||||||
|
if (OpNo >= N->getNumChildren()) {
|
||||||
|
errs() << "Invalid operand number in type constraint "
|
||||||
|
<< (OpNo+NumResults) << " ";
|
||||||
N->dump();
|
N->dump();
|
||||||
errs() << '\n';
|
errs() << '\n';
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OpNo < NumResults)
|
return N->getChild(OpNo);
|
||||||
return N; // FIXME: need value #
|
|
||||||
else
|
|
||||||
return N->getChild(OpNo-NumResults);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ApplyTypeConstraint - Given a node in a pattern, apply this type
|
/// ApplyTypeConstraint - Given a node in a pattern, apply this type
|
||||||
@ -565,11 +568,6 @@ TreePatternNode *SDTypeConstraint::getOperandNum(unsigned OpNo,
|
|||||||
bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
|
bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
|
||||||
const SDNodeInfo &NodeInfo,
|
const SDNodeInfo &NodeInfo,
|
||||||
TreePattern &TP) const {
|
TreePattern &TP) const {
|
||||||
unsigned NumResults = NodeInfo.getNumResults();
|
|
||||||
unsigned ResNo = 0; // TODO: Set to the result # we're working with.
|
|
||||||
assert(NumResults <= 1 &&
|
|
||||||
"We only work with nodes with zero or one result so far!");
|
|
||||||
|
|
||||||
// Check that the number of operands is sane. Negative operands -> varargs.
|
// Check that the number of operands is sane. Negative operands -> varargs.
|
||||||
if (NodeInfo.getNumOperands() >= 0) {
|
if (NodeInfo.getNumOperands() >= 0) {
|
||||||
if (N->getNumChildren() != (unsigned)NodeInfo.getNumOperands())
|
if (N->getNumChildren() != (unsigned)NodeInfo.getNumOperands())
|
||||||
@ -577,7 +575,8 @@ bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
|
|||||||
itostr(NodeInfo.getNumOperands()) + " operands!");
|
itostr(NodeInfo.getNumOperands()) + " operands!");
|
||||||
}
|
}
|
||||||
|
|
||||||
TreePatternNode *NodeToApply = getOperandNum(OperandNo, N, NumResults);
|
unsigned ResNo = 0; // The result number being referenced.
|
||||||
|
TreePatternNode *NodeToApply = getOperandNum(OperandNo, N, NodeInfo, ResNo);
|
||||||
|
|
||||||
switch (ConstraintType) {
|
switch (ConstraintType) {
|
||||||
default: assert(0 && "Unknown constraint type!");
|
default: assert(0 && "Unknown constraint type!");
|
||||||
@ -597,9 +596,9 @@ bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
|
|||||||
// Require it to be one of the legal vector VTs.
|
// Require it to be one of the legal vector VTs.
|
||||||
return NodeToApply->getExtType(ResNo).EnforceVector(TP);
|
return NodeToApply->getExtType(ResNo).EnforceVector(TP);
|
||||||
case SDTCisSameAs: {
|
case SDTCisSameAs: {
|
||||||
unsigned OResNo = 0; // FIXME: getOperandNum should return pair.
|
unsigned OResNo = 0;
|
||||||
TreePatternNode *OtherNode =
|
TreePatternNode *OtherNode =
|
||||||
getOperandNum(x.SDTCisSameAs_Info.OtherOperandNum, N, NumResults);
|
getOperandNum(x.SDTCisSameAs_Info.OtherOperandNum, N, NodeInfo, OResNo);
|
||||||
return NodeToApply->UpdateNodeType(OResNo, OtherNode->getExtType(ResNo),TP)|
|
return NodeToApply->UpdateNodeType(OResNo, OtherNode->getExtType(ResNo),TP)|
|
||||||
OtherNode->UpdateNodeType(ResNo,NodeToApply->getExtType(OResNo),TP);
|
OtherNode->UpdateNodeType(ResNo,NodeToApply->getExtType(OResNo),TP);
|
||||||
}
|
}
|
||||||
@ -616,9 +615,10 @@ bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
|
|||||||
if (!isInteger(VT))
|
if (!isInteger(VT))
|
||||||
TP.error(N->getOperator()->getName() + " VT operand must be integer!");
|
TP.error(N->getOperator()->getName() + " VT operand must be integer!");
|
||||||
|
|
||||||
unsigned OResNo = 0; // FIXME: getOperandNum should return pair.
|
unsigned OResNo = 0;
|
||||||
TreePatternNode *OtherNode =
|
TreePatternNode *OtherNode =
|
||||||
getOperandNum(x.SDTCisVTSmallerThanOp_Info.OtherOperandNum, N,NumResults);
|
getOperandNum(x.SDTCisVTSmallerThanOp_Info.OtherOperandNum, N, NodeInfo,
|
||||||
|
OResNo);
|
||||||
|
|
||||||
// It must be integer.
|
// It must be integer.
|
||||||
bool MadeChange = OtherNode->getExtType(OResNo).EnforceInteger(TP);
|
bool MadeChange = OtherNode->getExtType(OResNo).EnforceInteger(TP);
|
||||||
@ -630,16 +630,18 @@ bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
|
|||||||
return MadeChange;
|
return MadeChange;
|
||||||
}
|
}
|
||||||
case SDTCisOpSmallerThanOp: {
|
case SDTCisOpSmallerThanOp: {
|
||||||
unsigned BResNo = 0; // FIXME: getOperandNum should return pair.
|
unsigned BResNo = 0;
|
||||||
TreePatternNode *BigOperand =
|
TreePatternNode *BigOperand =
|
||||||
getOperandNum(x.SDTCisOpSmallerThanOp_Info.BigOperandNum, N, NumResults);
|
getOperandNum(x.SDTCisOpSmallerThanOp_Info.BigOperandNum, N, NodeInfo,
|
||||||
|
BResNo);
|
||||||
return NodeToApply->getExtType(ResNo).
|
return NodeToApply->getExtType(ResNo).
|
||||||
EnforceSmallerThan(BigOperand->getExtType(BResNo), TP);
|
EnforceSmallerThan(BigOperand->getExtType(BResNo), TP);
|
||||||
}
|
}
|
||||||
case SDTCisEltOfVec: {
|
case SDTCisEltOfVec: {
|
||||||
unsigned VResNo = 0; // FIXME: getOperandNum should return pair.
|
unsigned VResNo = 0;
|
||||||
TreePatternNode *VecOperand =
|
TreePatternNode *VecOperand =
|
||||||
getOperandNum(x.SDTCisEltOfVec_Info.OtherOperandNum, N, NumResults);
|
getOperandNum(x.SDTCisEltOfVec_Info.OtherOperandNum, N, NodeInfo,
|
||||||
|
VResNo);
|
||||||
if (VecOperand->hasTypeSet(VResNo)) {
|
if (VecOperand->hasTypeSet(VResNo)) {
|
||||||
if (!isVector(VecOperand->getType(VResNo)))
|
if (!isVector(VecOperand->getType(VResNo)))
|
||||||
TP.error(N->getOperator()->getName() + " VT operand must be a vector!");
|
TP.error(N->getOperator()->getName() + " VT operand must be a vector!");
|
||||||
|
@ -182,11 +182,6 @@ struct SDTypeConstraint {
|
|||||||
/// exception.
|
/// exception.
|
||||||
bool ApplyTypeConstraint(TreePatternNode *N, const SDNodeInfo &NodeInfo,
|
bool ApplyTypeConstraint(TreePatternNode *N, const SDNodeInfo &NodeInfo,
|
||||||
TreePattern &TP) const;
|
TreePattern &TP) const;
|
||||||
|
|
||||||
/// getOperandNum - Return the node corresponding to operand #OpNo in tree
|
|
||||||
/// N, which has NumResults results.
|
|
||||||
TreePatternNode *getOperandNum(unsigned OpNo, TreePatternNode *N,
|
|
||||||
unsigned NumResults) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// SDNodeInfo - One of these records is created for each SDNode instance in
|
/// SDNodeInfo - One of these records is created for each SDNode instance in
|
||||||
|
Loading…
Reference in New Issue
Block a user