From 7dbef3e035f10fcaa320e8e0fb48f0d96bcb9181 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Thu, 16 Aug 2012 00:06:53 +0000 Subject: [PATCH] [ms-inline asm] Add inputs and outputs to AST. No functional change. llvm-svn: 162000 --- clang/include/clang/AST/Stmt.h | 4 ++++ clang/lib/AST/Stmt.cpp | 21 +++++++++++++++------ clang/lib/Sema/SemaStmt.cpp | 21 +++++++++++---------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h index 943e005d1f2b..47dada86ddf1 100644 --- a/clang/include/clang/AST/Stmt.h +++ b/clang/include/clang/AST/Stmt.h @@ -1627,15 +1627,19 @@ class MSAsmStmt : public Stmt { bool IsVolatile; unsigned NumAsmToks; + unsigned NumInputs; + unsigned NumOutputs; unsigned NumClobbers; Token *AsmToks; + IdentifierInfo **Names; Stmt **Exprs; StringRef *Clobbers; public: MSAsmStmt(ASTContext &C, SourceLocation asmloc, SourceLocation lbraceloc, bool issimple, bool isvolatile, ArrayRef asmtoks, + ArrayRef inputs, ArrayRef outputs, StringRef asmstr, ArrayRef clobbers, SourceLocation endloc); diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index 680ebc81c8ea..77452c9d9d1c 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -583,14 +583,23 @@ AsmStmt::AsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple, std::copy(clobbers, clobbers + NumClobbers, Clobbers); } -MSAsmStmt::MSAsmStmt(ASTContext &C, - SourceLocation asmloc, SourceLocation lbraceloc, - bool issimple, bool isvolatile, ArrayRef asmtoks, - StringRef asmstr, ArrayRef clobbers, - SourceLocation endloc) +MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc, + SourceLocation lbraceloc, bool issimple, bool isvolatile, + ArrayRef asmtoks, ArrayRef inputs, + ArrayRef outputs, StringRef asmstr, + ArrayRef clobbers, SourceLocation endloc) : Stmt(MSAsmStmtClass), AsmLoc(asmloc), LBraceLoc(lbraceloc), EndLoc(endloc), AsmStr(asmstr.str()), IsSimple(issimple), IsVolatile(isvolatile), - NumAsmToks(asmtoks.size()), NumClobbers(clobbers.size()) { + NumAsmToks(asmtoks.size()), NumInputs(inputs.size()), + NumOutputs(outputs.size()), NumClobbers(clobbers.size()) { + + unsigned NumExprs = NumOutputs + NumInputs; + + Names = new (C) IdentifierInfo*[NumExprs]; + for (unsigned i = 0, e = NumOutputs; i != e; ++i) + Names[i] = outputs[i]; + for (unsigned i = NumOutputs, e = NumExprs; i != e; ++i) + Names[i] = inputs[i]; AsmToks = new (C) Token[NumAsmToks]; for (unsigned i = 0, e = NumAsmToks; i != e; ++i) diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp index 27e420fadcb2..b14c7c411633 100644 --- a/clang/lib/Sema/SemaStmt.cpp +++ b/clang/lib/Sema/SemaStmt.cpp @@ -2880,14 +2880,16 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, Diag(AsmLoc, diag::warn_unsupported_msasm); SmallVector Clobbers; std::set ClobberRegs; + SmallVector Inputs; + SmallVector Outputs; // Empty asm statements don't need to instantiate the AsmParser, etc. if (AsmToks.empty()) { StringRef AsmString; MSAsmStmt *NS = - new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, - /* IsSimple */ true, /* IsVolatile */ true, - AsmToks, AsmString, Clobbers, EndLoc); + new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, /*IsSimple*/ true, + /*IsVolatile*/ true, AsmToks, Inputs, Outputs, + AsmString, Clobbers, EndLoc); return Owned(NS); } @@ -2905,9 +2907,9 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, // patchMSAsmStrings doesn't correctly patch non-simple asm statements. if (!IsSimple) { MSAsmStmt *NS = - new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, - /* IsSimple */ true, /* IsVolatile */ true, - AsmToks, AsmString, Clobbers, EndLoc); + new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, /*IsSimple*/ true, + /*IsVolatile*/ true, AsmToks, Inputs, Outputs, + AsmString, Clobbers, EndLoc); return Owned(NS); } @@ -2999,10 +3001,9 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, Clobbers.push_back(*I); MSAsmStmt *NS = - new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, - IsSimple, /* IsVolatile */ true, - AsmToks, AsmString, Clobbers, EndLoc); - + new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, IsSimple, + /*IsVolatile*/ true, AsmToks, Inputs, Outputs, + AsmString, Clobbers, EndLoc); return Owned(NS); }