10b57cec5SDimitry Andric //==- SystemZInstPrinter.h - Convert SystemZ MCInst to assembly --*- C++ -*-==// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This class prints a SystemZ MCInst to a .s file. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZINSTPRINTER_H 140b57cec5SDimitry Andric #define LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZINSTPRINTER_H 150b57cec5SDimitry Andric 16fe6060f1SDimitry Andric #include "SystemZMCAsmInfo.h" 170b57cec5SDimitry Andric #include "llvm/MC/MCInstPrinter.h" 180b57cec5SDimitry Andric #include <cstdint> 190b57cec5SDimitry Andric 200b57cec5SDimitry Andric namespace llvm { 210b57cec5SDimitry Andric 220b57cec5SDimitry Andric class MCOperand; 230b57cec5SDimitry Andric 240b57cec5SDimitry Andric class SystemZInstPrinter : public MCInstPrinter { 250b57cec5SDimitry Andric public: SystemZInstPrinter(const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)260b57cec5SDimitry Andric SystemZInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, 270b57cec5SDimitry Andric const MCRegisterInfo &MRI) 280b57cec5SDimitry Andric : MCInstPrinter(MAI, MII, MRI) {} 290b57cec5SDimitry Andric 300b57cec5SDimitry Andric // Automatically generated by tblgen. 31e8d8bef9SDimitry Andric std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override; 32480093f4SDimitry Andric void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); 33bdd1243dSDimitry Andric static const char *getRegisterName(MCRegister Reg); 340b57cec5SDimitry Andric 350b57cec5SDimitry Andric // Print an address with the given base, displacement and index. 36bdd1243dSDimitry Andric void printAddress(const MCAsmInfo *MAI, MCRegister Base, 37bdd1243dSDimitry Andric const MCOperand &DispMO, MCRegister Index, raw_ostream &O); 380b57cec5SDimitry Andric 390b57cec5SDimitry Andric // Print the given operand. 40bdd1243dSDimitry Andric void printOperand(const MCOperand &MO, const MCAsmInfo *MAI, raw_ostream &O); 410b57cec5SDimitry Andric 42bdd1243dSDimitry Andric void printFormattedRegName(const MCAsmInfo *MAI, MCRegister Reg, 43bdd1243dSDimitry Andric raw_ostream &O) const; 44fe6060f1SDimitry Andric 450b57cec5SDimitry Andric // Override MCInstPrinter. 46bdd1243dSDimitry Andric void printRegName(raw_ostream &O, MCRegister Reg) const override; 47fe6060f1SDimitry Andric 48480093f4SDimitry Andric void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, 49480093f4SDimitry Andric const MCSubtargetInfo &STI, raw_ostream &O) override; 500b57cec5SDimitry Andric 510b57cec5SDimitry Andric private: 52bdd1243dSDimitry Andric template <unsigned N> 53bdd1243dSDimitry Andric void printUImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 54bdd1243dSDimitry Andric template <unsigned N> 55bdd1243dSDimitry Andric void printSImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 56bdd1243dSDimitry Andric 570b57cec5SDimitry Andric // Print various types of operand. 580b57cec5SDimitry Andric void printOperand(const MCInst *MI, int OpNum, raw_ostream &O); printOperand(const MCInst * MI,uint64_t,unsigned OpNum,raw_ostream & O)595ffd83dbSDimitry Andric void printOperand(const MCInst *MI, uint64_t /*Address*/, unsigned OpNum, 605ffd83dbSDimitry Andric raw_ostream &O) { 615ffd83dbSDimitry Andric printOperand(MI, OpNum, O); 625ffd83dbSDimitry Andric } 630b57cec5SDimitry Andric void printBDAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O); 640b57cec5SDimitry Andric void printBDXAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O); 650b57cec5SDimitry Andric void printBDLAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O); 660b57cec5SDimitry Andric void printBDRAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O); 670b57cec5SDimitry Andric void printBDVAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O); 680b57cec5SDimitry Andric void printU1ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 690b57cec5SDimitry Andric void printU2ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 700b57cec5SDimitry Andric void printU3ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 710b57cec5SDimitry Andric void printU4ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 720b57cec5SDimitry Andric void printS8ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 730b57cec5SDimitry Andric void printU8ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 740b57cec5SDimitry Andric void printU12ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 750b57cec5SDimitry Andric void printS16ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 760b57cec5SDimitry Andric void printU16ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 770b57cec5SDimitry Andric void printS32ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 780b57cec5SDimitry Andric void printU32ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 790b57cec5SDimitry Andric void printU48ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O); 800b57cec5SDimitry Andric void printPCRelOperand(const MCInst *MI, int OpNum, raw_ostream &O); printPCRelOperand(const MCInst * MI,uint64_t,int OpNum,raw_ostream & O)815ffd83dbSDimitry Andric void printPCRelOperand(const MCInst *MI, uint64_t /*Address*/, int OpNum, 825ffd83dbSDimitry Andric raw_ostream &O) { 835ffd83dbSDimitry Andric printPCRelOperand(MI, OpNum, O); 845ffd83dbSDimitry Andric } 855ffd83dbSDimitry Andric void printPCRelTLSOperand(const MCInst *MI, uint64_t Address, int OpNum, 865ffd83dbSDimitry Andric raw_ostream &O); 870b57cec5SDimitry Andric 880b57cec5SDimitry Andric // Print the mnemonic for a condition-code mask ("ne", "lh", etc.) 890b57cec5SDimitry Andric // This forms part of the instruction name rather than the operand list. 900b57cec5SDimitry Andric void printCond4Operand(const MCInst *MI, int OpNum, raw_ostream &O); 910b57cec5SDimitry Andric }; 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric } // end namespace llvm 940b57cec5SDimitry Andric 950b57cec5SDimitry Andric #endif // LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZINSTPRINTER_H 96