blob: b9632a3f8765d3384e66191e021372a4fd22ff3d [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;
Nikolay Haustovac106ad2016-03-01 13:57:29 +000025 class MCOperand;
Tom Stellarde1818af2016-02-18 03:42:32 +000026 class MCSubtargetInfo;
Nikolay Haustovac106ad2016-03-01 13:57:29 +000027 class Twine;
Tom Stellarde1818af2016-02-18 03:42:32 +000028
29 class AMDGPUDisassembler : public MCDisassembler {
Nikolay Haustov161a1582016-02-25 16:09:14 +000030 private:
Nikolay Haustov161a1582016-02-25 16:09:14 +000031 mutable ArrayRef<uint8_t> Bytes;
32
Tom Stellarde1818af2016-02-18 03:42:32 +000033 public:
34 AMDGPUDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) :
Nikolay Haustovac106ad2016-03-01 13:57:29 +000035 MCDisassembler(STI, Ctx) {}
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 Haustovac106ad2016-03-01 13:57:29 +000043 const char* getRegClassName(unsigned RegClassID) const;
Tom Stellarde1818af2016-02-18 03:42:32 +000044
Nikolay Haustovac106ad2016-03-01 13:57:29 +000045 MCOperand createRegOperand(unsigned int RegId) const;
46 MCOperand createRegOperand(unsigned RegClassID, unsigned Val) const;
47 MCOperand createSRegOperand(unsigned SRegClassID, unsigned Val) const;
Nikolay Haustov161a1582016-02-25 16:09:14 +000048
Nikolay Haustovac106ad2016-03-01 13:57:29 +000049 MCOperand errOperand(unsigned V, const llvm::Twine& ErrMsg) const;
Nikolay Haustov161a1582016-02-25 16:09:14 +000050
Nikolay Haustovac106ad2016-03-01 13:57:29 +000051 DecodeStatus tryDecodeInst(const uint8_t* Table,
52 MCInst &MI,
53 uint64_t Inst,
54 uint64_t Address) const;
Nikolay Haustov161a1582016-02-25 16:09:14 +000055
Nikolay Haustovac106ad2016-03-01 13:57:29 +000056 MCOperand decodeOperand_VGPR_32(unsigned Val) const;
57 MCOperand decodeOperand_VS_32(unsigned Val) const;
58 MCOperand decodeOperand_VS_64(unsigned Val) const;
Tom Stellarde1818af2016-02-18 03:42:32 +000059
Nikolay Haustovac106ad2016-03-01 13:57:29 +000060 MCOperand decodeOperand_VReg_64(unsigned Val) const;
61 MCOperand decodeOperand_VReg_96(unsigned Val) const;
62 MCOperand decodeOperand_VReg_128(unsigned Val) const;
Nikolay Haustov161a1582016-02-25 16:09:14 +000063
Nikolay Haustovac106ad2016-03-01 13:57:29 +000064 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 Stellarde1818af2016-02-18 03:42:32 +000080 };
81} // namespace llvm
82
Nikolay Haustovac106ad2016-03-01 13:57:29 +000083#endif //LLVM_LIB_TARGET_AMDGPU_DISASSEMBLER_AMDGPUDISASSEMBLER_H