xref: /freebsd/contrib/llvm-project/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZInstPrinterCommon.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1*700637cbSDimitry Andric //== SystemZInstPrinterCommon.h - Common SystemZ InstPrinter funcs *- C++ -*==//
2*700637cbSDimitry Andric //
3*700637cbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*700637cbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*700637cbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*700637cbSDimitry Andric //
7*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
8*700637cbSDimitry Andric //
9*700637cbSDimitry Andric // This class prints a SystemZ MCInst to a .s file.
10*700637cbSDimitry Andric //
11*700637cbSDimitry Andric //===----------------------------------------------------------------------===//
12*700637cbSDimitry Andric 
13*700637cbSDimitry Andric #ifndef LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZINSTPRINTERCOMMON_H
14*700637cbSDimitry Andric #define LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZINSTPRINTERCOMMON_H
15*700637cbSDimitry Andric 
16*700637cbSDimitry Andric #include "SystemZMCAsmInfo.h"
17*700637cbSDimitry Andric #include "llvm/MC/MCInstPrinter.h"
18*700637cbSDimitry Andric #include "llvm/MC/MCRegister.h"
19*700637cbSDimitry Andric #include <cstdint>
20*700637cbSDimitry Andric 
21*700637cbSDimitry Andric namespace llvm {
22*700637cbSDimitry Andric 
23*700637cbSDimitry Andric class MCOperand;
24*700637cbSDimitry Andric 
25*700637cbSDimitry Andric class SystemZInstPrinterCommon : public MCInstPrinter {
26*700637cbSDimitry Andric public:
SystemZInstPrinterCommon(const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)27*700637cbSDimitry Andric   SystemZInstPrinterCommon(const MCAsmInfo &MAI, const MCInstrInfo &MII,
28*700637cbSDimitry Andric                            const MCRegisterInfo &MRI)
29*700637cbSDimitry Andric       : MCInstPrinter(MAI, MII, MRI) {}
30*700637cbSDimitry Andric 
31*700637cbSDimitry Andric   // Print an address with the given base, displacement and index.
32*700637cbSDimitry Andric   void printAddress(const MCAsmInfo *MAI, MCRegister Base,
33*700637cbSDimitry Andric                     const MCOperand &DispMO, MCRegister Index, raw_ostream &O);
34*700637cbSDimitry Andric 
35*700637cbSDimitry Andric   // Print the given operand.
36*700637cbSDimitry Andric   void printOperand(const MCOperand &MO, const MCAsmInfo *MAI, raw_ostream &O);
37*700637cbSDimitry Andric 
printFormattedRegName(const MCAsmInfo * MAI,MCRegister Reg,raw_ostream & O)38*700637cbSDimitry Andric   virtual void printFormattedRegName(const MCAsmInfo *MAI, MCRegister Reg,
39*700637cbSDimitry Andric                                      raw_ostream &O) {}
40*700637cbSDimitry Andric 
41*700637cbSDimitry Andric   // Override MCInstPrinter.
42*700637cbSDimitry Andric   void printRegName(raw_ostream &O, MCRegister Reg) override;
43*700637cbSDimitry Andric 
44*700637cbSDimitry Andric protected:
45*700637cbSDimitry Andric   template <unsigned N>
46*700637cbSDimitry Andric   void printUImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
47*700637cbSDimitry Andric   template <unsigned N>
48*700637cbSDimitry Andric   void printSImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
49*700637cbSDimitry Andric 
50*700637cbSDimitry Andric   // Print various types of operand.
51*700637cbSDimitry Andric   void printOperand(const MCInst *MI, int OpNum, raw_ostream &O);
printOperand(const MCInst * MI,uint64_t,unsigned OpNum,raw_ostream & O)52*700637cbSDimitry Andric   void printOperand(const MCInst *MI, uint64_t /*Address*/, unsigned OpNum,
53*700637cbSDimitry Andric                     raw_ostream &O) {
54*700637cbSDimitry Andric     printOperand(MI, OpNum, O);
55*700637cbSDimitry Andric   }
56*700637cbSDimitry Andric   void printBDAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O);
57*700637cbSDimitry Andric   void printBDXAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O);
58*700637cbSDimitry Andric   void printBDLAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O);
59*700637cbSDimitry Andric   void printBDRAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O);
60*700637cbSDimitry Andric   void printBDVAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O);
61*700637cbSDimitry Andric   void printLXAAddrOperand(const MCInst *MI, int OpNum, raw_ostream &O);
62*700637cbSDimitry Andric   void printU1ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
63*700637cbSDimitry Andric   void printU2ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
64*700637cbSDimitry Andric   void printU3ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
65*700637cbSDimitry Andric   void printU4ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
66*700637cbSDimitry Andric   void printS8ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
67*700637cbSDimitry Andric   void printU8ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
68*700637cbSDimitry Andric   void printU12ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
69*700637cbSDimitry Andric   void printS16ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
70*700637cbSDimitry Andric   void printU16ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
71*700637cbSDimitry Andric   void printS32ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
72*700637cbSDimitry Andric   void printU32ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
73*700637cbSDimitry Andric   void printU48ImmOperand(const MCInst *MI, int OpNum, raw_ostream &O);
74*700637cbSDimitry Andric   void printPCRelOperand(const MCInst *MI, uint64_t Address, int OpNum,
75*700637cbSDimitry Andric                          raw_ostream &O);
76*700637cbSDimitry Andric   void printPCRelTLSOperand(const MCInst *MI, uint64_t Address, int OpNum,
77*700637cbSDimitry Andric                             raw_ostream &O);
78*700637cbSDimitry Andric 
79*700637cbSDimitry Andric   // Print the mnemonic for a condition-code mask ("ne", "lh", etc.)
80*700637cbSDimitry Andric   // This forms part of the instruction name rather than the operand list.
81*700637cbSDimitry Andric   void printCond4Operand(const MCInst *MI, int OpNum, raw_ostream &O);
82*700637cbSDimitry Andric };
83*700637cbSDimitry Andric 
84*700637cbSDimitry Andric } // end namespace llvm
85*700637cbSDimitry Andric 
86*700637cbSDimitry Andric #endif // LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZINSTPRINTERCOMMON_H
87