diff options
author | Kevin Enderby <enderby@apple.com> | 2012-10-23 22:52:52 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2012-10-23 22:52:52 +0000 |
commit | e1d4a8813427b76c5f59cf5b70a9df734b7e9284 (patch) | |
tree | a20c95c84240baea4d82d5839d641373b28c4ead /lib/Target/X86/InstPrinter | |
parent | 0787274b70e718af737bd3c0f427574acd829810 (diff) | |
download | external_llvm-e1d4a8813427b76c5f59cf5b70a9df734b7e9284.zip external_llvm-e1d4a8813427b76c5f59cf5b70a9df734b7e9284.tar.gz external_llvm-e1d4a8813427b76c5f59cf5b70a9df734b7e9284.tar.bz2 |
Make branch heavy code for generating marked up disassembly simpler
and easier to read by adding a couple helper functions. Suggestion by
Chandler Carruth and seconded by Meador Inge!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166515 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/InstPrinter')
-rw-r--r-- | lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp b/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp index edad473..a4bd114 100644 --- a/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp +++ b/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp @@ -34,11 +34,9 @@ using namespace llvm; void X86ATTInstPrinter::printRegName(raw_ostream &OS, unsigned RegNo) const { - if (UseMarkup) - OS << "<reg:"; - OS << '%' << getRegisterName(RegNo); - if (UseMarkup) - OS << ">"; + OS << markup("<reg:") + << '%' << getRegisterName(RegNo) + << markup(">"); } void X86ATTInstPrinter::printInst(const MCInst *MI, raw_ostream &OS, @@ -155,29 +153,21 @@ void X86ATTInstPrinter::printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) { const MCOperand &Op = MI->getOperand(OpNo); if (Op.isReg()) { - if (UseMarkup) - O << "<reg:"; - O << '%' << getRegisterName(Op.getReg()); - if (UseMarkup) - O << ">"; + printRegName(O, Op.getReg()); } else if (Op.isImm()) { - if (UseMarkup) - O << "<imm:"; // Print X86 immediates as signed values. - O << '$' << (int64_t)Op.getImm(); - if (UseMarkup) - O << ">"; + O << markup("<imm:") + << '$' << (int64_t)Op.getImm() + << markup(">"); if (CommentStream && (Op.getImm() > 255 || Op.getImm() < -256)) *CommentStream << format("imm = 0x%" PRIX64 "\n", (uint64_t)Op.getImm()); } else { assert(Op.isExpr() && "unknown operand kind in printOperand"); - if (UseMarkup) - O << "<imm:"; - O << '$' << *Op.getExpr(); - if (UseMarkup) - O << ">"; + O << markup("<imm:") + << '$' << *Op.getExpr() + << markup(">"); } } @@ -188,8 +178,7 @@ void X86ATTInstPrinter::printMemReference(const MCInst *MI, unsigned Op, const MCOperand &DispSpec = MI->getOperand(Op+3); const MCOperand &SegReg = MI->getOperand(Op+4); - if (UseMarkup) - O << "<mem:"; + O << markup("<mem:"); // If this has a segment register, print it. if (SegReg.getReg()) { @@ -216,17 +205,14 @@ void X86ATTInstPrinter::printMemReference(const MCInst *MI, unsigned Op, printOperand(MI, Op+2, O); unsigned ScaleVal = MI->getOperand(Op+1).getImm(); if (ScaleVal != 1) { - O << ','; - if (UseMarkup) - O << "<imm:"; - O << ScaleVal; - if (UseMarkup) - O << ">"; + O << ',' + << markup("<imm:") + << ScaleVal + << markup(">"); } } O << ')'; } - if (UseMarkup) - O << ">"; + O << markup(">"); } |