[cfe-commits] r70135 - in /cfe/trunk: clang.xcodeproj/project.pbxproj include/clang/Basic/TargetInfo.h lib/Basic/TargetInfo.cpp lib/CodeGen/CGStmt.cpp lib/Sema/SemaStmt.cpp

Chris Lattner sabre at nondot.org
Sun Apr 26 10:19:10 PDT 2009


Author: lattner
Date: Sun Apr 26 12:19:08 2009
New Revision: 70135

URL: http://llvm.org/viewvc/llvm-project?rev=70135&view=rev
Log:
pull the constraint string into the ConstraintInfo struct
instead of passing it around in addition to it.


Modified:
    cfe/trunk/clang.xcodeproj/project.pbxproj
    cfe/trunk/include/clang/Basic/TargetInfo.h
    cfe/trunk/lib/Basic/TargetInfo.cpp
    cfe/trunk/lib/CodeGen/CGStmt.cpp
    cfe/trunk/lib/Sema/SemaStmt.cpp

Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=70135&r1=70134&r2=70135&view=diff

==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Sun Apr 26 12:19:08 2009
@@ -51,7 +51,6 @@
 		356EF9B50C8F7DDF006650F5 /* LiveVariables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 356EF9B40C8F7DDF006650F5 /* LiveVariables.cpp */; };
 		35707EFE0CD0F5CC000B2204 /* SourceLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 35707EFD0CD0F5CC000B2204 /* SourceLocation.cpp */; };
 		357EA27D0F2526F300439B60 /* SemaLookup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 357EA27C0F2526F300439B60 /* SemaLookup.cpp */; };
-		3580CC0C0D072E5C00C5E4F4 /* LangOptions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3580CC0B0D072E5C00C5E4F4 /* LangOptions.cpp */; };
 		35847BE50CC7DBAF00C40FFF /* StmtIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 35847BE40CC7DBAF00C40FFF /* StmtIterator.cpp */; };
 		35862B0D0E3628CB0009F542 /* CheckDeadStores.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 35862B0C0E3628CB0009F542 /* CheckDeadStores.cpp */; };
 		35862B120E3629850009F542 /* GRExprEngineInternalChecks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 35862B110E3629850009F542 /* GRExprEngineInternalChecks.cpp */; };
@@ -395,7 +394,6 @@
 		356EF9B40C8F7DDF006650F5 /* LiveVariables.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LiveVariables.cpp; path = lib/Analysis/LiveVariables.cpp; sourceTree = "<group>"; };
 		35707EFD0CD0F5CC000B2204 /* SourceLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; path = SourceLocation.cpp; sourceTree = "<group>"; tabWidth = 2; };
 		357EA27C0F2526F300439B60 /* SemaLookup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = SemaLookup.cpp; path = lib/Sema/SemaLookup.cpp; sourceTree = "<group>"; tabWidth = 2; };
-		3580CC0B0D072E5C00C5E4F4 /* LangOptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; path = LangOptions.cpp; sourceTree = "<group>"; tabWidth = 2; };
 		35847BE30CC7DB9000C40FFF /* StmtIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = StmtIterator.h; path = clang/AST/StmtIterator.h; sourceTree = "<group>"; tabWidth = 2; };
 		35847BE40CC7DBAF00C40FFF /* StmtIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = StmtIterator.cpp; path = lib/AST/StmtIterator.cpp; sourceTree = "<group>"; tabWidth = 2; };
 		35862B0C0E3628CB0009F542 /* CheckDeadStores.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CheckDeadStores.cpp; path = lib/Analysis/CheckDeadStores.cpp; sourceTree = "<group>"; };
@@ -1260,7 +1258,6 @@
 				DED7D75D0A5242C7003AD0FB /* Diagnostic.cpp */,
 				DED7D75E0A5242C7003AD0FB /* FileManager.cpp */,
 				DE3986F30CB8D50C00223765 /* IdentifierTable.cpp */,
