]> granicus.if.org Git - clang/commitdiff
Combine AsmStmt::setOutputsAndInputs and AsmStmt::setClobbers.
authorAnders Carlsson <andersca@mac.com>
Sat, 30 Jan 2010 19:34:25 +0000 (19:34 +0000)
committerAnders Carlsson <andersca@mac.com>
Sat, 30 Jan 2010 19:34:25 +0000 (19:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94918 91177308-0d34-0410-b5e6-96231b3b80d8

clang.xcodeproj/project.pbxproj
include/clang/AST/Stmt.h
lib/AST/Stmt.cpp
lib/Frontend/PCHReaderStmt.cpp
lib/Sema/SemaStmt.cpp

index 4c50a746097ec5e64ec5e150dc3071d5096ed7c8..e24b54d3e892d428d0b6a8384d5edc5d5df4f4b4 100644 (file)
                DECB6F060F9D93A800F5FBC7 /* InitPreprocessor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InitPreprocessor.cpp; path = lib/Frontend/InitPreprocessor.cpp; sourceTree = "<group>"; };
                DECB734E0FA3ED8400F5FBC7 /* StmtObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StmtObjC.h; path = clang/AST/StmtObjC.h; sourceTree = "<group>"; };
                DECB73550FA3EE5A00F5FBC7 /* StmtCXX.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StmtCXX.h; path = clang/AST/StmtCXX.h; sourceTree = "<group>"; };
-               DECB77120FA5752300F5FBC7 /* PCHReaderStmt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PCHReaderStmt.cpp; path = lib/Frontend/PCHReaderStmt.cpp; sourceTree = "<group>"; };
+               DECB77120FA5752300F5FBC7 /* PCHReaderStmt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = PCHReaderStmt.cpp; path = lib/Frontend/PCHReaderStmt.cpp; sourceTree = "<group>"; tabWidth = 2; };
                DECB77780FA579B000F5FBC7 /* PCHReaderDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PCHReaderDecl.cpp; path = lib/Frontend/PCHReaderDecl.cpp; sourceTree = "<group>"; };
                DECB77F60FA5850200F5FBC7 /* PCHWriterDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PCHWriterDecl.cpp; path = lib/Frontend/PCHWriterDecl.cpp; sourceTree = "<group>"; };
                DECB78160FA5882F00F5FBC7 /* PCHWriterStmt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PCHWriterStmt.cpp; path = lib/Frontend/PCHWriterStmt.cpp; sourceTree = "<group>"; };
index 7abd55787ab38bf5c26f0746f58b8ea944617d38..a2dda2a959d8a70428377a16321cc394be1a0311 100644 (file)
@@ -1268,11 +1268,13 @@ public:
     return const_cast<AsmStmt*>(this)->getInputExpr(i);
   }
 
-  void setOutputsAndInputs(unsigned NumOutputs,
-                           unsigned NumInputs,
-                           const std::string *Names,
-                           StringLiteral **Constraints,
-                           Stmt **Exprs);
+  void setOutputsAndInputsAndClobbers(const std::string *Names,
+                                      StringLiteral **Constraints,
+                                      Stmt **Exprs,
+                                      unsigned NumOutputs,
+                                      unsigned NumInputs,                                      
+                                      StringLiteral **Clobbers,
+                                      unsigned NumClobbers);
 
   //===--- Other ---===//
 
@@ -1286,7 +1288,6 @@ public:
   unsigned getNumClobbers() const { return Clobbers.size(); }
   StringLiteral *getClobber(unsigned i) { return Clobbers[i]; }
   const StringLiteral *getClobber(unsigned i) const { return Clobbers[i]; }
-  void setClobbers(StringLiteral **Clobbers, unsigned NumClobbers);
 
   virtual SourceRange getSourceRange() const {
     return SourceRange(AsmLoc, RParenLoc);
index 821bcb5106168a941ee315e618c4abb8b9fedf1f..577b0ac5609969c05e822f67ece795a8e9116f72 100644 (file)
@@ -147,8 +147,6 @@ unsigned AsmStmt::getNumPlusOperands() const {
   return Res;
 }
 
-
-
 Expr *AsmStmt::getInputExpr(unsigned i) {
   return cast<Expr>(Exprs[i + NumOutputs]);
 }
@@ -161,11 +159,13 @@ std::string AsmStmt::getInputConstraint(unsigned i) const {
 }
 
 
-void AsmStmt::setOutputsAndInputs(unsigned NumOutputs,
-                                  unsigned NumInputs,
-                                  const std::string *Names,
-                                  StringLiteral **Constraints,
-                                  Stmt **Exprs) {
+void AsmStmt::setOutputsAndInputsAndClobbers(const std::string *Names,
+                                             StringLiteral **Constraints,
+                                             Stmt **Exprs,
+                                             unsigned NumOutputs,
+                                             unsigned NumInputs,                                      
+                                             StringLiteral **Clobbers,
+                                             unsigned NumClobbers) {
   this->NumOutputs = NumOutputs;
   this->NumInputs = NumInputs;
   this->Names.clear();
@@ -175,6 +175,9 @@ void AsmStmt::setOutputsAndInputs(unsigned NumOutputs,
                            Constraints, Constraints + NumOutputs + NumInputs);
   this->Exprs.clear();
   this->Exprs.insert(this->Exprs.end(), Exprs, Exprs + NumOutputs + NumInputs);
+  
+  this->Clobbers.clear();
+  this->Clobbers.insert(this->Clobbers.end(), Clobbers, Clobbers + NumClobbers);
 }
 
 /// getNamedOperand - Given a symbolic operand reference like %[foo],
@@ -197,11 +200,6 @@ int AsmStmt::getNamedOperand(const std::string &SymbolicName) const {
   return -1;
 }
 
-void AsmStmt::setClobbers(StringLiteral **Clobbers, unsigned NumClobbers) {
-  this->Clobbers.clear();
-  this->Clobbers.insert(this->Clobbers.end(), Clobbers, Clobbers + NumClobbers);
-}
-
 /// AnalyzeAsmString - Analyze the asm string of the current asm, decomposing
 /// it into pieces.  If the asm string is erroneous, emit errors and return
 /// true, otherwise return false.
index 21c9cbf17cd7e449845f4180c56219f75105594f..630aa36fd2cc1b1fbf92daef94f5ba336661041a 100644 (file)
@@ -325,14 +325,15 @@ unsigned PCHStmtReader::VisitAsmStmt(AsmStmt *S) {
     Constraints.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
     Exprs.push_back(StmtStack[StackIdx++]);
   }
-  S->setOutputsAndInputs(NumOutputs, NumInputs,
-                         Names.data(), Constraints.data(), Exprs.data());
 
   // Constraints
   llvm::SmallVector<StringLiteral*, 16> Clobbers;
   for (unsigned I = 0; I != NumClobbers; ++I)
     Clobbers.push_back(cast_or_null<StringLiteral>(StmtStack[StackIdx++]));
-  S->setClobbers(Clobbers.data(), NumClobbers);
+
+  S->setOutputsAndInputsAndClobbers(Names.data(), Constraints.data(), 
+                                    Exprs.data(), NumOutputs, NumInputs, 
+                                    Clobbers.data(), NumClobbers);
 
   assert(StackIdx == StmtStack.size() && "Error deserializing AsmStmt");
   return NumOutputs*2 + NumInputs*2 + NumClobbers + 1;
index fad3e4ba0a172c084c2e081b25697c510f0aa1fd..16623600529fa3fd95be47f99c21589c26ee23de 100644 (file)
@@ -1197,8 +1197,7 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
       return StmtError(Diag(Literal->getLocStart(),diag::err_asm_wide_character)
         << Literal->getSourceRange());
 
-    TargetInfo::ConstraintInfo Info(Literal->getString(),
-                                    Names[i]);
+    TargetInfo::ConstraintInfo Info(Literal->getString(), Names[i]);
     if (!Context.Target.validateOutputConstraint(Info))
       return StmtError(Diag(Literal->getLocStart(),
                             diag::err_asm_invalid_output_constraint)
@@ -1263,11 +1262,9 @@ Sema::OwningStmtResult Sema::ActOnAsmStmt(SourceLocation AsmLoc,
       return StmtError(Diag(Literal->getLocStart(),diag::err_asm_wide_character)
         << Literal->getSourceRange());
 
-    std::string Clobber(Literal->getStrData(),
-                        Literal->getStrData() +
-                        Literal->getByteLength());
+    llvm::StringRef Clobber = Literal->getString();
 
-    if (!Context.Target.isValidGCCRegisterName(Clobber.c_str()))
+    if (!Context.Target.isValidGCCRegisterName(Clobber))
       return StmtError(Diag(Literal->getLocStart(),
                   diag::err_asm_unknown_register_name) << Clobber);
   }