Update MCParsedAsmOperand debug methods.

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
This commit is contained in:
Jim Grosbach 2011-07-13 15:34:57 +00:00
parent 75f67e0d8d
commit b7f689bab9
6 changed files with 23 additions and 9 deletions

View File

@ -28,10 +28,20 @@ public:
/// getEndLoc - Get the location of the last token of this operand. /// getEndLoc - Get the location of the last token of this operand.
virtual SMLoc getEndLoc() const = 0; virtual SMLoc getEndLoc() const = 0;
/// dump - Print a debug representation of the operand to the given stream. /// print - Print a debug representation of the operand to the given stream.
virtual void dump(raw_ostream &OS) const = 0; 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. } // end namespace llvm.
#endif #endif

View File

@ -1194,7 +1194,7 @@ bool AsmParser::ParseStatement() {
for (unsigned i = 0; i != ParsedOperands.size(); ++i) { for (unsigned i = 0; i != ParsedOperands.size(); ++i) {
if (i != 0) if (i != 0)
OS << ", "; OS << ", ";
ParsedOperands[i]->dump(OS); ParsedOperands[i]->print(OS);
} }
OS << "]"; OS << "]";

View File

@ -12,6 +12,8 @@
#include "llvm/MC/MCParser/MCAsmLexer.h" #include "llvm/MC/MCParser/MCAsmLexer.h"
#include "llvm/MC/MCParser/MCParsedAsmOperand.h" #include "llvm/MC/MCParser/MCParsedAsmOperand.h"
#include "llvm/Support/SourceMgr.h" #include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Debug.h"
#include "llvm/Target/TargetAsmParser.h" #include "llvm/Target/TargetAsmParser.h"
using namespace llvm; using namespace llvm;
@ -41,4 +43,6 @@ bool MCAsmParser::ParseExpression(const MCExpr *&Res) {
return ParseExpression(Res, L); return ParseExpression(Res, L);
} }
void MCParsedAsmOperand::dump() const {
dbgs() << " " << *this;
}

View File

@ -692,7 +692,7 @@ public:
Inst.addOperand(MCOperand::CreateImm(unsigned(getProcIFlags()))); 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) { static ARMOperand *CreateCondCode(ARMCC::CondCodes CC, SMLoc S) {
ARMOperand *Op = new ARMOperand(CondCode); ARMOperand *Op = new ARMOperand(CondCode);
@ -846,7 +846,7 @@ public:
} // end anonymous namespace. } // end anonymous namespace.
void ARMOperand::dump(raw_ostream &OS) const { void ARMOperand::print(raw_ostream &OS) const {
switch (Kind) { switch (Kind) {
case CondCode: case CondCode:
OS << "<ARMCC::" << ARMCondCodeToString(getCondCode()) << ">"; OS << "<ARMCC::" << ARMCondCodeToString(getCondCode()) << ">";

View File

@ -219,7 +219,7 @@ public:
return StringRef(Tok.Data, Tok.Length); 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) { static MBlazeOperand *CreateToken(StringRef Str, SMLoc S) {
MBlazeOperand *Op = new MBlazeOperand(Token); MBlazeOperand *Op = new MBlazeOperand(Token);
@ -279,7 +279,7 @@ public:
} // end anonymous namespace. } // end anonymous namespace.
void MBlazeOperand::dump(raw_ostream &OS) const { void MBlazeOperand::print(raw_ostream &OS) const {
switch (Kind) { switch (Kind) {
case Immediate: case Immediate:
getImm()->print(OS); getImm()->print(OS);

View File

@ -145,7 +145,7 @@ struct X86Operand : public MCParsedAsmOperand {
/// getEndLoc - Get the location of the last token of this operand. /// getEndLoc - Get the location of the last token of this operand.
SMLoc getEndLoc() const { return EndLoc; } SMLoc getEndLoc() const { return EndLoc; }
virtual void dump(raw_ostream &OS) const {} virtual void print(raw_ostream &OS) const {}
StringRef getToken() const { StringRef getToken() const {
assert(Kind == Token && "Invalid access!"); assert(Kind == Token && "Invalid access!");