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