print instruction encodings with the existing comment facilities,

so that llvm-mc -show-encoding prints like this:

	hlt                                                 ## encoding: [0xf4]

instead of like this:

	hlt
                     # encoding: [0xf4]

llvm-svn: 95207
This commit is contained in:
Chris Lattner 2010-02-03 06:28:13 +00:00
parent 3eef965b06
commit 44f7325de5
1 changed files with 17 additions and 18 deletions

View File

@ -527,20 +527,15 @@ void MCAsmStreamer::EmitDwarfFileDirective(unsigned FileNo, StringRef Filename){
void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
assert(CurSection && "Cannot emit contents before setting section!");
// If we have an AsmPrinter, use that to print.
if (InstPrinter) {
InstPrinter->printInst(&Inst);
EmitEOL();
// Show the encoding if we have a code emitter.
// Show the encoding in a comment if we have a code emitter.
if (Emitter) {
SmallString<256> Code;
raw_svector_ostream VecOS(Code);
Emitter->EncodeInstruction(Inst, VecOS);
VecOS.flush();
OS.indent(20);
OS << " # encoding: [";
raw_ostream &OS = GetCommentOS();
OS << "encoding: [";
for (unsigned i = 0, e = Code.size(); i != e; ++i) {
if (i)
OS << ',';
@ -549,6 +544,10 @@ void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
OS << "]\n";
}
// If we have an AsmPrinter, use that to print.
if (InstPrinter) {
InstPrinter->printInst(&Inst);
EmitEOL();
return;
}