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