|
38 | 38 | #include "llvm/Support/Compiler.h" |
39 | 39 |
|
40 | 40 | using namespace llvm; |
| 41 | +using namespace llvm::MCD; |
41 | 42 |
|
42 | 43 | #define DEBUG_TYPE "amdgpu-disassembler" |
43 | 44 |
|
@@ -446,6 +447,14 @@ static DecodeStatus decodeVersionImm(MCInst &Inst, unsigned Imm, |
446 | 447 |
|
447 | 448 | #include "AMDGPUGenDisassemblerTables.inc" |
448 | 449 |
|
| 450 | +// Define bitwidths for various types used to instantiate the decoder. |
| 451 | +template <> static constexpr uint32_t llvm::MCD::InsnBitWidth<uint32_t> = 32; |
| 452 | +template <> static constexpr uint32_t llvm::MCD::InsnBitWidth<uint64_t> = 64; |
| 453 | +template <> |
| 454 | +static constexpr uint32_t llvm::MCD::InsnBitWidth<std::bitset<96>> = 96; |
| 455 | +template <> |
| 456 | +static constexpr uint32_t llvm::MCD::InsnBitWidth<std::bitset<128>> = 128; |
| 457 | + |
449 | 458 | //===----------------------------------------------------------------------===// |
450 | 459 | // |
451 | 460 | //===----------------------------------------------------------------------===// |
@@ -498,26 +507,24 @@ template <typename T> static inline T eatBytes(ArrayRef<uint8_t>& Bytes) { |
498 | 507 | return Res; |
499 | 508 | } |
500 | 509 |
|
501 | | -static inline DecoderUInt128 eat12Bytes(ArrayRef<uint8_t> &Bytes) { |
| 510 | +static inline std::bitset<96> eat12Bytes(ArrayRef<uint8_t> &Bytes) { |
| 511 | + using namespace llvm::support::endian; |
502 | 512 | assert(Bytes.size() >= 12); |
503 | | - uint64_t Lo = |
504 | | - support::endian::read<uint64_t, llvm::endianness::little>(Bytes.data()); |
| 513 | + std::bitset<96> Lo(read<uint64_t, endianness::little>(Bytes.data())); |
505 | 514 | Bytes = Bytes.slice(8); |
506 | | - uint64_t Hi = |
507 | | - support::endian::read<uint32_t, llvm::endianness::little>(Bytes.data()); |
| 515 | + std::bitset<96> Hi(read<uint32_t, endianness::little>(Bytes.data())); |
508 | 516 | Bytes = Bytes.slice(4); |
509 | | - return DecoderUInt128(Lo, Hi); |
| 517 | + return (Hi << 64) | Lo; |
510 | 518 | } |
511 | 519 |
|
512 | | -static inline DecoderUInt128 eat16Bytes(ArrayRef<uint8_t> &Bytes) { |
| 520 | +static inline std::bitset<128> eat16Bytes(ArrayRef<uint8_t> &Bytes) { |
| 521 | + using namespace llvm::support::endian; |
513 | 522 | assert(Bytes.size() >= 16); |
514 | | - uint64_t Lo = |
515 | | - support::endian::read<uint64_t, llvm::endianness::little>(Bytes.data()); |
| 523 | + std::bitset<128> Lo(read<uint64_t, endianness::little>(Bytes.data())); |
516 | 524 | Bytes = Bytes.slice(8); |
517 | | - uint64_t Hi = |
518 | | - support::endian::read<uint64_t, llvm::endianness::little>(Bytes.data()); |
| 525 | + std::bitset<128> Hi(read<uint64_t, endianness::little>(Bytes.data())); |
519 | 526 | Bytes = Bytes.slice(8); |
520 | | - return DecoderUInt128(Lo, Hi); |
| 527 | + return (Hi << 64) | Lo; |
521 | 528 | } |
522 | 529 |
|
523 | 530 | void AMDGPUDisassembler::decodeImmOperands(MCInst &MI, |
@@ -600,14 +607,14 @@ DecodeStatus AMDGPUDisassembler::getInstruction(MCInst &MI, uint64_t &Size, |
600 | 607 | // Try to decode DPP and SDWA first to solve conflict with VOP1 and VOP2 |
601 | 608 | // encodings |
602 | 609 | if (isGFX1250() && Bytes.size() >= 16) { |
603 | | - DecoderUInt128 DecW = eat16Bytes(Bytes); |
| 610 | + std::bitset<128> DecW = eat16Bytes(Bytes); |
604 | 611 | if (tryDecodeInst(DecoderTableGFX1250128, MI, DecW, Address, CS)) |
605 | 612 | break; |
606 | 613 | Bytes = Bytes_.slice(0, MaxInstBytesNum); |
607 | 614 | } |
608 | 615 |
|
609 | 616 | if (isGFX11Plus() && Bytes.size() >= 12) { |
610 | | - DecoderUInt128 DecW = eat12Bytes(Bytes); |
| 617 | + std::bitset<96> DecW = eat12Bytes(Bytes); |
611 | 618 |
|
612 | 619 | if (isGFX11() && |
613 | 620 | tryDecodeInst(DecoderTableGFX1196, DecoderTableGFX11_FAKE1696, MI, |
@@ -642,7 +649,7 @@ DecodeStatus AMDGPUDisassembler::getInstruction(MCInst &MI, uint64_t &Size, |
642 | 649 |
|
643 | 650 | } else if (Bytes.size() >= 16 && |
644 | 651 | STI.hasFeature(AMDGPU::FeatureGFX950Insts)) { |
645 | | - DecoderUInt128 DecW = eat16Bytes(Bytes); |
| 652 | + std::bitset<128> DecW = eat16Bytes(Bytes); |
646 | 653 | if (tryDecodeInst(DecoderTableGFX940128, MI, DecW, Address, CS)) |
647 | 654 | break; |
648 | 655 |
|
|
0 commit comments