blob: 1856a4ef94e383ee3da1be5bd2bb41a40dbbea66 [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
Mehdi Aminib550cb12016-04-18 09:17:29 +000019#include "llvm/ADT/ArrayRef.h"
Tom Stellarde1818af2016-02-18 03:42:32 +000020#include "llvm/MC/MCDisassembler/MCDisassembler.h"
21
22namespace llvm {
23
24 class MCContext;
25 class MCInst;
Nikolay Haustovac106ad2016-03-01 13:57:29 +000026 class MCOperand;
Tom Stellarde1818af2016-02-18 03:42:32 +000027 class MCSubtargetInfo;
Nikolay Haustovac106ad2016-03-01 13:57:29 +000028 class Twine;
Tom Stellarde1818af2016-02-18 03:42:32 +000029
30 class AMDGPUDisassembler : public MCDisassembler {
Nikolay Haustov161a1582016-02-25 16:09:14 +000031 private:
Nikolay Haustov161a1582016-02-25 16:09:14 +000032 mutable ArrayRef<uint8_t> Bytes;
33
Tom Stellarde1818af2016-02-18 03:42:32 +000034 public:
35 AMDGPUDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) :
Nikolay Haustovac106ad2016-03-01 13:57:29 +000036 MCDisassembler(STI, Ctx) {}
Tom Stellarde1818af2016-02-18 03:42:32 +000037
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 Haustovac106ad2016-03-01 13:57:29 +000044 const char* getRegClassName(unsigned RegClassID) const;
Tom Stellarde1818af2016-02-18 03:42:32 +000045
Nikolay Haustovac106ad2016-03-01 13:57:29 +000046 MCOperand createRegOperand(unsigned int RegId) const;
47 MCOperand createRegOperand(unsigned RegClassID, unsigned Val) const;
48 MCOperand createSRegOperand(unsigned SRegClassID, unsigned Val) const;
Nikolay Haustov161a1582016-02-25 16:09:14 +000049
Nikolay Haustovac106ad2016-03-01 13:57:29 +000050 MCOperand errOperand(unsigned V, const llvm::Twine& ErrMsg) const;
Nikolay Haustov161a1582016-02-25 16:09:14 +000051
Nikolay Haustovac106ad2016-03-01 13:57:29 +000052 DecodeStatus tryDecodeInst(const uint8_t* Table,
53 MCInst &MI,
54 uint64_t Inst,
55 uint64_t Address) const;
Nikolay Haustov161a1582016-02-25 16:09:14 +000056
Nikolay Haustovac106ad2016-03-01 13:57:29 +000057 MCOperand decodeOperand_VGPR_32(unsigned Val) const;
58 MCOperand decodeOperand_VS_32(unsigned Val) const;
59 MCOperand decodeOperand_VS_64(unsigned Val) const;
Tom Stellarde1818af2016-02-18 03:42:32 +000060
Nikolay Haustovac106ad2016-03-01 13:57:29 +000061 MCOperand decodeOperand_VReg_64(unsigned Val) const;
62 MCOperand decodeOperand_VReg_96(unsigned Val) const;
63 MCOperand decodeOperand_VReg_128(unsigned Val) const;
Nikolay Haustov161a1582016-02-25 16:09:14 +000064
Nikolay Haustovac106ad2016-03-01 13:57:29 +000065 MCOperand decodeOperand_SReg_32(unsigned Val) const;
Artem Tamazov38e496b2016-04-29 17:04:50 +000066 MCOperand decodeOperand_SReg_32_XM0(unsigned Val) const;
Nikolay Haustovac106ad2016-03-01 13:57:29 +000067 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 Stellarde1818af2016-02-18 03:42:32 +000081 };
82} // namespace llvm
83
Nikolay Haustovac106ad2016-03-01 13:57:29 +000084#endif //LLVM_LIB_TARGET_AMDGPU_DISASSEMBLER_AMDGPUDISASSEMBLER_H