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 19 class AMDGPUInstPrinter : public MCInstPrinter { 20 public: 21 AMDGPUInstPrinter(const MCAsmInfo &MAI, 22 const MCInstrInfo &MII, const MCRegisterInfo &MRI) 23 : MCInstPrinter(MAI, MII, MRI) {} 24 25 //Autogenerated by tblgen 26 void printRegName(raw_ostream &OS, unsigned RegNo) const override; 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(unsigned RegNo); 31 32 void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, 33 const MCSubtargetInfo &STI, raw_ostream &O) override; 34 static void printRegOperand(unsigned RegNo, raw_ostream &O, 35 const MCRegisterInfo &MRI); 36 37 private: 38 void printU4ImmOperand(const MCInst *MI, unsigned OpNo, 39 const MCSubtargetInfo &STI, raw_ostream &O); 40 void printU8ImmOperand(const MCInst *MI, unsigned OpNo, 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 printOffen(const MCInst *MI, unsigned OpNo, raw_ostream &O); 51 void printIdxen(const MCInst *MI, unsigned OpNo, raw_ostream &O); 52 void printAddr64(const MCInst *MI, unsigned OpNo, raw_ostream &O); 53 void printMBUFOffset(const MCInst *MI, unsigned OpNo, raw_ostream &O); 54 void printOffset(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 55 raw_ostream &O); 56 void printFlatOffset(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 57 raw_ostream &O); 58 59 void printOffset0(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 60 raw_ostream &O); 61 void printOffset1(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 62 raw_ostream &O); 63 void printSMRDOffset8(const MCInst *MI, unsigned OpNo, 64 const MCSubtargetInfo &STI, raw_ostream &O); 65 void printSMEMOffset(const MCInst *MI, unsigned OpNo, 66 const MCSubtargetInfo &STI, raw_ostream &O); 67 void printSMRDLiteralOffset(const MCInst *MI, unsigned OpNo, 68 const MCSubtargetInfo &STI, raw_ostream &O); 69 void printGDS(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 70 raw_ostream &O); 71 void printDLC(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 72 raw_ostream &O); 73 void printGLC(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 74 raw_ostream &O); 75 void printSLC(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 76 raw_ostream &O); 77 void printSWZ(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 78 raw_ostream &O); 79 void printTFE(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 80 raw_ostream &O); 81 void printDMask(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 82 raw_ostream &O); 83 void printDim(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 84 raw_ostream &O); 85 void printUNorm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 86 raw_ostream &O); 87 void printDA(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 88 raw_ostream &O); 89 void printR128A16(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 90 raw_ostream &O); 91 void printGFX10A16(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 92 raw_ostream &O); 93 void printLWE(const MCInst *MI, unsigned OpNo, 94 const MCSubtargetInfo &STI, raw_ostream &O); 95 void printD16(const MCInst *MI, unsigned OpNo, 96 const MCSubtargetInfo &STI, raw_ostream &O); 97 void printExpCompr(const MCInst *MI, unsigned OpNo, 98 const MCSubtargetInfo &STI, raw_ostream &O); 99 void printExpVM(const MCInst *MI, unsigned OpNo, 100 const MCSubtargetInfo &STI, raw_ostream &O); 101 void printFORMAT(const MCInst *MI, unsigned OpNo, 102 const MCSubtargetInfo &STI, raw_ostream &O); 103 void printSymbolicFormat(const MCInst *MI, 104 const MCSubtargetInfo &STI, raw_ostream &O); 105 106 void printRegOperand(unsigned RegNo, raw_ostream &O); 107 void printVOPDst(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 108 raw_ostream &O); 109 void printVINTRPDst(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 110 raw_ostream &O); 111 void printImmediateInt16(uint32_t Imm, const MCSubtargetInfo &STI, 112 raw_ostream &O); 113 void printImmediate16(uint32_t Imm, const MCSubtargetInfo &STI, 114 raw_ostream &O); 115 void printImmediateV216(uint32_t Imm, const MCSubtargetInfo &STI, 116 raw_ostream &O); 117 void printImmediate32(uint32_t Imm, const MCSubtargetInfo &STI, 118 raw_ostream &O); 119 void printImmediate64(uint64_t Imm, const MCSubtargetInfo &STI, 120 raw_ostream &O); 121 void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 122 raw_ostream &O); 123 void printOperand(const MCInst *MI, uint64_t /*Address*/, unsigned OpNum, 124 const MCSubtargetInfo &STI, raw_ostream &O) { 125 printOperand(MI, OpNum, STI, O); 126 } 127 void printOperandAndFPInputMods(const MCInst *MI, unsigned OpNo, 128 const MCSubtargetInfo &STI, raw_ostream &O); 129 void printOperandAndIntInputMods(const MCInst *MI, unsigned OpNo, 130 const MCSubtargetInfo &STI, raw_ostream &O); 131 void printDPP8(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 132 raw_ostream &O); 133 void printDPPCtrl(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 134 raw_ostream &O); 135 void printRowMask(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 136 raw_ostream &O); 137 void printBankMask(const MCInst *MI, unsigned OpNo, 138 const MCSubtargetInfo &STI, raw_ostream &O); 139 void printBoundCtrl(const MCInst *MI, unsigned OpNo, 140 const MCSubtargetInfo &STI, raw_ostream &O); 141 void printFI(const MCInst *MI, unsigned OpNo, 142 const MCSubtargetInfo &STI, raw_ostream &O); 143 void printSDWASel(const MCInst *MI, unsigned OpNo, raw_ostream &O); 144 void printSDWADstSel(const MCInst *MI, unsigned OpNo, 145 const MCSubtargetInfo &STI, raw_ostream &O); 146 void printSDWASrc0Sel(const MCInst *MI, unsigned OpNo, 147 const MCSubtargetInfo &STI, raw_ostream &O); 148 void printSDWASrc1Sel(const MCInst *MI, unsigned OpNo, 149 const MCSubtargetInfo &STI, raw_ostream &O); 150 void printSDWADstUnused(const MCInst *MI, unsigned OpNo, 151 const MCSubtargetInfo &STI, raw_ostream &O); 152 void printPackedModifier(const MCInst *MI, StringRef Name, unsigned Mod, 153 raw_ostream &O); 154 void printOpSel(const MCInst *MI, unsigned OpNo, 155 const MCSubtargetInfo &STI, raw_ostream &O); 156 void printOpSelHi(const MCInst *MI, unsigned OpNo, 157 const MCSubtargetInfo &STI, raw_ostream &O); 158 void printNegLo(const MCInst *MI, unsigned OpNo, 159 const MCSubtargetInfo &STI, raw_ostream &O); 160 void printNegHi(const MCInst *MI, unsigned OpNo, 161 const MCSubtargetInfo &STI, raw_ostream &O); 162 void printInterpSlot(const MCInst *MI, unsigned OpNo, 163 const MCSubtargetInfo &STI, raw_ostream &O); 164 void printInterpAttr(const MCInst *MI, unsigned OpNo, 165 const MCSubtargetInfo &STI, raw_ostream &O); 166 void printInterpAttrChan(const MCInst *MI, unsigned OpNo, 167 const MCSubtargetInfo &STI, raw_ostream &O); 168 169 void printVGPRIndexMode(const MCInst *MI, unsigned OpNo, 170 const MCSubtargetInfo &STI, raw_ostream &O); 171 void printMemOperand(const MCInst *MI, unsigned OpNo, 172 const MCSubtargetInfo &STI, raw_ostream &O); 173 void printBLGP(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 174 raw_ostream &O); 175 void printCBSZ(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 176 raw_ostream &O); 177 void printABID(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 178 raw_ostream &O); 179 void printDefaultVccOperand(unsigned OpNo, const MCSubtargetInfo &STI, 180 raw_ostream &O); 181 182 void printExpSrcN(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 183 raw_ostream &O, unsigned N); 184 void printExpSrc0(const MCInst *MI, unsigned OpNo, 185 const MCSubtargetInfo &STI, raw_ostream &O); 186 void printExpSrc1(const MCInst *MI, unsigned OpNo, 187 const MCSubtargetInfo &STI, raw_ostream &O); 188 void printExpSrc2(const MCInst *MI, unsigned OpNo, 189 const MCSubtargetInfo &STI, raw_ostream &O); 190 void printExpSrc3(const MCInst *MI, unsigned OpNo, 191 const MCSubtargetInfo &STI, raw_ostream &O); 192 void printExpTgt(const MCInst *MI, unsigned OpNo, 193 const MCSubtargetInfo &STI, raw_ostream &O); 194 195 public: 196 static void printIfSet(const MCInst *MI, unsigned OpNo, raw_ostream &O, 197 StringRef Asm, StringRef Default = ""); 198 static void printIfSet(const MCInst *MI, unsigned OpNo, raw_ostream &O, 199 char Asm); 200 protected: 201 void printAbs(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 202 raw_ostream &O); 203 void printHigh(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 204 raw_ostream &O); 205 void printClamp(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 206 raw_ostream &O); 207 void printClampSI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 208 raw_ostream &O); 209 void printOModSI(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 210 raw_ostream &O); 211 void printLiteral(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 212 raw_ostream &O); 213 void printLast(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 214 raw_ostream &O); 215 void printNeg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 216 raw_ostream &O); 217 void printOMOD(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 218 raw_ostream &O); 219 void printRel(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 220 raw_ostream &O); 221 void printUpdateExecMask(const MCInst *MI, unsigned OpNo, 222 const MCSubtargetInfo &STI, raw_ostream &O); 223 void printUpdatePred(const MCInst *MI, unsigned OpNo, 224 const MCSubtargetInfo &STI, raw_ostream &O); 225 void printWrite(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 226 raw_ostream &O); 227 void printBankSwizzle(const MCInst *MI, unsigned OpNo, 228 const MCSubtargetInfo &STI, raw_ostream &O); 229 void printRSel(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 230 raw_ostream &O); 231 void printCT(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 232 raw_ostream &O); 233 void printKCache(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 234 raw_ostream &O); 235 void printSendMsg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 236 raw_ostream &O); 237 void printSwizzle(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 238 raw_ostream &O); 239 void printWaitFlag(const MCInst *MI, unsigned OpNo, 240 const MCSubtargetInfo &STI, raw_ostream &O); 241 void printHwreg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 242 raw_ostream &O); 243 void printEndpgm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI, 244 raw_ostream &O); 245 }; 246 247 class R600InstPrinter : public MCInstPrinter { 248 public: 249 R600InstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, 250 const MCRegisterInfo &MRI) 251 : MCInstPrinter(MAI, MII, MRI) {} 252 253 void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, 254 const MCSubtargetInfo &STI, raw_ostream &O) override; 255 std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override; 256 void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); 257 static const char *getRegisterName(unsigned RegNo); 258 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); 275 }; 276 277 } // End namespace llvm 278 279 #endif 280