1 //===-- AMDGPUInstPrinter.h - AMDGPU MC Inst -> ASM interface ---*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUINSTPRINTER_H
13 #define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUINSTPRINTER_H
15 #include "llvm/MC/MCInstPrinter.h"
19 class AMDGPUInstPrinter : public MCInstPrinter {
21 AMDGPUInstPrinter(const MCAsmInfo &MAI,
22 const MCInstrInfo &MII, const MCRegisterInfo &MRI)
23 : MCInstPrinter(MAI, MII, MRI) {}
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);
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);
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,
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,
55 void printFlatOffset(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
58 void printOffset0(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
60 void printOffset1(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
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,
70 void printDLC(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
72 void printGLC(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
74 void printSLC(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
76 void printSWZ(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
78 void printTFE(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
80 void printDMask(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
82 void printDim(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
84 void printUNorm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
86 void printDA(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
88 void printR128A16(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
90 void printGFX10A16(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
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);
103 void printRegOperand(unsigned RegNo, raw_ostream &O);
104 void printVOPDst(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
106 void printVINTRPDst(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
108 void printImmediateInt16(uint32_t Imm, const MCSubtargetInfo &STI,
110 void printImmediate16(uint32_t Imm, const MCSubtargetInfo &STI,
112 void printImmediateIntV216(uint32_t Imm, const MCSubtargetInfo &STI,
114 void printImmediateV216(uint32_t Imm, const MCSubtargetInfo &STI,
116 void printImmediate32(uint32_t Imm, const MCSubtargetInfo &STI,
118 void printImmediate64(uint64_t Imm, const MCSubtargetInfo &STI,
120 void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
122 void printOperand(const MCInst *MI, uint64_t /*Address*/, unsigned OpNum,
123 const MCSubtargetInfo &STI, raw_ostream &O) {
124 printOperand(MI, OpNum, STI, O);
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,
132 void printDPPCtrl(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
134 void printRowMask(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
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,
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);
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,
174 void printCBSZ(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
176 void printABID(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
178 void printDefaultVccOperand(unsigned OpNo, const MCSubtargetInfo &STI,
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);
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,
202 void printAbs(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
204 void printHigh(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
206 void printClamp(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
208 void printClampSI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
210 void printOModSI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
212 void printLiteral(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
214 void printLast(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
216 void printNeg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
218 void printOMOD(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
220 void printRel(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
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,
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,
232 void printCT(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
234 void printKCache(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
236 void printSendMsg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
238 void printSwizzle(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
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,
244 void printEndpgm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
248 class R600InstPrinter : public MCInstPrinter {
250 R600InstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
251 const MCRegisterInfo &MRI)
252 : MCInstPrinter(MAI, MII, MRI) {}
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);
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);
277 } // End namespace llvm