10b57cec5SDimitry Andric //===-- AMDGPUInstPrinter.h - AMDGPU MC Inst -> ASM interface ---*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric /// \file
100b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
110b57cec5SDimitry Andric 
120b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUINSTPRINTER_H
130b57cec5SDimitry Andric #define LLVM_LIB_TARGET_AMDGPU_MCTARGETDESC_AMDGPUINSTPRINTER_H
140b57cec5SDimitry Andric 
150b57cec5SDimitry Andric #include "llvm/MC/MCInstPrinter.h"
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric namespace llvm {
1881ad6265SDimitry Andric class MCInstrDesc;
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric class AMDGPUInstPrinter : public MCInstPrinter {
210b57cec5SDimitry Andric public:
AMDGPUInstPrinter(const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)220b57cec5SDimitry Andric   AMDGPUInstPrinter(const MCAsmInfo &MAI,
230b57cec5SDimitry Andric                     const MCInstrInfo &MII, const MCRegisterInfo &MRI)
240b57cec5SDimitry Andric     : MCInstPrinter(MAI, MII, MRI) {}
250b57cec5SDimitry Andric 
260b57cec5SDimitry Andric   // Autogenerated by tblgen
27e8d8bef9SDimitry Andric   std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
28480093f4SDimitry Andric   void printInstruction(const MCInst *MI, uint64_t Address,
29480093f4SDimitry Andric                         const MCSubtargetInfo &STI, raw_ostream &O);
30bdd1243dSDimitry Andric   static const char *getRegisterName(MCRegister Reg);
310b57cec5SDimitry Andric 
32bdd1243dSDimitry Andric   void printRegName(raw_ostream &OS, MCRegister Reg) const override;
33480093f4SDimitry Andric   void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
34480093f4SDimitry Andric                  const MCSubtargetInfo &STI, raw_ostream &O) override;
350b57cec5SDimitry Andric   static void printRegOperand(unsigned RegNo, raw_ostream &O,
360b57cec5SDimitry Andric                               const MCRegisterInfo &MRI);
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric private:
390b57cec5SDimitry Andric   void printU4ImmOperand(const MCInst *MI, unsigned OpNo,
400b57cec5SDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
410b57cec5SDimitry Andric   void printU16ImmOperand(const MCInst *MI, unsigned OpNo,
420b57cec5SDimitry Andric                           const MCSubtargetInfo &STI, raw_ostream &O);
430b57cec5SDimitry Andric   void printU4ImmDecOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
440b57cec5SDimitry Andric   void printU8ImmDecOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
450b57cec5SDimitry Andric   void printU16ImmDecOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
460b57cec5SDimitry Andric   void printU32ImmOperand(const MCInst *MI, unsigned OpNo,
470b57cec5SDimitry Andric                           const MCSubtargetInfo &STI, raw_ostream &O);
480b57cec5SDimitry Andric   void printNamedBit(const MCInst *MI, unsigned OpNo, raw_ostream &O,
490b57cec5SDimitry Andric                      StringRef BitName);
500b57cec5SDimitry Andric   void printOffset(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
510b57cec5SDimitry Andric                    raw_ostream &O);
520b57cec5SDimitry Andric   void printFlatOffset(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
530b57cec5SDimitry Andric                        raw_ostream &O);
540b57cec5SDimitry Andric 
550b57cec5SDimitry Andric   void printOffset0(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
560b57cec5SDimitry Andric                     raw_ostream &O);
570b57cec5SDimitry Andric   void printOffset1(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
580b57cec5SDimitry Andric                     raw_ostream &O);
590b57cec5SDimitry Andric   void printSMRDOffset8(const MCInst *MI, unsigned OpNo,
600b57cec5SDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &O);
615ffd83dbSDimitry Andric   void printSMEMOffset(const MCInst *MI, unsigned OpNo,
620b57cec5SDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &O);
6381ad6265SDimitry Andric   void printSMEMOffsetMod(const MCInst *MI, unsigned OpNo,
6481ad6265SDimitry Andric                           const MCSubtargetInfo &STI, raw_ostream &O);
650b57cec5SDimitry Andric   void printSMRDLiteralOffset(const MCInst *MI, unsigned OpNo,
660b57cec5SDimitry Andric                               const MCSubtargetInfo &STI, raw_ostream &O);
67fe6060f1SDimitry Andric   void printCPol(const MCInst *MI, unsigned OpNo,
68fe6060f1SDimitry Andric                  const MCSubtargetInfo &STI, raw_ostream &O);
695f757f3fSDimitry Andric   void printTH(const MCInst *MI, int64_t TH, int64_t Scope, raw_ostream &O);
705f757f3fSDimitry Andric   void printScope(int64_t Scope, raw_ostream &O);
710b57cec5SDimitry Andric   void printDMask(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
720b57cec5SDimitry Andric                   raw_ostream &O);
730b57cec5SDimitry Andric   void printDim(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
740b57cec5SDimitry Andric                 raw_ostream &O);
750b57cec5SDimitry Andric   void printR128A16(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
760b57cec5SDimitry Andric                  raw_ostream &O);
770b57cec5SDimitry Andric   void printFORMAT(const MCInst *MI, unsigned OpNo,
780b57cec5SDimitry Andric                    const MCSubtargetInfo &STI, raw_ostream &O);
79e8d8bef9SDimitry Andric   void printSymbolicFormat(const MCInst *MI,
80e8d8bef9SDimitry Andric                            const MCSubtargetInfo &STI, raw_ostream &O);
810b57cec5SDimitry Andric 
820b57cec5SDimitry Andric   void printRegOperand(unsigned RegNo, raw_ostream &O);
830b57cec5SDimitry Andric   void printVOPDst(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
840b57cec5SDimitry Andric                    raw_ostream &O);
850b57cec5SDimitry Andric   void printVINTRPDst(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
860b57cec5SDimitry Andric                       raw_ostream &O);
875ffd83dbSDimitry Andric   void printImmediateInt16(uint32_t Imm, const MCSubtargetInfo &STI,
885ffd83dbSDimitry Andric                            raw_ostream &O);
890b57cec5SDimitry Andric   void printImmediate16(uint32_t Imm, const MCSubtargetInfo &STI,
900b57cec5SDimitry Andric                         raw_ostream &O);
911db9f3b2SDimitry Andric   void printImmediateV216(uint32_t Imm, uint8_t OpType,
921db9f3b2SDimitry Andric                           const MCSubtargetInfo &STI, raw_ostream &O);
931db9f3b2SDimitry Andric   bool printImmediateFloat32(uint32_t Imm, const MCSubtargetInfo &STI,
940b57cec5SDimitry Andric                              raw_ostream &O);
950b57cec5SDimitry Andric   void printImmediate32(uint32_t Imm, const MCSubtargetInfo &STI,
960b57cec5SDimitry Andric                         raw_ostream &O);
970b57cec5SDimitry Andric   void printImmediate64(uint64_t Imm, const MCSubtargetInfo &STI,
985f757f3fSDimitry Andric                         raw_ostream &O, bool IsFP);
990b57cec5SDimitry Andric   void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
1000b57cec5SDimitry Andric                     raw_ostream &O);
10181ad6265SDimitry Andric   void printRegularOperand(const MCInst *MI, unsigned OpNo,
10281ad6265SDimitry Andric                            const MCSubtargetInfo &STI, raw_ostream &O);
printOperand(const MCInst * MI,uint64_t,unsigned OpNum,const MCSubtargetInfo & STI,raw_ostream & O)1035ffd83dbSDimitry Andric   void printOperand(const MCInst *MI, uint64_t /*Address*/, unsigned OpNum,
1045ffd83dbSDimitry Andric                     const MCSubtargetInfo &STI, raw_ostream &O) {
1055ffd83dbSDimitry Andric     printOperand(MI, OpNum, STI, O);
1065ffd83dbSDimitry Andric   }
1070b57cec5SDimitry Andric   void printOperandAndFPInputMods(const MCInst *MI, unsigned OpNo,
1080b57cec5SDimitry Andric                                   const MCSubtargetInfo &STI, raw_ostream &O);
1090b57cec5SDimitry Andric   void printOperandAndIntInputMods(const MCInst *MI, unsigned OpNo,
1100b57cec5SDimitry Andric                                    const MCSubtargetInfo &STI, raw_ostream &O);
1110b57cec5SDimitry Andric   void printDPP8(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
1120b57cec5SDimitry Andric                  raw_ostream &O);
1130b57cec5SDimitry Andric   void printDPPCtrl(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
1140b57cec5SDimitry Andric                     raw_ostream &O);
11506c3fb27SDimitry Andric   void printDppRowMask(const MCInst *MI, unsigned OpNo,
11606c3fb27SDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &O);
11706c3fb27SDimitry Andric   void printDppBankMask(const MCInst *MI, unsigned OpNo,
1180b57cec5SDimitry Andric                         const MCSubtargetInfo &STI, raw_ostream &O);
119bdd1243dSDimitry Andric   void printDppBoundCtrl(const MCInst *MI, unsigned OpNo,
1200b57cec5SDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
12106c3fb27SDimitry Andric   void printDppFI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
12206c3fb27SDimitry Andric                   raw_ostream &O);
1230b57cec5SDimitry Andric   void printSDWASel(const MCInst *MI, unsigned OpNo, raw_ostream &O);
1240b57cec5SDimitry Andric   void printSDWADstSel(const MCInst *MI, unsigned OpNo,
1250b57cec5SDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &O);
1260b57cec5SDimitry Andric   void printSDWASrc0Sel(const MCInst *MI, unsigned OpNo,
1270b57cec5SDimitry Andric                         const MCSubtargetInfo &STI, raw_ostream &O);
1280b57cec5SDimitry Andric   void printSDWASrc1Sel(const MCInst *MI, unsigned OpNo,
1290b57cec5SDimitry Andric                         const MCSubtargetInfo &STI, raw_ostream &O);
1300b57cec5SDimitry Andric   void printSDWADstUnused(const MCInst *MI, unsigned OpNo,
1310b57cec5SDimitry Andric                           const MCSubtargetInfo &STI, raw_ostream &O);
1320b57cec5SDimitry Andric   void printPackedModifier(const MCInst *MI, StringRef Name, unsigned Mod,
1330b57cec5SDimitry Andric                            raw_ostream &O);
1340b57cec5SDimitry Andric   void printOpSel(const MCInst *MI, unsigned OpNo,
1350b57cec5SDimitry Andric                   const MCSubtargetInfo &STI, raw_ostream &O);
1360b57cec5SDimitry Andric   void printOpSelHi(const MCInst *MI, unsigned OpNo,
1370b57cec5SDimitry Andric                   const MCSubtargetInfo &STI, raw_ostream &O);
1380b57cec5SDimitry Andric   void printNegLo(const MCInst *MI, unsigned OpNo,
1390b57cec5SDimitry Andric                   const MCSubtargetInfo &STI, raw_ostream &O);
1400b57cec5SDimitry Andric   void printNegHi(const MCInst *MI, unsigned OpNo,
1410b57cec5SDimitry Andric                   const MCSubtargetInfo &STI, raw_ostream &O);
142b3edf446SDimitry Andric   void printIndexKey8bit(const MCInst *MI, unsigned OpNo,
143b3edf446SDimitry Andric                          const MCSubtargetInfo &STI, raw_ostream &O);
144b3edf446SDimitry Andric   void printIndexKey16bit(const MCInst *MI, unsigned OpNo,
145b3edf446SDimitry Andric                           const MCSubtargetInfo &STI, raw_ostream &O);
1460b57cec5SDimitry Andric   void printInterpSlot(const MCInst *MI, unsigned OpNo,
1470b57cec5SDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &O);
1480b57cec5SDimitry Andric   void printInterpAttr(const MCInst *MI, unsigned OpNo,
1490b57cec5SDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &O);
1500b57cec5SDimitry Andric   void printInterpAttrChan(const MCInst *MI, unsigned OpNo,
1510b57cec5SDimitry Andric                            const MCSubtargetInfo &STI, raw_ostream &O);
1520b57cec5SDimitry Andric 
15306c3fb27SDimitry Andric   void printGPRIdxMode(const MCInst *MI, unsigned OpNo,
1540b57cec5SDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &O);
1550b57cec5SDimitry Andric   void printMemOperand(const MCInst *MI, unsigned OpNo,
1560b57cec5SDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &O);
1570b57cec5SDimitry Andric   void printBLGP(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
1580b57cec5SDimitry Andric                  raw_ostream &O);
1590b57cec5SDimitry Andric   void printCBSZ(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
1600b57cec5SDimitry Andric                  raw_ostream &O);
1610b57cec5SDimitry Andric   void printABID(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
1620b57cec5SDimitry Andric                  raw_ostream &O);
16381ad6265SDimitry Andric   bool needsImpliedVcc(const MCInstrDesc &Desc, unsigned OpNo) const;
16481ad6265SDimitry Andric   void printDefaultVccOperand(bool FirstOperand, const MCSubtargetInfo &STI,
16581ad6265SDimitry Andric                               raw_ostream &O);
16681ad6265SDimitry Andric   void printWaitVDST(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
16781ad6265SDimitry Andric                     raw_ostream &O);
16881ad6265SDimitry Andric   void printWaitEXP(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
1690b57cec5SDimitry Andric                     raw_ostream &O);
1701db9f3b2SDimitry Andric   void printWaitVAVDst(const MCInst *MI, unsigned OpNo,
1711db9f3b2SDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &O);
1721db9f3b2SDimitry Andric   void printWaitVMVSrc(const MCInst *MI, unsigned OpNo,
1731db9f3b2SDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &O);
1740b57cec5SDimitry Andric 
175e8d8bef9SDimitry Andric   void printExpSrcN(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
176e8d8bef9SDimitry Andric                     raw_ostream &O, unsigned N);
1770b57cec5SDimitry Andric   void printExpSrc0(const MCInst *MI, unsigned OpNo,
1780b57cec5SDimitry Andric                     const MCSubtargetInfo &STI, raw_ostream &O);
1790b57cec5SDimitry Andric   void printExpSrc1(const MCInst *MI, unsigned OpNo,
1800b57cec5SDimitry Andric                     const MCSubtargetInfo &STI, raw_ostream &O);
1810b57cec5SDimitry Andric   void printExpSrc2(const MCInst *MI, unsigned OpNo,
1820b57cec5SDimitry Andric                     const MCSubtargetInfo &STI, raw_ostream &O);
1830b57cec5SDimitry Andric   void printExpSrc3(const MCInst *MI, unsigned OpNo,
1840b57cec5SDimitry Andric                     const MCSubtargetInfo &STI, raw_ostream &O);
1850b57cec5SDimitry Andric   void printExpTgt(const MCInst *MI, unsigned OpNo,
1860b57cec5SDimitry Andric                    const MCSubtargetInfo &STI, raw_ostream &O);
1870b57cec5SDimitry Andric 
1880b57cec5SDimitry Andric public:
1890b57cec5SDimitry Andric   static void printIfSet(const MCInst *MI, unsigned OpNo, raw_ostream &O,
1900b57cec5SDimitry Andric                          StringRef Asm, StringRef Default = "");
1910b57cec5SDimitry Andric   static void printIfSet(const MCInst *MI, unsigned OpNo, raw_ostream &O,
1920b57cec5SDimitry Andric                          char Asm);
1930b57cec5SDimitry Andric protected:
1940b57cec5SDimitry Andric   void printAbs(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
1950b57cec5SDimitry Andric                 raw_ostream &O);
1960b57cec5SDimitry Andric   void printClamp(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
1970b57cec5SDimitry Andric                   raw_ostream &O);
1980b57cec5SDimitry Andric   void printOModSI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
1990b57cec5SDimitry Andric                    raw_ostream &O);
2000b57cec5SDimitry Andric   void printLiteral(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
2010b57cec5SDimitry Andric                     raw_ostream &O);
2020b57cec5SDimitry Andric   void printLast(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
2030b57cec5SDimitry Andric                  raw_ostream &O);
2040b57cec5SDimitry Andric   void printNeg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
2050b57cec5SDimitry Andric                 raw_ostream &O);
2060b57cec5SDimitry Andric   void printOMOD(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
2070b57cec5SDimitry Andric                  raw_ostream &O);
2080b57cec5SDimitry Andric   void printRel(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
2090b57cec5SDimitry Andric                 raw_ostream &O);
2100b57cec5SDimitry Andric   void printUpdateExecMask(const MCInst *MI, unsigned OpNo,
2110b57cec5SDimitry Andric                            const MCSubtargetInfo &STI, raw_ostream &O);
2120b57cec5SDimitry Andric   void printUpdatePred(const MCInst *MI, unsigned OpNo,
2130b57cec5SDimitry Andric                        const MCSubtargetInfo &STI, raw_ostream &O);
2140b57cec5SDimitry Andric   void printWrite(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
2150b57cec5SDimitry Andric                   raw_ostream &O);
2160b57cec5SDimitry Andric   void printBankSwizzle(const MCInst *MI, unsigned OpNo,
2170b57cec5SDimitry Andric                         const MCSubtargetInfo &STI, raw_ostream &O);
2180b57cec5SDimitry Andric   void printRSel(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
2190b57cec5SDimitry Andric                  raw_ostream &O);
2200b57cec5SDimitry Andric   void printCT(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
2210b57cec5SDimitry Andric                raw_ostream &O);
2220b57cec5SDimitry Andric   void printKCache(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
2230b57cec5SDimitry Andric                    raw_ostream &O);
2240b57cec5SDimitry Andric   void printSendMsg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
2250b57cec5SDimitry Andric                     raw_ostream &O);
2260b57cec5SDimitry Andric   void printSwizzle(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
2270b57cec5SDimitry Andric                     raw_ostream &O);
22806c3fb27SDimitry Andric   void printSWaitCnt(const MCInst *MI, unsigned OpNo,
2290b57cec5SDimitry Andric                      const MCSubtargetInfo &STI, raw_ostream &O);
23081ad6265SDimitry Andric   void printDepCtr(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
23181ad6265SDimitry Andric                    raw_ostream &O);
23206c3fb27SDimitry Andric   void printSDelayALU(const MCInst *MI, unsigned OpNo,
23381ad6265SDimitry Andric                       const MCSubtargetInfo &STI, raw_ostream &O);
2340b57cec5SDimitry Andric   void printHwreg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
2350b57cec5SDimitry Andric                   raw_ostream &O);
2360b57cec5SDimitry Andric   void printEndpgm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
2370b57cec5SDimitry Andric                    raw_ostream &O);
2380b57cec5SDimitry Andric };
2390b57cec5SDimitry Andric 
2400b57cec5SDimitry Andric } // End namespace llvm
2410b57cec5SDimitry Andric 
2420b57cec5SDimitry Andric #endif
243