xref: /freebsd/contrib/llvm-project/llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.h (revision a90b9d0159070121c221b966469c3e36d912bf82)
1 //===-- M68kInstPrinter.h - Convert M68k MCInst to asm ----------*- 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 /// \file
10 /// This file contains declarations for an M68k MCInst printer.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_M68K_INSTPRINTER_M68KINSTPRINTER_H
15 #define LLVM_LIB_TARGET_M68K_INSTPRINTER_M68KINSTPRINTER_H
16 
17 #include "M68kMemOperandPrinter.h"
18 #include "llvm/MC/MCInstPrinter.h"
19 
20 namespace llvm {
21 
22 class TargetMachine;
23 
24 class M68kInstPrinter : public MCInstPrinter,
25                         public M68kMemOperandPrinter<M68kInstPrinter, MCInst> {
26   friend class M68kMemOperandPrinter;
27 
28 public:
29   M68kInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
30                   const MCRegisterInfo &MRI)
31       : MCInstPrinter(MAI, MII, MRI) {}
32 
33   // Autogenerated by tblgen.
34   void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
35   static const char *getRegisterName(MCRegister Reg);
36 
37   void printRegName(raw_ostream &OS, MCRegister Reg) const override;
38   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
39                  const MCSubtargetInfo &STI, raw_ostream &O) override;
40 
41   bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &OS);
42   void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
43                                unsigned PrintMethodIdx, raw_ostream &O);
44 
45   std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
46 
47 private:
48   void printOperand(const MCInst *MI, unsigned opNum, raw_ostream &O);
49   void printImmediate(const MCInst *MI, unsigned opNum, raw_ostream &O);
50   /// Print register mask for MOVEM instruction in order D0-D7,A0-A7
51   void printMoveMask(const MCInst *MI, unsigned opNum, raw_ostream &O);
52   /// Print register mask for MOVEM instruction in order A7-A0,D7-D0
53   void printMoveMaskR(const MCInst *MI, unsigned opNum, raw_ostream &O);
54   void printDisp(const MCInst *MI, unsigned opNum, raw_ostream &O);
55   void printAbsMem(const MCInst *MI, unsigned opNum, raw_ostream &O);
56 
57   //===----------------------------------------------------------------------===//
58   // Specializations
59   //===----------------------------------------------------------------------===//
60   //
61   void printPCRelImm(const MCInst *MI, uint64_t Address, unsigned opNum,
62                      raw_ostream &O) {
63     printAbsMem(MI, opNum, O);
64   }
65 
66   void printARI8Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
67     printARIMem(MI, opNum, O);
68   }
69   void printARI16Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
70     printARIMem(MI, opNum, O);
71   }
72   void printARI32Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
73     printARIMem(MI, opNum, O);
74   }
75 
76   void printARIPI8Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
77     printARIPIMem(MI, opNum, O);
78   }
79   void printARIPI16Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
80     printARIPIMem(MI, opNum, O);
81   }
82   void printARIPI32Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
83     printARIPIMem(MI, opNum, O);
84   }
85 
86   void printARIPD8Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
87     printARIPDMem(MI, opNum, O);
88   }
89   void printARIPD16Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
90     printARIPDMem(MI, opNum, O);
91   }
92   void printARIPD32Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
93     printARIPDMem(MI, opNum, O);
94   }
95 
96   void printARID8Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
97     printARIDMem(MI, opNum, O);
98   }
99   void printARID16Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
100     printARIDMem(MI, opNum, O);
101   }
102   void printARID32Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
103     printARIDMem(MI, opNum, O);
104   }
105 
106   void printARII8Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
107     printARIIMem(MI, opNum, O);
108   }
109   void printARII16Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
110     printARIIMem(MI, opNum, O);
111   }
112   void printARII32Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
113     printARIIMem(MI, opNum, O);
114   }
115 
116   void printAS8Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
117     printAbsMem(MI, opNum, O);
118   }
119   void printAS16Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
120     printAbsMem(MI, opNum, O);
121   }
122   void printAS32Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
123     printAbsMem(MI, opNum, O);
124   }
125 
126   void printAL8Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
127     printAbsMem(MI, opNum, O);
128   }
129   void printAL16Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
130     printAbsMem(MI, opNum, O);
131   }
132   void printAL32Mem(const MCInst *MI, unsigned opNum, raw_ostream &O) {
133     printAbsMem(MI, opNum, O);
134   }
135 
136   void printPCD8Mem(const MCInst *MI, uint64_t Address, unsigned opNum,
137                     raw_ostream &O) {
138     printPCDMem(MI, Address, opNum, O);
139   }
140   void printPCD16Mem(const MCInst *MI, uint64_t Address, unsigned opNum,
141                      raw_ostream &O) {
142     printPCDMem(MI, Address, opNum, O);
143   }
144   void printPCD32Mem(const MCInst *MI, uint64_t Address, unsigned opNum,
145                      raw_ostream &O) {
146     printPCDMem(MI, Address, opNum, O);
147   }
148 
149   void printPCI8Mem(const MCInst *MI, uint64_t Address, unsigned opNum,
150                     raw_ostream &O) {
151     printPCIMem(MI, Address, opNum, O);
152   }
153   void printPCI16Mem(const MCInst *MI, uint64_t Address, unsigned opNum,
154                      raw_ostream &O) {
155     printPCIMem(MI, Address, opNum, O);
156   }
157   void printPCI32Mem(const MCInst *MI, uint64_t Address, unsigned opNum,
158                      raw_ostream &O) {
159     printPCIMem(MI, Address, opNum, O);
160   }
161 };
162 } // end namespace llvm
163 
164 #endif // LLVM_LIB_TARGET_M68K_INSTPRINTER_M68KINSTPRINTER_H
165