-				3580CC0B0D072E5C00C5E4F4 /* LangOptions.cpp */,
 				35707EFD0CD0F5CC000B2204 /* SourceLocation.cpp */,
 				DED7D76D0A5242C7003AD0FB /* SourceManager.cpp */,
 				DED626C80AE0C065001E80A4 /* TargetInfo.cpp */,
@@ -1536,7 +1533,6 @@
 				DE3986F40CB8D50C00223765 /* IdentifierTable.cpp in Sources */,
 				35847BE50CC7DBAF00C40FFF /* StmtIterator.cpp in Sources */,
 				35707EFE0CD0F5CC000B2204 /* SourceLocation.cpp in Sources */,
-				3580CC0C0D072E5C00C5E4F4 /* LangOptions.cpp in Sources */,
 				DE704B260D0FBEBE009C7762 /* SemaDeclObjC.cpp in Sources */,
 				DE704DD20D1668A4009C7762 /* HeaderMap.cpp in Sources */,
 				35BB2D7F0D19954000944DB5 /* ASTConsumer.cpp in Sources */,

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=70135&r1=70134&r2=70135&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Sun Apr 26 12:19:08 2009
@@ -208,9 +208,15 @@
     };
     unsigned Flags;
     int TiedOperand;
-  public:
-    ConstraintInfo() : Flags(0), TiedOperand(-1) {}
     
+    std::string ConstraintStr;
+  public:
+    ConstraintInfo(const char *str, unsigned strlen)
+      : Flags(0), TiedOperand(-1), ConstraintStr(str, str+strlen) {}
+    explicit ConstraintInfo(const std::string &Str)
+      : Flags(0), TiedOperand(-1), ConstraintStr(Str) {}
+
+    const std::string &getConstraintStr() const { return ConstraintStr; }
     bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; }
     bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; }
     bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; }
@@ -229,9 +235,8 @@
   // validateOutputConstraint, validateInputConstraint - Checks that
   // a constraint is valid and provides information about it.
   // FIXME: These should return a real error instead of just true/false.
-  bool validateOutputConstraint(const char *Name, ConstraintInfo &Info) const;
-  bool validateInputConstraint(const char *Name, 
-                               const std::string *OutputNamesBegin,
+  bool validateOutputConstraint(ConstraintInfo &Info) const;
+  bool validateInputConstraint(const std::string *OutputNamesBegin,
                                const std::string *OutputNamesEnd,
                                ConstraintInfo* OutputConstraints,
                                ConstraintInfo &info) const;

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=70135&r1=70134&r2=70135&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Sun Apr 26 12:19:08 2009
@@ -163,8 +163,8 @@
   return Name;
 }
 
