diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-08-28 20:28:20 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-08-28 20:28:20 +0000 |
commit | 89fb6d7eba51c7864ec544e07accd23b24057122 (patch) | |
tree | de7f2a49582fa01408145ce8a273b651393d7564 /lib/Sema/SemaStmtAsm.cpp | |
parent | 5abd3d2ba4c4edb5140de5d65a16e5da4076f0b1 (diff) |
[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
Diffstat (limited to 'lib/Sema/SemaStmtAsm.cpp')
-rw-r--r-- | lib/Sema/SemaStmtAsm.cpp | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/lib/Sema/SemaStmtAsm.cpp b/lib/Sema/SemaStmtAsm.cpp index 638c87953c..f51e47656c 100644 --- a/lib/Sema/SemaStmtAsm.cpp +++ b/lib/Sema/SemaStmtAsm.cpp @@ -454,17 +454,20 @@ static std::string buildMSAsmString(Sema &SemaRef, ArrayRef<Token> AsmToks, 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 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, 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 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, 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); } |