[ms-inline asm] Add constraints to MSAsmStmt.  We don't currently compute
the constraints, so in the interim we speculatively assume a 'r' constraint.
This is expected to work for most cases on x86.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162784 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaStmtAsm.cpp b/lib/Sema/SemaStmtAsm.cpp
index 638c879..f51e476 100644
--- a/lib/Sema/SemaStmtAsm.cpp
+++ b/lib/Sema/SemaStmtAsm.cpp
@@ -454,17 +454,20 @@
   return Res.str();
 }
 
-#define DEF_SIMPLE_MSASM                                                   \
-  MSAsmStmt *NS =                                                          \
-    new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, /*IsSimple*/ true, \
-                            /*IsVolatile*/ true, AsmToks, Inputs, Outputs, \
-                            InputExprs, OutputExprs, AsmString, Clobbers,  \
-                            EndLoc);
+#define DEF_SIMPLE_MSASM                                                     \
+  MSAsmStmt *NS =                                                            \
+    new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, /*IsSimple*/ true,   \
+                            /*IsVolatile*/ true, AsmToks, Inputs, Outputs,   \
+                            InputExprs, OutputExprs, AsmString, Constraints, \
+                            Clobbers, EndLoc);
 
 StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc,
                                 SourceLocation LBraceLoc,
                                 ArrayRef<Token> AsmToks,
                                 SourceLocation EndLoc) {
+  SmallVector<StringRef, 4> Constraints;
+  std::vector<std::string> InputConstraints;
+  std::vector<std::string> OutputConstraints;
   SmallVector<StringRef,4> Clobbers;
   std::set<std::string> ClobberRegs;
   SmallVector<IdentifierInfo*, 4> Inputs;
@@ -606,9 +609,11 @@
               if (isDef) {
                 Outputs.push_back(II);
                 OutputExprs.push_back(Result.take());
+                OutputConstraints.push_back("=r");
               } else {
                 Inputs.push_back(II);
                 InputExprs.push_back(Result.take());
+                InputConstraints.push_back("r");
               }
             }
           }
@@ -620,10 +625,20 @@
          E = ClobberRegs.end(); I != E; ++I)
     Clobbers.push_back(*I);
 
+  // Merge the output and input constraints.  Output constraints are expected
+  // first.
+  for (std::vector<std::string>::iterator I = OutputConstraints.begin(),
+         E = OutputConstraints.end(); I != E; ++I)
+    Constraints.push_back(*I);
+
+  for (std::vector<std::string>::iterator I = InputConstraints.begin(),
+         E = InputConstraints.end(); I != E; ++I)
+    Constraints.push_back(*I);
+
   MSAsmStmt *NS =
     new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, IsSimple,
                             /*IsVolatile*/ true, AsmToks, Inputs, Outputs,
-                            InputExprs, OutputExprs, AsmString, Clobbers,
-                            EndLoc);
+                            InputExprs, OutputExprs, AsmString, Constraints,
+                            Clobbers, EndLoc);
   return Owned(NS);
 }