summaryrefslogtreecommitdiffstats
path: root/llvm/utils/TableGen/CodeGenInstruction.cpp
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2010-10-11 18:25:51 +0000
committerJim Grosbach <grosbach@apple.com>2010-10-11 18:25:51 +0000
commit191ad7c473b506280cb24ade7d0ab25ae63a2594 (patch)
treed4f06e389af4939fe5afcf790b784986185cb115 /llvm/utils/TableGen/CodeGenInstruction.cpp
parent2f6531eb8cec7cb918245377229b29578b52564c (diff)
downloadbcm5719-llvm-191ad7c473b506280cb24ade7d0ab25ae63a2594.tar.gz
bcm5719-llvm-191ad7c473b506280cb24ade7d0ab25ae63a2594.zip
When figuring out which operands match which encoding fields in an instruction,
try to match them by name first. If there is no by-name match, fall back to assuming they are in order (this was the previous behavior). llvm-svn: 116211
Diffstat (limited to 'llvm/utils/TableGen/CodeGenInstruction.cpp')
-rw-r--r--llvm/utils/TableGen/CodeGenInstruction.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/llvm/utils/TableGen/CodeGenInstruction.cpp b/llvm/utils/TableGen/CodeGenInstruction.cpp
index 01a1fe11f53..722ae53ed50 100644
--- a/llvm/utils/TableGen/CodeGenInstruction.cpp
+++ b/llvm/utils/TableGen/CodeGenInstruction.cpp
@@ -234,13 +234,26 @@ CodeGenInstruction::CodeGenInstruction(Record *R, const std::string &AsmStr)
/// specified name, throw an exception.
///
unsigned CodeGenInstruction::getOperandNamed(const std::string &Name) const {
- assert(!Name.empty() && "Cannot search for operand with no name!");
- for (unsigned i = 0, e = OperandList.size(); i != e; ++i)
- if (OperandList[i].Name == Name) return i;
+ unsigned OpIdx;
+ if (hasOperandNamed(Name, OpIdx)) return OpIdx;
throw "Instruction '" + TheDef->getName() +
"' does not have an operand named '$" + Name + "'!";
}
+/// hasOperandNamed - Query whether the instruction has an operand of the
+/// given name. If so, return true and set OpIdx to the index of the
+/// operand. Otherwise, return false.
+bool CodeGenInstruction::hasOperandNamed(const std::string &Name,
+ unsigned &OpIdx) const {
+ assert(!Name.empty() && "Cannot search for operand with no name!");
+ for (unsigned i = 0, e = OperandList.size(); i != e; ++i)
+ if (OperandList[i].Name == Name) {
+ OpIdx = i;
+ return true;
+ }
+ return false;
+}
+
std::pair<unsigned,unsigned>
CodeGenInstruction::ParseOperandName(const std::string &Op,
bool AllowWholeOp) {
OpenPOWER on IntegriCloud