From 98c5ddabca1debf935a07d14d0cbc9732374bdb8 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Thu, 15 Sep 2011 23:38:46 +0000 Subject: Don't attach annotations to MCInst's. Instead, have the disassembler return, and the printer accept, an annotation string which can be passed through if the client cares about annotations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139876 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/MCDisassembler/Disassembler.cpp | 24 ++++++------------------ lib/MC/MCDisassembler/EDDisassembler.cpp | 4 ++-- 2 files changed, 8 insertions(+), 20 deletions(-) (limited to 'lib/MC/MCDisassembler') diff --git a/lib/MC/MCDisassembler/Disassembler.cpp b/lib/MC/MCDisassembler/Disassembler.cpp index 858a58c..14fab08 100644 --- a/lib/MC/MCDisassembler/Disassembler.cpp +++ b/lib/MC/MCDisassembler/Disassembler.cpp @@ -144,7 +144,7 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes, MCInstPrinter *IP = DC->getIP(); MCDisassembler::DecodeStatus S; S = DisAsm->getInstruction(Inst, Size, MemoryObject, PC, - /*REMOVE*/ nulls()); + /*REMOVE*/ nulls(), DC->CommentStream); switch (S) { case MCDisassembler::Fail: case MCDisassembler::SoftFail: @@ -152,28 +152,16 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes, return 0; case MCDisassembler::Success: { - SmallVector InsnStr; - raw_svector_ostream OS(InsnStr); - IP->printInst(&Inst, OS); - OS.flush(); - DC->CommentStream.flush(); - assert(DC->CommentsToEmit.back() == '\n'); - - DC->CommentsToEmit.push_back('\n'); StringRef Comments = DC->CommentsToEmit.str(); - do { - // Emit a line of comments. - size_t Position = Comments.find('\n'); - OS << ' ' << DC->getAsmInfo()->getCommentString() - << ' ' << Comments.substr(0, Position) << '\n'; - - Comments = Comments.substr(Position+1); - } while (!Comments.empty()); + SmallVector InsnStr; + raw_svector_ostream OS(InsnStr); + IP->printInst(&Inst, OS, Comments); + OS.flush(); - DC->CommentsToEmit.clear(); // Tell the comment stream that the vector changed underneath it. + DC->CommentsToEmit.clear(); DC->CommentStream.resync(); assert(OutStringSize != 0 && "Output buffer cannot be zero size"); diff --git a/lib/MC/MCDisassembler/EDDisassembler.cpp b/lib/MC/MCDisassembler/EDDisassembler.cpp index 70b6300..83362a2 100644 --- a/lib/MC/MCDisassembler/EDDisassembler.cpp +++ b/lib/MC/MCDisassembler/EDDisassembler.cpp @@ -246,7 +246,7 @@ EDInst *EDDisassembler::createInst(EDByteReaderCallback byteReader, MCDisassembler::DecodeStatus S; S = Disassembler->getInstruction(*inst, byteSize, memoryObject, address, - ErrorStream); + ErrorStream, nulls()); switch (S) { case MCDisassembler::Fail: case MCDisassembler::SoftFail: @@ -327,7 +327,7 @@ bool EDDisassembler::registerIsProgramCounter(unsigned registerID) { int EDDisassembler::printInst(std::string &str, MCInst &inst) { PrinterMutex.acquire(); - InstPrinter->printInst(&inst, *InstStream); + InstPrinter->printInst(&inst, *InstStream, ""); InstStream->flush(); str = *InstString; InstString->clear(); -- cgit v1.1