1e1818af8STom Stellard //===-- AMDGPUDisassembler.cpp - Disassembler for AMDGPU ISA --------------===// 2e1818af8STom Stellard // 3e1818af8STom Stellard // The LLVM Compiler Infrastructure 4e1818af8STom Stellard // 5e1818af8STom Stellard // This file is distributed under the University of Illinois Open Source 6e1818af8STom Stellard // License. See LICENSE.TXT for details. 7e1818af8STom Stellard // 8e1818af8STom Stellard //===----------------------------------------------------------------------===// 9e1818af8STom Stellard // 10e1818af8STom Stellard //===----------------------------------------------------------------------===// 11e1818af8STom Stellard // 12e1818af8STom Stellard /// \file 13e1818af8STom Stellard /// 14e1818af8STom Stellard /// This file contains definition for AMDGPU ISA disassembler 15e1818af8STom Stellard // 16e1818af8STom Stellard //===----------------------------------------------------------------------===// 17e1818af8STom Stellard 18e1818af8STom Stellard // ToDo: What to do with instruction suffixes (v_mov_b32 vs v_mov_b32_e32)? 19e1818af8STom Stellard 20e1818af8STom Stellard #include "AMDGPUDisassembler.h" 21e1818af8STom Stellard #include "AMDGPU.h" 22e1818af8STom Stellard #include "AMDGPURegisterInfo.h" 23e1818af8STom Stellard #include "Utils/AMDGPUBaseInfo.h" 24e1818af8STom Stellard 25ac106addSNikolay Haustov #include "llvm/MC/MCContext.h" 26e1818af8STom Stellard #include "llvm/MC/MCFixedLenDisassembler.h" 27e1818af8STom Stellard #include "llvm/MC/MCInst.h" 28e1818af8STom Stellard #include "llvm/MC/MCInstrDesc.h" 29e1818af8STom Stellard #include "llvm/MC/MCSubtargetInfo.h" 30ac106addSNikolay Haustov #include "llvm/Support/Endian.h" 31e1818af8STom Stellard #include "llvm/Support/Debug.h" 32e1818af8STom Stellard #include "llvm/Support/TargetRegistry.h" 33e1818af8STom Stellard 34e1818af8STom Stellard 35e1818af8STom Stellard using namespace llvm; 36e1818af8STom Stellard 37e1818af8STom Stellard #define DEBUG_TYPE "amdgpu-disassembler" 38e1818af8STom Stellard 39e1818af8STom Stellard typedef llvm::MCDisassembler::DecodeStatus DecodeStatus; 40e1818af8STom Stellard 41e1818af8STom Stellard 42ac106addSNikolay Haustov inline static MCDisassembler::DecodeStatus 43ac106addSNikolay Haustov addOperand(MCInst &Inst, const MCOperand& Opnd) { 44ac106addSNikolay Haustov Inst.addOperand(Opnd); 45ac106addSNikolay Haustov return Opnd.isValid() ? 46ac106addSNikolay Haustov MCDisassembler::Success : 47ac106addSNikolay Haustov MCDisassembler::SoftFail; 48e1818af8STom Stellard } 49e1818af8STom Stellard 50ac106addSNikolay Haustov #define DECODE_OPERAND2(RegClass, DecName) \ 51ac106addSNikolay Haustov static DecodeStatus Decode##RegClass##RegisterClass(MCInst &Inst, \ 52ac106addSNikolay Haustov unsigned Imm, \ 53ac106addSNikolay Haustov uint64_t /*Addr*/, \ 54ac106addSNikolay Haustov const void *Decoder) { \ 55ac106addSNikolay Haustov auto DAsm = static_cast<const AMDGPUDisassembler*>(Decoder); \ 56ac106addSNikolay Haustov return addOperand(Inst, DAsm->decodeOperand_##DecName(Imm)); \ 57e1818af8STom Stellard } 58e1818af8STom Stellard 59ac106addSNikolay Haustov #define DECODE_OPERAND(RegClass) DECODE_OPERAND2(RegClass, RegClass) 60e1818af8STom Stellard 61ac106addSNikolay Haustov DECODE_OPERAND(VGPR_32) 62ac106addSNikolay Haustov DECODE_OPERAND(VS_32) 63ac106addSNikolay Haustov DECODE_OPERAND(VS_64) 64e1818af8STom Stellard 65ac106addSNikolay Haustov DECODE_OPERAND(VReg_64) 66ac106addSNikolay Haustov DECODE_OPERAND(VReg_96) 67ac106addSNikolay Haustov DECODE_OPERAND(VReg_128) 68e1818af8STom Stellard 69*a4db224dSValery Pykhtin DECODE_OPERAND(SGPR_32) 70ac106addSNikolay Haustov DECODE_OPERAND(SReg_32) 71ac106addSNikolay Haustov DECODE_OPERAND(SReg_64) 72ac106addSNikolay Haustov DECODE_OPERAND(SReg_128) 73ac106addSNikolay Haustov DECODE_OPERAND(SReg_256) 74*a4db224dSValery Pykhtin DECODE_OPERAND(SReg_512) 75e1818af8STom Stellard 76e1818af8STom Stellard #define GET_SUBTARGETINFO_ENUM 77e1818af8STom Stellard #include "AMDGPUGenSubtargetInfo.inc" 78e1818af8STom Stellard #undef GET_SUBTARGETINFO_ENUM 79e1818af8STom Stellard 80e1818af8STom Stellard #include "AMDGPUGenDisassemblerTables.inc" 81e1818af8STom Stellard 82e1818af8STom Stellard //===----------------------------------------------------------------------===// 83e1818af8STom Stellard // 84e1818af8STom Stellard //===----------------------------------------------------------------------===// 85e1818af8STom Stellard 86ac106addSNikolay Haustov static inline uint32_t eatB32(ArrayRef<uint8_t>& Bytes) { 87ac106addSNikolay Haustov assert(Bytes.size() >= sizeof eatB32(Bytes)); 88ac106addSNikolay Haustov const auto Res = support::endian::read32le(Bytes.data()); 89ac106addSNikolay Haustov Bytes = Bytes.slice(sizeof Res); 90ac106addSNikolay Haustov return Res; 91ac106addSNikolay Haustov } 92ac106addSNikolay Haustov 93ac106addSNikolay Haustov DecodeStatus AMDGPUDisassembler::tryDecodeInst(const uint8_t* Table, 94ac106addSNikolay Haustov MCInst &MI, 95ac106addSNikolay Haustov uint64_t Inst, 96ac106addSNikolay Haustov uint64_t Address) const { 97ac106addSNikolay Haustov assert(MI.getOpcode() == 0); 98ac106addSNikolay Haustov assert(MI.getNumOperands() == 0); 99ac106addSNikolay Haustov MCInst TmpInst; 100ac106addSNikolay Haustov const auto SavedBytes = Bytes; 101ac106addSNikolay Haustov if (decodeInstruction(Table, TmpInst, Inst, Address, this, STI)) { 102ac106addSNikolay Haustov MI = TmpInst; 103ac106addSNikolay Haustov return MCDisassembler::Success; 104ac106addSNikolay Haustov } 105ac106addSNikolay Haustov Bytes = SavedBytes; 106ac106addSNikolay Haustov return MCDisassembler::Fail; 107ac106addSNikolay Haustov } 108ac106addSNikolay Haustov 109e1818af8STom Stellard DecodeStatus AMDGPUDisassembler::getInstruction(MCInst &MI, uint64_t &Size, 110ac106addSNikolay Haustov ArrayRef<uint8_t> Bytes_, 111e1818af8STom Stellard uint64_t Address, 112e1818af8STom Stellard raw_ostream &WS, 113e1818af8STom Stellard raw_ostream &CS) const { 114e1818af8STom Stellard CommentStream = &CS; 115e1818af8STom Stellard 116e1818af8STom Stellard // ToDo: AMDGPUDisassembler supports only VI ISA. 117e1818af8STom Stellard assert(AMDGPU::isVI(STI) && "Can disassemble only VI ISA."); 118e1818af8STom Stellard 119ac106addSNikolay Haustov const unsigned MaxInstBytesNum = (std::min)((size_t)8, Bytes_.size()); 120ac106addSNikolay Haustov Bytes = Bytes_.slice(0, MaxInstBytesNum); 121161a158eSNikolay Haustov 122ac106addSNikolay Haustov DecodeStatus Res = MCDisassembler::Fail; 123ac106addSNikolay Haustov do { 124824e804bSValery Pykhtin // ToDo: better to switch encoding length using some bit predicate 125ac106addSNikolay Haustov // but it is unknown yet, so try all we can 126ac106addSNikolay Haustov if (Bytes.size() < 4) break; 127ac106addSNikolay Haustov const uint32_t DW = eatB32(Bytes); 128ac106addSNikolay Haustov Res = tryDecodeInst(DecoderTableVI32, MI, DW, Address); 129ac106addSNikolay Haustov if (Res) break; 130e1818af8STom Stellard 131ac106addSNikolay Haustov Res = tryDecodeInst(DecoderTableAMDGPU32, MI, DW, Address); 132ac106addSNikolay Haustov if (Res) break; 133ac106addSNikolay Haustov 134ac106addSNikolay Haustov if (Bytes.size() < 4) break; 135ac106addSNikolay Haustov const uint64_t QW = ((uint64_t)eatB32(Bytes) << 32) | DW; 136ac106addSNikolay Haustov Res = tryDecodeInst(DecoderTableVI64, MI, QW, Address); 137ac106addSNikolay Haustov if (Res) break; 138ac106addSNikolay Haustov 139ac106addSNikolay Haustov Res = tryDecodeInst(DecoderTableAMDGPU64, MI, QW, Address); 140ac106addSNikolay Haustov } while (false); 141ac106addSNikolay Haustov 142ac106addSNikolay Haustov Size = Res ? (MaxInstBytesNum - Bytes.size()) : 0; 143ac106addSNikolay Haustov return Res; 144161a158eSNikolay Haustov } 145e1818af8STom Stellard 146ac106addSNikolay Haustov const char* AMDGPUDisassembler::getRegClassName(unsigned RegClassID) const { 147ac106addSNikolay Haustov return getContext().getRegisterInfo()-> 148ac106addSNikolay Haustov getRegClassName(&AMDGPUMCRegisterClasses[RegClassID]); 149e1818af8STom Stellard } 150e1818af8STom Stellard 151ac106addSNikolay Haustov inline 152ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::errOperand(unsigned V, 153ac106addSNikolay Haustov const Twine& ErrMsg) const { 154ac106addSNikolay Haustov *CommentStream << "Error: " + ErrMsg; 155ac106addSNikolay Haustov 156ac106addSNikolay Haustov // ToDo: add support for error operands to MCInst.h 157ac106addSNikolay Haustov // return MCOperand::createError(V); 158ac106addSNikolay Haustov return MCOperand(); 159ac106addSNikolay Haustov } 160ac106addSNikolay Haustov 161ac106addSNikolay Haustov inline 162ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::createRegOperand(unsigned int RegId) const { 163ac106addSNikolay Haustov return MCOperand::createReg(RegId); 164ac106addSNikolay Haustov } 165ac106addSNikolay Haustov 166ac106addSNikolay Haustov inline 167ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::createRegOperand(unsigned RegClassID, 168ac106addSNikolay Haustov unsigned Val) const { 169ac106addSNikolay Haustov const auto& RegCl = AMDGPUMCRegisterClasses[RegClassID]; 170ac106addSNikolay Haustov if (Val >= RegCl.getNumRegs()) 171ac106addSNikolay Haustov return errOperand(Val, Twine(getRegClassName(RegClassID)) + 172ac106addSNikolay Haustov ": unknown register " + Twine(Val)); 173ac106addSNikolay Haustov return createRegOperand(RegCl.getRegister(Val)); 174ac106addSNikolay Haustov } 175ac106addSNikolay Haustov 176ac106addSNikolay Haustov inline 177ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::createSRegOperand(unsigned SRegClassID, 178ac106addSNikolay Haustov unsigned Val) const { 179ac106addSNikolay Haustov // ToDo: SI/CI have 104 SGPRs, VI - 102 180ac106addSNikolay Haustov // Valery: here we accepting as much as we can, let assembler sort it out 181ac106addSNikolay Haustov int shift = 0; 182ac106addSNikolay Haustov switch (SRegClassID) { 183ac106addSNikolay Haustov case AMDGPU::SGPR_32RegClassID: 184ac106addSNikolay Haustov case AMDGPU::SReg_32RegClassID: break; 185ac106addSNikolay Haustov case AMDGPU::SGPR_64RegClassID: 186ac106addSNikolay Haustov case AMDGPU::SReg_64RegClassID: shift = 1; break; 187ac106addSNikolay Haustov case AMDGPU::SReg_128RegClassID: 188ac106addSNikolay Haustov // ToDo: unclear if s[100:104] is available on VI. Can we use VCC as SGPR in 189ac106addSNikolay Haustov // this bundle? 190ac106addSNikolay Haustov case AMDGPU::SReg_256RegClassID: 191ac106addSNikolay Haustov // ToDo: unclear if s[96:104] is available on VI. Can we use VCC as SGPR in 192ac106addSNikolay Haustov // this bundle? 193ac106addSNikolay Haustov case AMDGPU::SReg_512RegClassID: shift = 2; break; 194ac106addSNikolay Haustov // ToDo: unclear if s[88:104] is available on VI. Can we use VCC as SGPR in 195ac106addSNikolay Haustov // this bundle? 196ac106addSNikolay Haustov default: assert(false); break; 197ac106addSNikolay Haustov } 198ac106addSNikolay Haustov if (Val % (1 << shift)) 199ac106addSNikolay Haustov *CommentStream << "Warning: " << getRegClassName(SRegClassID) 200ac106addSNikolay Haustov << ": scalar reg isn't aligned " << Val; 201ac106addSNikolay Haustov return createRegOperand(SRegClassID, Val >> shift); 202ac106addSNikolay Haustov } 203ac106addSNikolay Haustov 204ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_VS_32(unsigned Val) const { 205ac106addSNikolay Haustov return decodeSrcOp(OP32, Val); 206ac106addSNikolay Haustov } 207ac106addSNikolay Haustov 208ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_VS_64(unsigned Val) const { 209ac106addSNikolay Haustov return decodeSrcOp(OP64, Val); 210ac106addSNikolay Haustov } 211ac106addSNikolay Haustov 212ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_VGPR_32(unsigned Val) const { 213ac106addSNikolay Haustov return createRegOperand(AMDGPU::VGPR_32RegClassID, Val); 214ac106addSNikolay Haustov } 215ac106addSNikolay Haustov 216ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_VReg_64(unsigned Val) const { 217ac106addSNikolay Haustov return createRegOperand(AMDGPU::VReg_64RegClassID, Val); 218ac106addSNikolay Haustov } 219ac106addSNikolay Haustov 220ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_VReg_96(unsigned Val) const { 221ac106addSNikolay Haustov return createRegOperand(AMDGPU::VReg_96RegClassID, Val); 222ac106addSNikolay Haustov } 223ac106addSNikolay Haustov 224ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_VReg_128(unsigned Val) const { 225ac106addSNikolay Haustov return createRegOperand(AMDGPU::VReg_128RegClassID, Val); 226ac106addSNikolay Haustov } 227ac106addSNikolay Haustov 228ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_SGPR_32(unsigned Val) const { 229ac106addSNikolay Haustov return createSRegOperand(AMDGPU::SGPR_32RegClassID, Val); 230ac106addSNikolay Haustov } 231ac106addSNikolay Haustov 232ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_SReg_32(unsigned Val) const { 233ac106addSNikolay Haustov // table-gen generated disassembler doesn't care about operand types 234ac106addSNikolay Haustov // leaving only registry class so SSrc_32 operand turns into SReg_32 235ac106addSNikolay Haustov // and therefore we accept immediates and literals here as well 236ac106addSNikolay Haustov return decodeSrcOp(OP32, Val); 237ac106addSNikolay Haustov } 238ac106addSNikolay Haustov 239ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_SReg_64(unsigned Val) const { 240ac106addSNikolay Haustov // see decodeOperand_SReg_32 comment 241ac106addSNikolay Haustov return decodeSrcOp(OP64, Val); 242ac106addSNikolay Haustov } 243ac106addSNikolay Haustov 244ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_SReg_128(unsigned Val) const { 245ac106addSNikolay Haustov return createSRegOperand(AMDGPU::SReg_128RegClassID, Val); 246ac106addSNikolay Haustov } 247ac106addSNikolay Haustov 248ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_SReg_256(unsigned Val) const { 249ac106addSNikolay Haustov return createSRegOperand(AMDGPU::SReg_256RegClassID, Val); 250ac106addSNikolay Haustov } 251ac106addSNikolay Haustov 252ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_SReg_512(unsigned Val) const { 253ac106addSNikolay Haustov return createSRegOperand(AMDGPU::SReg_512RegClassID, Val); 254ac106addSNikolay Haustov } 255ac106addSNikolay Haustov 256ac106addSNikolay Haustov 257ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeLiteralConstant() const { 258ac106addSNikolay Haustov // For now all literal constants are supposed to be unsigned integer 259ac106addSNikolay Haustov // ToDo: deal with signed/unsigned 64-bit integer constants 260ac106addSNikolay Haustov // ToDo: deal with float/double constants 261ac106addSNikolay Haustov if (Bytes.size() < 4) 262ac106addSNikolay Haustov return errOperand(0, "cannot read literal, inst bytes left " + 263ac106addSNikolay Haustov Twine(Bytes.size())); 264ac106addSNikolay Haustov return MCOperand::createImm(eatB32(Bytes)); 265ac106addSNikolay Haustov } 266ac106addSNikolay Haustov 267ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeIntImmed(unsigned Imm) { 268ac106addSNikolay Haustov assert(Imm >= 128 && Imm <= 208); 269ac106addSNikolay Haustov return MCOperand::createImm((Imm <= 192) ? (Imm - 128) : (192 - Imm)); 270ac106addSNikolay Haustov } 271ac106addSNikolay Haustov 272ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeFPImmed(bool Is32, unsigned Imm) { 273ac106addSNikolay Haustov assert(Imm >= 240 && Imm <= 248); 274e1818af8STom Stellard // ToDo: case 248: 1/(2*PI) - is allowed only on VI 275e1818af8STom Stellard // ToDo: AMDGPUInstPrinter does not support 1/(2*PI). It consider 1/(2*PI) as 276e1818af8STom Stellard // literal constant. 277ac106addSNikolay Haustov float V = 0.0f; 278e1818af8STom Stellard switch (Imm) { 279ac106addSNikolay Haustov case 240: V = 0.5f; break; 280ac106addSNikolay Haustov case 241: V = -0.5f; break; 281ac106addSNikolay Haustov case 242: V = 1.0f; break; 282ac106addSNikolay Haustov case 243: V = -1.0f; break; 283ac106addSNikolay Haustov case 244: V = 2.0f; break; 284ac106addSNikolay Haustov case 245: V = -2.0f; break; 285ac106addSNikolay Haustov case 246: V = 4.0f; break; 286ac106addSNikolay Haustov case 247: V = -4.0f; break; 287ac106addSNikolay Haustov case 248: return MCOperand::createImm(Is32 ? // 1/(2*PI) 288ac106addSNikolay Haustov 0x3e22f983 : 289ac106addSNikolay Haustov 0x3fc45f306dc9c882); 290ac106addSNikolay Haustov default: break; 291e1818af8STom Stellard } 292ac106addSNikolay Haustov return MCOperand::createImm(Is32? FloatToBits(V) : DoubleToBits(V)); 293e1818af8STom Stellard } 294e1818af8STom Stellard 295ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeSrcOp(bool Is32, unsigned Val) const { 296e1818af8STom Stellard using namespace AMDGPU; 297ac106addSNikolay Haustov assert(Val < 512); // enum9 298ac106addSNikolay Haustov 299ac106addSNikolay Haustov if (Val >= 256) 300ac106addSNikolay Haustov return createRegOperand(Is32 ? VGPR_32RegClassID : VReg_64RegClassID, 301ac106addSNikolay Haustov Val - 256); 302ac106addSNikolay Haustov if (Val <= 101) 303ac106addSNikolay Haustov return createSRegOperand(Is32 ? SGPR_32RegClassID : SGPR_64RegClassID, 304ac106addSNikolay Haustov Val); 305ac106addSNikolay Haustov 306ac106addSNikolay Haustov if (Val >= 128 && Val <= 208) 307ac106addSNikolay Haustov return decodeIntImmed(Val); 308ac106addSNikolay Haustov 309ac106addSNikolay Haustov if (Val >= 240 && Val <= 248) 310ac106addSNikolay Haustov return decodeFPImmed(Is32, Val); 311ac106addSNikolay Haustov 312ac106addSNikolay Haustov if (Val == 255) 313ac106addSNikolay Haustov return decodeLiteralConstant(); 314ac106addSNikolay Haustov 315ac106addSNikolay Haustov return Is32 ? decodeSpecialReg32(Val) : decodeSpecialReg64(Val); 316ac106addSNikolay Haustov } 317ac106addSNikolay Haustov 318ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeSpecialReg32(unsigned Val) const { 319ac106addSNikolay Haustov using namespace AMDGPU; 320e1818af8STom Stellard switch (Val) { 321ac106addSNikolay Haustov case 102: return createRegOperand(getMCReg(FLAT_SCR_LO, STI)); 322ac106addSNikolay Haustov case 103: return createRegOperand(getMCReg(FLAT_SCR_HI, STI)); 323e1818af8STom Stellard // ToDo: no support for xnack_mask_lo/_hi register 324e1818af8STom Stellard case 104: 325ac106addSNikolay Haustov case 105: break; 326ac106addSNikolay Haustov case 106: return createRegOperand(VCC_LO); 327ac106addSNikolay Haustov case 107: return createRegOperand(VCC_HI); 328e1818af8STom Stellard // ToDo: no support for tba_lo/_hi register 329e1818af8STom Stellard case 108: 330ac106addSNikolay Haustov case 109: break; 331e1818af8STom Stellard // ToDo: no support for tma_lo/_hi register 332e1818af8STom Stellard case 110: 333ac106addSNikolay Haustov case 111: break; 334e1818af8STom Stellard // ToDo: no support for ttmp[0:11] register 335e1818af8STom Stellard case 112: 336e1818af8STom Stellard case 113: 337e1818af8STom Stellard case 114: 338e1818af8STom Stellard case 115: 339e1818af8STom Stellard case 116: 340e1818af8STom Stellard case 117: 341e1818af8STom Stellard case 118: 342e1818af8STom Stellard case 119: 343e1818af8STom Stellard case 120: 344e1818af8STom Stellard case 121: 345e1818af8STom Stellard case 122: 346ac106addSNikolay Haustov case 123: break; 347ac106addSNikolay Haustov case 124: return createRegOperand(M0); 348ac106addSNikolay Haustov case 126: return createRegOperand(EXEC_LO); 349ac106addSNikolay Haustov case 127: return createRegOperand(EXEC_HI); 350e1818af8STom Stellard // ToDo: no support for vccz register 351ac106addSNikolay Haustov case 251: break; 352e1818af8STom Stellard // ToDo: no support for execz register 353ac106addSNikolay Haustov case 252: break; 354ac106addSNikolay Haustov case 253: return createRegOperand(SCC); 355ac106addSNikolay Haustov default: break; 356e1818af8STom Stellard } 357ac106addSNikolay Haustov return errOperand(Val, "unknown operand encoding " + Twine(Val)); 358e1818af8STom Stellard } 359e1818af8STom Stellard 360ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeSpecialReg64(unsigned Val) const { 361161a158eSNikolay Haustov using namespace AMDGPU; 362161a158eSNikolay Haustov switch (Val) { 363ac106addSNikolay Haustov case 102: return createRegOperand(getMCReg(FLAT_SCR, STI)); 364ac106addSNikolay Haustov case 106: return createRegOperand(VCC); 365ac106addSNikolay Haustov case 126: return createRegOperand(EXEC); 366ac106addSNikolay Haustov default: break; 367161a158eSNikolay Haustov } 368ac106addSNikolay Haustov return errOperand(Val, "unknown operand encoding " + Twine(Val)); 369161a158eSNikolay Haustov } 370161a158eSNikolay Haustov 371e1818af8STom Stellard static MCDisassembler *createAMDGPUDisassembler(const Target &T, 372e1818af8STom Stellard const MCSubtargetInfo &STI, 373e1818af8STom Stellard MCContext &Ctx) { 374e1818af8STom Stellard return new AMDGPUDisassembler(STI, Ctx); 375e1818af8STom Stellard } 376e1818af8STom Stellard 377e1818af8STom Stellard extern "C" void LLVMInitializeAMDGPUDisassembler() { 378e1818af8STom Stellard TargetRegistry::RegisterMCDisassembler(TheGCNTarget, createAMDGPUDisassembler); 379e1818af8STom Stellard } 380