diff options
author | Sam Kolton <Sam.Kolton@amd.com> | 2016-03-31 14:15:04 +0000 |
---|---|---|
committer | Sam Kolton <Sam.Kolton@amd.com> | 2016-03-31 14:15:04 +0000 |
commit | 1048fb1818c6293492d8b1066c0e4df95813c0e0 (patch) | |
tree | 317d1a9ad51f750d5a37650edb191f20df06eee5 /llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp | |
parent | dc0602a2c20a3f514541165a19cb1534597c5dc6 (diff) | |
download | llvm-1048fb1818c6293492d8b1066c0e4df95813c0e0.zip llvm-1048fb1818c6293492d8b1066c0e4df95813c0e0.tar.gz llvm-1048fb1818c6293492d8b1066c0e4df95813c0e0.tar.bz2 |
[AMDGPU] Disassembler: support for DPP
Review: http://reviews.llvm.org/D18642
llvm-svn: 265015
Diffstat (limited to 'llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp')
-rw-r--r-- | llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp index a3c5866..2990b57 100644 --- a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp +++ b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp @@ -83,10 +83,10 @@ DECODE_OPERAND(SReg_512) // //===----------------------------------------------------------------------===// -static inline uint32_t eatB32(ArrayRef<uint8_t>& Bytes) { - assert(Bytes.size() >= sizeof eatB32(Bytes)); - const auto Res = support::endian::read32le(Bytes.data()); - Bytes = Bytes.slice(sizeof Res); +template <typename T> static inline T eatBytes(ArrayRef<uint8_t>& Bytes) { + assert(Bytes.size() >= sizeof(T)); + const auto Res = support::endian::read<T, support::endianness::little>(Bytes.data()); + Bytes = Bytes.slice(sizeof(T)); return Res; } @@ -123,8 +123,20 @@ DecodeStatus AMDGPUDisassembler::getInstruction(MCInst &MI, uint64_t &Size, do { // ToDo: better to switch encoding length using some bit predicate // but it is unknown yet, so try all we can + + // Try to decode DPP first to solve conflict with VOP1 and VOP2 encodings + if (Bytes.size() >= 8) { + const uint64_t QW = eatBytes<uint64_t>(Bytes); + Res = tryDecodeInst(DecoderTableDPP64, MI, QW, Address); + if (Res) break; + } + + // Reinitialize Bytes as DPP64 could have eaten too much + Bytes = Bytes_.slice(0, MaxInstBytesNum); + + // Try decode 32-bit instruction if (Bytes.size() < 4) break; - const uint32_t DW = eatB32(Bytes); + const uint32_t DW = eatBytes<uint32_t>(Bytes); Res = tryDecodeInst(DecoderTableVI32, MI, DW, Address); if (Res) break; @@ -132,7 +144,7 @@ DecodeStatus AMDGPUDisassembler::getInstruction(MCInst &MI, uint64_t &Size, if (Res) break; if (Bytes.size() < 4) break; - const uint64_t QW = ((uint64_t)eatB32(Bytes) << 32) | DW; + const uint64_t QW = ((uint64_t)eatBytes<uint32_t>(Bytes) << 32) | DW; Res = tryDecodeInst(DecoderTableVI64, MI, QW, Address); if (Res) break; @@ -261,7 +273,7 @@ MCOperand AMDGPUDisassembler::decodeLiteralConstant() const { if (Bytes.size() < 4) return errOperand(0, "cannot read literal, inst bytes left " + Twine(Bytes.size())); - return MCOperand::createImm(eatB32(Bytes)); + return MCOperand::createImm(eatBytes<uint32_t>(Bytes)); } MCOperand AMDGPUDisassembler::decodeIntImmed(unsigned Imm) { |