1 //==- SystemZInstPrinter.h - Convert SystemZ MCInst to assembly --*- C++ -*-==// 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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This class prints a SystemZ MCInst to a .s file. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZINSTPRINTER_H 14 #define LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZINSTPRINTER_H 15 16 #include "llvm/MC/MCInstPrinter.h" 17 #include <cstdint> 18 19 namespace llvm { 20 21 class MCOperand; 22 23 class SystemZInstPrinter : public MCInstPrinter { 24 public: 25 SystemZInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, 26 const MCRegisterInfo &MRI) 27 : MCInstPrinter(MAI, MII, MRI) {} 28 29 // Automatically generated by tblgen. 30 std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override; 31 void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); 32 static const char *getRegisterName(unsigned RegNo); 33 34 // Print an address with the given base, displacement and index. 35 static void printAddress(unsigned Base, int64_t Disp, unsigned Index, 36 raw_ostream &O); 37 38 // Print the given operand. 39 static void printOperand(const MCOperand &MO, const MCAsmInfo *MAI, 40 raw_ostream &O); 41 42 // Override MCInstPrinter. 43 void printRegName(raw_ostream &O, unsigned RegNo) const override; 44 void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, 45 const MCSubtargetInfo &STI, raw_ostream &O) override; 46 47 private: 48 // Print various types of operand. 49 void printOperand(const MCInst *MI, int OpNum, raw_ostream &O); 50 void printOperand(const MCInst *MI, uint64_t /*Address*/, unsigned OpNum, 51 raw_ostream &O) { 52 printOperand(MI, OpNum, O); 53 } 54 void printBDAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O); 55 void printBDXAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O); 56 void printBDLAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O); 57 void printBDRAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O); 58 void printBDVAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O); 59 void printU1ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 60 void printU2ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 61 void printU3ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 62 void printU4ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 63 void printU6ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 64 void printS8ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 65 void printU8ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 66 void printU12ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 67 void printS16ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 68 void printU16ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 69 void printS32ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 70 void printU32ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 71 void printU48ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 72 void printPCRelOperand(const MCInst *MI, int OpNum, raw_ostream &O); 73 void printPCRelOperand(const MCInst *MI, uint64_t /*Address*/, int OpNum, 74 raw_ostream &O) { 75 printPCRelOperand(MI, OpNum, O); 76 } 77 void printPCRelTLSOperand(const MCInst *MI, uint64_t Address, int OpNum, 78 raw_ostream &O); 79 80 // Print the mnemonic for a condition-code mask ("ne", "lh", etc.) 81 // This forms part of the instruction name rather than the operand list. 82 void printCond4Operand(const MCInst *MI, int OpNum, raw_ostream &O); 83 }; 84 85 } // end namespace llvm 86 87 #endif // LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZINSTPRINTER_H 88