xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.h (revision dd41de95a84d979615a2ef11df6850622bf6184e)
1 //===-- AMDGPUInstPrinter.h - AMDGPU MC Inst -> ASM interface ---*- 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 //===----------------------------------------------------------------------===//
11 
12 #ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUINSTPRINTER_H
13 #define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUINSTPRINTER_H
14 
15 #include "llvm/MC/MCInstPrinter.h"
16 
17 namespace llvm {
18 
19 class AMDGPUInstPrinter : public MCInstPrinter {
20 public:
21   AMDGPUInstPrinter(const MCAsmInfo &MAI,
22                     const MCInstrInfo &MII, const MCRegisterInfo &MRI)
23     : MCInstPrinter(MAI, MII, MRI) {}
24 
25   //Autogenerated by tblgen
26   void printRegName(raw_ostream &OS, unsigned RegNo) const override;
27   void printInstruction(const MCInst *MI, uint64_t Address,
28                         const MCSubtargetInfo &STI, raw_ostream &O);
29   static const char *getRegisterName(unsigned RegNo);
30 
31   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
32                  const MCSubtargetInfo &STI, raw_ostream &O) override;
33   static void printRegOperand(unsigned RegNo, raw_ostream &O,
34                               const MCRegisterInfo &MRI);
35 
36 private:
37   void printU4ImmOperand(const MCInst *MI, unsigned OpNo,
38                          const MCSubtargetInfo &STI, raw_ostream &O);
39   void printU8ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
40   void printU16ImmOperand(const MCInst *MI, unsigned OpNo,
41                           const MCSubtargetInfo &STI, raw_ostream &O);
42   void printU4ImmDecOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
43   void printU8ImmDecOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
44   void printU16ImmDecOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
45   void printU32ImmOperand(const MCInst *MI, unsigned OpNo,
46                           const MCSubtargetInfo &STI, raw_ostream &O);
47   void printNamedBit(const MCInst *MI, unsigned OpNo, raw_ostream &O,
48                      StringRef BitName);
49   void printOffen(const MCInst *MI, unsigned OpNo, raw_ostream &O);
50   void printIdxen(const MCInst *MI, unsigned OpNo, raw_ostream &O);
51   void printAddr64(const MCInst *MI, unsigned OpNo, raw_ostream &O);
52   void printMBUFOffset(const MCInst *MI, unsigned OpNo, raw_ostream &O);
53   void printOffset(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
54                    raw_ostream &O);
55   void printFlatOffset(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
56                        raw_ostream &O);
57 
58   void printOffset0(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
59                     raw_ostream &O);
60   void printOffset1(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
61                     raw_ostream &O);
62   void printSMRDOffset8(const MCInst *MI, unsigned OpNo,
63                        const MCSubtargetInfo &STI, raw_ostream &O);
64   void printSMEMOffset(const MCInst *MI, unsigned OpNo,
65                        const MCSubtargetInfo &STI, raw_ostream &O);
66   void printSMRDLiteralOffset(const MCInst *MI, unsigned OpNo,
67                               const MCSubtargetInfo &STI, raw_ostream &O);
68   void printGDS(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
69                 raw_ostream &O);
70   void printDLC(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
71                 raw_ostream &O);
72   void printGLC(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
73                 raw_ostream &O);
74   void printSLC(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
75                 raw_ostream &O);
76   void printSWZ(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
77                 raw_ostream &O);
78   void printTFE(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
79                 raw_ostream &O);
80   void printDMask(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
81                   raw_ostream &O);
82   void printDim(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
83                 raw_ostream &O);
84   void printUNorm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
85                   raw_ostream &O);
86   void printDA(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
87                raw_ostream &O);
88   void printR128A16(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
89                  raw_ostream &O);
90   void printGFX10A16(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
91                 raw_ostream &O);
92   void printLWE(const MCInst *MI, unsigned OpNo,
93                 const MCSubtargetInfo &STI, raw_ostream &O);
94   void printD16(const MCInst *MI, unsigned OpNo,
95                 const MCSubtargetInfo &STI, raw_ostream &O);
96   void printExpCompr(const MCInst *MI, unsigned OpNo,
97                      const MCSubtargetInfo &STI, raw_ostream &O);
98   void printExpVM(const MCInst *MI, unsigned OpNo,
99                   const MCSubtargetInfo &STI, raw_ostream &O);
100   void printFORMAT(const MCInst *MI, unsigned OpNo,
101                    const MCSubtargetInfo &STI, raw_ostream &O);
102 
103   void printRegOperand(unsigned RegNo, raw_ostream &O);
104   void printVOPDst(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
105                    raw_ostream &O);
106   void printVINTRPDst(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
107                       raw_ostream &O);
108   void printImmediateInt16(uint32_t Imm, const MCSubtargetInfo &STI,
109                            raw_ostream &O);
110   void printImmediate16(uint32_t Imm, const MCSubtargetInfo &STI,
111                         raw_ostream &O);
112   void printImmediateIntV216(uint32_t Imm, const MCSubtargetInfo &STI,
113                              raw_ostream &O);
114   void printImmediateV216(uint32_t Imm, const MCSubtargetInfo &STI,
115                           raw_ostream &O);
116   void printImmediate32(uint32_t Imm, const MCSubtargetInfo &STI,
117                         raw_ostream &O);
118   void printImmediate64(uint64_t Imm, const MCSubtargetInfo &STI,
119                         raw_ostream &O);
120   void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
121                     raw_ostream &O);
122   void printOperand(const MCInst *MI, uint64_t /*Address*/, unsigned OpNum,
123                     const MCSubtargetInfo &STI, raw_ostream &O) {
124     printOperand(MI, OpNum, STI, O);
125   }
126   void printOperandAndFPInputMods(const MCInst *MI, unsigned OpNo,
127                                   const MCSubtargetInfo &STI, raw_ostream &O);
128   void printOperandAndIntInputMods(const MCInst *MI, unsigned OpNo,
129                                    const MCSubtargetInfo &STI, raw_ostream &O);
130   void printDPP8(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
131                  raw_ostream &O);
132   void printDPPCtrl(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
133                     raw_ostream &O);
134   void printRowMask(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
135                     raw_ostream &O);
136   void printBankMask(const MCInst *MI, unsigned OpNo,
137                      const MCSubtargetInfo &STI, raw_ostream &O);
138   void printBoundCtrl(const MCInst *MI, unsigned OpNo,
139                       const MCSubtargetInfo &STI, raw_ostream &O);
140   void printFI(const MCInst *MI, unsigned OpNo,
141                const MCSubtargetInfo &STI, raw_ostream &O);
142   void printSDWASel(const MCInst *MI, unsigned OpNo, raw_ostream &O);
143   void printSDWADstSel(const MCInst *MI, unsigned OpNo,
144                        const MCSubtargetInfo &STI, raw_ostream &O);
145   void printSDWASrc0Sel(const MCInst *MI, unsigned OpNo,
146                         const MCSubtargetInfo &STI, raw_ostream &O);
147   void printSDWASrc1Sel(const MCInst *MI, unsigned OpNo,
148                         const MCSubtargetInfo &STI, raw_ostream &O);
149   void printSDWADstUnused(const MCInst *MI, unsigned OpNo,
150                           const MCSubtargetInfo &STI, raw_ostream &O);
151   void printPackedModifier(const MCInst *MI, StringRef Name, unsigned Mod,
152                            raw_ostream &O);
153   void printOpSel(const MCInst *MI, unsigned OpNo,
154                   const MCSubtargetInfo &STI, raw_ostream &O);
155   void printOpSelHi(const MCInst *MI, unsigned OpNo,
156                   const MCSubtargetInfo &STI, raw_ostream &O);
157   void printNegLo(const MCInst *MI, unsigned OpNo,
158                   const MCSubtargetInfo &STI, raw_ostream &O);
159   void printNegHi(const MCInst *MI, unsigned OpNo,
160                   const MCSubtargetInfo &STI, raw_ostream &O);
161   void printInterpSlot(const MCInst *MI, unsigned OpNo,
162                        const MCSubtargetInfo &STI, raw_ostream &O);
163   void printInterpAttr(const MCInst *MI, unsigned OpNo,
164                        const MCSubtargetInfo &STI, raw_ostream &O);
165   void printInterpAttrChan(const MCInst *MI, unsigned OpNo,
166                            const MCSubtargetInfo &STI, raw_ostream &O);
167 
168   void printVGPRIndexMode(const MCInst *MI, unsigned OpNo,
169                           const MCSubtargetInfo &STI, raw_ostream &O);
170   void printMemOperand(const MCInst *MI, unsigned OpNo,
171                        const MCSubtargetInfo &STI, raw_ostream &O);
172   void printBLGP(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
173                  raw_ostream &O);
174   void printCBSZ(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
175                  raw_ostream &O);
176   void printABID(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
177                  raw_ostream &O);
178   void printDefaultVccOperand(unsigned OpNo, const MCSubtargetInfo &STI,
179                               raw_ostream &O);
180 
181 
182   template <unsigned N>
183   void printExpSrcN(const MCInst *MI, unsigned OpNo,
184                     const MCSubtargetInfo &STI, raw_ostream &O);
185   void printExpSrc0(const MCInst *MI, unsigned OpNo,
186                     const MCSubtargetInfo &STI, raw_ostream &O);
187   void printExpSrc1(const MCInst *MI, unsigned OpNo,
188                     const MCSubtargetInfo &STI, raw_ostream &O);
189   void printExpSrc2(const MCInst *MI, unsigned OpNo,
190                     const MCSubtargetInfo &STI, raw_ostream &O);
191   void printExpSrc3(const MCInst *MI, unsigned OpNo,
192                     const MCSubtargetInfo &STI, raw_ostream &O);
193   void printExpTgt(const MCInst *MI, unsigned OpNo,
194                    const MCSubtargetInfo &STI, raw_ostream &O);
195 
196 public:
197   static void printIfSet(const MCInst *MI, unsigned OpNo, raw_ostream &O,
198                          StringRef Asm, StringRef Default = "");
199   static void printIfSet(const MCInst *MI, unsigned OpNo, raw_ostream &O,
200                          char Asm);
201 protected:
202   void printAbs(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
203                 raw_ostream &O);
204   void printHigh(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
205                  raw_ostream &O);
206   void printClamp(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
207                   raw_ostream &O);
208   void printClampSI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
209                     raw_ostream &O);
210   void printOModSI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
211                    raw_ostream &O);
212   void printLiteral(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
213                     raw_ostream &O);
214   void printLast(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
215                  raw_ostream &O);
216   void printNeg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
217                 raw_ostream &O);
218   void printOMOD(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
219                  raw_ostream &O);
220   void printRel(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
221                 raw_ostream &O);
222   void printUpdateExecMask(const MCInst *MI, unsigned OpNo,
223                            const MCSubtargetInfo &STI, raw_ostream &O);
224   void printUpdatePred(const MCInst *MI, unsigned OpNo,
225                        const MCSubtargetInfo &STI, raw_ostream &O);
226   void printWrite(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
227                   raw_ostream &O);
228   void printBankSwizzle(const MCInst *MI, unsigned OpNo,
229                         const MCSubtargetInfo &STI, raw_ostream &O);
230   void printRSel(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
231                  raw_ostream &O);
232   void printCT(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
233                raw_ostream &O);
234   void printKCache(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
235                    raw_ostream &O);
236   void printSendMsg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
237                     raw_ostream &O);
238   void printSwizzle(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
239                     raw_ostream &O);
240   void printWaitFlag(const MCInst *MI, unsigned OpNo,
241                      const MCSubtargetInfo &STI, raw_ostream &O);
242   void printHwreg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
243                   raw_ostream &O);
244   void printEndpgm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
245                    raw_ostream &O);
246 };
247 
248 class R600InstPrinter : public MCInstPrinter {
249 public:
250   R600InstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
251                   const MCRegisterInfo &MRI)
252     : MCInstPrinter(MAI, MII, MRI) {}
253 
254   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
255                  const MCSubtargetInfo &STI, raw_ostream &O) override;
256   void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
257   static const char *getRegisterName(unsigned RegNo);
258 
259   void printAbs(const MCInst *MI, unsigned OpNo, raw_ostream &O);
260   void printBankSwizzle(const MCInst *MI, unsigned OpNo, raw_ostream &O);
261   void printClamp(const MCInst *MI, unsigned OpNo, raw_ostream &O);
262   void printCT(const MCInst *MI, unsigned OpNo, raw_ostream &O);
263   void printKCache(const MCInst *MI, unsigned OpNo, raw_ostream &O);
264   void printLast(const MCInst *MI, unsigned OpNo, raw_ostream &O);
265   void printLiteral(const MCInst *MI, unsigned OpNo, raw_ostream &O);
266   void printMemOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
267   void printNeg(const MCInst *MI, unsigned OpNo, raw_ostream &O);
268   void printOMOD(const MCInst *MI, unsigned OpNo, raw_ostream &O);
269   void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
270   void printRel(const MCInst *MI, unsigned OpNo, raw_ostream &O);
271   void printRSel(const MCInst *MI, unsigned OpNo, raw_ostream &O);
272   void printUpdateExecMask(const MCInst *MI, unsigned OpNo, raw_ostream &O);
273   void printUpdatePred(const MCInst *MI, unsigned OpNo, raw_ostream &O);
274   void printWrite(const MCInst *MI, unsigned OpNo, raw_ostream &O);
275 };
276 
277 } // End namespace llvm
278 
279 #endif
280