TargetAsmParser *TargetParser;
+ unsigned ShowParsedOperands : 1;
+
protected: // Can only create subclasses.
MCAsmParser();
TargetAsmParser &getTargetParser() const { return *TargetParser; }
void setTargetParser(TargetAsmParser &P);
+ bool getShowParsedOperands() const { return ShowParsedOperands; }
+ void setShowParsedOperands(bool Value) { ShowParsedOperands = Value; }
+
/// Run - Run the parser on the input source buffer.
virtual bool Run(bool NoInitialTextSection, bool NoFinalize = false) = 0;
if (!HadError && Lexer.isNot(AsmToken::EndOfStatement))
HadError = TokError("unexpected token in argument list");
+ // Dump the parsed representation, if requested.
+ if (getShowParsedOperands()) {
+ SmallString<256> Str;
+ raw_svector_ostream OS(Str);
+ OS << "parsed instruction: [";
+ for (unsigned i = 0; i != ParsedOperands.size(); ++i) {
+ if (i != 0)
+ OS << ", ";
+ ParsedOperands[i]->dump(OS);
+ }
+ OS << "]";
+
+ PrintMessage(IDLoc, OS.str(), "note");
+ }
+
// If parsing succeeded, match the instruction.
if (!HadError) {
MCInst Inst;
#include "llvm/Target/TargetAsmParser.h"
using namespace llvm;
-MCAsmParser::MCAsmParser() : TargetParser(0) {
+MCAsmParser::MCAsmParser() : TargetParser(0), ShowParsedOperands(0) {
}
MCAsmParser::~MCAsmParser() {
static cl::opt<bool>
ShowInst("show-inst", cl::desc("Show internal instruction representation"));
+static cl::opt<bool>
+ShowInstOperands("show-inst-operands",
+ cl::desc("Show instructions operands as parsed"));
+
static cl::opt<unsigned>
OutputAsmVariant("output-asm-variant",
cl::desc("Syntax variant to use for output printing"));
return 1;
}
+ Parser->setShowParsedOperands(ShowInstOperands);
Parser->setTargetParser(*TAP.get());
int Res = Parser->Run(NoInitialTextSection);