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 69a4db224dSValery 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) 74a4db224dSValery 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 86*1048fb18SSam Kolton template <typename T> static inline T eatBytes(ArrayRef<uint8_t>& Bytes) { 87*1048fb18SSam Kolton assert(Bytes.size() >= sizeof(T)); 88*1048fb18SSam Kolton const auto Res = support::endian::read<T, support::endianness::little>(Bytes.data()); 89*1048fb18SSam Kolton Bytes = Bytes.slice(sizeof(T)); 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 126*1048fb18SSam Kolton 127*1048fb18SSam Kolton // Try to decode DPP first to solve conflict with VOP1 and VOP2 encodings 128*1048fb18SSam Kolton if (Bytes.size() >= 8) { 129*1048fb18SSam Kolton const uint64_t QW = eatBytes<uint64_t>(Bytes); 130*1048fb18SSam Kolton Res = tryDecodeInst(DecoderTableDPP64, MI, QW, Address); 131*1048fb18SSam Kolton if (Res) break; 132*1048fb18SSam Kolton } 133*1048fb18SSam Kolton 134*1048fb18SSam Kolton // Reinitialize Bytes as DPP64 could have eaten too much 135*1048fb18SSam Kolton Bytes = Bytes_.slice(0, MaxInstBytesNum); 136*1048fb18SSam Kolton 137*1048fb18SSam Kolton // Try decode 32-bit instruction 138ac106addSNikolay Haustov if (Bytes.size() < 4) break; 139*1048fb18SSam Kolton const uint32_t DW = eatBytes<uint32_t>(Bytes); 140ac106addSNikolay Haustov Res = tryDecodeInst(DecoderTableVI32, MI, DW, Address); 141ac106addSNikolay Haustov if (Res) break; 142e1818af8STom Stellard 143ac106addSNikolay Haustov Res = tryDecodeInst(DecoderTableAMDGPU32, MI, DW, Address); 144ac106addSNikolay Haustov if (Res) break; 145ac106addSNikolay Haustov 146ac106addSNikolay Haustov if (Bytes.size() < 4) break; 147*1048fb18SSam Kolton const uint64_t QW = ((uint64_t)eatBytes<uint32_t>(Bytes) << 32) | DW; 148ac106addSNikolay Haustov Res = tryDecodeInst(DecoderTableVI64, MI, QW, Address); 149ac106addSNikolay Haustov if (Res) break; 150ac106addSNikolay Haustov 151ac106addSNikolay Haustov Res = tryDecodeInst(DecoderTableAMDGPU64, MI, QW, Address); 152ac106addSNikolay Haustov } while (false); 153ac106addSNikolay Haustov 154ac106addSNikolay Haustov Size = Res ? (MaxInstBytesNum - Bytes.size()) : 0; 155ac106addSNikolay Haustov return Res; 156161a158eSNikolay Haustov } 157e1818af8STom Stellard 158ac106addSNikolay Haustov const char* AMDGPUDisassembler::getRegClassName(unsigned RegClassID) const { 159ac106addSNikolay Haustov return getContext().getRegisterInfo()-> 160ac106addSNikolay Haustov getRegClassName(&AMDGPUMCRegisterClasses[RegClassID]); 161e1818af8STom Stellard } 162e1818af8STom Stellard 163ac106addSNikolay Haustov inline 164ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::errOperand(unsigned V, 165ac106addSNikolay Haustov const Twine& ErrMsg) const { 166ac106addSNikolay Haustov *CommentStream << "Error: " + ErrMsg; 167ac106addSNikolay Haustov 168ac106addSNikolay Haustov // ToDo: add support for error operands to MCInst.h 169ac106addSNikolay Haustov // return MCOperand::createError(V); 170ac106addSNikolay Haustov return MCOperand(); 171ac106addSNikolay Haustov } 172ac106addSNikolay Haustov 173ac106addSNikolay Haustov inline 174ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::createRegOperand(unsigned int RegId) const { 175ac106addSNikolay Haustov return MCOperand::createReg(RegId); 176ac106addSNikolay Haustov } 177ac106addSNikolay Haustov 178ac106addSNikolay Haustov inline 179ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::createRegOperand(unsigned RegClassID, 180ac106addSNikolay Haustov unsigned Val) const { 181ac106addSNikolay Haustov const auto& RegCl = AMDGPUMCRegisterClasses[RegClassID]; 182ac106addSNikolay Haustov if (Val >= RegCl.getNumRegs()) 183ac106addSNikolay Haustov return errOperand(Val, Twine(getRegClassName(RegClassID)) + 184ac106addSNikolay Haustov ": unknown register " + Twine(Val)); 185ac106addSNikolay Haustov return createRegOperand(RegCl.getRegister(Val)); 186ac106addSNikolay Haustov } 187ac106addSNikolay Haustov 188ac106addSNikolay Haustov inline 189ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::createSRegOperand(unsigned SRegClassID, 190ac106addSNikolay Haustov unsigned Val) const { 191ac106addSNikolay Haustov // ToDo: SI/CI have 104 SGPRs, VI - 102 192ac106addSNikolay Haustov // Valery: here we accepting as much as we can, let assembler sort it out 193ac106addSNikolay Haustov int shift = 0; 194ac106addSNikolay Haustov switch (SRegClassID) { 195ac106addSNikolay Haustov case AMDGPU::SGPR_32RegClassID: 196ac106addSNikolay Haustov case AMDGPU::SReg_32RegClassID: break; 197ac106addSNikolay Haustov case AMDGPU::SGPR_64RegClassID: 198ac106addSNikolay Haustov case AMDGPU::SReg_64RegClassID: shift = 1; break; 199ac106addSNikolay Haustov case AMDGPU::SReg_128RegClassID: 200ac106addSNikolay Haustov // ToDo: unclear if s[100:104] is available on VI. Can we use VCC as SGPR in 201ac106addSNikolay Haustov // this bundle? 202ac106addSNikolay Haustov case AMDGPU::SReg_256RegClassID: 203ac106addSNikolay Haustov // ToDo: unclear if s[96:104] is available on VI. Can we use VCC as SGPR in 204ac106addSNikolay Haustov // this bundle? 205ac106addSNikolay Haustov case AMDGPU::SReg_512RegClassID: shift = 2; break; 206ac106addSNikolay Haustov // ToDo: unclear if s[88:104] is available on VI. Can we use VCC as SGPR in 207ac106addSNikolay Haustov // this bundle? 208ac106addSNikolay Haustov default: assert(false); break; 209ac106addSNikolay Haustov } 210ac106addSNikolay Haustov if (Val % (1 << shift)) 211ac106addSNikolay Haustov *CommentStream << "Warning: " << getRegClassName(SRegClassID) 212ac106addSNikolay Haustov << ": scalar reg isn't aligned " << Val; 213ac106addSNikolay Haustov return createRegOperand(SRegClassID, Val >> shift); 214ac106addSNikolay Haustov } 215ac106addSNikolay Haustov 216ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_VS_32(unsigned Val) const { 217ac106addSNikolay Haustov return decodeSrcOp(OP32, Val); 218ac106addSNikolay Haustov } 219ac106addSNikolay Haustov 220ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_VS_64(unsigned Val) const { 221ac106addSNikolay Haustov return decodeSrcOp(OP64, Val); 222ac106addSNikolay Haustov } 223ac106addSNikolay Haustov 224ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_VGPR_32(unsigned Val) const { 225ac106addSNikolay Haustov return createRegOperand(AMDGPU::VGPR_32RegClassID, Val); 226ac106addSNikolay Haustov } 227ac106addSNikolay Haustov 228ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_VReg_64(unsigned Val) const { 229ac106addSNikolay Haustov return createRegOperand(AMDGPU::VReg_64RegClassID, Val); 230ac106addSNikolay Haustov } 231ac106addSNikolay Haustov 232ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_VReg_96(unsigned Val) const { 233ac106addSNikolay Haustov return createRegOperand(AMDGPU::VReg_96RegClassID, Val); 234ac106addSNikolay Haustov } 235ac106addSNikolay Haustov 236ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_VReg_128(unsigned Val) const { 237ac106addSNikolay Haustov return createRegOperand(AMDGPU::VReg_128RegClassID, Val); 238ac106addSNikolay Haustov } 239ac106addSNikolay Haustov 240ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_SGPR_32(unsigned Val) const { 241ac106addSNikolay Haustov return createSRegOperand(AMDGPU::SGPR_32RegClassID, Val); 242ac106addSNikolay Haustov } 243ac106addSNikolay Haustov 244ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_SReg_32(unsigned Val) const { 245ac106addSNikolay Haustov // table-gen generated disassembler doesn't care about operand types 246ac106addSNikolay Haustov // leaving only registry class so SSrc_32 operand turns into SReg_32 247ac106addSNikolay Haustov // and therefore we accept immediates and literals here as well 248ac106addSNikolay Haustov return decodeSrcOp(OP32, Val); 249ac106addSNikolay Haustov } 250ac106addSNikolay Haustov 251ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_SReg_64(unsigned Val) const { 252ac106addSNikolay Haustov // see decodeOperand_SReg_32 comment 253ac106addSNikolay Haustov return decodeSrcOp(OP64, Val); 254ac106addSNikolay Haustov } 255ac106addSNikolay Haustov 256ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_SReg_128(unsigned Val) const { 257ac106addSNikolay Haustov return createSRegOperand(AMDGPU::SReg_128RegClassID, Val); 258ac106addSNikolay Haustov } 259ac106addSNikolay Haustov 260ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_SReg_256(unsigned Val) const { 261ac106addSNikolay Haustov return createSRegOperand(AMDGPU::SReg_256RegClassID, Val); 262ac106addSNikolay Haustov } 263ac106addSNikolay Haustov 264ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeOperand_SReg_512(unsigned Val) const { 265ac106addSNikolay Haustov return createSRegOperand(AMDGPU::SReg_512RegClassID, Val); 266ac106addSNikolay Haustov } 267ac106addSNikolay Haustov 268ac106addSNikolay Haustov 269ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeLiteralConstant() const { 270ac106addSNikolay Haustov // For now all literal constants are supposed to be unsigned integer 271ac106addSNikolay Haustov // ToDo: deal with signed/unsigned 64-bit integer constants 272ac106addSNikolay Haustov // ToDo: deal with float/double constants 273ac106addSNikolay Haustov if (Bytes.size() < 4) 274ac106addSNikolay Haustov return errOperand(0, "cannot read literal, inst bytes left " + 275ac106addSNikolay Haustov Twine(Bytes.size())); 276*1048fb18SSam Kolton return MCOperand::createImm(eatBytes<uint32_t>(Bytes)); 277ac106addSNikolay Haustov } 278ac106addSNikolay Haustov 279ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeIntImmed(unsigned Imm) { 280ac106addSNikolay Haustov assert(Imm >= 128 && Imm <= 208); 281ac106addSNikolay Haustov return MCOperand::createImm((Imm <= 192) ? (Imm - 128) : (192 - Imm)); 282ac106addSNikolay Haustov } 283ac106addSNikolay Haustov 284ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeFPImmed(bool Is32, unsigned Imm) { 285ac106addSNikolay Haustov assert(Imm >= 240 && Imm <= 248); 286e1818af8STom Stellard // ToDo: case 248: 1/(2*PI) - is allowed only on VI 287e1818af8STom Stellard // ToDo: AMDGPUInstPrinter does not support 1/(2*PI). It consider 1/(2*PI) as 288e1818af8STom Stellard // literal constant. 289ac106addSNikolay Haustov float V = 0.0f; 290e1818af8STom Stellard switch (Imm) { 291ac106addSNikolay Haustov case 240: V = 0.5f; break; 292ac106addSNikolay Haustov case 241: V = -0.5f; break; 293ac106addSNikolay Haustov case 242: V = 1.0f; break; 294ac106addSNikolay Haustov case 243: V = -1.0f; break; 295ac106addSNikolay Haustov case 244: V = 2.0f; break; 296ac106addSNikolay Haustov case 245: V = -2.0f; break; 297ac106addSNikolay Haustov case 246: V = 4.0f; break; 298ac106addSNikolay Haustov case 247: V = -4.0f; break; 299ac106addSNikolay Haustov case 248: return MCOperand::createImm(Is32 ? // 1/(2*PI) 300ac106addSNikolay Haustov 0x3e22f983 : 301ac106addSNikolay Haustov 0x3fc45f306dc9c882); 302ac106addSNikolay Haustov default: break; 303e1818af8STom Stellard } 304ac106addSNikolay Haustov return MCOperand::createImm(Is32? FloatToBits(V) : DoubleToBits(V)); 305e1818af8STom Stellard } 306e1818af8STom Stellard 307ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeSrcOp(bool Is32, unsigned Val) const { 308e1818af8STom Stellard using namespace AMDGPU; 309ac106addSNikolay Haustov assert(Val < 512); // enum9 310ac106addSNikolay Haustov 311ac106addSNikolay Haustov if (Val >= 256) 312ac106addSNikolay Haustov return createRegOperand(Is32 ? VGPR_32RegClassID : VReg_64RegClassID, 313ac106addSNikolay Haustov Val - 256); 314ac106addSNikolay Haustov if (Val <= 101) 315ac106addSNikolay Haustov return createSRegOperand(Is32 ? SGPR_32RegClassID : SGPR_64RegClassID, 316ac106addSNikolay Haustov Val); 317ac106addSNikolay Haustov 318ac106addSNikolay Haustov if (Val >= 128 && Val <= 208) 319ac106addSNikolay Haustov return decodeIntImmed(Val); 320ac106addSNikolay Haustov 321ac106addSNikolay Haustov if (Val >= 240 && Val <= 248) 322ac106addSNikolay Haustov return decodeFPImmed(Is32, Val); 323ac106addSNikolay Haustov 324ac106addSNikolay Haustov if (Val == 255) 325ac106addSNikolay Haustov return decodeLiteralConstant(); 326ac106addSNikolay Haustov 327ac106addSNikolay Haustov return Is32 ? decodeSpecialReg32(Val) : decodeSpecialReg64(Val); 328ac106addSNikolay Haustov } 329ac106addSNikolay Haustov 330ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeSpecialReg32(unsigned Val) const { 331ac106addSNikolay Haustov using namespace AMDGPU; 332e1818af8STom Stellard switch (Val) { 333ac106addSNikolay Haustov case 102: return createRegOperand(getMCReg(FLAT_SCR_LO, STI)); 334ac106addSNikolay Haustov case 103: return createRegOperand(getMCReg(FLAT_SCR_HI, STI)); 335e1818af8STom Stellard // ToDo: no support for xnack_mask_lo/_hi register 336e1818af8STom Stellard case 104: 337ac106addSNikolay Haustov case 105: break; 338ac106addSNikolay Haustov case 106: return createRegOperand(VCC_LO); 339ac106addSNikolay Haustov case 107: return createRegOperand(VCC_HI); 340e1818af8STom Stellard // ToDo: no support for tba_lo/_hi register 341e1818af8STom Stellard case 108: 342ac106addSNikolay Haustov case 109: break; 343e1818af8STom Stellard // ToDo: no support for tma_lo/_hi register 344e1818af8STom Stellard case 110: 345ac106addSNikolay Haustov case 111: break; 346e1818af8STom Stellard // ToDo: no support for ttmp[0:11] register 347e1818af8STom Stellard case 112: 348e1818af8STom Stellard case 113: 349e1818af8STom Stellard case 114: 350e1818af8STom Stellard case 115: 351e1818af8STom Stellard case 116: 352e1818af8STom Stellard case 117: 353e1818af8STom Stellard case 118: 354e1818af8STom Stellard case 119: 355e1818af8STom Stellard case 120: 356e1818af8STom Stellard case 121: 357e1818af8STom Stellard case 122: 358ac106addSNikolay Haustov case 123: break; 359ac106addSNikolay Haustov case 124: return createRegOperand(M0); 360ac106addSNikolay Haustov case 126: return createRegOperand(EXEC_LO); 361ac106addSNikolay Haustov case 127: return createRegOperand(EXEC_HI); 362e1818af8STom Stellard // ToDo: no support for vccz register 363ac106addSNikolay Haustov case 251: break; 364e1818af8STom Stellard // ToDo: no support for execz register 365ac106addSNikolay Haustov case 252: break; 366ac106addSNikolay Haustov case 253: return createRegOperand(SCC); 367ac106addSNikolay Haustov default: break; 368e1818af8STom Stellard } 369ac106addSNikolay Haustov return errOperand(Val, "unknown operand encoding " + Twine(Val)); 370e1818af8STom Stellard } 371e1818af8STom Stellard 372ac106addSNikolay Haustov MCOperand AMDGPUDisassembler::decodeSpecialReg64(unsigned Val) const { 373161a158eSNikolay Haustov using namespace AMDGPU; 374161a158eSNikolay Haustov switch (Val) { 375ac106addSNikolay Haustov case 102: return createRegOperand(getMCReg(FLAT_SCR, STI)); 376ac106addSNikolay Haustov case 106: return createRegOperand(VCC); 377ac106addSNikolay Haustov case 126: return createRegOperand(EXEC); 378ac106addSNikolay Haustov default: break; 379161a158eSNikolay Haustov } 380ac106addSNikolay Haustov return errOperand(Val, "unknown operand encoding " + Twine(Val)); 381161a158eSNikolay Haustov } 382161a158eSNikolay Haustov 383e1818af8STom Stellard static MCDisassembler *createAMDGPUDisassembler(const Target &T, 384e1818af8STom Stellard const MCSubtargetInfo &STI, 385e1818af8STom Stellard MCContext &Ctx) { 386e1818af8STom Stellard return new AMDGPUDisassembler(STI, Ctx); 387e1818af8STom Stellard } 388e1818af8STom Stellard 389e1818af8STom Stellard extern "C" void LLVMInitializeAMDGPUDisassembler() { 390e1818af8STom Stellard TargetRegistry::RegisterMCDisassembler(TheGCNTarget, createAMDGPUDisassembler); 391e1818af8STom Stellard } 392