summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChristopher Lamb <christopher.lamb@gmail.com>2008-03-10 04:13:41 +0000
committerChristopher Lamb <christopher.lamb@gmail.com>2008-03-10 04:13:41 +0000
commit620d7412508ae63378462df73d75706f19582646 (patch)
tree95c06363af08a4b3f5cfbe8321d65c103035a22c /utils
parent9be3c97183f832d084bcf0fab82f7cd8aae08385 (diff)
downloadllvm-620d7412508ae63378462df73d75706f19582646.tar.gz
llvm-620d7412508ae63378462df73d75706f19582646.tar.bz2
llvm-620d7412508ae63378462df73d75706f19582646.tar.xz
Add support in TableGen for unknown operands that infer their type from the pattern their used in. This will be used to allow insert/extract subreg patterns in .td files!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48125 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/CodeGenDAGPatterns.cpp12
-rw-r--r--utils/TableGen/CodeGenInstruction.cpp2
2 files changed, 10 insertions, 4 deletions
diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp
index 003f108fa4..95912194aa 100644
--- a/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -864,7 +864,7 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
CDP.getTargetInfo().getInstruction(getOperator()->getName());
// Apply the result type to the node
if (NumResults == 0 || InstInfo.NumDefs == 0) {
- MadeChange = UpdateNodeType(MVT::isVoid, TP);
+ MadeChange = UpdateNodeType(MVT::isVoid, TP);
} else {
Record *ResultNode = Inst.getResult(0);
@@ -872,6 +872,10 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
std::vector<unsigned char> VT;
VT.push_back(MVT::iPTR);
MadeChange = UpdateNodeType(VT, TP);
+ } else if (ResultNode->getName() == "unknown") {
+ std::vector<unsigned char> VT;
+ VT.push_back(MVT::isUnknown);
+ MadeChange = UpdateNodeType(VT, TP);
} else {
assert(ResultNode->isSubClassOf("RegisterClass") &&
"Operands should be register classes!");
@@ -910,14 +914,16 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
MadeChange |= Child->UpdateNodeType(VT, TP);
} else if (OperandNode->getName() == "ptr_rc") {
MadeChange |= Child->UpdateNodeType(MVT::iPTR, TP);
+ } else if (OperandNode->getName() == "unknown") {
+ MadeChange |= Child->UpdateNodeType(MVT::isUnknown, TP);
} else {
assert(0 && "Unknown operand type!");
abort();
}
MadeChange |= Child->ApplyTypeConstraints(TP, NotRegisters);
}
-
- if (ChildNo != getNumChildren())
+
+ if (ChildNo != getNumChildren() && !InstInfo.isVariadic)
TP.error("Instruction '" + getOperator()->getName() +
"' was provided too many operands!");
diff --git a/utils/TableGen/CodeGenInstruction.cpp b/utils/TableGen/CodeGenInstruction.cpp
index 0ee6b41d90..8b70647907 100644
--- a/utils/TableGen/CodeGenInstruction.cpp
+++ b/utils/TableGen/CodeGenInstruction.cpp
@@ -163,7 +163,7 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
isVariadic = true;
continue;
} else if (!Rec->isSubClassOf("RegisterClass") &&
- Rec->getName() != "ptr_rc")
+ Rec->getName() != "ptr_rc" && Rec->getName() != "unknown")
throw "Unknown operand class '" + Rec->getName() +
"' in instruction '" + R->getName() + "' instruction!";