LLVM 18.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} // end anonymous namespace
49
51 const MCSubtargetInfo &STI,
52 MCContext &Ctx) {
53 return new RISCVDisassembler(STI, Ctx, T.createMCInstrInfo());
54}
55
57 // Register the disassembler for each target.
62}
63
65 uint64_t Address,
66 const MCDisassembler *Decoder) {
67 bool IsRVE = Decoder->getSubtargetInfo().hasFeature(RISCV::FeatureRVE);
68
69 if (RegNo >= 32 || (IsRVE && RegNo >= 16))
71
72 MCRegister Reg = RISCV::X0 + RegNo;
75}
76
78 uint64_t Address,
79 const MCDisassembler *Decoder) {
80 if (RegNo >= 32)
82
83 MCRegister Reg = RISCV::F0_H + RegNo;
86}
87
89 uint64_t Address,
90 const MCDisassembler *Decoder) {
91 if (RegNo >= 32)
93
94 MCRegister Reg = RISCV::F0_F + RegNo;
97}
98
100 uint64_t Address,
101 const MCDisassembler *Decoder) {
102 if (RegNo >= 8) {
104 }
105 MCRegister Reg = RISCV::F8_F + RegNo;
108}
109
111 uint64_t Address,
112 const MCDisassembler *Decoder) {
113 if (RegNo >= 32)
115
116 MCRegister Reg = RISCV::F0_D + RegNo;
119}
120
122 uint64_t Address,
123 const MCDisassembler *Decoder) {
124 if (RegNo >= 8) {
126 }
127 MCRegister Reg = RISCV::F8_D + RegNo;
130}
131
133 uint64_t Address,
134 const MCDisassembler *Decoder) {
135 if (RegNo == 0) {
137 }
138
139 return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
140}
141
142static DecodeStatus
144 const MCDisassembler *Decoder) {
145 if (RegNo == 2) {
147 }
148
149 return DecodeGPRNoX0RegisterClass(Inst, RegNo, Address, Decoder);
150}
151
153 uint64_t Address,
154 const MCDisassembler *Decoder) {
155 if (RegNo >= 8)
157
158 MCRegister Reg = RISCV::X8 + RegNo;
161}
162
164 uint64_t Address,
165 const MCDisassembler *Decoder) {
166 if (RegNo >= 32 || RegNo & 1)
168
169 MCRegister Reg = RISCV::X0 + RegNo;
172}
173
175 uint64_t Address,
176 const void *Decoder) {
177 if (RegNo >= 8)
179
180 MCRegister Reg = (RegNo < 2) ? (RegNo + RISCV::X8) : (RegNo - 2 + RISCV::X18);
183}
184
186 uint64_t Address,
187 const MCDisassembler *Decoder) {
188 if (RegNo >= 32)
190
191 MCRegister Reg = RISCV::V0 + RegNo;
194}
195
197 uint64_t Address,
198 const MCDisassembler *Decoder) {
199 if (RegNo >= 32)
201
202 if (RegNo % 2)
204
205 const RISCVDisassembler *Dis =
206 static_cast<const RISCVDisassembler *>(Decoder);
207 const MCRegisterInfo *RI = Dis->getContext().getRegisterInfo();
208 MCRegister Reg =
209 RI->getMatchingSuperReg(RISCV::V0 + RegNo, RISCV::sub_vrm1_0,
210 &RISCVMCRegisterClasses[RISCV::VRM2RegClassID]);
211
214}
215
217 uint64_t Address,
218 const MCDisassembler *Decoder) {
219 if (RegNo >= 32)
221
222 if (RegNo % 4)
224
225 const RISCVDisassembler *Dis =
226 static_cast<const RISCVDisassembler *>(Decoder);
227 const MCRegisterInfo *RI = Dis->getContext().getRegisterInfo();
228 MCRegister Reg =
229 RI->getMatchingSuperReg(RISCV::V0 + RegNo, RISCV::sub_vrm1_0,
230 &RISCVMCRegisterClasses[RISCV::VRM4RegClassID]);
231
234}
235
237 uint64_t Address,
238 const MCDisassembler *Decoder) {
239 if (RegNo >= 32)
241
242 if (RegNo % 8)
244
245 const RISCVDisassembler *Dis =
246 static_cast<const RISCVDisassembler *>(Decoder);
247 const MCRegisterInfo *RI = Dis->getContext().getRegisterInfo();
248 MCRegister Reg =
249 RI->getMatchingSuperReg(RISCV::V0 + RegNo, RISCV::sub_vrm1_0,
250 &RISCVMCRegisterClasses[RISCV::VRM8RegClassID]);
251
254}
255
257 uint64_t Address,
258 const MCDisassembler *Decoder) {
259 MCRegister Reg = RISCV::NoRegister;
260 switch (RegNo) {
261 default:
263 case 0:
264 Reg = RISCV::V0;
265 break;
266 case 1:
267 break;
268 }
271}
272
273template <unsigned N>
275 int64_t Address,
276 const MCDisassembler *Decoder) {
277 assert(isUInt<N>(Imm) && "Invalid immediate");
280}
281
282template <unsigned N>
284 int64_t Address,
285 const MCDisassembler *Decoder) {
286 if (Imm == 0)
288 return decodeUImmOperand<N>(Inst, Imm, Address, Decoder);
289}
290
291template <unsigned N>
293 int64_t Address,
294 const MCDisassembler *Decoder) {
295 assert(isUInt<N>(Imm) && "Invalid immediate");
296 // Sign-extend the number in the bottom N bits of Imm
297 Inst.addOperand(MCOperand::createImm(SignExtend64<N>(Imm)));
299}
300
301template <unsigned N>
303 int64_t Address,
304 const MCDisassembler *Decoder) {
305 if (Imm == 0)
307 return decodeSImmOperand<N>(Inst, Imm, Address, Decoder);
308}
309
310template <unsigned N>
312 int64_t Address,
313 const MCDisassembler *Decoder) {
314 assert(isUInt<N>(Imm) && "Invalid immediate");
315 // Sign-extend the number in the bottom N bits of Imm after accounting for
316 // the fact that the N bit immediate is stored in N-1 bits (the LSB is
317 // always zero)
318 Inst.addOperand(MCOperand::createImm(SignExtend64<N>(Imm << 1)));
320}
321
323 int64_t Address,
324 const MCDisassembler *Decoder) {
325 assert(isUInt<6>(Imm) && "Invalid immediate");
326 if (Imm > 31) {
327 Imm = (SignExtend64<6>(Imm) & 0xfffff);
328 }
331}
332
333static DecodeStatus decodeFRMArg(MCInst &Inst, uint32_t Imm, int64_t Address,
334 const MCDisassembler *Decoder) {
335 assert(isUInt<3>(Imm) && "Invalid immediate");
338
341}
342
344 uint64_t Address,
345 const MCDisassembler *Decoder);
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
367static DecodeStatus decodeZcmpRlist(MCInst &Inst, unsigned Imm,
368 uint64_t Address, const void *Decoder);
369
370static DecodeStatus decodeZcmpSpimm(MCInst &Inst, unsigned Imm,
371 uint64_t Address, const void *Decoder);
372
373#include "RISCVGenDisassemblerTables.inc"
374
376 uint64_t Address,
377 const MCDisassembler *Decoder) {
378 uint32_t Rd = fieldFromInstruction(Insn, 7, 5);
379 DecodeStatus Result = DecodeGPRNoX0RegisterClass(Inst, Rd, Address, Decoder);
380 (void)Result;
381 assert(Result == MCDisassembler::Success && "Invalid register");
382 Inst.addOperand(Inst.getOperand(0));
385}
386
388 uint64_t Address,
389 const MCDisassembler *Decoder) {
390 Inst.addOperand(MCOperand::createReg(RISCV::X0));
391 uint32_t SImm6 =
392 fieldFromInstruction(Insn, 12, 1) << 5 | fieldFromInstruction(Insn, 2, 5);
393 DecodeStatus Result = decodeSImmOperand<6>(Inst, SImm6, Address, Decoder);
394 (void)Result;
395 assert(Result == MCDisassembler::Success && "Invalid immediate");
397}
398
400 uint64_t Address,
401 const MCDisassembler *Decoder) {
402 Inst.addOperand(MCOperand::createReg(RISCV::X0));
403 Inst.addOperand(Inst.getOperand(0));
404 uint32_t UImm6 =
405 fieldFromInstruction(Insn, 12, 1) << 5 | fieldFromInstruction(Insn, 2, 5);
406 DecodeStatus Result = decodeUImmOperand<6>(Inst, UImm6, Address, Decoder);
407 (void)Result;
408 assert(Result == MCDisassembler::Success && "Invalid immediate");
410}
411
413 uint64_t Address,
414 const MCDisassembler *Decoder) {
415 uint32_t Rd = fieldFromInstruction(Insn, 7, 5);
416 uint32_t Rs2 = fieldFromInstruction(Insn, 2, 5);
417 DecodeGPRRegisterClass(Inst, Rd, Address, Decoder);
418 DecodeGPRRegisterClass(Inst, Rs2, Address, Decoder);
420}
421
423 uint64_t Address,
424 const MCDisassembler *Decoder) {
425 uint32_t Rd = fieldFromInstruction(Insn, 7, 5);
426 uint32_t Rs2 = fieldFromInstruction(Insn, 2, 5);
427 DecodeGPRRegisterClass(Inst, Rd, Address, Decoder);
428 Inst.addOperand(Inst.getOperand(0));
429 DecodeGPRRegisterClass(Inst, Rs2, Address, Decoder);
431}
432
434 uint64_t Address,
435 const MCDisassembler *Decoder) {
436 uint32_t Rd1 = fieldFromInstruction(Insn, 7, 5);
437 uint32_t Rs1 = fieldFromInstruction(Insn, 15, 5);
438 uint32_t Rd2 = fieldFromInstruction(Insn, 20, 5);
439 uint32_t UImm2 = fieldFromInstruction(Insn, 25, 2);
440 DecodeGPRRegisterClass(Inst, Rd1, Address, Decoder);
441 DecodeGPRRegisterClass(Inst, Rd2, Address, Decoder);
442 DecodeGPRRegisterClass(Inst, Rs1, Address, Decoder);
443 DecodeStatus Result = decodeUImmOperand<2>(Inst, UImm2, Address, Decoder);
444 (void)Result;
445 assert(Result == MCDisassembler::Success && "Invalid immediate");
446
447 // Disassemble the final operand which is implicit.
448 unsigned Opcode = Inst.getOpcode();
449 bool IsWordOp = (Opcode == RISCV::TH_LWD || Opcode == RISCV::TH_LWUD ||
450 Opcode == RISCV::TH_SWD);
451 if (IsWordOp)
453 else
455
457}
458
459static DecodeStatus decodeZcmpRlist(MCInst &Inst, unsigned Imm,
460 uint64_t Address, const void *Decoder) {
461 if (Imm <= 3)
465}
466
467// spimm is based on rlist now.
468static DecodeStatus decodeZcmpSpimm(MCInst &Inst, unsigned Imm,
469 uint64_t Address, const void *Decoder) {
470 // TODO: check if spimm matches rlist
473}
474
475// Add implied SP operand for C.*SP compressed instructions. The SP operand
476// isn't explicitly encoded in the instruction.
477void RISCVDisassembler::addSPOperands(MCInst &MI) const {
478 const MCInstrDesc &MCID = MCII->get(MI.getOpcode());
479 for (unsigned i = 0; i < MCID.getNumOperands(); i++)
480 if (MCID.operands()[i].RegClass == RISCV::SPRegClassID)
481 MI.insert(MI.begin() + i, MCOperand::createReg(RISCV::X2));
482}
483
484DecodeStatus RISCVDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
485 ArrayRef<uint8_t> Bytes,
486 uint64_t Address,
487 raw_ostream &CS) const {
488 // TODO: This will need modification when supporting instruction set
489 // extensions with instructions > 32-bits (up to 176 bits wide).
492
493#define TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION(FEATURE_CHECKS, DECODER_TABLE, \
494 DESC, ADDITIONAL_OPERATION) \
495 do { \
496 if (FEATURE_CHECKS) { \
497 LLVM_DEBUG(dbgs() << "Trying " DESC ":\n"); \
498 Result = decodeInstruction(DECODER_TABLE, MI, Insn, Address, this, STI); \
499 if (Result != MCDisassembler::Fail) { \
500 ADDITIONAL_OPERATION; \
501 return Result; \
502 } \
503 } \
504 } while (false)
505#define TRY_TO_DECODE_AND_ADD_SP(FEATURE_CHECKS, DECODER_TABLE, DESC) \
506 TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION(FEATURE_CHECKS, DECODER_TABLE, DESC, \
507 addSPOperands(MI))
508#define TRY_TO_DECODE(FEATURE_CHECKS, DECODER_TABLE, DESC) \
509 TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION(FEATURE_CHECKS, DECODER_TABLE, DESC, \
510 (void)nullptr)
511#define TRY_TO_DECODE_FEATURE(FEATURE, DECODER_TABLE, DESC) \
512 TRY_TO_DECODE(STI.hasFeature(FEATURE), DECODER_TABLE, DESC)
513
514 // It's a 32 bit instruction if bit 0 and 1 are 1.
515 if ((Bytes[0] & 0x3) == 0x3) {
516 if (Bytes.size() < 4) {
517 Size = 0;
519 }
520 Size = 4;
521
523
524 TRY_TO_DECODE(STI.hasFeature(RISCV::FeatureStdExtZdinx) &&
525 !STI.hasFeature(RISCV::Feature64Bit),
526 DecoderTableRV32Zdinx32,
527 "RV32Zdinx table (Double in Integer and rv32)");
528 TRY_TO_DECODE_FEATURE(RISCV::FeatureStdExtZfinx, DecoderTableRVZfinx32,
529 "RVZfinx table (Float in Integer)");
530 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXVentanaCondOps,
531 DecoderTableXVentana32, "Ventana custom opcode table");
532 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadBa, DecoderTableXTHeadBa32,
533 "XTHeadBa custom opcode table");
534 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadBb, DecoderTableXTHeadBb32,
535 "XTHeadBb custom opcode table");
536 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadBs, DecoderTableXTHeadBs32,
537 "XTHeadBs custom opcode table");
538 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadCondMov,
539 DecoderTableXTHeadCondMov32,
540 "XTHeadCondMov custom opcode table");
541 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadCmo, DecoderTableXTHeadCmo32,
542 "XTHeadCmo custom opcode table");
543 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadFMemIdx,
544 DecoderTableXTHeadFMemIdx32,
545 "XTHeadFMemIdx custom opcode table");
546 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadMac, DecoderTableXTHeadMac32,
547 "XTHeadMac custom opcode table");
548 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadMemIdx,
549 DecoderTableXTHeadMemIdx32,
550 "XTHeadMemIdx custom opcode table");
551 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadMemPair,
552 DecoderTableXTHeadMemPair32,
553 "XTHeadMemPair custom opcode table");
554 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadSync,
555 DecoderTableXTHeadSync32,
556 "XTHeadSync custom opcode table");
557 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXTHeadVdot, DecoderTableXTHeadVdot32,
558 "XTHeadVdot custom opcode table");
559 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXSfvcp, DecoderTableXSfvcp32,
560 "SiFive VCIX custom opcode table");
561 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXSfcie, DecoderTableXSfcie32,
562 "Sifive CIE custom opcode table");
563 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCVbitmanip,
564 DecoderTableXCVbitmanip32,
565 "CORE-V Bit Manipulation custom opcode table");
566 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCVmac, DecoderTableXCVmac32,
567 "CORE-V MAC custom opcode table");
568 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCValu, DecoderTableXCValu32,
569 "CORE-V ALU custom opcode table");
570 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCVsimd, DecoderTableXCVsimd32,
571 "CORE-V SIMD extensions custom opcode table");
572 TRY_TO_DECODE_FEATURE(RISCV::FeatureVendorXCVbi, DecoderTableXCVbi32,
573 "CORE-V Immediate Branching custom opcode table");
574 TRY_TO_DECODE(true, DecoderTable32, "RISCV32 table");
575
577 }
578
579 if (Bytes.size() < 2) {
580 Size = 0;
582 }
583 Size = 2;
584
586 TRY_TO_DECODE_AND_ADD_SP(!STI.hasFeature(RISCV::Feature64Bit),
587 DecoderTableRISCV32Only_16,
588 "RISCV32Only_16 table (16-bit Instruction)");
589 TRY_TO_DECODE_FEATURE(RISCV::FeatureStdExtZcmt, DecoderTableRVZcmt16,
590 "Zcmt table (16-bit Table Jump Instructions)");
592 RISCV::FeatureStdExtZcmp, DecoderTableRVZcmp16,
593 "Zcmp table (16-bit Push/Pop & Double Move Instructions)");
594 TRY_TO_DECODE_AND_ADD_SP(true, DecoderTable16,
595 "RISCV_C table (16-bit Instruction)");
596
598}
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 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 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 DecodeGPRPF64RegisterClass(MCInst &Inst, uint32_t RegNo, uint64_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 decodeZcmpSpimm(MCInst &Inst, unsigned Imm, uint64_t Address, const void *Decoder)
static DecodeStatus decodeUImmOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus decodeZcmpRlist(MCInst &Inst, unsigned Imm, uint64_t Address, const void *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 decodeVMaskReg(MCInst &Inst, uint64_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 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 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 decodeUImmNonZeroOperand(MCInst &Inst, uint32_t Imm, int64_t Address, const MCDisassembler *Decoder)
static DecodeStatus DecodeSR07RegisterClass(MCInst &Inst, uint64_t RegNo, uint64_t Address, const void *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:76
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:376
uint32_t read32le(const void *P)
Definition: Endian.h:379
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.