Index: llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.h =================================================================== --- llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.h +++ llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.h @@ -35,18 +35,18 @@ // Print an address with the given base, displacement and index. static void printAddress(const MCAsmInfo *MAI, unsigned Base, const MCOperand &DispMO, unsigned Index, - raw_ostream &O); + raw_ostream &O, bool UseMarkup); // Print the given operand. static void printOperand(const MCOperand &MO, const MCAsmInfo *MAI, - raw_ostream &O); + raw_ostream &O, bool UseMarkup); static void printFormattedRegName(const MCAsmInfo *MAI, unsigned RegNo, - raw_ostream &O); + raw_ostream &O, bool UseMarkup); // Override MCInstPrinter. inline void printRegName(raw_ostream &O, unsigned RegNo) const override { - printFormattedRegName(&MAI, RegNo, O); + printFormattedRegName(&MAI, RegNo, O, true); } void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, @@ -54,10 +54,11 @@ private: // Print various types of operand. - void printOperand(const MCInst *MI, int OpNum, raw_ostream &O); + void printOperand(const MCInst *MI, int OpNum, raw_ostream &O, + bool UseMarkup); void printOperand(const MCInst *MI, uint64_t /*Address*/, unsigned OpNum, - raw_ostream &O) { - printOperand(MI, OpNum, O); + raw_ostream &O, bool UseMarkup) { + printOperand(MI, OpNum, O, UseMarkup); } void printBDAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O); void printBDXAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O); Index: llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.cpp =================================================================== --- llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.cpp +++ llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinter.cpp @@ -25,46 +25,50 @@ void SystemZInstPrinter::printAddress(const MCAsmInfo *MAI, unsigned Base, const MCOperand &DispMO, unsigned Index, - raw_ostream &O) { - printOperand(DispMO, MAI, O); + raw_ostream &O, bool UseMarkup) { + printOperand(DispMO, MAI, O, UseMarkup); if (Base || Index) { O << '('; if (Index) { - printFormattedRegName(MAI, Index, O); + printFormattedRegName(MAI, Index, O, UseMarkup); if (Base) O << ','; } if (Base) - printFormattedRegName(MAI, Base, O); + printFormattedRegName(MAI, Index, O, UseMarkup); O << ')'; } } void SystemZInstPrinter::printOperand(const MCOperand &MO, const MCAsmInfo *MAI, - raw_ostream &O) { + raw_ostream &O, bool UseMarkup) { if (MO.isReg()) { if (!MO.getReg()) O << '0'; else - printFormattedRegName(MAI, MO.getReg(), O); - } - else if (MO.isImm()) + printFormattedRegName(MAI, MO.getReg(), O, UseMarkup); + } else if (MO.isImm()) { + if (UseMarkup) + O << ""; + } else if (MO.isExpr()) MO.getExpr()->print(O, MAI); else llvm_unreachable("Invalid operand"); } void SystemZInstPrinter::printFormattedRegName(const MCAsmInfo *MAI, - unsigned RegNo, raw_ostream &O) { + unsigned RegNo, raw_ostream &O, + bool UseMarkup) { const char *RegName = getRegisterName(RegNo); if (MAI->getAssemblerDialect() == AD_HLASM) { // Skip register prefix so that only register number is left assert(isalpha(RegName[0]) && isdigit(RegName[1])); - O << (RegName + 1); + O << markup(""); } else - O << '%' << RegName; + O << markup(""); } void SystemZInstPrinter::printInst(const MCInst *MI, uint64_t Address, @@ -75,90 +79,101 @@ } template -static void printUImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { +static void printUImmOperand(const MCInst *MI, int OpNum, raw_ostream &O, + bool UseMarkup) { int64_t Value = MI->getOperand(OpNum).getImm(); assert(isUInt(Value) && "Invalid uimm argument"); + if (UseMarkup) + O << ""; } template -static void printSImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { +static void printSImmOperand(const MCInst *MI, int OpNum, raw_ostream &O, + bool UseMarkup) { int64_t Value = MI->getOperand(OpNum).getImm(); assert(isInt(Value) && "Invalid simm argument"); + if (UseMarkup) + O << ""; } void SystemZInstPrinter::printU1ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { - printUImmOperand<1>(MI, OpNum, O); + printUImmOperand<1>(MI, OpNum, O, UseMarkup); } void SystemZInstPrinter::printU2ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { - printUImmOperand<2>(MI, OpNum, O); + printUImmOperand<2>(MI, OpNum, O, UseMarkup); } void SystemZInstPrinter::printU3ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { - printUImmOperand<3>(MI, OpNum, O); + printUImmOperand<3>(MI, OpNum, O, UseMarkup); } void SystemZInstPrinter::printU4ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { - printUImmOperand<4>(MI, OpNum, O); + printUImmOperand<4>(MI, OpNum, O, UseMarkup); } void SystemZInstPrinter::printU6ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { - printUImmOperand<6>(MI, OpNum, O); + printUImmOperand<6>(MI, OpNum, O, UseMarkup); } void SystemZInstPrinter::printS8ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { - printSImmOperand<8>(MI, OpNum, O); + printSImmOperand<8>(MI, OpNum, O, UseMarkup); } void SystemZInstPrinter::printU8ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { - printUImmOperand<8>(MI, OpNum, O); + printUImmOperand<8>(MI, OpNum, O, UseMarkup); } void SystemZInstPrinter::printU12ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { - printUImmOperand<12>(MI, OpNum, O); + printUImmOperand<12>(MI, OpNum, O, UseMarkup); } void SystemZInstPrinter::printS16ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { - printSImmOperand<16>(MI, OpNum, O); + printSImmOperand<16>(MI, OpNum, O, UseMarkup); } void SystemZInstPrinter::printU16ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { - printUImmOperand<16>(MI, OpNum, O); + printUImmOperand<16>(MI, OpNum, O, UseMarkup); } void SystemZInstPrinter::printS32ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { - printSImmOperand<32>(MI, OpNum, O); + printSImmOperand<32>(MI, OpNum, O, UseMarkup); } void SystemZInstPrinter::printU32ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { - printUImmOperand<32>(MI, OpNum, O); + printUImmOperand<32>(MI, OpNum, O, UseMarkup); } void SystemZInstPrinter::printU48ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O) { - printUImmOperand<48>(MI, OpNum, O); + printUImmOperand<48>(MI, OpNum, O, UseMarkup); } void SystemZInstPrinter::printPCRelOperand(const MCInst *MI, int OpNum, raw_ostream &O) { const MCOperand &MO = MI->getOperand(OpNum); if (MO.isImm()) { - O << "0x"; + O << markup(""); } else MO.getExpr()->print(O, &MAI); } @@ -188,20 +203,20 @@ } void SystemZInstPrinter::printOperand(const MCInst *MI, int OpNum, - raw_ostream &O) { - printOperand(MI->getOperand(OpNum), &MAI, O); + raw_ostream &O, bool UseMarkup) { + printOperand(MI->getOperand(OpNum), &MAI, O, UseMarkup); } void SystemZInstPrinter::printBDAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O) { printAddress(&MAI, MI->getOperand(OpNum).getReg(), MI->getOperand(OpNum + 1), - 0, O); + 0, O, UseMarkup); } void SystemZInstPrinter::printBDXAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O) { printAddress(&MAI, MI->getOperand(OpNum).getReg(), MI->getOperand(OpNum + 1), - MI->getOperand(OpNum + 2).getReg(), O); + MI->getOperand(OpNum + 2).getReg(), O, UseMarkup); } void SystemZInstPrinter::printBDLAddrOperand(const MCInst *MI, int OpNum, @@ -209,7 +224,7 @@ unsigned Base = MI->getOperand(OpNum).getReg(); const MCOperand &DispMO = MI->getOperand(OpNum + 1); uint64_t Length = MI->getOperand(OpNum + 2).getImm(); - printOperand(DispMO, &MAI, O); + printOperand(DispMO, &MAI, O, UseMarkup); O << '(' << Length; if (Base) { O << ","; @@ -223,7 +238,7 @@ unsigned Base = MI->getOperand(OpNum).getReg(); const MCOperand &DispMO = MI->getOperand(OpNum + 1); unsigned Length = MI->getOperand(OpNum + 2).getReg(); - printOperand(DispMO, &MAI, O); + printOperand(DispMO, &MAI, O, UseMarkup); O << "("; printRegName(O, Length); if (Base) { @@ -236,7 +251,7 @@ void SystemZInstPrinter::printBDVAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O) { printAddress(&MAI, MI->getOperand(OpNum).getReg(), MI->getOperand(OpNum + 1), - MI->getOperand(OpNum + 2).getReg(), O); + MI->getOperand(OpNum + 2).getReg(), O, UseMarkup); } void SystemZInstPrinter::printCond4Operand(const MCInst *MI, int OpNum, Index: llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp =================================================================== --- llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp +++ llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp @@ -802,7 +802,7 @@ SystemZMCInstLower Lower(MF->getContext(), *this); MCOp = Lower.lowerOperand(MO); } - SystemZInstPrinter::printOperand(MCOp, MAI, OS); + SystemZInstPrinter::printOperand(MCOp, MAI, OS, false); return false; } @@ -810,10 +810,10 @@ unsigned OpNo, const char *ExtraCode, raw_ostream &OS) { - SystemZInstPrinter:: - printAddress(MAI, MI->getOperand(OpNo).getReg(), - MCOperand::createImm(MI->getOperand(OpNo + 1).getImm()), - MI->getOperand(OpNo + 2).getReg(), OS); + SystemZInstPrinter::printAddress( + MAI, MI->getOperand(OpNo).getReg(), + MCOperand::createImm(MI->getOperand(OpNo + 1).getImm()), + MI->getOperand(OpNo + 2).getReg(), OS, false); return false; } Index: llvm/test/MC/Disassembler/SystemZ/marked-up.txt =================================================================== --- /dev/null +++ llvm/test/MC/Disassembler/SystemZ/marked-up.txt @@ -0,0 +1,11 @@ +# RUN: llvm-mc --mdis %s -triple=s390x-linux-gnu -mcpu=zEC12 2>&1 | FileCheck %s + +# CHECK: blr +0x07 0x4a +# CHECK: lrl , +0xc4 0xfd 0x00 0x00 0x00 0x47 +# CHECK: stc , +0x42 0x00 0x0f 0xff +# CHECK: trace , , () +0x99 0x00 0x10 0x00 +