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
136template <auto DecodeFn, auto PredicateFn>
138 uint64_t Address,
139 const MCDisassembler *Decoder) {
140 if (!PredicateFn(RegNo))
142 return DecodeFn(Inst, RegNo, Address, Decoder);
143}
144
145constexpr bool PredNoX0(uint32_t RegNo) { return RegNo != 0; }
146constexpr bool PredNoX2(uint32_t RegNo) { return RegNo != 2; }
147constexpr bool PredNoX31(uint32_t RegNo) { return RegNo != 31; }
148
155
157 uint64_t Address,
158 const MCDisassembler *Decoder) {
159 if (RegNo >= 32 || RegNo % 2)
161
162 const RISCVDisassembler *Dis =
163 static_cast<const RISCVDisassembler *>(Decoder);
164 const MCRegisterInfo *RI = Dis->getContext().getRegisterInfo();
166 RISCV::X0 + RegNo, RISCV::sub_gpr_even,
167 &RISCVMCRegisterClasses[RISCV::GPRPairRegClassID]);
170}
171
174
176 uint64_t Address,
177 const MCDisassembler *Decoder) {
178 if (RegNo >= 8 || RegNo % 2)
180
181 const RISCVDisassembler *Dis =
182 static_cast<const RISCVDisassembler *>(Decoder);
183 const MCRegisterInfo *RI = Dis->getContext().getRegisterInfo();
185 RISCV::X8 + RegNo, RISCV::sub_gpr_even,
186 &RISCVMCRegisterClasses[RISCV::GPRPairCRegClassID]);
189}
190
192 uint64_t Address,
193 const void *Decoder) {
194 if (RegNo >= 8)
196
197 MCRegister Reg = (RegNo < 2) ? (RegNo + RISCV::X8) : (RegNo - 2 + RISCV::X18);
200}
201
202template <unsigned RegisterClass, unsigned NumRegsInClass, unsigned LMul>
204 uint64_t Address,
205 const MCDisassembler *Decoder) {
206 if (RegNo >= NumRegsInClass || RegNo % LMul)
208
209 const RISCVDisassembler *Dis =
210 static_cast<const RISCVDisassembler *>(Decoder);
211 const MCRegisterInfo *RI = Dis->getContext().getRegisterInfo();
213 RI->getMatchingSuperReg(RISCV::V0 + RegNo, RISCV::sub_vrm1_0,
214 &RISCVMCRegisterClasses[RegisterClass]);
215
218}
219
221 uint64_t Address,
222 const MCDisassembler *Decoder) {
223 if (RegNo > 15 || RegNo % 2)
225
226 MCRegister Reg = RISCV::T0 + RegNo;
229}
230
232 uint64_t Address,
233 const MCDisassembler *Decoder) {
234 if (RegNo > 15 || RegNo % 4)
236
237 MCRegister Reg = RISCV::T0 + RegNo;
240}
241
243 uint64_t Address,
244 const MCDisassembler *Decoder) {
245 if (RegNo >= 2)
247
248 MCRegister Reg = (RegNo == 0) ? RISCV::V0 : RISCV::NoRegister;
249
252}
253
255 const MCDisassembler *Decoder) {
258}
259
261 const MCDisassembler *Decoder) {
264}
265
266template <unsigned N>
268 int64_t Address,
269 const MCDisassembler *Decoder) {
270 assert(isUInt<N>(Imm) && "Invalid immediate");
273}
274
275template <unsigned Width, unsigned LowerBound>
277 int64_t Address,
278 const MCDisassembler *Decoder) {
279 assert(isUInt<Width>(Imm) && "Invalid immediate");
280
281 if (Imm < LowerBound)
283
286}
287
288template <unsigned Width, unsigned LowerBound>
290 int64_t Address,
291 const MCDisassembler *Decoder) {
292 assert(isUInt<Width>(Imm) && "Invalid immediate");
293
294 if ((Imm + 1) < LowerBound)
296
297 Inst.addOperand(MCOperand::createImm(Imm + 1));
299}
300
302 int64_t Address,
303 const MCDisassembler *Decoder) {
304 assert(isUInt<3>(Imm) && "Invalid Slist immediate");
305 const uint8_t Slist[] = {0, 1, 2, 4, 8, 16, 15, 31};
306 Inst.addOperand(MCOperand::createImm(Slist[Imm]));
308}
309
311 int64_t Address,
312 const MCDisassembler *Decoder) {
313 assert(isUInt<6>(Imm) && "Invalid immediate");
314
315 if (!Decoder->getSubtargetInfo().hasFeature(RISCV::Feature64Bit) &&
316 !isUInt<5>(Imm))
318
321}
322
323template <unsigned N>
325 int64_t Address,
326 const MCDisassembler *Decoder) {
327 if (Imm == 0)
329 return decodeUImmOperand<N>(Inst, Imm, Address, Decoder);
330}
331
332static DecodeStatus
334 const MCDisassembler *Decoder) {
335 if (Imm == 0)
337 return decodeUImmLog2XLenOperand(Inst, Imm, Address, Decoder);
338}
339
340template <unsigned N>
342 int64_t Address,
343 const MCDisassembler *Decoder) {
344 assert(isUInt<N>(Imm) && "Invalid immediate");
345 Inst.addOperand(MCOperand::createImm(Imm + 1));
347}
348
350 int64_t Address,
351 const MCDisassembler *Decoder) {
352 assert(isUInt<5>(Imm) && "Invalid immediate");
353 Inst.addOperand(MCOperand::createImm(Imm ? Imm : -1LL));
355}
356
357template <unsigned N>
359 int64_t Address,
360 const MCDisassembler *Decoder) {
361 assert(isUInt<N>(Imm) && "Invalid immediate");
362 // Sign-extend the number in the bottom N bits of Imm
365}
366
367template <unsigned N>
369 int64_t Address,
370 const MCDisassembler *Decoder) {
371 if (Imm == 0)
373 return decodeSImmOperand<N>(Inst, Imm, Address, Decoder);
374}
375
376template <unsigned T, unsigned N>
378 int64_t Address,
379 const MCDisassembler *Decoder) {
380 assert(isUInt<T - N + 1>(Imm) && "Invalid immediate");
381 // Sign-extend the number in the bottom T bits of Imm after accounting for
382 // the fact that the T bit immediate is stored in T-N bits (the LSB is
383 // always zero)
386}
387
389 int64_t Address,
390 const MCDisassembler *Decoder) {
391 assert(isUInt<6>(Imm) && "Invalid immediate");
392 if (Imm == 0)
394 Imm = SignExtend64<6>(Imm) & 0xfffff;
397}
398
399static DecodeStatus decodeFRMArg(MCInst &Inst, uint32_t Imm, int64_t Address,
400 const MCDisassembler *Decoder) {
401 assert(isUInt<3>(Imm) && "Invalid immediate");
404
407}
408
410 uint64_t Address,
411 const MCDisassembler *Decoder) {
412 bool IsRVE = Decoder->getSubtargetInfo().hasFeature(RISCV::FeatureStdExtE);
413 if (Imm < RISCVZC::RA || (IsRVE && Imm >= RISCVZC::RA_S0_S2))
417}
418
420 uint64_t Address,
421 const MCDisassembler *Decoder) {
422 if (Imm < RISCVZC::RA_S0)
424 return decodeZcmpRlist(Inst, Imm, Address, Decoder);
425}
426
427#include "RISCVGenDisassemblerTables.inc"
428
429namespace {
430
431struct DecoderListEntry {
432 const uint8_t *Table;
433 FeatureBitset ContainedFeatures;
434 const char *Desc;
435
436 bool haveContainedFeatures(const FeatureBitset &ActiveFeatures) const {
437 return ContainedFeatures.none() ||
438 (ContainedFeatures & ActiveFeatures).any();
439 }
440};
441
442} // end anonymous namespace
443
444static constexpr FeatureBitset XCVFeatureGroup = {
445 RISCV::FeatureVendorXCVbitmanip, RISCV::FeatureVendorXCVelw,
446 RISCV::FeatureVendorXCVmac, RISCV::FeatureVendorXCVmem,
447 RISCV::FeatureVendorXCValu, RISCV::FeatureVendorXCVsimd,
448 RISCV::FeatureVendorXCVbi};
449
451 RISCV::FeatureVendorXRivosVizip,
452};
453
454static constexpr FeatureBitset XqciFeatureGroup = {
455 RISCV::FeatureVendorXqcia, RISCV::FeatureVendorXqciac,
456 RISCV::FeatureVendorXqcibi, RISCV::FeatureVendorXqcibm,
457 RISCV::FeatureVendorXqcicli, RISCV::FeatureVendorXqcicm,
458 RISCV::FeatureVendorXqcics, RISCV::FeatureVendorXqcicsr,
459 RISCV::FeatureVendorXqciint, RISCV::FeatureVendorXqciio,
460 RISCV::FeatureVendorXqcilb, RISCV::FeatureVendorXqcili,
461 RISCV::FeatureVendorXqcilia, RISCV::FeatureVendorXqcilo,
462 RISCV::FeatureVendorXqcilsm, RISCV::FeatureVendorXqcisim,
463 RISCV::FeatureVendorXqcisls, RISCV::FeatureVendorXqcisync,
464};
465
466static constexpr FeatureBitset XSfVectorGroup = {
467 RISCV::FeatureVendorXSfvcp, RISCV::FeatureVendorXSfvqmaccdod,
468 RISCV::FeatureVendorXSfvqmaccqoq, RISCV::FeatureVendorXSfvfwmaccqqq,
469 RISCV::FeatureVendorXSfvfnrclipxfqf, RISCV::FeatureVendorXSfmmbase,
470 RISCV::FeatureVendorXSfvfexpa, RISCV::FeatureVendorXSfvfexpa64e,
471 RISCV::FeatureVendorXSfvfbfexp16e, RISCV::FeatureVendorXSfvfexp16e,
472 RISCV::FeatureVendorXSfvfexp32e};
473static constexpr FeatureBitset XSfSystemGroup = {
474 RISCV::FeatureVendorXSiFivecdiscarddlone,
475 RISCV::FeatureVendorXSiFivecflushdlone,
476};
477
478static constexpr FeatureBitset XMIPSGroup = {
479 RISCV::FeatureVendorXMIPSLSP,
480 RISCV::FeatureVendorXMIPSCMov,
481 RISCV::FeatureVendorXMIPSCBOP,
482 RISCV::FeatureVendorXMIPSEXECTL,
483};
484
485static constexpr FeatureBitset XTHeadGroup = {
486 RISCV::FeatureVendorXTHeadBa, RISCV::FeatureVendorXTHeadBb,
487 RISCV::FeatureVendorXTHeadBs, RISCV::FeatureVendorXTHeadCondMov,
488 RISCV::FeatureVendorXTHeadCmo, RISCV::FeatureVendorXTHeadFMemIdx,
489 RISCV::FeatureVendorXTHeadMac, RISCV::FeatureVendorXTHeadMemIdx,
490 RISCV::FeatureVendorXTHeadMemPair, RISCV::FeatureVendorXTHeadSync,
491 RISCV::FeatureVendorXTHeadVdot};
492
493static constexpr FeatureBitset XAndesGroup = {
494 RISCV::FeatureVendorXAndesPerf, RISCV::FeatureVendorXAndesBFHCvt,
495 RISCV::FeatureVendorXAndesVBFHCvt, RISCV::FeatureVendorXAndesVSIntH,
496 RISCV::FeatureVendorXAndesVSIntLoad, RISCV::FeatureVendorXAndesVPackFPH,
497 RISCV::FeatureVendorXAndesVDot};
498
499static constexpr FeatureBitset XSMTGroup = {RISCV::FeatureVendorXSMTVDot};
500
501static constexpr FeatureBitset XAIFGroup = {RISCV::FeatureVendorXAIFET};
502
503static constexpr DecoderListEntry DecoderList32[]{
504 // Vendor Extensions
505 {DecoderTableXCV32, XCVFeatureGroup, "CORE-V extensions"},
506 {DecoderTableXRivos32, XRivosFeatureGroup, "Rivos"},
507 {DecoderTableXqci32, XqciFeatureGroup, "Qualcomm uC Extensions"},
508 {DecoderTableXVentana32,
509 {RISCV::FeatureVendorXVentanaCondOps},
510 "XVentanaCondOps"},
511 {DecoderTableXTHead32, XTHeadGroup, "T-Head extensions"},
512 {DecoderTableXSfvector32, XSfVectorGroup, "SiFive vector extensions"},
513 {DecoderTableXSfsystem32, XSfSystemGroup, "SiFive system extensions"},
514 {DecoderTableXSfcease32, {RISCV::FeatureVendorXSfcease}, "SiFive sf.cease"},
515 {DecoderTableXMIPS32, XMIPSGroup, "Mips extensions"},
516 {DecoderTableXAndes32, XAndesGroup, "Andes extensions"},
517 {DecoderTableXSMT32, XSMTGroup, "SpacemiT extensions"},
518 {DecoderTableXAIF32, XAIFGroup, "AI Foundry extensions"},
519 // Standard Extensions
520 {DecoderTable32, {}, "standard 32-bit instructions"},
521 {DecoderTableRV32Only32, {}, "RV32-only standard 32-bit instructions"},
522 {DecoderTableZfinx32, {}, "Zfinx (Float in Integer)"},
523 {DecoderTableZdinxRV32Only32, {}, "RV32-only Zdinx (Double in Integer)"},
524};
525
526namespace {
527// Define bitwidths for various types used to instantiate the decoder.
528template <> constexpr uint32_t InsnBitWidth<uint16_t> = 16;
529template <> constexpr uint32_t InsnBitWidth<uint32_t> = 32;
530// Use uint64_t to represent 48 bit instructions.
531template <> constexpr uint32_t InsnBitWidth<uint64_t> = 48;
532} // namespace
533
534DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size,
535 ArrayRef<uint8_t> Bytes,
536 uint64_t Address,
537 raw_ostream &CS) const {
538 if (Bytes.size() < 4) {
539 Size = 0;
541 }
542 Size = 4;
543
544 uint32_t Insn = support::endian::read32le(Bytes.data());
545
546 for (const DecoderListEntry &Entry : DecoderList32) {
547 if (!Entry.haveContainedFeatures(STI.getFeatureBits()))
548 continue;
549
550 LLVM_DEBUG(dbgs() << "Trying " << Entry.Desc << " table:\n");
552 decodeInstruction(Entry.Table, MI, Insn, Address, this, STI);
553 if (Result == MCDisassembler::Fail)
554 continue;
555
556 return Result;
557 }
558
560}
561
562static constexpr DecoderListEntry DecoderList16[]{
563 // Vendor Extensions
564 {DecoderTableXqci16, XqciFeatureGroup, "Qualcomm uC 16-bit"},
565 {DecoderTableXqccmp16,
566 {RISCV::FeatureVendorXqccmp},
567 "Xqccmp (Qualcomm 16-bit Push/Pop & Double Move Instructions)"},
568 {DecoderTableXqccmt16,
569 {RISCV::FeatureVendorXqccmt},
570 "Xqccmt (Qualcomm 16-bit Table Jump Instructions)"},
571 {DecoderTableXwchc16, {RISCV::FeatureVendorXwchc}, "WCH QingKe XW"},
572 // Standard Extensions
573 // DecoderTableZicfiss16 must be checked before DecoderTable16.
574 {DecoderTableZicfiss16, {}, "Zicfiss (Shadow Stack 16-bit)"},
575 {DecoderTable16, {}, "standard 16-bit instructions"},
576 {DecoderTableRV32Only16, {}, "RV32-only 16-bit instructions"},
577 // Zc* instructions incompatible with Zcf or Zcd
578 {DecoderTableZcOverlap16,
579 {},
580 "ZcOverlap (16-bit Instructions overlapping with Zcf/Zcd)"},
581};
582
583DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size,
584 ArrayRef<uint8_t> Bytes,
585 uint64_t Address,
586 raw_ostream &CS) const {
587 if (Bytes.size() < 2) {
588 Size = 0;
590 }
591 Size = 2;
592
593 uint16_t Insn = support::endian::read16le(Bytes.data());
594
595 for (const DecoderListEntry &Entry : DecoderList16) {
596 if (!Entry.haveContainedFeatures(STI.getFeatureBits()))
597 continue;
598
599 LLVM_DEBUG(dbgs() << "Trying " << Entry.Desc << " table:\n");
601 decodeInstruction(Entry.Table, MI, Insn, Address, this, STI);
602 if (Result != MCDisassembler::Fail)
603 return Result;
604 }
605
607}
608
609static constexpr DecoderListEntry DecoderList48[]{
610 {DecoderTableXqci48, XqciFeatureGroup, "Qualcomm uC 48bit"},
611};
612
613DecodeStatus RISCVDisassembler::getInstruction48(MCInst &MI, uint64_t &Size,
614 ArrayRef<uint8_t> Bytes,
615 uint64_t Address,
616 raw_ostream &CS) const {
617 if (Bytes.size() < 6) {
618 Size = 0;
620 }
621 Size = 6;
622
623 uint64_t Insn = 0;
624 for (size_t i = Size; i-- != 0;)
625 Insn += (static_cast<uint64_t>(Bytes[i]) << 8 * i);
626
627 for (const DecoderListEntry &Entry : DecoderList48) {
628 if (!Entry.haveContainedFeatures(STI.getFeatureBits()))
629 continue;
630
631 LLVM_DEBUG(dbgs() << "Trying " << Entry.Desc << " table:\n");
633 decodeInstruction(Entry.Table, MI, Insn, Address, this, STI);
634 if (Result == MCDisassembler::Fail)
635 continue;
636
637 return Result;
638 }
639
641}
642
643DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
644 ArrayRef<uint8_t> Bytes,
645 uint64_t Address,
646 raw_ostream &CS) const {
647 CommentStream = &CS;
648 // It's a 16 bit instruction if bit 0 and 1 are not 0b11.
649 if ((Bytes[0] & 0b11) != 0b11)
650 return getInstruction16(MI, Size, Bytes, Address, CS);
651
652 // Try to decode as a 32-bit instruction first.
653 DecodeStatus Result = getInstruction32(MI, Size, Bytes, Address, CS);
654 if (Result != MCDisassembler::Fail)
655 return Result;
656
657 // If bits [4:2] are 0b111 this might be a 48-bit or larger instruction,
658 // otherwise assume it's an unknown 32-bit instruction.
659 if ((Bytes[0] & 0b1'1100) != 0b1'1100) {
660 Size = Bytes.size() >= 4 ? 4 : 0;
662 }
663
664 // 48-bit instructions are encoded as 0bxx011111.
665 if ((Bytes[0] & 0b11'1111) == 0b01'1111)
666 return getInstruction48(MI, Size, Bytes, Address, CS);
667
668 // 64-bit instructions are encoded as 0x0111111.
669 if ((Bytes[0] & 0b111'1111) == 0b011'1111) {
670 Size = Bytes.size() >= 8 ? 8 : 0;
672 }
673
674 // Remaining cases need to check a second byte.
675 if (Bytes.size() < 2) {
676 Size = 0;
678 }
679
680 // 80-bit through 176-bit instructions are encoded as 0bxnnnxxxx_x1111111.
681 // Where the number of bits is (80 + (nnn * 16)) for nnn != 0b111.
682 unsigned nnn = (Bytes[1] >> 4) & 0b111;
683 if (nnn != 0b111) {
684 Size = 10 + (nnn * 2);
685 if (Bytes.size() < Size)
686 Size = 0;
688 }
689
690 // Remaining encodings are reserved for > 176-bit instructions.
691 Size = 0;
693}
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
constexpr auto DecodeGPRNoX31RegisterClass
static constexpr FeatureBitset XSMTGroup
static DecodeStatus decodeUImmLog2XLenOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
constexpr auto DecodeGPRPairNoX0RegisterClass
constexpr bool PredNoX2(uint32_t RegNo)
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 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[]
constexpr bool PredNoX0(uint32_t RegNo)
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 DecodeGPRPairRegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
constexpr auto DecodeGPRNoX2RegisterClass
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 DecodeFilteredRegisterClass(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)
constexpr bool PredNoX31(uint32_t RegNo)
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)
constexpr auto DecodeGPRNoX0RegisterClass
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:119
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
Get the array size.
Definition ArrayRef.h:141
const T * data() const
Definition ArrayRef.h:138
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.
Target & getTheRISCV32Target()
Target & getTheRISCV64beTarget()
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
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.