LLVM 23.0.0git
RISCVDisassembler.cpp
Go to the documentation of this file.
1//===-- RISCVDisassembler.cpp - Disassembler for RISC-V -------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the RISCVDisassembler class.
10//
11//===----------------------------------------------------------------------===//
12
16#include "llvm/MC/MCContext.h"
17#include "llvm/MC/MCDecoder.h"
20#include "llvm/MC/MCInst.h"
21#include "llvm/MC/MCInstrInfo.h"
26#include "llvm/Support/Endian.h"
27
28using namespace llvm;
29using namespace llvm::MCD;
30
31#define DEBUG_TYPE "riscv-disassembler"
32
34
35namespace {
36class RISCVDisassembler : public MCDisassembler {
37 std::unique_ptr<MCInstrInfo const> const MCII;
38
39public:
40 RISCVDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx,
41 MCInstrInfo const *MCII)
42 : MCDisassembler(STI, Ctx), MCII(MCII) {}
43
44 DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size,
45 ArrayRef<uint8_t> Bytes, uint64_t Address,
46 raw_ostream &CStream) const override;
47
48private:
49 DecodeStatus getInstruction48(MCInst &Instr, uint64_t &Size,
50 ArrayRef<uint8_t> Bytes, uint64_t Address,
51 raw_ostream &CStream) const;
52
53 DecodeStatus getInstruction32(MCInst &Instr, uint64_t &Size,
54 ArrayRef<uint8_t> Bytes, uint64_t Address,
55 raw_ostream &CStream) const;
56 DecodeStatus getInstruction16(MCInst &Instr, uint64_t &Size,
57 ArrayRef<uint8_t> Bytes, uint64_t Address,
58 raw_ostream &CStream) const;
59};
60} // end anonymous namespace
61
63 const MCSubtargetInfo &STI,
64 MCContext &Ctx) {
65 return new RISCVDisassembler(STI, Ctx, T.createMCInstrInfo());
66}
67
80
81template <unsigned FirstReg, unsigned NumRegsInClass, unsigned RVELimit = 0>
83 uint64_t Address,
84 const MCDisassembler *Decoder) {
85 bool CheckRVE = RVELimit != 0 &&
86 Decoder->getSubtargetInfo().hasFeature(RISCV::FeatureStdExtE);
87
88 if (RegNo >= NumRegsInClass || (CheckRVE && RegNo >= RVELimit))
90
91 MCRegister Reg = FirstReg + RegNo;
94}
95
96constexpr auto DecodeGPRRegisterClass =
97 DecodeSimpleRegisterClass<RISCV::X0, 32, /*RVELimit=*/16>;
98
100 uint64_t Address,
101 const MCDisassembler *Decoder) {
102 MCRegister Reg = RISCV::X0 + RegNo;
103 if (Reg != RISCV::X1 && Reg != RISCV::X5)
105
108}
109
111 const MCDisassembler *Decoder) {
112 Inst.addOperand(MCOperand::createReg(RISCV::X1));
114}
115
117 const MCDisassembler *Decoder) {
118 Inst.addOperand(MCOperand::createReg(RISCV::X2));
120}
121
123 uint32_t Address,
124 const MCDisassembler *Decoder) {
125 assert(RegNo == 2);
126 Inst.addOperand(MCOperand::createReg(RISCV::X2));
128}
129
131 const MCDisassembler *Decoder) {
132 Inst.addOperand(MCOperand::createReg(RISCV::X5));
134}
135
137 uint64_t Address,
138 const MCDisassembler *Decoder) {
139 if (RegNo == 0)
141
142 return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
143}
144
146 uint32_t Address,
147 const MCDisassembler *Decoder) {
148 if (RegNo == 2)
150
151 return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
152}
153
155 uint64_t Address,
156 const MCDisassembler *Decoder) {
157 if (RegNo == 31) {
159 }
160
161 return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
162}
163
165 uint64_t Address,
166 const MCDisassembler *Decoder) {
167 if (RegNo >= 32 || RegNo % 2)
169
170 const RISCVDisassembler *Dis =
171 static_cast<const RISCVDisassembler *>(Decoder);
172 const MCRegisterInfo *RI = Dis->getContext().getRegisterInfo();
174 RISCV::X0 + RegNo, RISCV::sub_gpr_even,
175 &RISCVMCRegisterClasses[RISCV::GPRPairRegClassID]);
178}
179
180static DecodeStatus
182 const MCDisassembler *Decoder) {
183 if (RegNo == 0)
185
186 return DecodeGPRPairRegisterClass(Inst, RegNo, Address, Decoder);
187}
188
190 uint64_t Address,
191 const MCDisassembler *Decoder) {
192 if (RegNo >= 8 || RegNo % 2)
194
195 const RISCVDisassembler *Dis =
196 static_cast<const RISCVDisassembler *>(Decoder);
197 const MCRegisterInfo *RI = Dis->getContext().getRegisterInfo();
199 RISCV::X8 + RegNo, RISCV::sub_gpr_even,
200 &RISCVMCRegisterClasses[RISCV::GPRPairCRegClassID]);
203}
204
206 uint64_t Address,
207 const void *Decoder) {
208 if (RegNo >= 8)
210
211 MCRegister Reg = (RegNo < 2) ? (RegNo + RISCV::X8) : (RegNo - 2 + RISCV::X18);
214}
215
216template <unsigned RegisterClass, unsigned NumRegsInClass, unsigned LMul>
218 uint64_t Address,
219 const MCDisassembler *Decoder) {
220 if (RegNo >= NumRegsInClass || RegNo % LMul)
222
223 const RISCVDisassembler *Dis =
224 static_cast<const RISCVDisassembler *>(Decoder);
225 const MCRegisterInfo *RI = Dis->getContext().getRegisterInfo();
227 RI->getMatchingSuperReg(RISCV::V0 + RegNo, RISCV::sub_vrm1_0,
228 &RISCVMCRegisterClasses[RegisterClass]);
229
232}
233
235 uint64_t Address,
236 const MCDisassembler *Decoder) {
237 if (RegNo > 15 || RegNo % 2)
239
240 MCRegister Reg = RISCV::T0 + RegNo;
243}
244
246 uint64_t Address,
247 const MCDisassembler *Decoder) {
248 if (RegNo > 15 || RegNo % 4)
250
251 MCRegister Reg = RISCV::T0 + RegNo;
254}
255
257 uint64_t Address,
258 const MCDisassembler *Decoder) {
259 if (RegNo >= 2)
261
262 MCRegister Reg = (RegNo == 0) ? RISCV::V0 : RISCV::NoRegister;
263
266}
267
269 const MCDisassembler *Decoder) {
272}
273
275 const MCDisassembler *Decoder) {
278}
279
280template <unsigned N>
282 int64_t Address,
283 const MCDisassembler *Decoder) {
284 assert(isUInt<N>(Imm) && "Invalid immediate");
287}
288
289template <unsigned Width, unsigned LowerBound>
291 int64_t Address,
292 const MCDisassembler *Decoder) {
293 assert(isUInt<Width>(Imm) && "Invalid immediate");
294
295 if (Imm < LowerBound)
297
300}
301
302template <unsigned Width, unsigned LowerBound>
304 int64_t Address,
305 const MCDisassembler *Decoder) {
306 assert(isUInt<Width>(Imm) && "Invalid immediate");
307
308 if ((Imm + 1) < LowerBound)
310
311 Inst.addOperand(MCOperand::createImm(Imm + 1));
313}
314
316 int64_t Address,
317 const MCDisassembler *Decoder) {
318 assert(isUInt<3>(Imm) && "Invalid Slist immediate");
319 const uint8_t Slist[] = {0, 1, 2, 4, 8, 16, 15, 31};
320 Inst.addOperand(MCOperand::createImm(Slist[Imm]));
322}
323
325 int64_t Address,
326 const MCDisassembler *Decoder) {
327 assert(isUInt<6>(Imm) && "Invalid immediate");
328
329 if (!Decoder->getSubtargetInfo().hasFeature(RISCV::Feature64Bit) &&
330 !isUInt<5>(Imm))
332
335}
336
337template <unsigned N>
339 int64_t Address,
340 const MCDisassembler *Decoder) {
341 if (Imm == 0)
343 return decodeUImmOperand<N>(Inst, Imm, Address, Decoder);
344}
345
346static DecodeStatus
348 const MCDisassembler *Decoder) {
349 if (Imm == 0)
351 return decodeUImmLog2XLenOperand(Inst, Imm, Address, Decoder);
352}
353
354template <unsigned N>
356 int64_t Address,
357 const MCDisassembler *Decoder) {
358 assert(isUInt<N>(Imm) && "Invalid immediate");
359 Inst.addOperand(MCOperand::createImm(Imm + 1));
361}
362
364 int64_t Address,
365 const MCDisassembler *Decoder) {
366 assert(isUInt<5>(Imm) && "Invalid immediate");
367 Inst.addOperand(MCOperand::createImm(Imm ? Imm : -1LL));
369}
370
371template <unsigned N>
373 int64_t Address,
374 const MCDisassembler *Decoder) {
375 assert(isUInt<N>(Imm) && "Invalid immediate");
376 // Sign-extend the number in the bottom N bits of Imm
379}
380
381template <unsigned N>
383 int64_t Address,
384 const MCDisassembler *Decoder) {
385 if (Imm == 0)
387 return decodeSImmOperand<N>(Inst, Imm, Address, Decoder);
388}
389
390template <unsigned T, unsigned N>
392 int64_t Address,
393 const MCDisassembler *Decoder) {
394 assert(isUInt<T - N + 1>(Imm) && "Invalid immediate");
395 // Sign-extend the number in the bottom T bits of Imm after accounting for
396 // the fact that the T bit immediate is stored in T-N bits (the LSB is
397 // always zero)
400}
401
403 int64_t Address,
404 const MCDisassembler *Decoder) {
405 assert(isUInt<6>(Imm) && "Invalid immediate");
406 if (Imm == 0)
408 Imm = SignExtend64<6>(Imm) & 0xfffff;
411}
412
413static DecodeStatus decodeFRMArg(MCInst &Inst, uint32_t Imm, int64_t Address,
414 const MCDisassembler *Decoder) {
415 assert(isUInt<3>(Imm) && "Invalid immediate");
418
421}
422
424 uint64_t Address,
425 const MCDisassembler *Decoder) {
426 bool IsRVE = Decoder->getSubtargetInfo().hasFeature(RISCV::FeatureStdExtE);
427 if (Imm < RISCVZC::RA || (IsRVE && Imm >= RISCVZC::RA_S0_S2))
431}
432
434 uint64_t Address,
435 const MCDisassembler *Decoder) {
436 if (Imm < RISCVZC::RA_S0)
438 return decodeZcmpRlist(Inst, Imm, Address, Decoder);
439}
440
441#include "RISCVGenDisassemblerTables.inc"
442
443namespace {
444
445struct DecoderListEntry {
446 const uint8_t *Table;
447 FeatureBitset ContainedFeatures;
448 const char *Desc;
449
450 bool haveContainedFeatures(const FeatureBitset &ActiveFeatures) const {
451 return ContainedFeatures.none() ||
452 (ContainedFeatures & ActiveFeatures).any();
453 }
454};
455
456} // end anonymous namespace
457
458static constexpr FeatureBitset XCVFeatureGroup = {
459 RISCV::FeatureVendorXCVbitmanip, RISCV::FeatureVendorXCVelw,
460 RISCV::FeatureVendorXCVmac, RISCV::FeatureVendorXCVmem,
461 RISCV::FeatureVendorXCValu, RISCV::FeatureVendorXCVsimd,
462 RISCV::FeatureVendorXCVbi};
463
465 RISCV::FeatureVendorXRivosVisni,
466 RISCV::FeatureVendorXRivosVizip,
467};
468
469static constexpr FeatureBitset XqciFeatureGroup = {
470 RISCV::FeatureVendorXqcia, RISCV::FeatureVendorXqciac,
471 RISCV::FeatureVendorXqcibi, RISCV::FeatureVendorXqcibm,
472 RISCV::FeatureVendorXqcicli, RISCV::FeatureVendorXqcicm,
473 RISCV::FeatureVendorXqcics, RISCV::FeatureVendorXqcicsr,
474 RISCV::FeatureVendorXqciint, RISCV::FeatureVendorXqciio,
475 RISCV::FeatureVendorXqcilb, RISCV::FeatureVendorXqcili,
476 RISCV::FeatureVendorXqcilia, RISCV::FeatureVendorXqcilo,
477 RISCV::FeatureVendorXqcilsm, RISCV::FeatureVendorXqcisim,
478 RISCV::FeatureVendorXqcisls, RISCV::FeatureVendorXqcisync,
479};
480
481static constexpr FeatureBitset XSfVectorGroup = {
482 RISCV::FeatureVendorXSfvcp, RISCV::FeatureVendorXSfvqmaccdod,
483 RISCV::FeatureVendorXSfvqmaccqoq, RISCV::FeatureVendorXSfvfwmaccqqq,
484 RISCV::FeatureVendorXSfvfnrclipxfqf, RISCV::FeatureVendorXSfmmbase,
485 RISCV::FeatureVendorXSfvfexpa, RISCV::FeatureVendorXSfvfexpa64e,
486 RISCV::FeatureVendorXSfvfbfexp16e, RISCV::FeatureVendorXSfvfexp16e,
487 RISCV::FeatureVendorXSfvfexp32e};
488static constexpr FeatureBitset XSfSystemGroup = {
489 RISCV::FeatureVendorXSiFivecdiscarddlone,
490 RISCV::FeatureVendorXSiFivecflushdlone,
491};
492
493static constexpr FeatureBitset XMIPSGroup = {
494 RISCV::FeatureVendorXMIPSLSP,
495 RISCV::FeatureVendorXMIPSCMov,
496 RISCV::FeatureVendorXMIPSCBOP,
497 RISCV::FeatureVendorXMIPSEXECTL,
498};
499
500static constexpr FeatureBitset XTHeadGroup = {
501 RISCV::FeatureVendorXTHeadBa, RISCV::FeatureVendorXTHeadBb,
502 RISCV::FeatureVendorXTHeadBs, RISCV::FeatureVendorXTHeadCondMov,
503 RISCV::FeatureVendorXTHeadCmo, RISCV::FeatureVendorXTHeadFMemIdx,
504 RISCV::FeatureVendorXTHeadMac, RISCV::FeatureVendorXTHeadMemIdx,
505 RISCV::FeatureVendorXTHeadMemPair, RISCV::FeatureVendorXTHeadSync,
506 RISCV::FeatureVendorXTHeadVdot};
507
508static constexpr FeatureBitset XAndesGroup = {
509 RISCV::FeatureVendorXAndesPerf, RISCV::FeatureVendorXAndesBFHCvt,
510 RISCV::FeatureVendorXAndesVBFHCvt, RISCV::FeatureVendorXAndesVSIntH,
511 RISCV::FeatureVendorXAndesVSIntLoad, RISCV::FeatureVendorXAndesVPackFPH,
512 RISCV::FeatureVendorXAndesVDot};
513
514static constexpr FeatureBitset XSMTGroup = {RISCV::FeatureVendorXSMTVDot};
515
516static constexpr FeatureBitset XAIFGroup = {RISCV::FeatureVendorXAIFET};
517
518static constexpr DecoderListEntry DecoderList32[]{
519 // Vendor Extensions
520 {DecoderTableXCV32, XCVFeatureGroup, "CORE-V extensions"},
521 {DecoderTableXRivos32, XRivosFeatureGroup, "Rivos"},
522 {DecoderTableXqci32, XqciFeatureGroup, "Qualcomm uC Extensions"},
523 {DecoderTableXVentana32,
524 {RISCV::FeatureVendorXVentanaCondOps},
525 "XVentanaCondOps"},
526 {DecoderTableXTHead32, XTHeadGroup, "T-Head extensions"},
527 {DecoderTableXSfvector32, XSfVectorGroup, "SiFive vector extensions"},
528 {DecoderTableXSfsystem32, XSfSystemGroup, "SiFive system extensions"},
529 {DecoderTableXSfcease32, {RISCV::FeatureVendorXSfcease}, "SiFive sf.cease"},
530 {DecoderTableXMIPS32, XMIPSGroup, "Mips extensions"},
531 {DecoderTableXAndes32, XAndesGroup, "Andes extensions"},
532 {DecoderTableXSMT32, XSMTGroup, "SpacemiT extensions"},
533 {DecoderTableXAIF32, XAIFGroup, "AI Foundry extensions"},
534 // Standard Extensions
535 {DecoderTable32, {}, "standard 32-bit instructions"},
536 {DecoderTableRV32Only32, {}, "RV32-only standard 32-bit instructions"},
537 {DecoderTableZfinx32, {}, "Zfinx (Float in Integer)"},
538 {DecoderTableZdinxRV32Only32, {}, "RV32-only Zdinx (Double in Integer)"},
539};
540
541namespace {
542// Define bitwidths for various types used to instantiate the decoder.
543template <> constexpr uint32_t InsnBitWidth<uint16_t> = 16;
544template <> constexpr uint32_t InsnBitWidth<uint32_t> = 32;
545// Use uint64_t to represent 48 bit instructions.
546template <> constexpr uint32_t InsnBitWidth<uint64_t> = 48;
547} // namespace
548
549DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size,
550 ArrayRef<uint8_t> Bytes,
551 uint64_t Address,
552 raw_ostream &CS) const {
553 if (Bytes.size() < 4) {
554 Size = 0;
556 }
557 Size = 4;
558
559 uint32_t Insn = support::endian::read32le(Bytes.data());
560
561 for (const DecoderListEntry &Entry : DecoderList32) {
562 if (!Entry.haveContainedFeatures(STI.getFeatureBits()))
563 continue;
564
565 LLVM_DEBUG(dbgs() << "Trying " << Entry.Desc << " table:\n");
567 decodeInstruction(Entry.Table, MI, Insn, Address, this, STI);
568 if (Result == MCDisassembler::Fail)
569 continue;
570
571 return Result;
572 }
573
575}
576
577static constexpr DecoderListEntry DecoderList16[]{
578 // Vendor Extensions
579 {DecoderTableXqci16, XqciFeatureGroup, "Qualcomm uC 16-bit"},
580 {DecoderTableXqccmp16,
581 {RISCV::FeatureVendorXqccmp},
582 "Xqccmp (Qualcomm 16-bit Push/Pop & Double Move Instructions)"},
583 {DecoderTableXwchc16, {RISCV::FeatureVendorXwchc}, "WCH QingKe XW"},
584 // Standard Extensions
585 // DecoderTableZicfiss16 must be checked before DecoderTable16.
586 {DecoderTableZicfiss16, {}, "Zicfiss (Shadow Stack 16-bit)"},
587 {DecoderTable16, {}, "standard 16-bit instructions"},
588 {DecoderTableRV32Only16, {}, "RV32-only 16-bit instructions"},
589 // Zc* instructions incompatible with Zcf or Zcd
590 {DecoderTableZcOverlap16,
591 {},
592 "ZcOverlap (16-bit Instructions overlapping with Zcf/Zcd)"},
593};
594
595DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size,
596 ArrayRef<uint8_t> Bytes,
597 uint64_t Address,
598 raw_ostream &CS) const {
599 if (Bytes.size() < 2) {
600 Size = 0;
602 }
603 Size = 2;
604
605 uint16_t Insn = support::endian::read16le(Bytes.data());
606
607 for (const DecoderListEntry &Entry : DecoderList16) {
608 if (!Entry.haveContainedFeatures(STI.getFeatureBits()))
609 continue;
610
611 LLVM_DEBUG(dbgs() << "Trying " << Entry.Desc << " table:\n");
613 decodeInstruction(Entry.Table, MI, Insn, Address, this, STI);
614 if (Result != MCDisassembler::Fail)
615 return Result;
616 }
617
619}
620
621static constexpr DecoderListEntry DecoderList48[]{
622 {DecoderTableXqci48, XqciFeatureGroup, "Qualcomm uC 48bit"},
623};
624
625DecodeStatus RISCVDisassembler::getInstruction48(MCInst &MI, uint64_t &Size,
626 ArrayRef<uint8_t> Bytes,
627 uint64_t Address,
628 raw_ostream &CS) const {
629 if (Bytes.size() < 6) {
630 Size = 0;
632 }
633 Size = 6;
634
635 uint64_t Insn = 0;
636 for (size_t i = Size; i-- != 0;)
637 Insn += (static_cast<uint64_t>(Bytes[i]) << 8 * i);
638
639 for (const DecoderListEntry &Entry : DecoderList48) {
640 if (!Entry.haveContainedFeatures(STI.getFeatureBits()))
641 continue;
642
643 LLVM_DEBUG(dbgs() << "Trying " << Entry.Desc << " table:\n");
645 decodeInstruction(Entry.Table, MI, Insn, Address, this, STI);
646 if (Result == MCDisassembler::Fail)
647 continue;
648
649 return Result;
650 }
651
653}
654
655DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
656 ArrayRef<uint8_t> Bytes,
657 uint64_t Address,
658 raw_ostream &CS) const {
659 CommentStream = &CS;
660 // It's a 16 bit instruction if bit 0 and 1 are not 0b11.
661 if ((Bytes[0] & 0b11) != 0b11)
662 return getInstruction16(MI, Size, Bytes, Address, CS);
663
664 // Try to decode as a 32-bit instruction first.
665 DecodeStatus Result = getInstruction32(MI, Size, Bytes, Address, CS);
666 if (Result != MCDisassembler::Fail)
667 return Result;
668
669 // If bits [4:2] are 0b111 this might be a 48-bit or larger instruction,
670 // otherwise assume it's an unknown 32-bit instruction.
671 if ((Bytes[0] & 0b1'1100) != 0b1'1100) {
672 Size = Bytes.size() >= 4 ? 4 : 0;
674 }
675
676 // 48-bit instructions are encoded as 0bxx011111.
677 if ((Bytes[0] & 0b11'1111) == 0b01'1111)
678 return getInstruction48(MI, Size, Bytes, Address, CS);
679
680 // 64-bit instructions are encoded as 0x0111111.
681 if ((Bytes[0] & 0b111'1111) == 0b011'1111) {
682 Size = Bytes.size() >= 8 ? 8 : 0;
684 }
685
686 // Remaining cases need to check a second byte.
687 if (Bytes.size() < 2) {
688 Size = 0;
690 }
691
692 // 80-bit through 176-bit instructions are encoded as 0bxnnnxxxx_x1111111.
693 // Where the number of bits is (80 + (nnn * 16)) for nnn != 0b111.
694 unsigned nnn = (Bytes[1] >> 4) & 0b111;
695 if (nnn != 0b111) {
696 Size = 10 + (nnn * 2);
697 if (Bytes.size() < Size)
698 Size = 0;
700 }
701
702 // Remaining encodings are reserved for > 176-bit instructions.
703 Size = 0;
705}
MCDisassembler::DecodeStatus DecodeStatus
static DecodeStatus DecodeSimpleRegisterClass(MCInst &Inst, unsigned RegNo, uint64_t Address, const MCDisassembler *Decoder)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition Compiler.h:213
#define LLVM_EXTERNAL_VISIBILITY
Definition Compiler.h:132
IRTranslator LLVM IR MI
Register Reg
#define T
static constexpr FeatureBitset XqciFeatureGroup
static DecodeStatus decodeUImmSlistOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static constexpr FeatureBitset XAIFGroup
static constexpr FeatureBitset XSMTGroup
static DecodeStatus decodeUImmLog2XLenOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static constexpr FeatureBitset XCVFeatureGroup
static constexpr DecoderListEntry DecoderList48[]
static DecodeStatus decodeSImmOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static constexpr DecoderListEntry DecoderList16[]
static DecodeStatus DecodeGPRX1X5RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPRNoX31RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeImmFourOperand(MCInst &Inst, const MCDisassembler *Decoder)
static DecodeStatus decodeUImmLog2XLenNonZeroOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static MCDisassembler * createRISCVDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
static DecodeStatus DecodeTRM2RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeVectorRegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeSImmOperandAndLslN(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static constexpr FeatureBitset XSfVectorGroup
static constexpr DecoderListEntry DecoderList32[]
static DecodeStatus DecodeGPRX5RegisterClass(MCInst &Inst, const MCDisassembler *Decoder)
static DecodeStatus decodeImmThreeOperand(MCInst &Inst, const MCDisassembler *Decoder)
static DecodeStatus decodeXqccmpRlistS0(MCInst &Inst, uint32_t Imm, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeUImmPlus1Operand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeCLUIImmOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeZcmpRlist(MCInst &Inst, uint32_t Imm, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeUImmOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPRNoX2RegisterClass(MCInst &Inst, uint64_t RegNo, uint32_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPRPairRegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeImmZibiOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeSPRegisterClass(MCInst &Inst, const MCDisassembler *Decoder)
static constexpr FeatureBitset XMIPSGroup
constexpr auto DecodeGPRRegisterClass
static DecodeStatus decodeSImmNonZeroOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPRPairNoX0RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static constexpr FeatureBitset XAndesGroup
static DecodeStatus DecodeTRM4RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPRNoX0RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeFRMArg(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPRX1RegisterClass(MCInst &Inst, const MCDisassembler *Decoder)
static DecodeStatus DecodeSR07RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const void *Decoder)
static constexpr FeatureBitset XTHeadGroup
static DecodeStatus DecodeSimpleRegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static constexpr FeatureBitset XRivosFeatureGroup
static DecodeStatus decodeUImmPlus1OperandGE(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVDisassembler()
static DecodeStatus decodeVMaskReg(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeUImmNonZeroOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static constexpr FeatureBitset XSfSystemGroup
static DecodeStatus decodeUImmOperandGE(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPRPairCRegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
#define LLVM_DEBUG(...)
Definition Debug.h:114
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
size - Get the array size.
Definition ArrayRef.h:142
const T * data() const
Definition ArrayRef.h:139
Container class for subtarget features.
Context object for machine code objects.
Definition MCContext.h:83
Superclass for all disassemblers.
const MCSubtargetInfo & getSubtargetInfo() const
DecodeStatus
Ternary decode status.
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
void addOperand(const MCOperand Op)
Definition MCInst.h:215
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
static MCOperand createReg(MCRegister Reg)
Definition MCInst.h:138
static MCOperand createImm(int64_t Val)
Definition MCInst.h:145
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
MCRegister getMatchingSuperReg(MCRegister Reg, unsigned SubIdx, const MCRegisterClass *RC) const
Return a super-register of the specified register Reg so its sub-register of index SubIdx is Reg.
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
Target - Wrapper for Target specific information.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
constexpr bool any(E Val)
@ Entry
Definition COFF.h:862
static bool isValidRoundingMode(unsigned Mode)
uint16_t read16le(const void *P)
Definition Endian.h:429
uint32_t read32le(const void *P)
Definition Endian.h:432
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
Target & getTheRISCV32Target()
Target & getTheRISCV64beTarget()
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:207
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
Definition MathExtras.h:189
Target & getTheRISCV64Target()
constexpr int64_t SignExtend64(uint64_t x)
Sign-extend the number in the bottom B bits of X to a 64-bit integer.
Definition MathExtras.h:572
Target & getTheRISCV32beTarget()
#define N
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.