// Constructors
//===----------------------------------------------------------------------===//
-AsmStmt::AsmStmt(SourceLocation asmloc, bool isvolatile,
+AsmStmt::AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile,
unsigned numoutputs, unsigned numinputs,
std::string *names, StringLiteral **constraints,
Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
StringLiteral **clobbers, SourceLocation rparenloc)
: Stmt(AsmStmtClass), AsmLoc(asmloc), RParenLoc(rparenloc), AsmStr(asmstr)
- , IsVolatile(isvolatile), NumOutputs(numoutputs), NumInputs(numinputs) {
+ , IsSimple(issimple), IsVolatile(isvolatile)
+ , NumOutputs(numoutputs), NumInputs(numinputs) {
for (unsigned i = 0, e = numinputs + numoutputs; i != e; i++) {
Names.push_back(names[i]);
Exprs.push_back(exprs[i]);
// Remember if this was a volatile asm.
bool isVolatile = DS.getTypeQualifiers() & DeclSpec::TQ_volatile;
-
+ bool isSimple = false;
if (Tok.isNot(tok::l_paren)) {
Diag(Tok, diag::err_expected_lparen_after, "asm");
SkipUntil(tok::r_paren);
llvm::SmallVector<std::string, 4> Names;
llvm::SmallVector<ExprTy*, 4> Constraints;
llvm::SmallVector<ExprTy*, 4> Exprs;
+ llvm::SmallVector<ExprTy*, 4> Clobbers;
+
+ unsigned NumInputs = 0, NumOutputs = 0;
- // Parse Outputs, if present.
- ParseAsmOperandsOpt(Names, Constraints, Exprs);
+ SourceLocation RParenLoc;
+ if (Tok.is(tok::r_paren)) {
+ // We have a simple asm expression
+ isSimple = true;
+
+ RParenLoc = ConsumeParen();
+ } else {
+ // Parse Outputs, if present.
+ ParseAsmOperandsOpt(Names, Constraints, Exprs);
- unsigned NumOutputs = Names.size();
+ NumOutputs = Names.size();
- // Parse Inputs, if present.
- ParseAsmOperandsOpt(Names, Constraints, Exprs);
- assert(Names.size() == Constraints.size() &&
- Constraints.size() == Exprs.size()
- && "Input operand size mismatch!");
+ // Parse Inputs, if present.
+ ParseAsmOperandsOpt(Names, Constraints, Exprs);
+ assert(Names.size() == Constraints.size() &&
+ Constraints.size() == Exprs.size()
+ && "Input operand size mismatch!");
- unsigned NumInputs = Names.size() - NumOutputs;
-
- llvm::SmallVector<ExprTy*, 4> Clobbers;
+ NumInputs = Names.size() - NumOutputs;
- // Parse the clobbers, if present.
- if (Tok.is(tok::colon)) {
- ConsumeToken();
+ // Parse the clobbers, if present.
+ if (Tok.is(tok::colon)) {
+ ConsumeToken();
- // Parse the asm-string list for clobbers.
- while (1) {
- ExprResult Clobber = ParseAsmStringLiteral();
+ // Parse the asm-string list for clobbers.
+ while (1) {
+ ExprResult Clobber = ParseAsmStringLiteral();
- if (Clobber.isInvalid)
- break;
+ if (Clobber.isInvalid)
+ break;
- Clobbers.push_back(Clobber.Val);
+ Clobbers.push_back(Clobber.Val);
- if (Tok.isNot(tok::comma)) break;
- ConsumeToken();
+ if (Tok.isNot(tok::comma)) break;
+ ConsumeToken();
+ }
}
- }
- SourceLocation RParenLoc = MatchRHSPunctuation(tok::r_paren, Loc);
+ RParenLoc = MatchRHSPunctuation(tok::r_paren, Loc);
+ }
- return Actions.ActOnAsmStmt(AsmLoc, isVolatile, NumOutputs, NumInputs,
+ return Actions.ActOnAsmStmt(AsmLoc, isSimple, isVolatile,
+ NumOutputs, NumInputs,
&Names[0], &Constraints[0], &Exprs[0],
AsmString.Val,
Clobbers.size(), &Clobbers[0],
SourceLocation AsmLoc, RParenLoc;
StringLiteral *AsmStr;
+ bool IsSimple;
bool IsVolatile;
unsigned NumOutputs;
llvm::SmallVector<StringLiteral*, 4> Clobbers;
public:
- AsmStmt(SourceLocation asmloc, bool isvolatile, unsigned numoutputs,
- unsigned numinputs, std::string *names, StringLiteral **constraints,
+ AsmStmt(SourceLocation asmloc, bool issimple, bool isvolatile,
+ unsigned numoutputs, unsigned numinputs,
+ std::string *names, StringLiteral **constraints,
Expr **exprs, StringLiteral *asmstr, unsigned numclobbers,
StringLiteral **clobbers, SourceLocation rparenloc);
bool isVolatile() const { return IsVolatile; }
-
+ bool isSimple() const { return IsSimple; }
+
unsigned getNumOutputs() const { return NumOutputs; }
const std::string &getOutputName(unsigned i) const
{ return Names[i]; }