aboutsummaryrefslogtreecommitdiff
path: root/include/clang/AST/Stmt.h
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-08-27 19:38:01 +0000
committerChad Rosier <mcrosier@apple.com>2012-08-27 19:38:01 +0000
commit066ef86b435a5c567778c25fc201a2831049ad4b (patch)
treece7d38b6baedbc685461ec4917b479670bd9da23 /include/clang/AST/Stmt.h
parent728581e7702cafe32cc9e1b5b61a15f5042ce189 (diff)
downloadclang-066ef86b435a5c567778c25fc201a2831049ad4b.tar.gz
[ms-inline asm] Hoist common logic into the AsmStmt base class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162692 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/Stmt.h')
-rw-r--r--include/clang/AST/Stmt.h96
1 files changed, 50 insertions, 46 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index dd26732ef9..048f1ae3b8 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -1367,16 +1367,28 @@ public:
///
class AsmStmt : public Stmt {
protected:
+ SourceLocation AsmLoc;
bool IsSimple;
bool IsVolatile;
- AsmStmt(StmtClass SC, bool issimple, bool isvolatile) :
- Stmt (SC), IsSimple(issimple), IsVolatile(isvolatile) { }
+ unsigned NumOutputs;
+ unsigned NumInputs;
+ unsigned NumClobbers;
+
+ IdentifierInfo **Names;
+
+ AsmStmt(StmtClass SC, SourceLocation asmloc, bool issimple, bool isvolatile,
+ unsigned numoutputs, unsigned numinputs, unsigned numclobbers) :
+ Stmt (SC), AsmLoc(asmloc), IsSimple(issimple), IsVolatile(isvolatile),
+ NumOutputs(numoutputs), NumInputs(numinputs), NumClobbers(numclobbers) { }
public:
/// \brief Build an empty inline-assembly statement.
explicit AsmStmt(StmtClass SC, EmptyShell Empty) :
- Stmt(SC, Empty) { }
+ Stmt(SC, Empty), Names(0) { }
+
+ SourceLocation getAsmLoc() const { return AsmLoc; }
+ void setAsmLoc(SourceLocation L) { AsmLoc = L; }
bool isSimple() const { return IsSimple; }
void setSimple(bool V) { IsSimple = V; }
@@ -1386,6 +1398,38 @@ public:
SourceRange getSourceRange() const LLVM_READONLY { return SourceRange(); }
+ //===--- Output operands ---===//
+
+ unsigned getNumOutputs() const { return NumOutputs; }
+
+ IdentifierInfo *getOutputIdentifier(unsigned i) const {
+ return Names[i];
+ }
+
+ StringRef getOutputName(unsigned i) const {
+ if (IdentifierInfo *II = getOutputIdentifier(i))
+ return II->getName();
+
+ return StringRef();
+ }
+
+ //===--- Input operands ---===//
+
+ unsigned getNumInputs() const { return NumInputs; }
+
+ IdentifierInfo *getInputIdentifier(unsigned i) const {
+ return Names[i + NumOutputs];
+ }
+
+ StringRef getInputName(unsigned i) const {
+ if (IdentifierInfo *II = getInputIdentifier(i))
+ return II->getName();
+
+ return StringRef();
+ }
+
+ //===--- Other ---===//
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == GCCAsmStmtClass ||
T->getStmtClass() == MSAsmStmtClass;
@@ -1396,15 +1440,10 @@ public:
/// This represents a GCC inline-assembly statement extension.
///
class GCCAsmStmt : public AsmStmt {
- SourceLocation AsmLoc, RParenLoc;
+ SourceLocation RParenLoc;
StringLiteral *AsmStr;
- unsigned NumOutputs;
- unsigned NumInputs;
- unsigned NumClobbers;
-
// FIXME: If we wanted to, we could allocate all of these in one big array.
- IdentifierInfo **Names;
StringLiteral **Constraints;
Stmt **Exprs;
StringLiteral **Clobbers;
@@ -1418,10 +1457,8 @@ public:
/// \brief Build an empty inline-assembly statement.
explicit GCCAsmStmt(EmptyShell Empty) : AsmStmt(GCCAsmStmtClass, Empty),
- Names(0), Constraints(0), Exprs(0), Clobbers(0) { }
+ Constraints(0), Exprs(0), Clobbers(0) { }
- SourceLocation getAsmLoc() const { return AsmLoc; }
- void setAsmLoc(SourceLocation L) { AsmLoc = L; }
SourceLocation getRParenLoc() const { return RParenLoc; }
void setRParenLoc(SourceLocation L) { RParenLoc = L; }
@@ -1485,19 +1522,6 @@ public:
//===--- Output operands ---===//
- unsigned getNumOutputs() const { return NumOutputs; }
-
- IdentifierInfo *getOutputIdentifier(unsigned i) const {
- return Names[i];
- }
-
- StringRef getOutputName(unsigned i) const {
- if (IdentifierInfo *II = getOutputIdentifier(i))
- return II->getName();
-
- return StringRef();
- }
-
/// getOutputConstraint - Return the constraint string for the specified
/// output operand. All output constraints are known to be non-empty (either
/// '=' or '+').
@@ -1641,12 +1665,8 @@ class MSAsmStmt : public AsmStmt {
std::string AsmStr;
unsigned NumAsmToks;
- unsigned NumInputs;
- unsigned NumOutputs;
- unsigned NumClobbers;
Token *AsmToks;
- IdentifierInfo **Names;
Stmt **Exprs;
StringRef *Clobbers;
@@ -1660,11 +1680,8 @@ public:
/// \brief Build an empty MS-style inline-assembly statement.
explicit MSAsmStmt(EmptyShell Empty) : AsmStmt(MSAsmStmtClass, Empty),
- NumAsmToks(0), NumInputs(0), NumOutputs(0), NumClobbers(0), AsmToks(0),
- Names(0), Exprs(0), Clobbers(0) { }
+ NumAsmToks(0), AsmToks(0), Exprs(0), Clobbers(0) { }
- SourceLocation getAsmLoc() const { return AsmLoc; }
- void setAsmLoc(SourceLocation L) { AsmLoc = L; }
SourceLocation getLBraceLoc() const { return LBraceLoc; }
void setLBraceLoc(SourceLocation L) { LBraceLoc = L; }
SourceLocation getEndLoc() const { return EndLoc; }
@@ -1683,19 +1700,6 @@ public:
//===--- Output operands ---===//
- unsigned getNumOutputs() const { return NumOutputs; }
-
- IdentifierInfo *getOutputIdentifier(unsigned i) const {
- return Names[i];
- }
-
- StringRef getOutputName(unsigned i) const {
- if (IdentifierInfo *II = getOutputIdentifier(i))
- return II->getName();
-
- return StringRef();
- }
-
Expr *getOutputExpr(unsigned i);
const Expr *getOutputExpr(unsigned i) const {