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
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index ff1f76f..93c4f5b 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -771,34 +771,15 @@
     if (EscapedChar == '[') {
       const char *NameEnd = (const char*)memchr(StrStart, ']', StrEnd-StrStart);
       // FIXME: Should be caught by sema.
+      // FIXME: Does sema catch multiple operands with the same name?
       assert(NameEnd != 0 && "Could not parse symbolic name");
-      
       std::string SymbolicName(StrStart, NameEnd);
-      
       StrStart = NameEnd+1;
       
-      int Index = -1;
-      
-      // Check if this is an output operand.
-      for (unsigned i = 0; i != S.getNumOutputs(); ++i) {
-        if (S.getOutputName(i) == SymbolicName) {
-          Index = i;
-          break;
-        }
-      }
-      
-      if (Index == -1) {
-        for (unsigned i = 0; i != S.getNumInputs(); ++i) {
-          if (S.getInputName(i) == SymbolicName) {
-            Index = S.getNumOutputs() + i;
-            break;
-          }
-        }
-      }
-      
-      assert(Index != -1 && "Did not find right operand!");
-     
-      Result += '$' + llvm::utostr(Index);
+      int OperandIndex = S.getNamedOperand(SymbolicName);
+      assert(OperandIndex != -1 && "FIXME: Catch in Sema.");
+
+      Result += '$' + llvm::utostr(unsigned(OperandIndex));
       continue;
     }