LLVM 19.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"
19#include "llvm/MC/MCInst.h"
20#include "llvm/MC/MCInstrInfo.h"
24#include "llvm/Support/Endian.h"
25
26using namespace llvm;
27
28#define DEBUG_TYPE "riscv-disassembler"
29
31
32namespace {
33class RISCVDisassembler : public MCDisassembler {
34 std::unique_ptr<MCInstrInfo const> const MCII;
35
36public:
37 RISCVDisassembler(const MCSubtargetInfo &STI, MCContext &Ctx,
38 MCInstrInfo const *MCII)
39 : MCDisassembler(STI, Ctx), MCII(MCII) {}
40
42 ArrayRef<uint8_t> Bytes, uint64_t Address,
43 raw_ostream &CStream) const override;
44
45private:
46 void addSPOperands(MCInst &MI) const;
47
48 DecodeStatus getInstruction32(MCInst &Instr, uint64_t &Size,
49 ArrayRef<uint8_t> Bytes, uint64_t Address,
50 raw_ostream &CStream) const;
51 DecodeStatus getInstruction16(MCInst &Instr, uint64_t &Size,
52 ArrayRef<uint8_t> Bytes, uint64_t Address,
53 raw_ostream &CStream) const;
54};
55} // end anonymous namespace
56
58 const MCSubtargetInfo &STI,
59 MCContext &Ctx) {
60 return new RISCVDisassembler(STI, Ctx, T.createMCInstrInfo());
61}
62
64 // Register the disassembler for each target.
69}
70
72 uint64_t Address,
73 const MCDisassembler *Decoder) {
74 bool IsRVE = Decoder->getSubtargetInfo().hasFeature(RISCV::FeatureStdExtE);
75
76 if (RegNo >= 32 || (IsRVE && RegNo >= 16))
78
79 MCRegister Reg = RISCV::X0 + RegNo;
82}
83
85 uint64_t Address,
86 const MCDisassembler *Decoder) {
87 MCRegister Reg = RISCV::X0 + RegNo;
88 if (Reg != RISCV::X1 && Reg != RISCV::X5)
90
93}
94
96 uint64_t Address,
97 const MCDisassembler *Decoder) {
98 if (RegNo >= 32)
100
101 MCRegister Reg = RISCV::F0_H + RegNo;
104}
105
107 uint64_t Address,
108 const MCDisassembler *Decoder) {
109 if (RegNo >= 32)
111
112 MCRegister Reg = RISCV::F0_F + RegNo;
115}
116
118 uint64_t Address,
119 const MCDisassembler *Decoder) {
120 if (RegNo >= 8) {
122 }
123 MCRegister Reg = RISCV::F8_F + RegNo;
126}
127
129 uint64_t Address,
130 const MCDisassembler *Decoder) {
131 if (RegNo >= 32)
133
134 MCRegister Reg = RISCV::F0_D + RegNo;
137}
138
140 uint64_t Address,
141 const MCDisassembler *Decoder) {
142 if (RegNo >= 8) {
144 }
145 MCRegister Reg = RISCV::F8_D + RegNo;
148}
149
151 uint64_t Address,
152 const MCDisassembler *Decoder) {
153 if (RegNo == 0) {
155 }
156
157 return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
158}
159
160static DecodeStatus
162 const MCDisassembler *Decoder) {
163 if (RegNo == 2) {
165 }
166
167 return DecodeGPRNoX0RegisterClass(Inst, RegNo, Address, Decoder);
168}
169
171 uint64_t Address,
172 const MCDisassembler *Decoder) {
173 if (RegNo >= 8)
175
176 MCRegister Reg = RISCV::X8 + RegNo;
179}
180
182 uint64_t Address,
183 const MCDisassembler *Decoder) {
184 if (RegNo >= 32 || RegNo & 1)
186
187 MCRegister Reg = RISCV::X0 + RegNo;
190}
191
193 uint64_t Address,
194 const void *Decoder) {
195 if (RegNo >= 8)
197
198 MCRegister Reg = (RegNo < 2) ? (RegNo + RISCV::X8) : (RegNo - 2 + RISCV::X18);
201}
202
204 uint64_t Address,
205 const MCDisassembler *Decoder) {
206 if (RegNo >= 32)
208
209 MCRegister Reg = RISCV::V0 + RegNo;
212}
213
215 uint64_t Address,
216 const MCDisassembler *Decoder) {
217 if (RegNo >= 32 || RegNo % 2)
219
220 const RISCVDisassembler *Dis =
221 static_cast<const RISCVDisassembler *>(Decoder);
222 const MCRegisterInfo *RI = Dis->getContext().getRegisterInfo();
223 MCRegister Reg =
224 RI->getMatchingSuperReg(RISCV::V0 + RegNo, RISCV::sub_vrm1_0,
225 &RISCVMCRegisterClasses[RISCV::VRM2RegClassID]);
226
229}
230
232 uint64_t Address,
233 const MCDisassembler *Decoder) {
234 if (RegNo >= 32 || RegNo % 4)
236
237 const RISCVDisassembler *Dis =
238 static_cast<const RISCVDisassembler *>(Decoder);
239 const MCRegisterInfo *RI = Dis->getContext().getRegisterInfo();
240 MCRegister Reg =
241 RI->getMatchingSuperReg(RISCV::V0 + RegNo, RISCV::sub_vrm1_0,
242 &RISCVMCRegisterClasses[RISCV::VRM4RegClassID]);
243
246}
247
249 uint64_t Address,
250 const MCDisassembler *Decoder) {
251 if (RegNo >= 32 || RegNo % 8)
253
254 const RISCVDisassembler *Dis =
255 static_cast<const RISCVDisassembler *>(Decoder);
256 const MCRegisterInfo *RI = Dis->getContext().getRegisterInfo();
257 MCRegister Reg =
258 RI->getMatchingSuperReg(RISCV::V0 + RegNo, RISCV::sub_vrm1_0,
259 &RISCVMCRegisterClasses[RISCV::VRM8RegClassID]);
260
263}
264
266 uint64_t Address,
267 const MCDisassembler *Decoder) {
268 if (RegNo >= 2)
270
271 MCRegister Reg = (RegNo == 0) ? RISCV::V0 : RISCV::NoRegister;
272
275}
276
277template <unsigned N>
279 int64_t Address,
280 const MCDisassembler *Decoder) {
281 assert(isUInt<N>(Imm) && "Invalid immediate");
284}
285
286template <unsigned N>
288 int64_t Address,
289 const MCDisassembler *Decoder) {
290 if (Imm == 0)
292 return decodeUImmOperand<N>(Inst, Imm, Address, Decoder);
293}
294
295template <unsigned N>
297 int64_t Address,
298 const MCDisassembler *Decoder) {
299 assert(isUInt<N>(Imm) && "Invalid immediate");
300 // Sign-extend the number in the bottom N bits of Imm
301 Inst.addOperand(MCOperand::createImm(SignExtend64<N>(Imm)));
303}
304
305template <unsigned N>
307 int64_t Address,
308 const MCDisassembler *Decoder) {
309 if (Imm == 0)
311 return decodeSImmOperand<N>(Inst, Imm, Address, Decoder);
312}
313
314template <unsigned N>
316 int64_t Address,
317 const MCDisassembler *Decoder) {
318 assert(isUInt<N>(Imm) && "Invalid immediate");
319 // Sign-extend the number in the bottom N bits of Imm after accounting for
320 // the fact that the N bit immediate is stored in N-1 bits (the LSB is
321 // always zero)
322 Inst.addOperand(MCOperand::createImm(SignExtend64<N>(Imm << 1)));
324}
325
327 int64_t Address,
328 const MCDisassembler *Decoder) {
329 assert(isUInt<6>(Imm) && "Invalid immediate");
330 if (Imm > 31) {
331 Imm = (SignExtend64<6>(Imm) & 0xfffff);
332 }
335}
336
337static DecodeStatus decodeFRMArg(MCInst &Inst, uint32_t Imm, int64_t Address,
338 const MCDisassembler *Decoder) {
339 assert(isUInt<3>(Imm) && "Invalid immediate");
342
345}
346
348 uint64_t Address,
349 const MCDisassembler *Decoder);
350
352 uint64_t Address,
353 const MCDisassembler *Decoder);
354
356 uint64_t Address,
357 const MCDisassembler *Decoder);
358
360 uint64_t Address,
361 const MCDisassembler *Decoder);
362
364 uint64_t Address,
365 const MCDisassembler *Decoder);
366
368 uint64_t Address,
369 const MCDisassembler *Decoder);
370
372 uint64_t Address, const void *Decoder);
373
375 const MCDisassembler *Decoder);
376
378 uint64_t Address, const void *Decoder);
379
381 uint64_t Address,
382 const MCDisassembler *Decoder);
383
384#include "RISCVGenDisassemblerTables.inc"
385
387 uint64_t Address,
388 const MCDisassembler *Decoder) {
389 uint32_t Rd = fieldFromInstruction(Insn, 7, 5);
390 [[maybe_unused]] DecodeStatus Result =
391 DecodeGPRNoX0RegisterClass(Inst, Rd, Address, Decoder);
392 assert(Result == MCDisassembler::Success && "Invalid register");
393 Inst.addOperand(Inst.getOperand(0));
396}
397
399 uint64_t Address,
400 const MCDisassembler *Decoder) {
401 uint32_t Rs1 = fieldFromInstruction(Insn, 7, 5);
402 [[maybe_unused]] DecodeStatus Result =
403 DecodeGPRX1X5RegisterClass(Inst, Rs1, Address, Decoder);
404 assert(Result == MCDisassembler::Success && "Invalid register");
406}
407
409 uint64_t Address,
410 const MCDisassembler *Decoder) {
411 Inst.addOperand(MCOperand::createReg(RISCV::X0));
412 uint32_t SImm6 =
413 fieldFromInstruction(Insn, 12, 1) << 5 | fieldFromInstruction(Insn, 2, 5);
414 [[maybe_unused]] DecodeStatus Result =
415 decodeSImmOperand<6>(Inst, SImm6, Address, Decoder);
416 assert(Result == MCDisassembler::Success && "Invalid immediate");
418}
419
421 uint64_t Address,
422 const MCDisassembler *Decoder) {
423 Inst.addOperand(MCOperand::createReg(RISCV::X0));
424 Inst.addOperand(Inst.getOperand(0));
425 uint32_t UImm6 =
426 fieldFromInstruction(Insn, 12, 1) << 5 | fieldFromInstruction(Insn, 2, 5);
427 [[maybe_unused]] DecodeStatus Result =
428 decodeUImmOperand<6>(Inst, UImm6, Address, Decoder);
429 assert(Result == MCDisassembler::Success && "Invalid immediate");
431}
432
434 uint64_t Address,
435 const MCDisassembler *Decoder) {
436 uint32_t Rd = fieldFromInstruction(Insn, 7, 5);
437 uint32_t Rs2 = fieldFromInstruction(Insn, 2, 5);
438 DecodeGPRRegisterClass(Inst, Rd, Address, Decoder);
439 DecodeGPRRegisterClass(Inst, Rs2, Address, Decoder);
441}
442
444 uint64_t Address,
445 const MCDisassembler *Decoder) {
446 uint32_t Rd = fieldFromInstruction(Insn, 7, 5);
447 uint32_t Rs2 = fieldFromInstruction(Insn, 2, 5);
448 DecodeGPRRegisterClass(Inst, Rd, Address, Decoder);
449 Inst.addOperand(Inst.getOperand(0));
450 DecodeGPRRegisterClass(Inst, Rs2, Address, Decoder);
452}
453
455 uint64_t Address,
456 const MCDisassembler *Decoder) {
457 uint32_t Rd1 = fieldFromInstruction(Insn, 7, 5);
458 uint32_t Rs1 = fieldFromInstruction(Insn, 15, 5);
459 uint32_t Rd2 = fieldFromInstruction(Insn, 20, 5);
460 uint32_t UImm2 = fieldFromInstruction(Insn, 25, 2);
461 DecodeGPRRegisterClass(Inst, Rd1, Address, Decoder);
462 DecodeGPRRegisterClass(Inst, Rd2, Address, Decoder);
463 DecodeGPRRegisterClass(Inst, Rs1, Address, Decoder);
464 [[maybe_unused]] DecodeStatus Result =
465 decodeUImmOperand<2>(Inst, UImm2, Address, Decoder);
466 assert(Result == MCDisassembler::Success && "Invalid immediate");
467
468 // Disassemble the final operand which is implicit.
469 unsigned Opcode = Inst.getOpcode();
470 bool IsWordOp = (Opcode == RISCV::TH_LWD || Opcode == RISCV::TH_LWUD ||
471 Opcode == RISCV::TH_SWD);
472 if (IsWordOp)
474 else
476
478}
479
481 uint64_t Address, const void *Decoder) {
482 if (Imm <= 3)
486}
487
489 const MCDisassembler *Decoder) {
490 uint32_t Rs1 = fieldFromInstruction(Insn, 0, 5);
491 uint32_t Rs2 = fieldFromInstruction(Insn, 5, 5);
492 DecodeGPRRegisterClass(Inst, Rs1, Address, Decoder);
493 DecodeGPRRegisterClass(Inst, Rs2, Address, Decoder);
495}
496
498 uint64_t Address, const void *Decoder) {
501}
502
503// Add implied SP operand for C.*SP compressed instructions. The SP operand
504// isn't explicitly encoded in the instruction.
505void RISCVDisassembler::addSPOperands(MCInst &MI) const {
506 const MCInstrDesc &MCID = MCII->get(MI.getOpcode());
507 for (unsigned i = 0; i < MCID.getNumOperands(); i++)
508 if (MCID.operands()[i].RegClass == RISCV::SPRegClassID)
509 MI.insert(MI.begin() + i, MCOperand::createReg(RISCV::X2));
510}
511
512#define TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION(FEATURE_CHECKS, DECODER_TABLE, \
513 DESC, ADDITIONAL_OPERATION) \
514 do { \
515 if (FEATURE_CHECKS) { \
516 LLVM_DEBUG(dbgs() << "Trying " DESC ":\n"); \
517 DecodeStatus Result = \
518 decodeInstruction(DECODER_TABLE, MI, Insn, Address, this, STI); \
519 if (Result != MCDisassembler::Fail) { \
520 ADDITIONAL_OPERATION; \
521 return Result; \
522 } \
523 } \
524 } while (false)
525#define TRY_TO_DECODE_AND_ADD_SP(FEATURE_CHECKS, DECODER_TABLE, DESC) \
526 TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION(FEATURE_CHECKS, DECODER_TABLE, DESC, \
527 addSPOperands(MI))
528#define TRY_TO_DECODE(FEATURE_CHECKS, DECODER_TABLE, DESC) \
529 TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION(FEATURE_CHECKS, DECODER_TABLE, DESC, \
530 (void)nullptr)
531#define TRY_TO_DECODE_FEATURE(FEATURE, DECODER_TABLE, DESC) \
532 TRY_TO_DECODE(STI.hasFeature(FEATURE), DECODER_TABLE, DESC)
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
545
546 TRY_TO_DECODE(STI.hasFeature(RISCV::FeatureStdExtZdinx) &&
547 !STI.hasFeature(RISCV::Feature64Bit),
548 DecoderTableRV32Zdinx32,
549 "RV32Zdinx table (Double in Integer and rv32)");
550 TRY_TO_DECODE(STI.hasFeature(RISCV::FeatureStdExtZacas) &&
551 !STI.hasFeature(RISCV::Feature64Bit),
552 DecoderTableRV32Zacas32,
553 "RV32Zacas table (Compare-And-Swap and rv32)");
554 TRY_TO_DECODE_FEATURE(RISCV::FeatureStdExtZfinx, DecoderTableRVZfinx32,
555 "RVZfinx table (Float in Integer)");
556 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXVentanaCondOps,
557 DecoderTableXVentana32, "Ventana custom opcode table");
558 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadBa, DecoderTableXTHeadBa32,
559 "XTHeadBa custom opcode table");
560 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadBb, DecoderTableXTHeadBb32,
561 "XTHeadBb custom opcode table");
562 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadBs, DecoderTableXTHeadBs32,
563 "XTHeadBs custom opcode table");
564 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadCondMov,
565 DecoderTableXTHeadCondMov32,
566 "XTHeadCondMov custom opcode table");
567 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadCmo, DecoderTableXTHeadCmo32,
568 "XTHeadCmo custom opcode table");
569 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadFMemIdx,
570 DecoderTableXTHeadFMemIdx32,
571 "XTHeadFMemIdx custom opcode table");
572 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadMac, DecoderTableXTHeadMac32,
573 "XTHeadMac custom opcode table");
574 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadMemIdx,
575 DecoderTableXTHeadMemIdx32,
576 "XTHeadMemIdx custom opcode table");
577 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadMemPair,
578 DecoderTableXTHeadMemPair32,
579 "XTHeadMemPair custom opcode table");
580 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadSync,
581 DecoderTableXTHeadSync32,
582 "XTHeadSync custom opcode table");
583 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadVdot,
584 DecoderTableXTHeadVdot32,
585 "XTHeadVdot custom opcode table");
586 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXSfvcp, DecoderTableXSfvcp32,
587 "SiFive VCIX custom opcode table");
589 RISCV::FeatureVendorXSfvqmaccdod, DecoderTableXSfvqmaccdod32,
590 "SiFive Matrix Multiplication (2x8 and 8x2) Instruction opcode table");
592 RISCV::FeatureVendorXSfvqmaccqoq, DecoderTableXSfvqmaccqoq32,
593 "SiFive Matrix Multiplication (4x8 and 8x4) Instruction opcode table");
595 RISCV::FeatureVendorXSfvfwmaccqqq, DecoderTableXSfvfwmaccqqq32,
596 "SiFive Matrix Multiplication Instruction opcode table");
598 RISCV::FeatureVendorXSfvfnrclipxfqf, DecoderTableXSfvfnrclipxfqf32,
599 "SiFive FP32-to-int8 Ranged Clip Instructions opcode table");
600 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXSiFivecdiscarddlone,
601 DecoderTableXSiFivecdiscarddlone32,
602 "SiFive sf.cdiscard.d.l1 custom opcode table");
603 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXSiFivecflushdlone,
604 DecoderTableXSiFivecflushdlone32,
605 "SiFive sf.cflush.d.l1 custom opcode table");
606 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXSfcease, DecoderTableXSfcease32,
607 "SiFive sf.cease custom opcode table");
608 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCVbitmanip,
609 DecoderTableXCVbitmanip32,
610 "CORE-V Bit Manipulation custom opcode table");
611 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCVelw, DecoderTableXCVelw32,
612 "CORE-V Event load custom opcode table");
613 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCVmac, DecoderTableXCVmac32,
614 "CORE-V MAC custom opcode table");
615 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCVmem, DecoderTableXCVmem32,
616 "CORE-V MEM custom opcode table");
617 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCValu, DecoderTableXCValu32,
618 "CORE-V ALU custom opcode table");
619 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCVsimd, DecoderTableXCVsimd32,
620 "CORE-V SIMD extensions custom opcode table");
621 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCVbi, DecoderTableXCVbi32,
622 "CORE-V Immediate Branching custom opcode table");
623 TRY_TO_DECODE(true, DecoderTable32, "RISCV32 table");
624
626}
627
628DecodeStatus RISCVDisassembler::getInstruction16(MCInst &MI, uint64_t &Size,
629 ArrayRef<uint8_t> Bytes,
630 uint64_t Address,
631 raw_ostream &CS) const {
632 if (Bytes.size() < 2) {
633 Size = 0;
635 }
636 Size = 2;
637
639 TRY_TO_DECODE_AND_ADD_SP(!STI.hasFeature(RISCV::Feature64Bit),
640 DecoderTableRISCV32Only_16,
641 "RISCV32Only_16 table (16-bit Instruction)");
642 TRY_TO_DECODE_FEATURE(RISCV::FeatureStdExtZicfiss, DecoderTableZicfiss16,
643 "RVZicfiss table (Shadow Stack)");
644 TRY_TO_DECODE_FEATURE(RISCV::FeatureStdExtZcmt, DecoderTableRVZcmt16,
645 "Zcmt table (16-bit Table Jump Instructions)");
647 RISCV::FeatureStdExtZcmp, DecoderTableRVZcmp16,
648 "Zcmp table (16-bit Push/Pop & Double Move Instructions)");
649 TRY_TO_DECODE_AND_ADD_SP(true, DecoderTable16,
650 "RISCV_C table (16-bit Instruction)");
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 // TODO: This will need modification when supporting instruction set
660 // extensions with instructions > 32-bits (up to 176 bits wide).
661
662 // It's a 32 bit instruction if bit 0 and 1 are 1.
663 if ((Bytes[0] & 0x3) == 0x3)
664 return getInstruction32(MI, Size, Bytes, Address, CS);
665
666 return getInstruction16(MI, Size, Bytes, Address, CS);
667}
SmallVector< AArch64_IMM::ImmInsnModel, 4 > Insn
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:135
uint64_t Size
IRTranslator LLVM IR MI
#define TRY_TO_DECODE(FEATURE_CHECKS, DECODER_TABLE, DESC)
static DecodeStatus decodeRegReg(MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeZcmpRlist(MCInst &Inst, uint32_t Imm, uint64_t Address, const void *Decoder)
static DecodeStatus decodeRVCInstrRdRs1Rs2(MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
MCDisassembler::DecodeStatus DecodeStatus
static DecodeStatus decodeSImmOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPRX1X5RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPRCRegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFPR64RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static MCDisassembler * createRISCVDisassembler(const Target &T, const MCSubtargetInfo &STI, MCContext &Ctx)
static DecodeStatus decodeRVCInstrRdRs1ImmZero(MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
#define TRY_TO_DECODE_FEATURE(FEATURE, DECODER_TABLE, DESC)
static DecodeStatus decodeSImmOperandAndLsl1(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFPR32CRegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeXTHeadMemPair(MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeCLUIImmOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeCSSPushPopchk(MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeUImmOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFPR32RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeVRM8RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeVRM4RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeRVCInstrRdSImm(MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeVRRegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeVRM2RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPRPairRegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeZcmpSpimm(MCInst &Inst, uint32_t Imm, uint64_t Address, const void *Decoder)
static DecodeStatus DecodeGPRNoX0X2RegisterClass(MCInst &Inst, uint64_t RegNo, uint32_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeRVCInstrRdRs2(MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeSImmNonZeroOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeFPR64CRegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVDisassembler()
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 DecodeSR07RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const void *Decoder)
static DecodeStatus decodeRVCInstrRdRs1UImm(MCInst &Inst, uint32_t Insn, uint64_t Address, const MCDisassembler *Decoder)
#define TRY_TO_DECODE_AND_ADD_SP(FEATURE_CHECKS, DECODER_TABLE, DESC)
static DecodeStatus DecodeFPR16RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeGPRRegisterClass(MCInst &Inst, uint32_t RegNo, uint64_t Address, const MCDisassembler *Decoder)
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)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:165
const T * data() const
Definition: ArrayRef.h:162
Context object for machine code objects.
Definition: MCContext.h:81
Superclass for all disassemblers.
const MCSubtargetInfo & getSubtargetInfo() const
DecodeStatus
Ternary decode status.
virtual DecodeStatus getInstruction(MCInst &Instr, uint64_t &Size, ArrayRef< uint8_t > Bytes, uint64_t Address, raw_ostream &CStream) const =0
Returns the disassembly of a single instruction.
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
unsigned getOpcode() const
Definition: MCInst.h:198
void addOperand(const MCOperand Op)
Definition: MCInst.h:210
const MCOperand & getOperand(unsigned i) const
Definition: MCInst.h:206
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:198
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
Definition: MCInstrDesc.h:237
ArrayRef< MCOperandInfo > operands() const
Definition: MCInstrDesc.h:239
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
static MCOperand createReg(unsigned Reg)
Definition: MCInst.h:134
static MCOperand createImm(int64_t Val)
Definition: MCInst.h:141
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:33
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:52
static bool isValidRoundingMode(unsigned Mode)
uint16_t read16le(const void *P)
Definition: Endian.h:421
uint32_t read32le(const void *P)
Definition: Endian.h:424
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Target & getTheRISCV32Target()
Target & getTheRISCV64Target()
static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn)
RegisterMCDisassembler - Register a MCDisassembler implementation for the given target.