aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Stmt.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-10 06:33:24 +0000
committerChris Lattner <sabre@nondot.org>2009-03-10 06:33:24 +0000
commit10ca96ae9aed6906c3302403ef1a146a8d4c6b74 (patch)
tree5b363ae980aee4bc3a1552ca642a50ef2d2f9184 /lib/AST/Stmt.cpp
parentbb57265fdba1e8af05dd917b8bf243d49cfb3465 (diff)
move matching of named operands into AsmStmt class. At the same
time handle + operands in operand counting, fixing asm.c:t7 to expand into $2 instead of $1. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66531 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Stmt.cpp')
-rw-r--r--lib/AST/Stmt.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 682a9b1ee4..b7feda9b8f 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -154,6 +154,31 @@ std::string AsmStmt::getInputConstraint(unsigned i) const {
Constraints[i + NumOutputs]->getByteLength());
}
+
+/// getNamedOperand - Given a symbolic operand reference like %[foo],
+/// translate this into a numeric value needed to reference the same operand.
+/// This returns -1 if the operand name is invalid.
+int AsmStmt::getNamedOperand(const std::string &SymbolicName) const {
+ unsigned NumPlusOperands = 0;
+
+ // Check if this is an output operand.
+ for (unsigned i = 0, e = getNumOutputs(); i != e; ++i) {
+ if (getOutputName(i) == SymbolicName)
+ return i;
+
+ // Keep track of the number of '+' operands.
+ if (isOutputPlusConstraint(i)) ++NumPlusOperands;
+ }
+
+ for (unsigned i = 0, e = getNumInputs(); i != e; ++i)
+ if (getInputName(i) == SymbolicName)
+ return getNumOutputs() + NumPlusOperands + i;
+
+ // Not found.
+ return -1;
+}
+
+
//===----------------------------------------------------------------------===//
// Constructors
//===----------------------------------------------------------------------===//