diff options
author | quic_hchandel <165007698+hchandel@users.noreply.github.com> | 2025-01-23 10:14:25 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-23 10:14:25 +0530 |
commit | 163935a48df69bde944fae2b4581541dab30c730 (patch) | |
tree | 245858613552f5c5c31219ce7fcd5b3a96f5b7af /llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp | |
parent | aa273fd83eccb55215f4cb18285f8462a1013f5c (diff) | |
download | llvm-163935a48df69bde944fae2b4581541dab30c730.zip llvm-163935a48df69bde944fae2b4581541dab30c730.tar.gz llvm-163935a48df69bde944fae2b4581541dab30c730.tar.bz2 |
[RISCV] Add Qualcomm uC Xqcilo (Large Offset Load Store) extension (#123881)
This extension adds eight 48 bit load store instructions.
The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest
This patch adds assembler only support.
---------
Co-authored-by: Harsh Chandel <hchandel@qti.qualcomm.com>
Diffstat (limited to 'llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp')
-rw-r--r-- | llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp index 971ef90..a0b87f7 100644 --- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp +++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp @@ -45,6 +45,10 @@ public: private: void addSPOperands(MCInst &MI) const; + DecodeStatus getInstruction48(MCInst &Instr, uint64_t &Size, + ArrayRef<uint8_t> Bytes, uint64_t Address, + raw_ostream &CStream) const; + DecodeStatus getInstruction32(MCInst &Instr, uint64_t &Size, ArrayRef<uint8_t> Bytes, uint64_t Address, raw_ostream &CStream) const; @@ -745,6 +749,27 @@ DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size, return MCDisassembler::Fail; } +DecodeStatus RISCVDisassembler::getInstruction48(MCInst &MI, uint64_t &Size, + ArrayRef<uint8_t> Bytes, + uint64_t Address, + raw_ostream &CS) const { + if (Bytes.size() < 6) { + Size = 0; + return MCDisassembler::Fail; + } + Size = 6; + + uint64_t Insn = 0; + for (size_t i = Size; i-- != 0;) { + Insn += (static_cast<uint64_t>(Bytes[i]) << 8 * i); + } + TRY_TO_DECODE_FEATURE( + RISCV::FeatureVendorXqcilo, DecoderTableXqcilo48, + "Qualcomm uC Large Offset Load Store custom 48bit opcode table"); + + return MCDisassembler::Fail; +} + DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size, ArrayRef<uint8_t> Bytes, uint64_t Address, @@ -760,8 +785,7 @@ DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size, // 48-bit instructions are encoded as 0bxx011111. if ((Bytes[0] & 0b11'1111) == 0b01'1111) { - Size = Bytes.size() >= 6 ? 6 : 0; - return MCDisassembler::Fail; + return getInstruction48(MI, Size, Bytes, Address, CS); } // 64-bit instructions are encoded as 0x0111111. |