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
17namespace llvm {
18class MCInstrDesc;
19
20class AMDGPUInstPrinter : public MCInstPrinter {
21public:
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>
28 getMnemonic(const MCInst &MI) const override;
29 void printInstruction(const MCInst *MI, uint64_t Address,
30 const MCSubtargetInfo &STI, raw_ostream &O);
31 static const char *getRegisterName(MCRegister Reg);
32
33 void printRegName(raw_ostream &OS, MCRegister Reg) override;
34 void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
35 const MCSubtargetInfo &STI, raw_ostream &O) override;
36 static void printRegOperand(MCRegister Reg, raw_ostream &O,
37 const MCRegisterInfo &MRI);
38 void printRegOperand(MCRegister Reg, unsigned Opc, unsigned OpNo,
39 raw_ostream &O, const MCRegisterInfo &MRI);
40
41private:
42 void printU16ImmOperand(const MCInst *MI, unsigned OpNo,
43 const MCSubtargetInfo &STI, 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 printFP64ImmOperand(const MCInst *MI, unsigned OpNo,
48 const MCSubtargetInfo &STI, raw_ostream &O);
49 void printNamedBit(const MCInst *MI, unsigned OpNo, raw_ostream &O,
50 StringRef BitName);
51 void printOffset(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
52 raw_ostream &O);
53 void printFlatOffset(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
54 raw_ostream &O);
55
56 void printSMRDOffset8(const MCInst *MI, unsigned OpNo,
57 const MCSubtargetInfo &STI, raw_ostream &O);
58 void printSMEMOffset(const MCInst *MI, unsigned OpNo,
59 const MCSubtargetInfo &STI, raw_ostream &O);
60 void printSMRDLiteralOffset(const MCInst *MI, unsigned OpNo,
61 const MCSubtargetInfo &STI, raw_ostream &O);
62 void printCPol(const MCInst *MI, unsigned OpNo,
63 const MCSubtargetInfo &STI, raw_ostream &O);
64 void printTH(const MCInst *MI, int64_t TH, int64_t Scope, raw_ostream &O);
65 void printScope(int64_t Scope, raw_ostream &O);
66 void printDim(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
67 raw_ostream &O);
68 void printR128A16(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
69 raw_ostream &O);
70 void printFORMAT(const MCInst *MI, unsigned OpNo,
71 const MCSubtargetInfo &STI, raw_ostream &O);
72 void printSymbolicFormat(const MCInst *MI,
73 const MCSubtargetInfo &STI, raw_ostream &O);
74 void printRsrcReg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
75 raw_ostream &O);
76
77 void printVOPDst(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
78 raw_ostream &O);
79 void printVINTRPDst(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
80 raw_ostream &O);
81 void printAVLdSt32Align2RegOp(const MCInst *MI, unsigned OpNo,
82 const MCSubtargetInfo &STI, raw_ostream &O);
83
84 void printImmediateInt16(uint32_t Imm, const MCSubtargetInfo &STI,
85 raw_ostream &O);
86 void printImmediateBF16(uint32_t Imm, const MCSubtargetInfo &STI,
87 raw_ostream &O);
88 void printImmediateF16(uint32_t Imm, const MCSubtargetInfo &STI,
89 raw_ostream &O);
90 void printImmediateV216(uint32_t Imm, uint8_t OpType,
91 const MCSubtargetInfo &STI, raw_ostream &O);
92 bool printImmediateFloat32(uint32_t Imm, const MCSubtargetInfo &STI,
93 raw_ostream &O);
94 void printImmediate32(uint32_t Imm, const MCSubtargetInfo &STI,
95 raw_ostream &O);
96 void printImmediate64(uint64_t Imm, const MCSubtargetInfo &STI,
97 raw_ostream &O, bool IsFP);
98 void printLiteral64(uint64_t Imm, raw_ostream &O, bool IsFP);
99 void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
100 raw_ostream &O);
101 void printRegularOperand(const MCInst *MI, unsigned OpNo,
102 const MCSubtargetInfo &STI, raw_ostream &O);
103 void printOperand(const MCInst *MI, uint64_t /*Address*/, unsigned OpNum,
104 const MCSubtargetInfo &STI, raw_ostream &O) {
105 printOperand(MI, OpNo: OpNum, STI, O);
106 }
107 void printOperandAndFPInputMods(const MCInst *MI, unsigned OpNo,
108 const MCSubtargetInfo &STI, raw_ostream &O);
109 void printOperandAndIntInputMods(const MCInst *MI, unsigned OpNo,
110 const MCSubtargetInfo &STI, raw_ostream &O);
111 void printDPP8(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
112 raw_ostream &O);
113 void printDPPCtrl(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
114 raw_ostream &O);
115 void printDppBoundCtrl(const MCInst *MI, unsigned OpNo,
116 const MCSubtargetInfo &STI, raw_ostream &O);
117 void printDppFI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
118 raw_ostream &O);
119 void printSDWASel(const MCInst *MI, unsigned OpNo, raw_ostream &O);
120 void printSDWADstSel(const MCInst *MI, unsigned OpNo,
121 const MCSubtargetInfo &STI, raw_ostream &O);
122 void printSDWASrc0Sel(const MCInst *MI, unsigned OpNo,
123 const MCSubtargetInfo &STI, raw_ostream &O);
124 void printSDWASrc1Sel(const MCInst *MI, unsigned OpNo,
125 const MCSubtargetInfo &STI, raw_ostream &O);
126 void printSDWADstUnused(const MCInst *MI, unsigned OpNo,
127 const MCSubtargetInfo &STI, raw_ostream &O);
128 void printPackedModifier(const MCInst *MI, StringRef Name, unsigned Mod,
129 raw_ostream &O);
130 void printOpSel(const MCInst *MI, unsigned OpNo,
131 const MCSubtargetInfo &STI, raw_ostream &O);
132 void printOpSelHi(const MCInst *MI, unsigned OpNo,
133 const MCSubtargetInfo &STI, raw_ostream &O);
134 void printNegLo(const MCInst *MI, unsigned OpNo,
135 const MCSubtargetInfo &STI, raw_ostream &O);
136 void printNegHi(const MCInst *MI, unsigned OpNo,
137 const MCSubtargetInfo &STI, raw_ostream &O);
138 void printIndexKey8bit(const MCInst *MI, unsigned OpNo,
139 const MCSubtargetInfo &STI, raw_ostream &O);
140 void printIndexKey16bit(const MCInst *MI, unsigned OpNo,
141 const MCSubtargetInfo &STI, raw_ostream &O);
142 void printIndexKey32bit(const MCInst *MI, unsigned OpNo,
143 const MCSubtargetInfo &STI, raw_ostream &O);
144 void printMatrixFMT(const MCInst *MI, unsigned OpNo,
145 const MCSubtargetInfo &STI, raw_ostream &O, char AorB);
146 void printMatrixAFMT(const MCInst *MI, unsigned OpNo,
147 const MCSubtargetInfo &STI, raw_ostream &O);
148 void printMatrixBFMT(const MCInst *MI, unsigned OpNo,
149 const MCSubtargetInfo &STI, raw_ostream &O);
150 void printMatrixScale(const MCInst *MI, unsigned OpNo,
151 const MCSubtargetInfo &STI, raw_ostream &O, char AorB);
152 void printMatrixAScale(const MCInst *MI, unsigned OpNo,
153 const MCSubtargetInfo &STI, raw_ostream &O);
154 void printMatrixBScale(const MCInst *MI, unsigned OpNo,
155 const MCSubtargetInfo &STI, raw_ostream &O);
156 void printMatrixScaleFmt(const MCInst *MI, unsigned OpNo,
157 const MCSubtargetInfo &STI, raw_ostream &O,
158 char AorB);
159 void printMatrixAScaleFmt(const MCInst *MI, unsigned OpNo,
160 const MCSubtargetInfo &STI, raw_ostream &O);
161 void printMatrixBScaleFmt(const MCInst *MI, unsigned OpNo,
162 const MCSubtargetInfo &STI, raw_ostream &O);
163 void printInterpSlot(const MCInst *MI, unsigned OpNo,
164 const MCSubtargetInfo &STI, raw_ostream &O);
165 void printInterpAttr(const MCInst *MI, unsigned OpNo,
166 const MCSubtargetInfo &STI, raw_ostream &O);
167 void printInterpAttrChan(const MCInst *MI, unsigned OpNo,
168 const MCSubtargetInfo &STI, raw_ostream &O);
169
170 void printGPRIdxMode(const MCInst *MI, unsigned OpNo,
171 const MCSubtargetInfo &STI, raw_ostream &O);
172 void printMemOperand(const MCInst *MI, unsigned OpNo,
173 const MCSubtargetInfo &STI, raw_ostream &O);
174 void printBLGP(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
175 raw_ostream &O);
176 bool needsImpliedVcc(const MCInstrDesc &Desc, unsigned OpNo) const;
177 void printDefaultVccOperand(bool FirstOperand, const MCSubtargetInfo &STI,
178 raw_ostream &O);
179
180 void printExpSrcN(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
181 raw_ostream &O, unsigned N);
182 void printExpSrc0(const MCInst *MI, unsigned OpNo,
183 const MCSubtargetInfo &STI, raw_ostream &O);
184 void printExpSrc1(const MCInst *MI, unsigned OpNo,
185 const MCSubtargetInfo &STI, raw_ostream &O);
186 void printExpSrc2(const MCInst *MI, unsigned OpNo,
187 const MCSubtargetInfo &STI, raw_ostream &O);
188 void printExpSrc3(const MCInst *MI, unsigned OpNo,
189 const MCSubtargetInfo &STI, raw_ostream &O);
190 void printExpTgt(const MCInst *MI, unsigned OpNo,
191 const MCSubtargetInfo &STI, raw_ostream &O);
192 void printNamedInt(const MCInst *MI, unsigned OpNo,
193 const MCSubtargetInfo &STI, raw_ostream &O,
194 StringRef Prefix, bool PrintInHex, bool AlwaysPrint);
195
196 void printBitOp3(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
197 raw_ostream &O);
198
199public:
200 static void printIfSet(const MCInst *MI, unsigned OpNo, raw_ostream &O,
201 StringRef Asm, StringRef Default = "");
202 static void printIfSet(const MCInst *MI, unsigned OpNo, raw_ostream &O,
203 char Asm);
204
205protected:
206 void printOModSI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
207 raw_ostream &O);
208 void printSendMsg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
209 raw_ostream &O);
210 void printWaitEvent(const MCInst *MI, unsigned OpNo,
211 const MCSubtargetInfo &STI, raw_ostream &O);
212 void printSwizzle(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
213 raw_ostream &O);
214 void printSWaitCnt(const MCInst *MI, unsigned OpNo,
215 const MCSubtargetInfo &STI, raw_ostream &O);
216 void printDepCtr(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
217 raw_ostream &O);
218 void printSDelayALU(const MCInst *MI, unsigned OpNo,
219 const MCSubtargetInfo &STI, raw_ostream &O);
220 void printHwreg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
221 raw_ostream &O);
222 void printEndpgm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
223 raw_ostream &O);
224};
225
226} // End namespace llvm
227
228#endif
229