mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
improve type checking of SDNode operand count. This rejects all cases
where an incorrect number of operands is provided to an sdnode instead of just a few cases. llvm-svn: 99761
This commit is contained in:
parent
4de7f7e862
commit
117eb269f9
@ -586,13 +586,6 @@ static TreePatternNode *getOperandNum(unsigned OpNo, TreePatternNode *N,
|
|||||||
bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
|
bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode *N,
|
||||||
const SDNodeInfo &NodeInfo,
|
const SDNodeInfo &NodeInfo,
|
||||||
TreePattern &TP) const {
|
TreePattern &TP) const {
|
||||||
// Check that the number of operands is sane. Negative operands -> varargs.
|
|
||||||
if (NodeInfo.getNumOperands() >= 0) {
|
|
||||||
if (N->getNumChildren() != (unsigned)NodeInfo.getNumOperands())
|
|
||||||
TP.error(N->getOperator()->getName() + " node requires exactly " +
|
|
||||||
itostr(NodeInfo.getNumOperands()) + " operands!");
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned ResNo = 0; // The result number being referenced.
|
unsigned ResNo = 0; // The result number being referenced.
|
||||||
TreePatternNode *NodeToApply = getOperandNum(OperandNo, N, NodeInfo, ResNo);
|
TreePatternNode *NodeToApply = getOperandNum(OperandNo, N, NodeInfo, ResNo);
|
||||||
|
|
||||||
@ -1238,6 +1231,12 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
|
|||||||
if (getOperator()->isSubClassOf("SDNode")) {
|
if (getOperator()->isSubClassOf("SDNode")) {
|
||||||
const SDNodeInfo &NI = CDP.getSDNodeInfo(getOperator());
|
const SDNodeInfo &NI = CDP.getSDNodeInfo(getOperator());
|
||||||
|
|
||||||
|
// Check that the number of operands is sane. Negative operands -> varargs.
|
||||||
|
if (NI.getNumOperands() >= 0 &&
|
||||||
|
getNumChildren() != (unsigned)NI.getNumOperands())
|
||||||
|
TP.error(getOperator()->getName() + " node requires exactly " +
|
||||||
|
itostr(NI.getNumOperands()) + " operands!");
|
||||||
|
|
||||||
bool MadeChange = NI.ApplyTypeConstraints(this, TP);
|
bool MadeChange = NI.ApplyTypeConstraints(this, TP);
|
||||||
for (unsigned i = 0, e = getNumChildren(); i != e; ++i)
|
for (unsigned i = 0, e = getNumChildren(); i != e; ++i)
|
||||||
MadeChange |= getChild(i)->ApplyTypeConstraints(TP, NotRegisters);
|
MadeChange |= getChild(i)->ApplyTypeConstraints(TP, NotRegisters);
|
||||||
@ -1469,7 +1468,7 @@ TreePatternNode *TreePattern::ParseTreePattern(Init *TheInit, StringRef OpName){
|
|||||||
|
|
||||||
// Input argument?
|
// Input argument?
|
||||||
TreePatternNode *Res = new TreePatternNode(DI, 1);
|
TreePatternNode *Res = new TreePatternNode(DI, 1);
|
||||||
if (R->getName() == "node") {
|
if (R->getName() == "node" && !OpName.empty()) {
|
||||||
if (OpName.empty())
|
if (OpName.empty())
|
||||||
error("'node' argument requires a name to match with operand list");
|
error("'node' argument requires a name to match with operand list");
|
||||||
Args.push_back(OpName);
|
Args.push_back(OpName);
|
||||||
|
@ -199,6 +199,9 @@ public:
|
|||||||
SDNodeInfo(Record *R); // Parse the specified record.
|
SDNodeInfo(Record *R); // Parse the specified record.
|
||||||
|
|
||||||
unsigned getNumResults() const { return NumResults; }
|
unsigned getNumResults() const { return NumResults; }
|
||||||
|
|
||||||
|
/// getNumOperands - This is the number of operands required or -1 if
|
||||||
|
/// variadic.
|
||||||
int getNumOperands() const { return NumOperands; }
|
int getNumOperands() const { return NumOperands; }
|
||||||
Record *getRecord() const { return Def; }
|
Record *getRecord() const { return Def; }
|
||||||
const std::string &getEnumName() const { return EnumName; }
|
const std::string &getEnumName() const { return EnumName; }
|
||||||
|
Loading…
Reference in New Issue
Block a user