-bool TargetInfo::validateOutputConstraint(const char *Name, 
-                                          ConstraintInfo &Info) const {
+bool TargetInfo::validateOutputConstraint(ConstraintInfo &Info) const {
+  const char *Name = Info.getConstraintStr().c_str();
   // An output constraint must start with '=' or '+'
   if (*Name != '=' && *Name != '+')
     return false;
@@ -231,11 +231,12 @@
   return false;
 }
 
-bool TargetInfo::validateInputConstraint(const char *Name,
-                                         const std::string *OutputNamesBegin,
+bool TargetInfo::validateInputConstraint(const std::string *OutputNamesBegin,
                                          const std::string *OutputNamesEnd,
                                          ConstraintInfo *OutputConstraints,
                                          ConstraintInfo &Info) const {
+  const char *Name = Info.ConstraintStr.c_str();
+
   while (*Name) {
     switch (*Name) {
     default:

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=70135&r1=70134&r2=70135&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Sun Apr 26 12:19:08 2009
@@ -798,9 +798,8 @@
   for (unsigned i = 0, e = S.getNumOutputs(); i != e; i++) {    
     std::string OutputConstraint(S.getOutputConstraint(i));
     
-    TargetInfo::ConstraintInfo Info;
-    bool result = Target.validateOutputConstraint(OutputConstraint.c_str(), 
-                                                  Info);
+    TargetInfo::ConstraintInfo Info(OutputConstraint);
+    bool result = Target.validateOutputConstraint(Info);
     assert(result && "Failed to parse output constraint"); result=result;
     
     OutputConstraintInfos.push_back(Info);
@@ -853,9 +852,8 @@
 
     std::string InputConstraint(S.getInputConstraint(i));
     
-    TargetInfo::ConstraintInfo Info;
-    bool result = Target.validateInputConstraint(InputConstraint.c_str(),
-                                                 S.begin_output_names(),
+    TargetInfo::ConstraintInfo Info(InputConstraint);
+    bool result = Target.validateInputConstraint(S.begin_output_names(),
                                                  S.end_output_names(),
                                                  &OutputConstraintInfos[0],
                                                  Info); result=result;

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=70135&r1=70134&r2=70135&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Sun Apr 26 12:19:08 2009
@@ -922,15 +922,15 @@
       return StmtError(Diag(Literal->getLocStart(),diag::err_asm_wide_character)
         << Literal->getSourceRange());
 
-    std::string OutputConstraint(Literal->getStrData(), 
-                                 Literal->getByteLength());
-
-    TargetInfo::ConstraintInfo Info;
-    if (!Context.Target.validateOutputConstraint(OutputConstraint.c_str(),Info))
+    TargetInfo::ConstraintInfo Info(Literal->getStrData(), 
+                                    Literal->getByteLength());
+    if (!Context.Target.validateOutputConstraint(Info))
       return StmtError(Diag(Literal->getLocStart(),
-                  diag::err_asm_invalid_output_constraint) << OutputConstraint);
+                            diag::err_asm_invalid_output_constraint)
+                       << Info.getConstraintStr());
 
     // Check that the output exprs are valid lvalues.
+    // FIXME: Operands to asms should not be parsed as ParenExprs.
     ParenExpr *OutputExpr = cast<ParenExpr>(Exprs[i]);
     if (CheckAsmLValue(OutputExpr, *this)) {
       return StmtError(Diag(OutputExpr->getSubExpr()->getLocStart(),
@@ -947,17 +947,15 @@
       return StmtError(Diag(Literal->getLocStart(),diag::err_asm_wide_character)
         << Literal->getSourceRange());
 
-    std::string InputConstraint(Literal->getStrData(),
-                                Literal->getByteLength());
-
-    TargetInfo::ConstraintInfo Info;
-    if (!Context.Target.validateInputConstraint(InputConstraint.c_str(),
-                                                &Names[0],
+    TargetInfo::ConstraintInfo Info(Literal->getStrData(), 
+                                    Literal->getByteLength());
+    if (!Context.Target.validateInputConstraint(&Names[0],
                                                 &Names[0] + NumOutputs, 
                                                 &OutputConstraintInfos[0],
                                                 Info)) {
       return StmtError(Diag(Literal->getLocStart(),
-                  diag::err_asm_invalid_input_constraint) << InputConstraint);
+                            diag::err_asm_invalid_input_constraint)
+                       << Info.getConstraintStr());
     }
 
     ParenExpr *InputExpr = cast<ParenExpr>(Exprs[i]);
@@ -967,14 +965,15 @@
       if (CheckAsmLValue(InputExpr, *this))
         return StmtError(Diag(InputExpr->getSubExpr()->getLocStart(),
                               diag::err_asm_invalid_lvalue_in_input)
-             << InputConstraint << InputExpr->getSubExpr()->getSourceRange());
+                         << Info.getConstraintStr()
+                         << InputExpr->getSubExpr()->getSourceRange());
     }
 
     if (Info.allowsRegister()) {
       if (InputExpr->getType()->isVoidType()) {
         return StmtError(Diag(InputExpr->getSubExpr()->getLocStart(),
                               diag::err_asm_invalid_type_in_input)
-          << InputExpr->getType() << InputConstraint 
+          << InputExpr->getType() << Info.getConstraintStr() 
           << InputExpr->getSubExpr()->getSourceRange());
       }
     }





More information about the cfe-commits mailing list