Update MCParsedAsmOperand debug methods.
authorJim Grosbach <grosbach@apple.com>
Wed, 13 Jul 2011 15:34:57 +0000 (15:34 +0000)
committerJim Grosbach <grosbach@apple.com>
Wed, 13 Jul 2011 15:34:57 +0000 (15:34 +0000)
Update the debug output interface for MCParsedAsmOperand to have a print()
method which takes an output stream argument, an << operator which invokes
the print method using the given stream, and a dump() method which prints
the operand to the dbgs() stream. This makes the interface more consistent
with the rest of LLVM, and more convenient to use at the debugger command
line.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135043 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCParser/MCParsedAsmOperand.h
lib/MC/MCParser/AsmParser.cpp
lib/MC/MCParser/MCAsmParser.cpp
lib/Target/ARM/AsmParser/ARMAsmParser.cpp
lib/Target/MBlaze/AsmParser/MBlazeAsmParser.cpp
lib/Target/X86/AsmParser/X86AsmParser.cpp

index 91f5773b8df85fa9e4aab726083f3e3511c19efc..2556e5f27a305705d4936de27427bc08254d4c33 100644 (file)
@@ -28,10 +28,20 @@ public:
   /// getEndLoc - Get the location of the last token of this operand.
   virtual SMLoc getEndLoc() const = 0;
 
-  /// dump - Print a debug representation of the operand to the given stream.
-  virtual void dump(raw_ostream &OS) const = 0;
+  /// print - Print a debug representation of the operand to the given stream.
+  virtual void print(raw_ostream &OS) const = 0;
+  /// dump - Print to the debug stream.
+  virtual void dump() const;
 };
 
+//===----------------------------------------------------------------------===//
+// Debugging Support
+
+inline raw_ostream& operator<<(raw_ostream &OS, const MCParsedAsmOperand &MO) {
+  MO.print(OS);
+  return OS;
+}
+
 } // end namespace llvm.
 
 #endif
index db188f7c8b64f419407eb48334eecf112db2fac0..0c181f39611e356cf42d0caa038e00302a01c6fd 100644 (file)
@@ -1194,7 +1194,7 @@ bool AsmParser::ParseStatement() {
     for (unsigned i = 0; i != ParsedOperands.size(); ++i) {
       if (i != 0)
         OS << ", ";
-      ParsedOperands[i]->dump(OS);
+      ParsedOperands[i]->print(OS);
     }
     OS << "]";
 
index 70295efc613ca0a6bebb23d087f4919118f82e7c..4030e41036aadec2a98e76f53e1340126689da4d 100644 (file)
@@ -12,6 +12,8 @@
 #include "llvm/MC/MCParser/MCAsmLexer.h"
 #include "llvm/MC/MCParser/MCParsedAsmOperand.h"
 #include "llvm/Support/SourceMgr.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/Debug.h"
 #include "llvm/Target/TargetAsmParser.h"
 using namespace llvm;
 
@@ -41,4 +43,6 @@ bool MCAsmParser::ParseExpression(const MCExpr *&Res) {
   return ParseExpression(Res, L);
 }
 
-
+void MCParsedAsmOperand::dump() const {
+  dbgs() << "  " << *this;
+}
index 8bfefdfb3a3cfd88b6e428786894f9d2751b8b7e..e90962ff0b3337c2906fe2806d3f5410dfbc7fca 100644 (file)
@@ -692,7 +692,7 @@ public:
     Inst.addOperand(MCOperand::CreateImm(unsigned(getProcIFlags())));
   }
 
-  virtual void dump(raw_ostream &OS) const;
+  virtual void print(raw_ostream &OS) const;
 
   static ARMOperand *CreateCondCode(ARMCC::CondCodes CC, SMLoc S) {
     ARMOperand *Op = new ARMOperand(CondCode);
@@ -846,7 +846,7 @@ public:
 
 } // end anonymous namespace.
 
-void ARMOperand::dump(raw_ostream &OS) const {
+void ARMOperand::print(raw_ostream &OS) const {
   switch (Kind) {
   case CondCode:
     OS << "<ARMCC::" << ARMCondCodeToString(getCondCode()) << ">";
index 8759e0c5f2f064e3f1a242a780b48d3ac2b789d9..eebd9d878943a3ff5f72e507ca40877ae84874a7 100644 (file)
@@ -219,7 +219,7 @@ public:
     return StringRef(Tok.Data, Tok.Length);
   }
 
-  virtual void dump(raw_ostream &OS) const;
+  virtual void print(raw_ostream &OS) const;
 
   static MBlazeOperand *CreateToken(StringRef Str, SMLoc S) {
     MBlazeOperand *Op = new MBlazeOperand(Token);
@@ -279,7 +279,7 @@ public:
 
 } // end anonymous namespace.
 
-void MBlazeOperand::dump(raw_ostream &OS) const {
+void MBlazeOperand::print(raw_ostream &OS) const {
   switch (Kind) {
   case Immediate:
     getImm()->print(OS);
index c6f0b2412955c332f745162b83b76ff27fb25bb1..77f5c125aa19b4a6999c9ead3651a5455c125800 100644 (file)
@@ -145,7 +145,7 @@ struct X86Operand : public MCParsedAsmOperand {
   /// getEndLoc - Get the location of the last token of this operand.
   SMLoc getEndLoc() const { return EndLoc; }
 
-  virtual void dump(raw_ostream &OS) const {}
+  virtual void print(raw_ostream &OS) const {}
 
   StringRef getToken() const {
     assert(Kind == Token && "Invalid access!");