Tom Stellard | e1818af | 2016-02-18 03:42:32 +0000 | [diff] [blame] | 1 | //===-- AMDGPUDisassembler.hpp - Disassembler for AMDGPU ISA ---*- C++ -*--===// |
| 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 | /// \file |
| 11 | /// |
| 12 | /// This file contains declaration for AMDGPU ISA disassembler |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #ifndef LLVM_LIB_TARGET_AMDGPU_DISASSEMBLER_AMDGPUDISASSEMBLER_H |
| 17 | #define LLVM_LIB_TARGET_AMDGPU_DISASSEMBLER_AMDGPUDISASSEMBLER_H |
| 18 | |
| 19 | #include "llvm/MC/MCDisassembler/MCDisassembler.h" |
| 20 | |
| 21 | namespace llvm { |
| 22 | |
| 23 | class MCContext; |
| 24 | class MCInst; |
Nikolay Haustov | ac106ad | 2016-03-01 13:57:29 +0000 | [diff] [blame] | 25 | class MCOperand; |
Tom Stellard | e1818af | 2016-02-18 03:42:32 +0000 | [diff] [blame] | 26 | class MCSubtargetInfo; |
Nikolay Haustov | ac106ad | 2016-03-01 13:57:29 +0000 | [diff] [blame] | 27 | class Twine; |
Tom Stellard | e1818af | 2016-02-18 03:42:32 +0000 | [diff] [blame] | 28 | |
| 29 | class AMDGPUDisassembler : public MCDisassembler { |
Nikolay Haustov | 161a158 | 2016-02-25 16:09:14 +0000 | [diff] [blame] | 30 | private: |
Nikolay Haustov | 161a158 | 2016-02-25 16:09:14 +0000 | [diff] [blame] | 31 | mutable ArrayRef<uint8_t> Bytes; |
| 32 | |
Tom Stellard | e1818af | 2016-02-18 03:42:32 +0000 | [diff] [blame] | 33 | public: |
| 34 | AMDGPUDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) : |
Nikolay Haustov | ac106ad | 2016-03-01 13:57:29 +0000 | [diff] [blame] | 35 | MCDisassembler(STI, Ctx) {} |
Tom Stellard | e1818af | 2016-02-18 03:42:32 +0000 | [diff] [blame] | 36 | |
| 37 | ~AMDGPUDisassembler() {} |
| 38 | |
| 39 | DecodeStatus getInstruction(MCInst &MI, uint64_t &Size, |
| 40 | ArrayRef<uint8_t> Bytes, uint64_t Address, |
| 41 | raw_ostream &WS, raw_ostream &CS) const override; |
| 42 | |
Nikolay Haustov | ac106ad | 2016-03-01 13:57:29 +0000 | [diff] [blame] | 43 | const char* getRegClassName(unsigned RegClassID) const; |
Tom Stellard | e1818af | 2016-02-18 03:42:32 +0000 | [diff] [blame] | 44 | |
Nikolay Haustov | ac106ad | 2016-03-01 13:57:29 +0000 | [diff] [blame] | 45 | MCOperand createRegOperand(unsigned int RegId) const; |
| 46 | MCOperand createRegOperand(unsigned RegClassID, unsigned Val) const; |
| 47 | MCOperand createSRegOperand(unsigned SRegClassID, unsigned Val) const; |
Nikolay Haustov | 161a158 | 2016-02-25 16:09:14 +0000 | [diff] [blame] | 48 | |
Nikolay Haustov | ac106ad | 2016-03-01 13:57:29 +0000 | [diff] [blame] | 49 | MCOperand errOperand(unsigned V, const llvm::Twine& ErrMsg) const; |
Nikolay Haustov | 161a158 | 2016-02-25 16:09:14 +0000 | [diff] [blame] | 50 | |
Nikolay Haustov | ac106ad | 2016-03-01 13:57:29 +0000 | [diff] [blame] | 51 | DecodeStatus tryDecodeInst(const uint8_t* Table, |
| 52 | MCInst &MI, |
| 53 | uint64_t Inst, |
| 54 | uint64_t Address) const; |
Nikolay Haustov | 161a158 | 2016-02-25 16:09:14 +0000 | [diff] [blame] | 55 | |
Nikolay Haustov | ac106ad | 2016-03-01 13:57:29 +0000 | [diff] [blame] | 56 | MCOperand decodeOperand_VGPR_32(unsigned Val) const; |
| 57 | MCOperand decodeOperand_VS_32(unsigned Val) const; |
| 58 | MCOperand decodeOperand_VS_64(unsigned Val) const; |
Tom Stellard | e1818af | 2016-02-18 03:42:32 +0000 | [diff] [blame] | 59 | |
Nikolay Haustov | ac106ad | 2016-03-01 13:57:29 +0000 | [diff] [blame] | 60 | MCOperand decodeOperand_VReg_64(unsigned Val) const; |
| 61 | MCOperand decodeOperand_VReg_96(unsigned Val) const; |
| 62 | MCOperand decodeOperand_VReg_128(unsigned Val) const; |
Nikolay Haustov | 161a158 | 2016-02-25 16:09:14 +0000 | [diff] [blame] | 63 | |
Nikolay Haustov | ac106ad | 2016-03-01 13:57:29 +0000 | [diff] [blame] | 64 | MCOperand decodeOperand_SGPR_32(unsigned Val) const; |
| 65 | MCOperand decodeOperand_SReg_32(unsigned Val) const; |
| 66 | MCOperand decodeOperand_SReg_64(unsigned Val) const; |
| 67 | MCOperand decodeOperand_SReg_128(unsigned Val) const; |
| 68 | MCOperand decodeOperand_SReg_256(unsigned Val) const; |
| 69 | MCOperand decodeOperand_SReg_512(unsigned Val) const; |
| 70 | |
| 71 | enum { OP32 = true, OP64 = false }; |
| 72 | |
| 73 | static MCOperand decodeIntImmed(unsigned Imm); |
| 74 | static MCOperand decodeFPImmed(bool Is32, unsigned Imm); |
| 75 | MCOperand decodeLiteralConstant() const; |
| 76 | |
| 77 | MCOperand decodeSrcOp(bool Is32, unsigned Val) const; |
| 78 | MCOperand decodeSpecialReg32(unsigned Val) const; |
| 79 | MCOperand decodeSpecialReg64(unsigned Val) const; |
Tom Stellard | e1818af | 2016-02-18 03:42:32 +0000 | [diff] [blame] | 80 | }; |
| 81 | } // namespace llvm |
| 82 | |
Nikolay Haustov | ac106ad | 2016-03-01 13:57:29 +0000 | [diff] [blame] | 83 | #endif //LLVM_LIB_TARGET_AMDGPU_DISASSEMBLER_AMDGPUDISASSEMBLER_H |