[cfe-commits] r166063 - in /cfe/trunk: include/clang/AST/Stmt.h lib/AST/Stmt.cpp lib/Sema/SemaStmtAsm.cpp
Chad Rosier
mcrosier at apple.com
Tue Oct 16 14:55:39 PDT 2012
Author: mcrosier
Date: Tue Oct 16 16:55:39 2012
New Revision: 166063
URL: http://llvm.org/viewvc/llvm-project?rev=166063&view=rev
Log:
[ms-inline asm] Move some logic around to simplify the interface between the
front-end and the AsmParser. No functional change intended.
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/Sema/SemaStmtAsm.cpp
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=166063&r1=166062&r2=166063&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Tue Oct 16 16:55:39 2012
@@ -1660,9 +1660,9 @@
public:
MSAsmStmt(ASTContext &C, SourceLocation asmloc, SourceLocation lbraceloc,
bool issimple, bool isvolatile, ArrayRef<Token> asmtoks,
- ArrayRef<IdentifierInfo*> inputs, ArrayRef<IdentifierInfo*> outputs,
- ArrayRef<Expr*> inputexprs, ArrayRef<Expr*> outputexprs,
- StringRef asmstr, ArrayRef<StringRef> constraints,
+ unsigned numoutputs, unsigned numinputs,
+ ArrayRef<IdentifierInfo*> names, ArrayRef<StringRef> constraints,
+ ArrayRef<Expr*> exprs, StringRef asmstr,
ArrayRef<StringRef> clobbers, SourceLocation endloc);
/// \brief Build an empty MS-style inline-assembly statement.
Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=166063&r1=166062&r2=166063&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Tue Oct 16 16:55:39 2012
@@ -673,30 +673,24 @@
MSAsmStmt::MSAsmStmt(ASTContext &C, SourceLocation asmloc,
SourceLocation lbraceloc, bool issimple, bool isvolatile,
- ArrayRef<Token> asmtoks, ArrayRef<IdentifierInfo*> inputs,
- ArrayRef<IdentifierInfo*> outputs,
- ArrayRef<Expr*> inputexprs, ArrayRef<Expr*> outputexprs,
- StringRef asmstr, ArrayRef<StringRef> constraints,
- ArrayRef<StringRef> clobbers, SourceLocation endloc)
- : AsmStmt(MSAsmStmtClass, asmloc, issimple, isvolatile, outputs.size(),
- inputs.size(), clobbers.size()), LBraceLoc(lbraceloc),
+ ArrayRef<Token> asmtoks, unsigned numoutputs,
+ unsigned numinputs, ArrayRef<IdentifierInfo*> names,
+ ArrayRef<StringRef> constraints, ArrayRef<Expr*> exprs,
+ StringRef asmstr, ArrayRef<StringRef> clobbers,
+ SourceLocation endloc)
+ : AsmStmt(MSAsmStmtClass, asmloc, issimple, isvolatile, numoutputs,
+ numinputs, clobbers.size()), LBraceLoc(lbraceloc),
EndLoc(endloc), AsmStr(asmstr.str()), NumAsmToks(asmtoks.size()) {
- assert (inputs.size() == inputexprs.size() && "Input expr size mismatch!");
- assert (outputs.size() == outputexprs.size() && "Input expr size mismatch!");
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, j = 0, e = NumExprs; i != e; ++i, ++j)
- Names[i] = inputs[j];
+ for (unsigned i = 0, e = NumExprs; i != e; ++i)
+ Names[i] = names[i];
Exprs = new (C) Stmt*[NumExprs];
- for (unsigned i = 0, e = NumOutputs; i != e; ++i)
- Exprs[i] = outputexprs[i];
- for (unsigned i = NumOutputs, j = 0, e = NumExprs; i != e; ++i, ++j)
- Exprs[i] = inputexprs[j];
+ for (unsigned i = 0, e = NumExprs; i != e; ++i)
+ Exprs[i] = exprs[i];
AsmToks = new (C) Token[NumAsmToks];
for (unsigned i = 0, e = NumAsmToks; i != e; ++i)
Modified: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAsm.cpp?rev=166063&r1=166062&r2=166063&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp Tue Oct 16 16:55:39 2012
@@ -390,12 +390,15 @@
ArrayRef<Token> AsmToks,SourceLocation EndLoc) {
SmallVector<IdentifierInfo*, 4> Inputs;
SmallVector<IdentifierInfo*, 4> Outputs;
- SmallVector<Expr*, 4> InputExprs;
- SmallVector<Expr*, 4> OutputExprs;
- SmallVector<StringRef, 4> Constraints;
+ SmallVector<IdentifierInfo*, 4> Names;
SmallVector<std::string, 4> InputConstraints;
SmallVector<std::string, 4> OutputConstraints;
-
+ SmallVector<StringRef, 4> Constraints;
+ unsigned NumOutputs;
+ unsigned NumInputs;
+ SmallVector<Expr*, 4> InputExprs;
+ SmallVector<Expr*, 4> OutputExprs;
+ SmallVector<Expr*, 4> Exprs;
SmallVector<StringRef, 4> Clobbers;
std::set<std::string> ClobberRegs;
@@ -406,8 +409,8 @@
StringRef EmptyAsmStr;
MSAsmStmt *NS =
new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, /*IsSimple*/ true,
- /*IsVolatile*/ true, AsmToks, Inputs, Outputs,
- InputExprs, OutputExprs, EmptyAsmStr, Constraints,
+ /*IsVolatile*/ true, AsmToks, /*NumOutputs*/ 0,
+ /*NumInputs*/ 0, Names, Constraints, Exprs, EmptyAsmStr,
Clobbers, EndLoc);
return Owned(NS);
}
@@ -534,19 +537,30 @@
Parser->freeParsedOperands();
}
}
+
+ // Set the number of Outputs and Inputs.
+ NumOutputs = Outputs.size();
+ NumInputs = Inputs.size();
+
+ // Set the unique clobbers.
for (std::set<std::string>::iterator I = ClobberRegs.begin(),
E = ClobberRegs.end(); I != E; ++I)
Clobbers.push_back(*I);
- // Merge the output and input constraints. Output constraints are expected
- // first.
- for (SmallVectorImpl<std::string>::iterator I = OutputConstraints.begin(),
- E = OutputConstraints.end(); I != E; ++I)
- Constraints.push_back(*I);
-
- for (SmallVectorImpl<std::string>::iterator I = InputConstraints.begin(),
- E = InputConstraints.end(); I != E; ++I)
- Constraints.push_back(*I);
+ // Merge the various outputs and inputs. Output are expected first.
+ Names.resize(NumOutputs + NumInputs);
+ Constraints.resize(NumOutputs + NumInputs);
+ Exprs.resize(NumOutputs + NumInputs);
+ for (unsigned i = 0; i < NumOutputs; ++i) {
+ Names[i] = Outputs[i];
+ Constraints[i] = OutputConstraints[i];
+ Exprs[i] = OutputExprs[i];
+ }
+ for (unsigned i = 0, j = NumOutputs; i < NumInputs; ++i, ++j) {
+ Names[j] = Inputs[i];
+ Constraints[j] = InputConstraints[i];
+ Exprs[j] = InputExprs[i];
+ }
// Build the IR assembly string.
std::string AsmStringIR;
@@ -584,9 +598,9 @@
AsmString = OS.str();
MSAsmStmt *NS =
- new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, /*IsSimple*/ false,
- /*IsVolatile*/ true, AsmToks, Inputs, Outputs,
- InputExprs, OutputExprs, AsmString, Constraints,
+ new (Context) MSAsmStmt(Context, AsmLoc, LBraceLoc, /*IsSimple*/ true,
+ /*IsVolatile*/ true, AsmToks, NumOutputs,
+ NumInputs, Names, Constraints, Exprs, AsmString,
Clobbers, EndLoc);
return Owned(NS);
}
More information about the cfe-commits
mailing list