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