forked from OSchip/llvm-project
[ms-inline asm] Move some logic around to simplify the interface between the
front-end and the AsmParser. No functional change intended. llvm-svn: 166063
This commit is contained in:
parent
35e1bda695
commit
f8037a1fb6
|
@ -1660,9 +1660,9 @@ class MSAsmStmt : public AsmStmt {
|
|||
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.
|
||||
|
|
|
@ -673,30 +673,24 @@ GCCAsmStmt::GCCAsmStmt(ASTContext &C, SourceLocation asmloc, bool issimple,
|
|||
|
||||
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)
|
||||
|
|
|
@ -390,12 +390,15 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
|
|||
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 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
|
|||
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 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
|
|||
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 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc,
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue