aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h
blob: b9632a3f8765d3384e66191e021372a4fd22ff3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//===-- AMDGPUDisassembler.hpp - Disassembler for AMDGPU ISA ---*- C++ -*--===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
/// \file
///
/// This file contains declaration for AMDGPU ISA disassembler
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIB_TARGET_AMDGPU_DISASSEMBLER_AMDGPUDISASSEMBLER_H
#define LLVM_LIB_TARGET_AMDGPU_DISASSEMBLER_AMDGPUDISASSEMBLER_H

#include "llvm/MC/MCDisassembler/MCDisassembler.h"

namespace llvm {

  class MCContext;
  class MCInst;
  class MCOperand;
  class MCSubtargetInfo;
  class Twine;

  class AMDGPUDisassembler : public MCDisassembler {
  private:
    mutable ArrayRef<uint8_t> Bytes;

  public:
    AMDGPUDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx) :
      MCDisassembler(STI, Ctx) {}

    ~AMDGPUDisassembler() {}

    DecodeStatus getInstruction(MCInst &MI, uint64_t &Size,
                                ArrayRef<uint8_t> Bytes, uint64_t Address,
                                raw_ostream &WS, raw_ostream &CS) const override;

    const char* getRegClassName(unsigned RegClassID) const;

    MCOperand createRegOperand(unsigned int RegId) const;
    MCOperand createRegOperand(unsigned RegClassID, unsigned Val) const;
    MCOperand createSRegOperand(unsigned SRegClassID, unsigned Val) const;

    MCOperand errOperand(unsigned V, const llvm::Twine& ErrMsg) const;

    DecodeStatus tryDecodeInst(const uint8_t* Table,
                               MCInst &MI,
                               uint64_t Inst,
                               uint64_t Address) const;

    MCOperand decodeOperand_VGPR_32(unsigned Val) const;
    MCOperand decodeOperand_VS_32(unsigned Val) const;
    MCOperand decodeOperand_VS_64(unsigned Val) const;

    MCOperand decodeOperand_VReg_64(unsigned Val) const;
    MCOperand decodeOperand_VReg_96(unsigned Val) const;
    MCOperand decodeOperand_VReg_128(unsigned Val) const;

    MCOperand decodeOperand_SGPR_32(unsigned Val) const;
    MCOperand decodeOperand_SReg_32(unsigned Val) const;
    MCOperand decodeOperand_SReg_64(unsigned Val) const;
    MCOperand decodeOperand_SReg_128(unsigned Val) const;
    MCOperand decodeOperand_SReg_256(unsigned Val) const;
    MCOperand decodeOperand_SReg_512(unsigned Val) const;

    enum { OP32 = true, OP64 = false };

    static MCOperand decodeIntImmed(unsigned Imm);
    static MCOperand decodeFPImmed(bool Is32, unsigned Imm);
    MCOperand decodeLiteralConstant() const;

    MCOperand decodeSrcOp(bool Is32, unsigned Val) const;
    MCOperand decodeSpecialReg32(unsigned Val) const;
    MCOperand decodeSpecialReg64(unsigned Val) const;
  };
} // namespace llvm

#endif //LLVM_LIB_TARGET_AMDGPU_DISASSEMBLER_AMDGPUDISASSEMBLER_H