aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC/MCParser
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-08-11 06:37:09 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-08-11 06:37:09 +0000
commit3c14ca47fc057c5999cd41ce2782e0ebaa2bcf7d (patch)
treee77a324585af330678555645cef5e8590e7df6d4 /lib/MC/MCParser
parentb3cb6967949493a2e1b10d015ac08b746736764e (diff)
downloadexternal_llvm-3c14ca47fc057c5999cd41ce2782e0ebaa2bcf7d.zip
external_llvm-3c14ca47fc057c5999cd41ce2782e0ebaa2bcf7d.tar.gz
external_llvm-3c14ca47fc057c5999cd41ce2782e0ebaa2bcf7d.tar.bz2
llvm-mc: Add -show-inst-operands, for dumping the parsed instruction representation before matching.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110791 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCParser')
-rw-r--r--lib/MC/MCParser/AsmParser.cpp15
-rw-r--r--lib/MC/MCParser/MCAsmParser.cpp2
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp
index 70a37e3..016f8f9 100644
--- a/lib/MC/MCParser/AsmParser.cpp
+++ b/lib/MC/MCParser/AsmParser.cpp
@@ -916,6 +916,21 @@ bool AsmParser::ParseStatement() {
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;
diff --git a/lib/MC/MCParser/MCAsmParser.cpp b/lib/MC/MCParser/MCAsmParser.cpp
index 0e0533b..70295ef 100644
--- a/lib/MC/MCParser/MCAsmParser.cpp
+++ b/lib/MC/MCParser/MCAsmParser.cpp
@@ -15,7 +15,7 @@
#include "llvm/Target/TargetAsmParser.h"
using namespace llvm;
-MCAsmParser::MCAsmParser() : TargetParser(0) {
+MCAsmParser::MCAsmParser() : TargetParser(0), ShowParsedOperands(0) {
}
MCAsmParser::~MCAsmParser() {