aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-10 04:59:06 +0000
committerChris Lattner <sabre@nondot.org>2009-03-10 04:59:06 +0000
commitb327793860737d1c103a73aeda8057dd628a101d (patch)
tree0ab061e01ed8d2c718f7e35be9e6c3d2ba012c53
parentf1a08caedb52a3287d38dfff0ac6e1c0a6531c3e (diff)
add some helper methods to AsmStmt and add some comments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66521 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Stmt.h49
-rw-r--r--lib/AST/Stmt.cpp23
-rw-r--r--lib/AST/StmtPrinter.cpp4
-rw-r--r--lib/CodeGen/CGStmt.cpp6
4 files changed, 60 insertions, 22 deletions
diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h
index 465b26ff23..40420ddc4b 100644
--- a/include/clang/AST/Stmt.h
+++ b/include/clang/AST/Stmt.h
@@ -923,36 +923,65 @@ public:
bool isVolatile() const { return IsVolatile; }
bool isSimple() const { return IsSimple; }
+ //===--- Output operands ---===//
+
unsigned getNumOutputs() const { return NumOutputs; }
const std::string &getOutputName(unsigned i) const {
return Names[i];
}
- const StringLiteral *getOutputConstraint(unsigned i) const {
+ /// getOutputConstraint - Return the constraint string for the specified
+ /// output operand. All output constraints are known to be non-empty (either
+ /// '=' or '+').
+ std::string getOutputConstraint(unsigned i) const;
+
+ const StringLiteral *getOutputConstraintLiteral(unsigned i) const {
return Constraints[i];
}
-
- StringLiteral *getOutputConstraint(unsigned i)
- { return Constraints[i]; }
-
- const Expr *getOutputExpr(unsigned i) const;
+ StringLiteral *getOutputConstraintLiteral(unsigned i) {
+ return Constraints[i];
+ }
+
+
Expr *getOutputExpr(unsigned i);
+ const Expr *getOutputExpr(unsigned i) const {
+ return const_cast<AsmStmt*>(this)->getOutputExpr(i);
+ }
+
+ /// isOutputPlusConstraint - Return true if the specified output constraint
+ /// is a "+" constraint (which is both an input and an output) or false if it
+ /// is an "=" constraint (just an output).
+ bool isOutputPlusConstraint(unsigned i) const {
+ return getOutputConstraint(i)[0] == '+';
+ }
+
+ //===--- Input operands ---===//
+
unsigned getNumInputs() const { return NumInputs; }
const std::string &getInputName(unsigned i) const {
return Names[i + NumOutputs];
}
- StringLiteral *getInputConstraint(unsigned i) {
+
+ /// getInputConstraint - Return the specified input constraint. Unlike output
+ /// constraints, these can be empty.
+ std::string getInputConstraint(unsigned i) const;
+
+ const StringLiteral *getInputConstraintLiteral(unsigned i) const {
return Constraints[i + NumOutputs];
}
- const StringLiteral *getInputConstraint(unsigned i) const {
+ StringLiteral *getInputConstraintLiteral(unsigned i) {
return Constraints[i + NumOutputs];
}
-
+
+
Expr *getInputExpr(unsigned i);
- const Expr *getInputExpr(unsigned i) const;
+
+ const Expr *getInputExpr(unsigned i) const {
+ return const_cast<AsmStmt*>(this)->getInputExpr(i);
+ }
const StringLiteral *getAsmString() const { return AsmStr; }
StringLiteral *getAsmString() { return AsmStr; }
diff --git a/lib/AST/Stmt.cpp b/lib/AST/Stmt.cpp
index 749b677d91..682a9b1ee4 100644
--- a/lib/AST/Stmt.cpp
+++ b/lib/AST/Stmt.cpp
@@ -130,17 +130,28 @@ bool Stmt::hasImplicitControlFlow() const {
}
}
-const Expr* AsmStmt::getOutputExpr(unsigned i) const {
+Expr *AsmStmt::getOutputExpr(unsigned i) {
return cast<Expr>(Exprs[i]);
}
-Expr* AsmStmt::getOutputExpr(unsigned i) {
- return cast<Expr>(Exprs[i]);
+
+/// getOutputConstraint - Return the constraint string for the specified
+/// output operand. All output constraints are known to be non-empty (either
+/// '=' or '+').
+std::string AsmStmt::getOutputConstraint(unsigned i) const {
+ return std::string(Constraints[i]->getStrData(),
+ Constraints[i]->getByteLength());
}
-Expr* AsmStmt::getInputExpr(unsigned i) {
+
+
+Expr *AsmStmt::getInputExpr(unsigned i) {
return cast<Expr>(Exprs[i + NumOutputs]);
}
-const Expr* AsmStmt::getInputExpr(unsigned i) const {
- return cast<Expr>(Exprs[i + NumOutputs]);
+
+/// getInputConstraint - Return the specified input constraint. Unlike output
+/// constraints, these can be empty.
+std::string AsmStmt::getInputConstraint(unsigned i) const {
+ return std::string(Constraints[i + NumOutputs]->getStrData(),
+ Constraints[i + NumOutputs]->getByteLength());
}
//===----------------------------------------------------------------------===//
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index e6ac310b83..bcd1a86ca6 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -397,7 +397,7 @@ void StmtPrinter::VisitAsmStmt(AsmStmt *Node) {
OS << "] ";
}
- VisitStringLiteral(Node->getOutputConstraint(i));
+ VisitStringLiteral(Node->getOutputConstraintLiteral(i));
OS << " ";
Visit(Node->getOutputExpr(i));
}
@@ -416,7 +416,7 @@ void StmtPrinter::VisitAsmStmt(AsmStmt *Node) {
OS << "] ";
}
- VisitStringLiteral(Node->getInputConstraint(i));
+ VisitStringLiteral(Node->getInputConstraintLiteral(i));
OS << " ";
Visit(Node->getInputExpr(i));
}
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index 69ed0803c3..3fd6526777 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -919,8 +919,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
llvm::SmallVector<TargetInfo::ConstraintInfo, 4> OutputConstraintInfos;
for (unsigned i = 0, e = S.getNumOutputs(); i != e; i++) {
- std::string OutputConstraint(S.getOutputConstraint(i)->getStrData(),
- S.getOutputConstraint(i)->getByteLength());
+ std::string OutputConstraint(S.getOutputConstraint(i));
TargetInfo::ConstraintInfo Info;
bool result = Target.validateOutputConstraint(OutputConstraint.c_str(),
@@ -973,8 +972,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
for (unsigned i = 0, e = S.getNumInputs(); i != e; i++) {
const Expr *InputExpr = S.getInputExpr(i);
- std::string InputConstraint(S.getInputConstraint(i)->getStrData(),
- S.getInputConstraint(i)->getByteLength());
+ std::string InputConstraint(S.getInputConstraint(i));
TargetInfo::ConstraintInfo Info;
bool result = Target.validateInputConstraint(InputConstraint.c_str(),