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 | 3dd7bf2c86921460ce2153361d55ca0d38392f33 (patch) | |
tree | 886ef7a52bcd9fcd40a351e273c616c86b84e125 /clang/lib/AST/Stmt.cpp | |
parent | 6cb2080e5edd6c5d494ed0ad1b5ea7dc5067336d (diff) | |
download | bcm5719-llvm-3dd7bf2c86921460ce2153361d55ca0d38392f33.tar.gz bcm5719-llvm-3dd7bf2c86921460ce2153361d55ca0d38392f33.zip |
[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.
llvm-svn: 162784
Diffstat (limited to 'clang/lib/AST/Stmt.cpp')
-rw-r--r-- | clang/lib/AST/Stmt.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 84622658d5e..ac432e85a7c 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -630,14 +630,6 @@ Expr *MSAsmStmt::getOutputExpr(unsigned i) { return cast<Expr>(Exprs[i]); } -/// getOutputConstraint - Return the constraint string for the specified -/// output operand. All output constraints are known to be non-empty (either -/// '=' or '+'). -StringRef MSAsmStmt::getOutputConstraint(unsigned i) const { - // FIXME: Compute constraints. - return StringRef(); -} - Expr *MSAsmStmt::getInputExpr(unsigned i) { return cast<Expr>(Exprs[i + NumOutputs]); } @@ -645,13 +637,6 @@ void MSAsmStmt::setInputExpr(unsigned i, Expr *E) { Exprs[i + NumOutputs] = E; } -/// getInputConstraint - Return the specified input constraint. Unlike output -/// constraints, these can be empty. -StringRef MSAsmStmt::getInputConstraint(unsigned i) const { - // FIXME: Compute constraints. - return StringRef(); -} - QualType CXXCatchStmt::getCaughtType() const { if (ExceptionDecl) return ExceptionDecl->getType(); @@ -691,8 +676,8 @@ MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc, ArrayRef<Token> asmtoks, ArrayRef<IdentifierInfo*> inputs, ArrayRef<IdentifierInfo*> outputs, ArrayRef<Expr*> inputexprs, ArrayRef<Expr*> outputexprs, - StringRef asmstr, ArrayRef<StringRef> clobbers, - SourceLocation endloc) + StringRef asmstr, ArrayRef<StringRef> constraints, + ArrayRef<StringRef> clobbers, SourceLocation endloc) : AsmStmt(MSAsmStmtClass, asmloc, issimple, isvolatile, outputs.size(), inputs.size(), clobbers.size()), LBraceLoc(lbraceloc), EndLoc(endloc), AsmStr(asmstr.str()), NumAsmToks(asmtoks.size()) { @@ -717,6 +702,14 @@ MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc, for (unsigned i = 0, e = NumAsmToks; i != e; ++i) AsmToks[i] = asmtoks[i]; + Constraints = new (C) StringRef[NumExprs]; + for (unsigned i = 0, e = NumExprs; i != e; ++i) { + size_t size = constraints[i].size(); + char *dest = new (C) char[size]; + std::strncpy(dest, constraints[i].data(), size); + Constraints[i] = StringRef(dest, size); + } + Clobbers = new (C) StringRef[NumClobbers]; for (unsigned i = 0, e = NumClobbers; i != e; ++i) { // FIXME: Avoid the allocation/copy if at all possible. |