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