16512a8ddStltao //=- SystemZHLASMInstPrinter.cpp - Convert SystemZ MCInst to HLASM assembly -=// 26512a8ddStltao // 36512a8ddStltao // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 46512a8ddStltao // See https://llvm.org/LICENSE.txt for license information. 56512a8ddStltao // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 66512a8ddStltao // 76512a8ddStltao //===----------------------------------------------------------------------===// 86512a8ddStltao 96512a8ddStltao #include "SystemZHLASMInstPrinter.h" 106512a8ddStltao #include "llvm/MC/MCInst.h" 116512a8ddStltao #include "llvm/MC/MCRegister.h" 126512a8ddStltao #include "llvm/Support/raw_ostream.h" 136512a8ddStltao 146512a8ddStltao using namespace llvm; 156512a8ddStltao 166512a8ddStltao #define DEBUG_TYPE "asm-printer" 176512a8ddStltao 186512a8ddStltao #include "SystemZGenHLASMAsmWriter.inc" 196512a8ddStltao 206512a8ddStltao void SystemZHLASMInstPrinter::printFormattedRegName(const MCAsmInfo *MAI, 216512a8ddStltao MCRegister Reg, 22*facdae62SFangrui Song raw_ostream &O) { 236512a8ddStltao const char *RegName = getRegisterName(Reg); 246512a8ddStltao // Skip register prefix so that only register number is left 256512a8ddStltao assert(isalpha(RegName[0]) && isdigit(RegName[1])); 266512a8ddStltao markup(O, Markup::Register) << (RegName + 1); 276512a8ddStltao } 286512a8ddStltao 296512a8ddStltao void SystemZHLASMInstPrinter::printInst(const MCInst *MI, uint64_t Address, 306512a8ddStltao StringRef Annot, 316512a8ddStltao const MCSubtargetInfo &STI, 326512a8ddStltao raw_ostream &O) { 33c1704059Stltao std::string Str; 34c1704059Stltao raw_string_ostream RSO(Str); 35c1704059Stltao printInstruction(MI, Address, RSO); 36c1704059Stltao // Eat the first tab character and replace it with a space since it is 37c1704059Stltao // hardcoded in AsmWriterEmitter::EmitPrintInstruction 38c1704059Stltao // TODO: introduce a line prefix member to AsmWriter to avoid this problem 39c1704059Stltao if (!Str.empty() && Str.front() == '\t') 40c1704059Stltao O << " " << Str.substr(1, Str.length()); 41c1704059Stltao else 42c1704059Stltao O << Str; 43c1704059Stltao 446512a8ddStltao printAnnotation(O, Annot); 456512a8ddStltao } 46