[cfe-commits] r66521 - in /cfe/trunk: include/clang/AST/Stmt.h lib/AST/Stmt.cpp lib/AST/StmtPrinter.cpp lib/CodeGen/CGStmt.cpp
Chris Lattner
sabre at nondot.org
Mon Mar 9 21:59:07 PDT 2009
Author: lattner
Date: Mon Mar 9 23:59:06 2009
New Revision: 66521
URL: http://llvm.org/viewvc/llvm-project?rev=66521&view=rev
Log:
add some helper methods to AsmStmt and add some comments.
Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/CodeGen/CGStmt.cpp
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=66521&r1=66520&r2=66521&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Mon Mar 9 23:59:06 2009
@@ -923,36 +923,65 @@
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; }
Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=66521&r1=66520&r2=66521&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Mon Mar 9 23:59:06 2009
@@ -130,17 +130,28 @@
}
}
-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());
}
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=66521&r1=66520&r2=66521&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Mon Mar 9 23:59:06 2009
@@ -397,7 +397,7 @@
OS << "] ";
}
- VisitStringLiteral(Node->getOutputConstraint(i));
+ VisitStringLiteral(Node->getOutputConstraintLiteral(i));
OS << " ";
Visit(Node->getOutputExpr(i));
}
@@ -416,7 +416,7 @@
OS << "] ";
}
- VisitStringLiteral(Node->getInputConstraint(i));
+ VisitStringLiteral(Node->getInputConstraintLiteral(i));
OS << " ";
Visit(Node->getInputExpr(i));
}
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=66521&r1=66520&r2=66521&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Mon Mar 9 23:59:06 2009
@@ -919,8 +919,7 @@
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 @@
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(),
More information about the cfe-commits
mailing list