46 lines · cpp
1//=- SystemZHLASMInstPrinter.cpp - Convert SystemZ MCInst to HLASM assembly -=//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "SystemZHLASMInstPrinter.h"10#include "llvm/MC/MCInst.h"11#include "llvm/MC/MCRegister.h"12#include "llvm/Support/raw_ostream.h"13 14using namespace llvm;15 16#define DEBUG_TYPE "asm-printer"17 18#include "SystemZGenHLASMAsmWriter.inc"19 20void SystemZHLASMInstPrinter::printFormattedRegName(const MCAsmInfo *MAI,21 MCRegister Reg,22 raw_ostream &O) {23 const char *RegName = getRegisterName(Reg);24 // Skip register prefix so that only register number is left25 assert(isalpha(RegName[0]) && isdigit(RegName[1]));26 markup(O, Markup::Register) << (RegName + 1);27}28 29void SystemZHLASMInstPrinter::printInst(const MCInst *MI, uint64_t Address,30 StringRef Annot,31 const MCSubtargetInfo &STI,32 raw_ostream &O) {33 std::string Str;34 raw_string_ostream RSO(Str);35 printInstruction(MI, Address, RSO);36 // Eat the first tab character and replace it with a space since it is37 // hardcoded in AsmWriterEmitter::EmitPrintInstruction38 // TODO: introduce a line prefix member to AsmWriter to avoid this problem39 if (!Str.empty() && Str.front() == '\t')40 O << " " << Str.substr(1, Str.length());41 else42 O << Str;43 44 printAnnotation(O, Annot);45}46