aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-07-04 19:20:19 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-04-09 14:54:45 +0000
commit255d6c9fe5a7577c6caf78004034f2555bd0cba0 (patch)
treeb5136fa6092bd88d67f3f8e83405ec6fe0144c66 /contrib/llvm-project/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h
parenta0b3fbe4ccb6961765d2325bb2ecae6ff2111102 (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h')
-rw-r--r--contrib/llvm-project/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h87
1 files changed, 83 insertions, 4 deletions
diff --git a/contrib/llvm-project/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h b/contrib/llvm-project/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h
index eea6074d5281..31869f0917ae 100644
--- a/contrib/llvm-project/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h
+++ b/contrib/llvm-project/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.h
@@ -15,8 +15,10 @@
#ifndef LLVM_LIB_TARGET_AMDGPU_DISASSEMBLER_AMDGPUDISASSEMBLER_H
#define LLVM_LIB_TARGET_AMDGPU_DISASSEMBLER_AMDGPUDISASSEMBLER_H
+#include "llvm/ADT/APInt.h"
#include "llvm/MC/MCDisassembler/MCDisassembler.h"
#include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCInst.h"
#include "llvm/Support/DataExtractor.h"
#include <memory>
@@ -27,6 +29,60 @@ class MCOperand;
class MCSubtargetInfo;
class Twine;
+// Exposes an interface expected by autogenerated code in
+// FixedLenDecoderEmitter
+class DecoderUInt128 {
+private:
+ uint64_t Lo = 0;
+ uint64_t Hi = 0;
+
+public:
+ DecoderUInt128() = default;
+ DecoderUInt128(uint64_t Lo, uint64_t Hi = 0) : Lo(Lo), Hi(Hi) {}
+ operator bool() const { return Lo || Hi; }
+ void insertBits(uint64_t SubBits, unsigned BitPosition, unsigned NumBits) {
+ assert(NumBits && NumBits <= 64);
+ assert(SubBits >> 1 >> (NumBits - 1) == 0);
+ assert(BitPosition < 128);
+ if (BitPosition < 64) {
+ Lo |= SubBits << BitPosition;
+ Hi |= SubBits >> 1 >> (63 - BitPosition);
+ } else {
+ Hi |= SubBits << (BitPosition - 64);
+ }
+ }
+ uint64_t extractBitsAsZExtValue(unsigned NumBits,
+ unsigned BitPosition) const {
+ assert(NumBits && NumBits <= 64);
+ assert(BitPosition < 128);
+ uint64_t Val;
+ if (BitPosition < 64)
+ Val = Lo >> BitPosition | Hi << 1 << (63 - BitPosition);
+ else
+ Val = Hi >> (BitPosition - 64);
+ return Val & ((uint64_t(2) << (NumBits - 1)) - 1);
+ }
+ DecoderUInt128 operator&(const DecoderUInt128 &RHS) const {
+ return DecoderUInt128(Lo & RHS.Lo, Hi & RHS.Hi);
+ }
+ DecoderUInt128 operator&(const uint64_t &RHS) const {
+ return *this & DecoderUInt128(RHS);
+ }
+ DecoderUInt128 operator~() const { return DecoderUInt128(~Lo, ~Hi); }
+ bool operator==(const DecoderUInt128 &RHS) {
+ return Lo == RHS.Lo && Hi == RHS.Hi;
+ }
+ bool operator!=(const DecoderUInt128 &RHS) {
+ return Lo != RHS.Lo || Hi != RHS.Hi;
+ }
+ bool operator!=(const int &RHS) {
+ return *this != DecoderUInt128(RHS);
+ }
+ friend raw_ostream &operator<<(raw_ostream &OS, const DecoderUInt128 &RHS) {
+ return OS << APInt(128, {RHS.Lo, RHS.Hi});
+ }
+};
+
//===----------------------------------------------------------------------===//
// AMDGPUDisassembler
//===----------------------------------------------------------------------===//
@@ -57,8 +113,21 @@ public:
MCOperand errOperand(unsigned V, const Twine& ErrMsg) const;
- DecodeStatus tryDecodeInst(const uint8_t* Table, MCInst &MI, uint64_t Inst,
- uint64_t Address) const;
+ template <typename InsnType>
+ DecodeStatus tryDecodeInst(const uint8_t *Table, MCInst &MI, InsnType Inst,
+ uint64_t Address) const {
+ assert(MI.getOpcode() == 0);
+ assert(MI.getNumOperands() == 0);
+ MCInst TmpInst;
+ HasLiteral = false;
+ const auto SavedBytes = Bytes;
+ if (decodeInstruction(Table, TmpInst, Inst, Address, this, STI)) {
+ MI = TmpInst;
+ return MCDisassembler::Success;
+ }
+ Bytes = SavedBytes;
+ return MCDisassembler::Fail;
+ }
Optional<DecodeStatus> onSymbolStart(SymbolInfoTy &Symbol, uint64_t &Size,
ArrayRef<uint8_t> Bytes,
@@ -87,10 +156,14 @@ public:
DecodeStatus decodeCOMPUTE_PGM_RSRC2(uint32_t FourByteBuffer,
raw_string_ostream &KdStream) const;
+ DecodeStatus convertEXPInst(MCInst &MI) const;
+ DecodeStatus convertVINTERPInst(MCInst &MI) const;
DecodeStatus convertFMAanyK(MCInst &MI, int ImmLitIdx) const;
DecodeStatus convertSDWAInst(MCInst &MI) const;
DecodeStatus convertDPP8Inst(MCInst &MI) const;
DecodeStatus convertMIMGInst(MCInst &MI) const;
+ DecodeStatus convertVOP3PDPPInst(MCInst &MI) const;
+ DecodeStatus convertVOPCDPPInst(MCInst &MI) const;
MCOperand decodeOperand_VGPR_32(unsigned Val) const;
MCOperand decodeOperand_VRegOrLds_32(unsigned Val) const;
@@ -127,6 +200,9 @@ public:
MCOperand decodeOperand_AReg_1024(unsigned Val) const;
MCOperand decodeOperand_AV_32(unsigned Val) const;
MCOperand decodeOperand_AV_64(unsigned Val) const;
+ MCOperand decodeOperand_AV_128(unsigned Val) const;
+ MCOperand decodeOperand_AVDst_128(unsigned Val) const;
+ MCOperand decodeOperand_AVDst_512(unsigned Val) const;
enum OpWidthTy {
OPW32,
@@ -157,6 +233,7 @@ public:
MCOperand decodeSrcOp(const OpWidthTy Width, unsigned Val,
bool MandatoryLiteral = false) const;
MCOperand decodeDstOp(const OpWidthTy Width, unsigned Val) const;
+ MCOperand decodeVOPDDstYOp(MCInst &Inst, unsigned Val) const;
MCOperand decodeSpecialReg32(unsigned Val) const;
MCOperand decodeSpecialReg64(unsigned Val) const;
@@ -177,6 +254,8 @@ public:
bool isGFX9Plus() const;
bool isGFX10() const;
bool isGFX10Plus() const;
+ bool isGFX11() const;
+ bool isGFX11Plus() const;
bool hasArchitectedFlatScratch() const;
};
@@ -196,8 +275,8 @@ public:
: MCSymbolizer(Ctx, std::move(RelInfo)), DisInfo(disInfo) {}
bool tryAddingSymbolicOperand(MCInst &Inst, raw_ostream &cStream,
- int64_t Value, uint64_t Address,
- bool IsBranch, uint64_t Offset,
+ int64_t Value, uint64_t Address, bool IsBranch,
+ uint64_t Offset, uint64_t OpSize,
uint64_t InstSize) override;
void tryAddingPcLoadReferenceComment(raw_ostream &cStream,