diff options
Diffstat (limited to 'llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp')
-rw-r--r-- | llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp index b5fc59e..03eb101 100644 --- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp +++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp @@ -168,6 +168,17 @@ static DecodeStatus DecodeGPRPF64RegisterClass(MCInst &Inst, uint32_t RegNo, return MCDisassembler::Success; } +static DecodeStatus DecodeSR07RegisterClass(MCInst &Inst, uint64_t RegNo, + uint64_t Address, + const void *Decoder) { + if (RegNo >= 8) + return MCDisassembler::Fail; + + MCRegister Reg = (RegNo < 2) ? (RegNo + RISCV::X8) : (RegNo - 2 + RISCV::X18); + Inst.addOperand(MCOperand::createReg(Reg)); + return MCDisassembler::Success; +} + static DecodeStatus DecodeVRRegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder) { @@ -370,6 +381,12 @@ static DecodeStatus decodeXTHeadMemPair(MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder); +static DecodeStatus decodeZcmpRlist(MCInst &Inst, unsigned Imm, + uint64_t Address, const void *Decoder); + +static DecodeStatus decodeZcmpSpimm(MCInst &Inst, unsigned Imm, + uint64_t Address, const void *Decoder); + #include "RISCVGenDisassemblerTables.inc" static DecodeStatus decodeRVCInstrRdRs1ImmZero(MCInst &Inst, uint32_t Insn, @@ -456,6 +473,22 @@ static DecodeStatus decodeXTHeadMemPair(MCInst &Inst, uint32_t Insn, return MCDisassembler::Success; } +static DecodeStatus decodeZcmpRlist(MCInst &Inst, unsigned Imm, + uint64_t Address, const void *Decoder) { + if (Imm <= 3) + return MCDisassembler::Fail; + Inst.addOperand(MCOperand::createImm(Imm)); + return MCDisassembler::Success; +} + +// spimm is based on rlist now. +static DecodeStatus decodeZcmpSpimm(MCInst &Inst, unsigned Imm, + uint64_t Address, const void *Decoder) { + // TODO: check if spimm matches rlist + Inst.addOperand(MCOperand::createImm(Imm)); + return MCDisassembler::Success; +} + DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size, ArrayRef<uint8_t> Bytes, uint64_t Address, @@ -612,6 +645,15 @@ DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size, if (Result != MCDisassembler::Fail) return Result; } + if (STI.hasFeature(RISCV::FeatureStdExtZcmp)) { + LLVM_DEBUG( + dbgs() + << "Trying Zcmp table (16-bit Push/Pop & Double Move Instructions):\n"); + Result = + decodeInstruction(DecoderTableRVZcmp16, MI, Insn, Address, this, STI); + if (Result != MCDisassembler::Fail) + return Result; + } LLVM_DEBUG(dbgs() << "Trying RISCV_C table (16-bit Instruction):\n"); // Calling the auto-generated decoder function. |