xref: /freebsd/contrib/llvm-project/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.h (revision 5036d9652a5701d00e9e40ea942c278e9f77d33d)
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 class MCInstrDesc;
19 
20 class AMDGPUInstPrinter : public MCInstPrinter {
21 public:
22   AMDGPUInstPrinter(const MCAsmInfo &MAI,
23                     const MCInstrInfo &MII, const MCRegisterInfo &MRI)
24     : MCInstPrinter(MAI, MII, MRI) {}
25 
26   // Autogenerated by tblgen
27   std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
28   void printInstruction(const MCInst *MI, uint64_t Address,
29                         const MCSubtargetInfo &STI, raw_ostream &O);
30   static const char *getRegisterName(MCRegister Reg);
31 
32   void printRegName(raw_ostream &OS, MCRegister Reg) const override;
33   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
34                  const MCSubtargetInfo &STI, raw_ostream &O) override;
35   static void printRegOperand(unsigned RegNo, raw_ostream &O,
36                               const MCRegisterInfo &MRI);
37 
38 private:
39   void printU4ImmOperand(const MCInst *MI, unsigned OpNo,
40                          const MCSubtargetInfo &STI, raw_ostream &O);
41   void printU16ImmOperand(const MCInst *MI, unsigned OpNo,
42                           const MCSubtargetInfo &STI, raw_ostream &O);
43   void printU4ImmDecOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
44   void printU8ImmDecOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
45   void printU16ImmDecOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
46   void printU32ImmOperand(const MCInst *MI, unsigned OpNo,
47                           const MCSubtargetInfo &STI, raw_ostream &O);
48   void printNamedBit(const MCInst *MI, unsigned OpNo, raw_ostream &O,
49                      StringRef BitName);
50   void printOffset(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
51                    raw_ostream &O);
52   void printFlatOffset(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
53                        raw_ostream &O);
54 
55   void printOffset0(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
56                     raw_ostream &O);
57   void printOffset1(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
58                     raw_ostream &O);
59   void printSMRDOffset8(const MCInst *MI, unsigned OpNo,
60                        const MCSubtargetInfo &STI, raw_ostream &O);
61   void printSMEMOffset(const MCInst *MI, unsigned OpNo,
62                        const MCSubtargetInfo &STI, raw_ostream &O);
63   void printSMEMOffsetMod(const MCInst *MI, unsigned OpNo,
64                           const MCSubtargetInfo &STI, raw_ostream &O);
65   void printSMRDLiteralOffset(const MCInst *MI, unsigned OpNo,
66                               const MCSubtargetInfo &STI, raw_ostream &O);
67   void printCPol(const MCInst *MI, unsigned OpNo,
68                  const MCSubtargetInfo &STI, raw_ostream &O);
69   void printTH(const MCInst *MI, int64_t TH, int64_t Scope, raw_ostream &O);
70   void printScope(int64_t Scope, raw_ostream &O);
71   void printDMask(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
72                   raw_ostream &O);
73   void printDim(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
74                 raw_ostream &O);
75   void printR128A16(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
76                  raw_ostream &O);
77   void printFORMAT(const MCInst *MI, unsigned OpNo,
78                    const MCSubtargetInfo &STI, raw_ostream &O);
79   void printSymbolicFormat(const MCInst *MI,
80                            const MCSubtargetInfo &STI, raw_ostream &O);
81 
82   void printRegOperand(unsigned RegNo, raw_ostream &O);
83   void printVOPDst(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
84                    raw_ostream &O);
85   void printVINTRPDst(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
86                       raw_ostream &O);
87   void printImmediateInt16(uint32_t Imm, const MCSubtargetInfo &STI,
88                            raw_ostream &O);
89   void printImmediateBF16(uint32_t Imm, const MCSubtargetInfo &STI,
90                           raw_ostream &O);
91   void printImmediateF16(uint32_t Imm, const MCSubtargetInfo &STI,
92                          raw_ostream &O);
93   void printImmediateV216(uint32_t Imm, uint8_t OpType,
94                           const MCSubtargetInfo &STI, raw_ostream &O);
95   bool printImmediateFloat32(uint32_t Imm, const MCSubtargetInfo &STI,
96                              raw_ostream &O);
97   void printImmediate32(uint32_t Imm, const MCSubtargetInfo &STI,
98                         raw_ostream &O);
99   void printImmediate64(uint64_t Imm, const MCSubtargetInfo &STI,
100                         raw_ostream &O, bool IsFP);
101   void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
102                     raw_ostream &O);
103   void printRegularOperand(const MCInst *MI, unsigned OpNo,
104                            const MCSubtargetInfo &STI, raw_ostream &O);
105   void printOperand(const MCInst *MI, uint64_t /*Address*/, unsigned OpNum,
106                     const MCSubtargetInfo &STI, raw_ostream &O) {
107     printOperand(MI, OpNum, STI, O);
108   }
109   void printOperandAndFPInputMods(const MCInst *MI, unsigned OpNo,
110                                   const MCSubtargetInfo &STI, raw_ostream &O);
111   void printOperandAndIntInputMods(const MCInst *MI, unsigned OpNo,
112                                    const MCSubtargetInfo &STI, raw_ostream &O);
113   void printDPP8(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
114                  raw_ostream &O);
115   void printDPPCtrl(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
116                     raw_ostream &O);
117   void printDppRowMask(const MCInst *MI, unsigned OpNo,
118                        const MCSubtargetInfo &STI, raw_ostream &O);
119   void printDppBankMask(const MCInst *MI, unsigned OpNo,
120                         const MCSubtargetInfo &STI, raw_ostream &O);
121   void printDppBoundCtrl(const MCInst *MI, unsigned OpNo,
122                          const MCSubtargetInfo &STI, raw_ostream &O);
123   void printDppFI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
124                   raw_ostream &O);
125   void printSDWASel(const MCInst *MI, unsigned OpNo, raw_ostream &O);
126   void printSDWADstSel(const MCInst *MI, unsigned OpNo,
127                        const MCSubtargetInfo &STI, raw_ostream &O);
128   void printSDWASrc0Sel(const MCInst *MI, unsigned OpNo,
129                         const MCSubtargetInfo &STI, raw_ostream &O);
130   void printSDWASrc1Sel(const MCInst *MI, unsigned OpNo,
131                         const MCSubtargetInfo &STI, raw_ostream &O);
132   void printSDWADstUnused(const MCInst *MI, unsigned OpNo,
133                           const MCSubtargetInfo &STI, raw_ostream &O);
134   void printPackedModifier(const MCInst *MI, StringRef Name, unsigned Mod,
135                            raw_ostream &O);
136   void printOpSel(const MCInst *MI, unsigned OpNo,
137                   const MCSubtargetInfo &STI, raw_ostream &O);
138   void printOpSelHi(const MCInst *MI, unsigned OpNo,
139                   const MCSubtargetInfo &STI, raw_ostream &O);
140   void printNegLo(const MCInst *MI, unsigned OpNo,
141                   const MCSubtargetInfo &STI, raw_ostream &O);
142   void printNegHi(const MCInst *MI, unsigned OpNo,
143                   const MCSubtargetInfo &STI, raw_ostream &O);
144   void printIndexKey8bit(const MCInst *MI, unsigned OpNo,
145                          const MCSubtargetInfo &STI, raw_ostream &O);
146   void printIndexKey16bit(const MCInst *MI, unsigned OpNo,
147                           const MCSubtargetInfo &STI, raw_ostream &O);
148   void printInterpSlot(const MCInst *MI, unsigned OpNo,
149                        const MCSubtargetInfo &STI, raw_ostream &O);
150   void printInterpAttr(const MCInst *MI, unsigned OpNo,
151                        const MCSubtargetInfo &STI, raw_ostream &O);
152   void printInterpAttrChan(const MCInst *MI, unsigned OpNo,
153                            const MCSubtargetInfo &STI, raw_ostream &O);
154 
155   void printGPRIdxMode(const MCInst *MI, unsigned OpNo,
156                        const MCSubtargetInfo &STI, raw_ostream &O);
157   void printMemOperand(const MCInst *MI, unsigned OpNo,
158                        const MCSubtargetInfo &STI, raw_ostream &O);
159   void printBLGP(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
160                  raw_ostream &O);
161   void printCBSZ(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
162                  raw_ostream &O);
163   void printABID(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
164                  raw_ostream &O);
165   bool needsImpliedVcc(const MCInstrDesc &Desc, unsigned OpNo) const;
166   void printDefaultVccOperand(bool FirstOperand, const MCSubtargetInfo &STI,
167                               raw_ostream &O);
168   void printWaitVDST(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
169                     raw_ostream &O);
170   void printWaitEXP(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
171                     raw_ostream &O);
172   void printWaitVAVDst(const MCInst *MI, unsigned OpNo,
173                        const MCSubtargetInfo &STI, raw_ostream &O);
174   void printWaitVMVSrc(const MCInst *MI, unsigned OpNo,
175                        const MCSubtargetInfo &STI, raw_ostream &O);
176 
177   void printExpSrcN(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
178                     raw_ostream &O, unsigned N);
179   void printExpSrc0(const MCInst *MI, unsigned OpNo,
180                     const MCSubtargetInfo &STI, raw_ostream &O);
181   void printExpSrc1(const MCInst *MI, unsigned OpNo,
182                     const MCSubtargetInfo &STI, raw_ostream &O);
183   void printExpSrc2(const MCInst *MI, unsigned OpNo,
184                     const MCSubtargetInfo &STI, raw_ostream &O);
185   void printExpSrc3(const MCInst *MI, unsigned OpNo,
186                     const MCSubtargetInfo &STI, raw_ostream &O);
187   void printExpTgt(const MCInst *MI, unsigned OpNo,
188                    const MCSubtargetInfo &STI, raw_ostream &O);
189   void printByteSel(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
190                     raw_ostream &O);
191 
192 public:
193   static void printIfSet(const MCInst *MI, unsigned OpNo, raw_ostream &O,
194                          StringRef Asm, StringRef Default = "");
195   static void printIfSet(const MCInst *MI, unsigned OpNo, raw_ostream &O,
196                          char Asm);
197 protected:
198   void printAbs(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
199                 raw_ostream &O);
200   void printClamp(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
201                   raw_ostream &O);
202   void printOModSI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
203                    raw_ostream &O);
204   void printLiteral(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
205                     raw_ostream &O);
206   void printLast(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
207                  raw_ostream &O);
208   void printNeg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
209                 raw_ostream &O);
210   void printOMOD(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
211                  raw_ostream &O);
212   void printRel(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
213                 raw_ostream &O);
214   void printUpdateExecMask(const MCInst *MI, unsigned OpNo,
215                            const MCSubtargetInfo &STI, raw_ostream &O);
216   void printUpdatePred(const MCInst *MI, unsigned OpNo,
217                        const MCSubtargetInfo &STI, raw_ostream &O);
218   void printWrite(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
219                   raw_ostream &O);
220   void printBankSwizzle(const MCInst *MI, unsigned OpNo,
221                         const MCSubtargetInfo &STI, raw_ostream &O);
222   void printRSel(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
223                  raw_ostream &O);
224   void printCT(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
225                raw_ostream &O);
226   void printKCache(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
227                    raw_ostream &O);
228   void printSendMsg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
229                     raw_ostream &O);
230   void printSwizzle(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
231                     raw_ostream &O);
232   void printSWaitCnt(const MCInst *MI, unsigned OpNo,
233                      const MCSubtargetInfo &STI, raw_ostream &O);
234   void printDepCtr(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
235                    raw_ostream &O);
236   void printSDelayALU(const MCInst *MI, unsigned OpNo,
237                       const MCSubtargetInfo &STI, raw_ostream &O);
238   void printHwreg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
239                   raw_ostream &O);
240   void printEndpgm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
241                    raw_ostream &O);
242 };
243 
244 } // End namespace llvm
245 
246 #endif
247