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
242static DecodeStatus DecodeYBNDSWImm(MCInst &Inst, uint64_t Imm, int64_t Address,
243 const MCDisassembler *Decoder) {
244 assert(isUInt<9>(Imm) && "Invalid immediate");
245 uint64_t Result;
246 if (Imm == 0) {
247 // If imm[8:0] == 0, result is 4096.
248 Result = 4096;
249 } else if (Imm <= 255) {
250 // If imm[8] == 0 and imm[7:0] != 0, result is imm[7:0].
251 Result = Imm;
252 } else {
253 uint64_t Imm7To0 = Imm & 0xFF;
254 if (Imm7To0 <= 31) {
255 // If imm[8] == 1 and imm[7:5] == 0 (i.e. imm[7:0] <= 31), result is
256 // `256 | (imm[3:0] << 4) | (imm[4] << 3)`.
257 Result = 256 + ((Imm & 0xF) << 4) + (((Imm >> 4) & 1) << 3);
258 } else {
259 // Otherwise, result is imm[7:0] << 4.
260 Result = Imm7To0 << 4;
261 }
262 }
263 Inst.addOperand(MCOperand::createImm(Result));
265}
266
268 uint64_t Address,
269 const MCDisassembler *Decoder) {
270 if (RegNo >= 2)
272
273 MCRegister Reg = (RegNo == 0) ? RISCV::V0 : RISCV::NoRegister;
274
277}
278
280 const MCDisassembler *Decoder) {
283}
284
286 const MCDisassembler *Decoder) {
289}
290
291template <unsigned N>
293 int64_t Address,
294 const MCDisassembler *Decoder) {
295 assert(isUInt<N>(Imm) && "Invalid immediate");
298}
299
300template <unsigned Width, unsigned LowerBound>
302 int64_t Address,
303 const MCDisassembler *Decoder) {
304 assert(isUInt<Width>(Imm) && "Invalid immediate");
305
306 if (Imm < LowerBound)
308
311}
312
313template <unsigned Width, unsigned LowerBound>
315 int64_t Address,
316 const MCDisassembler *Decoder) {
317 assert(isUInt<Width>(Imm) && "Invalid immediate");
318
319 if ((Imm + 1) < LowerBound)
321
322 Inst.addOperand(MCOperand::createImm(Imm + 1));
324}
325
327 int64_t Address,
328 const MCDisassembler *Decoder) {
329 assert(isUInt<3>(Imm) && "Invalid Slist immediate");
330 const uint8_t Slist[] = {0, 1, 2, 4, 8, 16, 15, 31};
331 Inst.addOperand(MCOperand::createImm(Slist[Imm]));
333}
334
336 int64_t Address,
337 const MCDisassembler *Decoder) {
338 assert(isUInt<6>(Imm) && "Invalid immediate");
339
340 if (!Decoder->getSubtargetInfo().hasFeature(RISCV::Feature64Bit) &&
341 !isUInt<5>(Imm))
343
346}
347
349 int64_t Address,
350 const MCDisassembler *Decoder) {
351 assert(isUInt<7>(Imm) && "Invalid immediate");
352
353 uint32_t ExpectedValue =
354 Decoder->getSubtargetInfo().hasFeature(RISCV::Feature64Bit) ? 64 : 32;
355 if (Imm != ExpectedValue)
357
360}
361
362template <unsigned N>
364 int64_t Address,
365 const MCDisassembler *Decoder) {
366 if (Imm == 0)
368 return decodeUImmOperand<N>(Inst, Imm, Address, Decoder);
369}
370
371static DecodeStatus
373 const MCDisassembler *Decoder) {
374 if (Imm == 0)
376 return decodeUImmLog2XLenOperand(Inst, Imm, Address, Decoder);
377}
378
379template <unsigned N>
381 int64_t Address,
382 const MCDisassembler *Decoder) {
383 assert(isUInt<N>(Imm) && "Invalid immediate");
384 Inst.addOperand(MCOperand::createImm(Imm + 1));
386}
387
389 int64_t Address,
390 const MCDisassembler *Decoder) {
391 assert(isUInt<5>(Imm) && "Invalid immediate");
392 Inst.addOperand(MCOperand::createImm(Imm ? Imm : -1LL));
394}
395
396template <unsigned N>
398 int64_t Address,
399 const MCDisassembler *Decoder) {
400 assert(isUInt<N>(Imm) && "Invalid immediate");
401 // Sign-extend the number in the bottom N bits of Imm
404}
405
406template <unsigned N>
408 int64_t Address,
409 const MCDisassembler *Decoder) {
410 if (Imm == 0)
412 return decodeSImmOperand<N>(Inst, Imm, Address, Decoder);
413}
414
415template <unsigned T, unsigned N>
417 int64_t Address,
418 const MCDisassembler *Decoder) {
419 assert(isUInt<T - N + 1>(Imm) && "Invalid immediate");
420 // Sign-extend the number in the bottom T bits of Imm after accounting for
421 // the fact that the T bit immediate is stored in T-N bits (the LSB is
422 // always zero)
425}
426
428 int64_t Address,
429 const MCDisassembler *Decoder) {
430 assert(isUInt<6>(Imm) && "Invalid immediate");
431 if (Imm == 0)
433 Imm = SignExtend64<6>(Imm) & 0xfffff;
436}
437
438static DecodeStatus decodeFRMArg(MCInst &Inst, uint32_t Imm, int64_t Address,
439 const MCDisassembler *Decoder) {
440 assert(isUInt<3>(Imm) && "Invalid immediate");
443
446}
447
449 uint64_t Address,
450 const MCDisassembler *Decoder) {
451 bool IsRVE = Decoder->getSubtargetInfo().hasFeature(RISCV::FeatureStdExtE);
452 if (Imm < RISCVZC::RA || (IsRVE && Imm >= RISCVZC::RA_S0_S2))
456}
457
459 uint64_t Address,
460 const MCDisassembler *Decoder) {
461 if (Imm < RISCVZC::RA_S0)
463 return decodeZcmpRlist(Inst, Imm, Address, Decoder);
464}
465
466#include "RISCVGenDisassemblerTables.inc"
467
468namespace {
469
470struct DecoderListEntry {
471 const uint8_t *Table;
472 FeatureBitset ContainedFeatures;
473 const char *Desc;
474
475 bool haveContainedFeatures(const FeatureBitset &ActiveFeatures) const {
476 return ContainedFeatures.none() ||
477 (ContainedFeatures & ActiveFeatures).any();
478 }
479};
480
481} // end anonymous namespace
482
483static constexpr FeatureBitset XCVFeatureGroup = {
484 RISCV::FeatureVendorXCVbitmanip, RISCV::FeatureVendorXCVelw,
485 RISCV::FeatureVendorXCVmac, RISCV::FeatureVendorXCVmem,
486 RISCV::FeatureVendorXCValu, RISCV::FeatureVendorXCVsimd,
487 RISCV::FeatureVendorXCVbi};
488
490 RISCV::FeatureVendorXRivosVizip,
491};
492
493static constexpr FeatureBitset XqciFeatureGroup = {
494 RISCV::FeatureVendorXqcia, RISCV::FeatureVendorXqciac,
495 RISCV::FeatureVendorXqcibi, RISCV::FeatureVendorXqcibm,
496 RISCV::FeatureVendorXqcicli, RISCV::FeatureVendorXqcicm,
497 RISCV::FeatureVendorXqcics, RISCV::FeatureVendorXqcicsr,
498 RISCV::FeatureVendorXqciint, RISCV::FeatureVendorXqciio,
499 RISCV::FeatureVendorXqcilb, RISCV::FeatureVendorXqcili,
500 RISCV::FeatureVendorXqcilia, RISCV::FeatureVendorXqcilo,
501 RISCV::FeatureVendorXqcilsm, RISCV::FeatureVendorXqcisim,
502 RISCV::FeatureVendorXqcisls, RISCV::FeatureVendorXqcisync,
503};
504
505static constexpr FeatureBitset XSfVectorGroup = {
506 RISCV::FeatureVendorXSfvcp, RISCV::FeatureVendorXSfvqmaccdod,
507 RISCV::FeatureVendorXSfvqmaccqoq, RISCV::FeatureVendorXSfvfwmaccqqq,
508 RISCV::FeatureVendorXSfvfnrclipxfqf, RISCV::FeatureVendorXSfmmbase,
509 RISCV::FeatureVendorXSfvfexpa, RISCV::FeatureVendorXSfvfexpa64e,
510 RISCV::FeatureVendorXSfvfbfexp16e, RISCV::FeatureVendorXSfvfexp16e,
511 RISCV::FeatureVendorXSfvfexp32e};
512static constexpr FeatureBitset XSfSystemGroup = {
513 RISCV::FeatureVendorXSiFivecdiscarddlone,
514 RISCV::FeatureVendorXSiFivecflushdlone,
515};
516
517static constexpr FeatureBitset XMIPSGroup = {
518 RISCV::FeatureVendorXMIPSLSP,
519 RISCV::FeatureVendorXMIPSCMov,
520 RISCV::FeatureVendorXMIPSCBOP,
521 RISCV::FeatureVendorXMIPSEXECTL,
522};
523
524static constexpr FeatureBitset XTHeadGroup = {
525 RISCV::FeatureVendorXTHeadBa, RISCV::FeatureVendorXTHeadBb,
526 RISCV::FeatureVendorXTHeadBs, RISCV::FeatureVendorXTHeadCondMov,
527 RISCV::FeatureVendorXTHeadCmo, RISCV::FeatureVendorXTHeadFMemIdx,
528 RISCV::FeatureVendorXTHeadMac, RISCV::FeatureVendorXTHeadMemIdx,
529 RISCV::FeatureVendorXTHeadMemPair, RISCV::FeatureVendorXTHeadSync,
530 RISCV::FeatureVendorXTHeadVdot};
531
532static constexpr FeatureBitset XAndesGroup = {
533 RISCV::FeatureVendorXAndesPerf, RISCV::FeatureVendorXAndesBFHCvt,
534 RISCV::FeatureVendorXAndesVBFHCvt, RISCV::FeatureVendorXAndesVSIntH,
535 RISCV::FeatureVendorXAndesVSIntLoad, RISCV::FeatureVendorXAndesVPackFPH,
536 RISCV::FeatureVendorXAndesVDot};
537
538static constexpr FeatureBitset XSMTGroup = {RISCV::FeatureVendorXSMTVDot};
539
540static constexpr FeatureBitset XAIFGroup = {RISCV::FeatureVendorXAIFET};
541
542static constexpr DecoderListEntry DecoderList32[]{
543 // Vendor Extensions
544 {DecoderTableXCV32, XCVFeatureGroup, "CORE-V extensions"},
545 {DecoderTableXRivos32, XRivosFeatureGroup, "Rivos"},
546 {DecoderTableXqci32, XqciFeatureGroup, "Qualcomm uC Extensions"},
547 {DecoderTableXVentana32,
548 {RISCV::FeatureVendorXVentanaCondOps},
549 "XVentanaCondOps"},
550 {DecoderTableXTHead32, XTHeadGroup, "T-Head extensions"},
551 {DecoderTableXSfvector32, XSfVectorGroup, "SiFive vector extensions"},
552 {DecoderTableXSfsystem32, XSfSystemGroup, "SiFive system extensions"},
553 {DecoderTableXSfcease32, {RISCV::FeatureVendorXSfcease}, "SiFive sf.cease"},
554 {DecoderTableXMIPS32, XMIPSGroup, "Mips extensions"},
555 {DecoderTableXAndes32, XAndesGroup, "Andes extensions"},
556 {DecoderTableXSMT32, XSMTGroup, "SpacemiT extensions"},
557 {DecoderTableXAIF32, XAIFGroup, "AI Foundry extensions"},
558 // Standard Extensions
559 {DecoderTable32, {}, "standard 32-bit instructions"},
560 {DecoderTableRV32Only32, {}, "RV32-only standard 32-bit instructions"},
561 {DecoderTableZfinx32, {}, "Zfinx (Float in Integer)"},
562 {DecoderTableZdinxRV32Only32, {}, "RV32-only Zdinx (Double in Integer)"},
563};
564
565namespace {
566// Define bitwidths for various types used to instantiate the decoder.
567template <> constexpr uint32_t InsnBitWidth<uint16_t> = 16;
568template <> constexpr uint32_t InsnBitWidth<uint32_t> = 32;
569// Use uint64_t to represent 48 bit instructions.
570template <> constexpr uint32_t InsnBitWidth<uint64_t> = 48;
571} // namespace
572
573DecodeStatus RISCVDisassembler::getInstruction32(MCInst &MI, uint64_t &Size,
574 ArrayRef<uint8_t> Bytes,
575 uint64_t Address,
576 raw_ostream &CS) const {
577 if (Bytes.size() < 4) {
578 Size = 0;
580 }
581 Size = 4;
582
583 uint32_t Insn = support::endian::read32le(Bytes.data());
584
585 for (const DecoderListEntry &Entry : DecoderList32) {
586 if (!Entry.haveContainedFeatures(STI.getFeatureBits()))
587 continue;
588
589 LLVM_DEBUG(dbgs() << "Trying " << Entry.Desc << " table:\n");
591 decodeInstruction(Entry.Table, MI, Insn, Address, this, STI);
592 if (Result == MCDisassembler::Fail)
593 continue;
594
595 return Result;
596 }
597
599}
600
601static constexpr DecoderListEntry DecoderList16[]{
602 // Vendor Extensions
603 {DecoderTableXqci16, XqciFeatureGroup, "Qualcomm uC 16-bit"},
604 {DecoderTableXqccmp16,
605 {RISCV::FeatureVendorXqccmp},
606 "Xqccmp (Qualcomm 16-bit Push/Pop & Double Move Instructions)"},
607 {DecoderTableXqccmt16,
608 {RISCV::FeatureVendorXqccmt},
609 "Xqccmt (Qualcomm 16-bit Table Jump Instructions)"},
610 {DecoderTableXwchc16, {RISCV::FeatureVendorXwchc}, "WCH QingKe XW"},
611 // Standard Extensions
612 // DecoderTableZicfiss16 must be checked before DecoderTable16.
613 {DecoderTableZicfiss16, {}, "Zicfiss (Shadow Stack 16-bit)"},
614 {DecoderTable16, {}, "standard 16-bit instructions"},
615 {DecoderTableRV32Only16, {}, "RV32-only 16-bit instructions"},
616 // Zc* instructions incompatible with Zcf or Zcd
617 {DecoderTableZcOverlap16,
618 {},
619 "ZcOverlap (16-bit Instructions overlapping with Zcf/Zcd)"},
620};
621
622DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size,
623 ArrayRef<uint8_t> Bytes,
624 uint64_t Address,
625 raw_ostream &CS) const {
626 if (Bytes.size() < 2) {
627 Size = 0;
629 }
630 Size = 2;
631
632 uint16_t Insn = support::endian::read16le(Bytes.data());
633
634 for (const DecoderListEntry &Entry : DecoderList16) {
635 if (!Entry.haveContainedFeatures(STI.getFeatureBits()))
636 continue;
637
638 LLVM_DEBUG(dbgs() << "Trying " << Entry.Desc << " table:\n");
640 decodeInstruction(Entry.Table, MI, Insn, Address, this, STI);
641 if (Result != MCDisassembler::Fail)
642 return Result;
643 }
644
646}
647
648static constexpr DecoderListEntry DecoderList48[]{
649 {DecoderTableXqci48, XqciFeatureGroup, "Qualcomm uC 48bit"},
650};
651
652DecodeStatus RISCVDisassembler::getInstruction48(MCInst &MI, uint64_t &Size,
653 ArrayRef<uint8_t> Bytes,
654 uint64_t Address,
655 raw_ostream &CS) const {
656 if (Bytes.size() < 6) {
657 Size = 0;
659 }
660 Size = 6;
661
662 uint64_t Insn = 0;
663 for (size_t i = Size; i-- != 0;)
664 Insn += (static_cast<uint64_t>(Bytes[i]) << 8 * i);
665
666 for (const DecoderListEntry &Entry : DecoderList48) {
667 if (!Entry.haveContainedFeatures(STI.getFeatureBits()))
668 continue;
669
670 LLVM_DEBUG(dbgs() << "Trying " << Entry.Desc << " table:\n");
672 decodeInstruction(Entry.Table, MI, Insn, Address, this, STI);
673 if (Result == MCDisassembler::Fail)
674 continue;
675
676 return Result;
677 }
678
680}
681
682DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
683 ArrayRef<uint8_t> Bytes,
684 uint64_t Address,
685 raw_ostream &CS) const {
686 CommentStream = &CS;
687 // It's a 16 bit instruction if bit 0 and 1 are not 0b11.
688 if ((Bytes[0] & 0b11) != 0b11)
689 return getInstruction16(MI, Size, Bytes, Address, CS);
690
691 // Try to decode as a 32-bit instruction first.
692 DecodeStatus Result = getInstruction32(MI, Size, Bytes, Address, CS);
693 if (Result != MCDisassembler::Fail)
694 return Result;
695
696 // If bits [4:2] are 0b111 this might be a 48-bit or larger instruction,
697 // otherwise assume it's an unknown 32-bit instruction.
698 if ((Bytes[0] & 0b1'1100) != 0b1'1100) {
699 Size = Bytes.size() >= 4 ? 4 : 0;
701 }
702
703 // 48-bit instructions are encoded as 0bxx011111.
704 if ((Bytes[0] & 0b11'1111) == 0b01'1111)
705 return getInstruction48(MI, Size, Bytes, Address, CS);
706
707 // 64-bit instructions are encoded as 0x0111111.
708 if ((Bytes[0] & 0b111'1111) == 0b011'1111) {
709 Size = Bytes.size() >= 8 ? 8 : 0;
711 }
712
713 // Remaining cases need to check a second byte.
714 if (Bytes.size() < 2) {
715 Size = 0;
717 }
718
719 // 80-bit through 176-bit instructions are encoded as 0bxnnnxxxx_x1111111.
720 // Where the number of bits is (80 + (nnn * 16)) for nnn != 0b111.
721 unsigned nnn = (Bytes[1] >> 4) & 0b111;
722 if (nnn != 0b111) {
723 Size = 10 + (nnn * 2);
724 if (Bytes.size() < Size)
725 Size = 0;
727 }
728
729 // Remaining encodings are reserved for > 176-bit instructions.
730 Size = 0;
732}
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 DecodeStatus decodeUImm7EqXLenOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
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)
static DecodeStatus DecodeYBNDSWImm(MCInst &Inst, uint64_t Imm, int64_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.