blob: 273089de4dba4676fd0acae4aa234a9e593a8f77 [file] [log] [blame]
Tom Stellarde1818af2016-02-18 03:42:32 +00001//===-- 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
21namespace llvm {
22
23 class MCContext;
24 class MCInst;
25 class MCSubtargetInfo;
26
27 class AMDGPUDisassembler : public MCDisassembler {
Nikolay Haustov161a1582016-02-25 16:09:14 +000028 private:
29 /// true if 32-bit literal constant is placed after instruction
30 mutable bool HasLiteral;
31 mutable ArrayRef<uint8_t> Bytes;
32
Tom Stellarde1818af2016-02-18 03:42:32 +000033 public:
34 AMDGPUDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) :
Nikolay Haustov161a1582016-02-25 16:09:14 +000035 MCDisassembler(STI, Ctx), HasLiteral(false) {}
Tom Stellarde1818af2016-02-18 03:42:32 +000036
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 Haustov161a1582016-02-25 16:09:14 +000043 /// Decode inline float value in SRC field
44 DecodeStatus DecodeImmedFloat(unsigned Imm, uint32_t &F) const;
45 /// Decode inline double value in SRC field
46 DecodeStatus DecodeImmedDouble(unsigned Imm, uint64_t &D) const;
47 /// Decode inline integer value in SRC field
48 DecodeStatus DecodeImmedInteger(unsigned Imm, int64_t &I) const;
Tom Stellarde1818af2016-02-18 03:42:32 +000049 /// Decode VGPR register
Nikolay Haustov161a1582016-02-25 16:09:14 +000050 DecodeStatus DecodeVgprRegister(unsigned Val, unsigned &RegID,
51 unsigned Size = 32) const;
Tom Stellarde1818af2016-02-18 03:42:32 +000052 /// Decode SGPR register
Nikolay Haustov161a1582016-02-25 16:09:14 +000053 DecodeStatus DecodeSgprRegister(unsigned Val, unsigned &RegID,
54 unsigned Size = 32) const;
55 /// Decode 32-bit register in SRC field
56 DecodeStatus DecodeSrc32Register(unsigned Val, unsigned &RegID) const;
57 /// Decode 64-bit register in SRC field
58 DecodeStatus DecodeSrc64Register(unsigned Val, unsigned &RegID) const;
Tom Stellarde1818af2016-02-18 03:42:32 +000059
Nikolay Haustov161a1582016-02-25 16:09:14 +000060 /// Decode literal constant after instruction
61 DecodeStatus DecodeLiteralConstant(MCInst &Inst, uint64_t &Literal) const;
62
63 DecodeStatus DecodeVGPR_32RegisterClass(MCInst &Inst, unsigned Imm,
64 uint64_t Addr) const;
65
66 DecodeStatus DecodeVSRegisterClass(MCInst &Inst, unsigned Imm,
67 uint64_t Addr, bool Is32) const;
68
69 DecodeStatus DecodeVS_32RegisterClass(MCInst &Inst, unsigned Imm,
Tom Stellarde1818af2016-02-18 03:42:32 +000070 uint64_t Addr) const;
71
Nikolay Haustov161a1582016-02-25 16:09:14 +000072 DecodeStatus DecodeVS_64RegisterClass(MCInst &Inst, unsigned Imm,
73 uint64_t Addr) const;
74
75 DecodeStatus DecodeVReg_64RegisterClass(MCInst &Inst, unsigned Imm,
Tom Stellarde1818af2016-02-18 03:42:32 +000076 uint64_t Addr) const;
77 };
78} // namespace llvm
79
Nikolay Haustov161a1582016-02-25 16:09:14 +000080#endif // LLVM_LIB_TARGET_AMDGPU_DISASSEMBLER_AMDGPUDISASSEMBLER_H