Coverage Report

Created: 2026-11-12 06:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/capstonenext/arch/RISCV/RISCVDisassembler.c
Line
Count
Source
1
/* Capstone Disassembly Engine, http://www.capstone-engine.org */
2
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2022, */
3
/*    Rot127 <unisono@quyllur.org> 2022-2023 */
4
/* Automatically translated source file from LLVM. */
5
6
/* LLVM-commit: <commit> */
7
/* LLVM-tag: <tag> */
8
9
/* Only small edits allowed. */
10
/* For multiple similar edits, please create a Patch for the translator. */
11
12
/* Capstone's C++ file translator: */
13
/* https://github.com/capstone-engine/capstone/tree/next/suite/auto-sync */
14
15
//===-- RISCVDisassembler.cpp - Disassembler for RISC-V -------------------===//
16
//
17
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
18
// See https://llvm.org/LICENSE.txt for license information.
19
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
20
//
21
//===----------------------------------------------------------------------===//
22
//
23
// This file implements the RISCVDisassembler class.
24
//
25
//===----------------------------------------------------------------------===//
26
27
#include <stdio.h>
28
#include <string.h>
29
#include <stdlib.h>
30
#include <capstone/platform.h>
31
32
#include "../../MCInst.h"
33
#include "../../MathExtras.h"
34
#include "../../MCInstPrinter.h"
35
#include "../../MCDisassembler.h"
36
#include "../../MCFixedLenDisassembler.h"
37
#include "../../cs_priv.h"
38
#include "../../utils.h"
39
#include "RISCVDisassemblerExtension.h"
40
#include "RISCVBaseInfo.h"
41
#include "RISCVMapping.h"
42
43
#define GET_SUBTARGETINFO_ENUM
44
#include "RISCVGenSubtargetInfo.inc"
45
46
#define GET_REGINFO_ENUM
47
#include "RISCVGenRegisterInfo.inc"
48
49
#define GET_INSTRINFO_ENUM
50
#define GET_INSTRINFO_MC_DESC
51
#include "RISCVGenInstrInfo.inc"
52
53
8.86k
#define CONCAT(a, b) CONCAT_(a, b)
54
8.86k
#define CONCAT_(a, b) a##_##b
55
56
#define DEBUG_TYPE "riscv-disassembler"
57
58
DecodeStatus RISCV_getInstruction(MCInst *Instr, uint16_t *Size,
59
          const uint8_t *Bytes, size_t BytesLen,
60
          uint64_t Address, SStream *CStream);
61
void addSPOperands(MCInst *MI);
62
;
63
// end anonymous namespace
64
65
static DecodeStatus DecodeGPRRegisterClass(MCInst *Inst, uint32_t RegNo,
66
             uint64_t Address,
67
             const void *Decoder)
68
68.0k
{
69
68.0k
  bool IsRVE = RISCV_getFeatureBits(Inst->csh->mode, RISCV_FeatureRVE);
70
71
68.0k
  if (RegNo >= 32 || (IsRVE && RegNo >= 16))
72
0
    return MCDisassembler_Fail;
73
74
68.0k
  MCRegister Reg = RISCV_X0 + RegNo;
75
68.0k
  MCOperand_CreateReg0(Inst, (Reg));
76
68.0k
  return MCDisassembler_Success;
77
68.0k
}
78
79
static DecodeStatus DecodeGPRX1X5RegisterClass(MCInst *Inst, uint32_t RegNo,
80
                 uint64_t Address,
81
                 const void *Decoder)
82
0
{
83
0
  MCRegister Reg = RISCV_X0 + RegNo;
84
0
  if (Reg != RISCV_X1 && Reg != RISCV_X5)
85
0
    return MCDisassembler_Fail;
86
87
0
  MCOperand_CreateReg0(Inst, (Reg));
88
0
  return MCDisassembler_Success;
89
0
}
90
91
static DecodeStatus DecodeFPR16RegisterClass(MCInst *Inst, uint32_t RegNo,
92
               uint64_t Address,
93
               const void *Decoder)
94
9.93k
{
95
9.93k
  if (RegNo >= 32)
96
0
    return MCDisassembler_Fail;
97
98
9.93k
  MCRegister Reg = RISCV_F0_H + RegNo;
99
9.93k
  MCOperand_CreateReg0(Inst, (Reg));
100
9.93k
  return MCDisassembler_Success;
101
9.93k
}
102
103
static DecodeStatus DecodeFPR32RegisterClass(MCInst *Inst, uint32_t RegNo,
104
               uint64_t Address,
105
               const void *Decoder)
106
4.30k
{
107
4.30k
  if (RegNo >= 32)
108
0
    return MCDisassembler_Fail;
109
110
4.30k
  MCRegister Reg = RISCV_F0_F + RegNo;
111
4.30k
  MCOperand_CreateReg0(Inst, (Reg));
112
4.30k
  return MCDisassembler_Success;
113
4.30k
}
114
115
static DecodeStatus DecodeFPR32CRegisterClass(MCInst *Inst, uint32_t RegNo,
116
                uint64_t Address,
117
                const void *Decoder)
118
0
{
119
0
  if (RegNo >= 8) {
120
0
    return MCDisassembler_Fail;
121
0
  }
122
0
  MCRegister Reg = RISCV_F8_F + RegNo;
123
0
  MCOperand_CreateReg0(Inst, (Reg));
124
0
  return MCDisassembler_Success;
125
0
}
126
127
static DecodeStatus DecodeFPR64RegisterClass(MCInst *Inst, uint32_t RegNo,
128
               uint64_t Address,
129
               const void *Decoder)
130
0
{
131
0
  if (RegNo >= 32)
132
0
    return MCDisassembler_Fail;
133
134
0
  MCRegister Reg = RISCV_F0_D + RegNo;
135
0
  MCOperand_CreateReg0(Inst, (Reg));
136
0
  return MCDisassembler_Success;
137
0
}
138
139
static DecodeStatus DecodeFPR64CRegisterClass(MCInst *Inst, uint32_t RegNo,
140
                uint64_t Address,
141
                const void *Decoder)
142
0
{
143
0
  if (RegNo >= 8) {
144
0
    return MCDisassembler_Fail;
145
0
  }
146
0
  MCRegister Reg = RISCV_F8_D + RegNo;
147
0
  MCOperand_CreateReg0(Inst, (Reg));
148
0
  return MCDisassembler_Success;
149
0
}
150
151
static DecodeStatus DecodeGPRNoX0RegisterClass(MCInst *Inst, uint32_t RegNo,
152
                 uint64_t Address,
153
                 const void *Decoder)
154
17.8k
{
155
17.8k
  if (RegNo == 0) {
156
6
    return MCDisassembler_Fail;
157
6
  }
158
159
17.7k
  return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
160
17.8k
}
161
162
static DecodeStatus DecodeGPRNoX0X2RegisterClass(MCInst *Inst, uint64_t RegNo,
163
             uint32_t Address,
164
             const void *Decoder)
165
1.12k
{
166
1.12k
  if (RegNo == 2) {
167
0
    return MCDisassembler_Fail;
168
0
  }
169
170
1.12k
  return DecodeGPRNoX0RegisterClass(Inst, RegNo, Address, Decoder);
171
1.12k
}
172
173
static DecodeStatus DecodeGPRCRegisterClass(MCInst *Inst, uint32_t RegNo,
174
              uint64_t Address,
175
              const void *Decoder)
176
31.5k
{
177
31.5k
  if (RegNo >= 8)
178
0
    return MCDisassembler_Fail;
179
180
31.5k
  MCRegister Reg = RISCV_X8 + RegNo;
181
31.5k
  MCOperand_CreateReg0(Inst, (Reg));
182
31.5k
  return MCDisassembler_Success;
183
31.5k
}
184
185
static DecodeStatus DecodeGPRPairRegisterClass(MCInst *Inst, uint32_t RegNo,
186
                 uint64_t Address,
187
                 const void *Decoder)
188
286
{
189
286
  if (RegNo >= 32 || RegNo & 1)
190
2
    return MCDisassembler_Fail;
191
192
284
  MCRegister Reg = RISCV_X0 + RegNo;
193
284
  MCOperand_CreateReg0(Inst, (Reg));
194
284
  return MCDisassembler_Success;
195
286
}
196
197
static DecodeStatus DecodeSR07RegisterClass(MCInst *Inst, uint64_t RegNo,
198
              uint64_t Address,
199
              const void *Decoder)
200
0
{
201
0
  if (RegNo >= 8)
202
0
    return MCDisassembler_Fail;
203
204
0
  MCRegister Reg = (RegNo < 2) ? (RegNo + RISCV_X8) :
205
0
               (RegNo - 2 + RISCV_X18);
206
0
  MCOperand_CreateReg0(Inst, (Reg));
207
0
  return MCDisassembler_Success;
208
0
}
209
210
static DecodeStatus DecodeVRRegisterClass(MCInst *Inst, uint32_t RegNo,
211
            uint64_t Address, const void *Decoder)
212
18.0k
{
213
18.0k
  if (RegNo >= 32)
214
0
    return MCDisassembler_Fail;
215
216
18.0k
  MCRegister Reg = RISCV_V0 + RegNo;
217
18.0k
  MCOperand_CreateReg0(Inst, (Reg));
218
18.0k
  return MCDisassembler_Success;
219
18.0k
}
220
221
static DecodeStatus DecodeVRM2RegisterClass(MCInst *Inst, uint32_t RegNo,
222
              uint64_t Address,
223
              const void *Decoder)
224
720
{
225
720
  if (RegNo >= 32 || RegNo % 2)
226
3
    return MCDisassembler_Fail;
227
228
717
  MCRegister Reg = MCRegisterInfo_getMatchingSuperReg(
229
717
    Inst->MRI, RISCV_V0 + RegNo, RISCV_sub_vrm1_0,
230
717
    MCRegisterInfo_getRegClass(Inst->MRI, RISCV_VRM2RegClassID));
231
232
717
  MCOperand_CreateReg0(Inst, (Reg));
233
717
  return MCDisassembler_Success;
234
720
}
235
236
static DecodeStatus DecodeVRM4RegisterClass(MCInst *Inst, uint32_t RegNo,
237
              uint64_t Address,
238
              const void *Decoder)
239
604
{
240
604
  if (RegNo >= 32 || RegNo % 4)
241
4
    return MCDisassembler_Fail;
242
243
600
  MCRegister Reg = MCRegisterInfo_getMatchingSuperReg(
244
600
    Inst->MRI, RISCV_V0 + RegNo, RISCV_sub_vrm1_0,
245
600
    MCRegisterInfo_getRegClass(Inst->MRI, RISCV_VRM4RegClassID));
246
247
600
  MCOperand_CreateReg0(Inst, (Reg));
248
600
  return MCDisassembler_Success;
249
604
}
250
251
static DecodeStatus DecodeVRM8RegisterClass(MCInst *Inst, uint32_t RegNo,
252
              uint64_t Address,
253
              const void *Decoder)
254
772
{
255
772
  if (RegNo >= 32 || RegNo % 8)
256
3
    return MCDisassembler_Fail;
257
258
769
  MCRegister Reg = MCRegisterInfo_getMatchingSuperReg(
259
769
    Inst->MRI, RISCV_V0 + RegNo, RISCV_sub_vrm1_0,
260
769
    MCRegisterInfo_getRegClass(Inst->MRI, RISCV_VRM8RegClassID));
261
262
769
  MCOperand_CreateReg0(Inst, (Reg));
263
769
  return MCDisassembler_Success;
264
772
}
265
266
static DecodeStatus decodeVMaskReg(MCInst *Inst, uint64_t RegNo,
267
           uint64_t Address, const void *Decoder)
268
5.93k
{
269
5.93k
  if (RegNo > 2) {
270
0
    return MCDisassembler_Fail;
271
0
  }
272
5.93k
  MCRegister Reg = (RegNo == 0) ? RISCV_V0 : RISCV_NoRegister;
273
274
5.93k
  MCOperand_CreateReg0(Inst, (Reg));
275
5.93k
  return MCDisassembler_Success;
276
5.93k
}
277
278
#define DEFINE_decodeUImmOperand(N) \
279
  static DecodeStatus CONCAT(decodeUImmOperand, \
280
           N)(MCInst * Inst, uint32_t Imm, \
281
              int64_t Address, const void *Decoder) \
282
34.5k
  { \
283
34.5k
    if (!isUIntN(N, Imm)) \
284
34.5k
      return MCDisassembler_Fail; \
285
34.5k
    MCOperand_CreateImm0(Inst, (Imm)); \
286
34.5k
    return MCDisassembler_Success; \
287
34.5k
  }
RISCVDisassembler.c:decodeUImmOperand_8
Line
Count
Source
282
5.12k
  { \
283
5.12k
    if (!isUIntN(N, Imm)) \
284
5.12k
      return MCDisassembler_Fail; \
285
5.12k
    MCOperand_CreateImm0(Inst, (Imm)); \
286
5.12k
    return MCDisassembler_Success; \
287
5.12k
  }
RISCVDisassembler.c:decodeUImmOperand_9
Line
Count
Source
282
2.41k
  { \
283
2.41k
    if (!isUIntN(N, Imm)) \
284
2.41k
      return MCDisassembler_Fail; \
285
2.41k
    MCOperand_CreateImm0(Inst, (Imm)); \
286
2.41k
    return MCDisassembler_Success; \
287
2.41k
  }
RISCVDisassembler.c:decodeUImmOperand_7
Line
Count
Source
282
3.94k
  { \
283
3.94k
    if (!isUIntN(N, Imm)) \
284
3.94k
      return MCDisassembler_Fail; \
285
3.94k
    MCOperand_CreateImm0(Inst, (Imm)); \
286
3.94k
    return MCDisassembler_Success; \
287
3.94k
  }
RISCVDisassembler.c:decodeUImmOperand_2
Line
Count
Source
282
2.53k
  { \
283
2.53k
    if (!isUIntN(N, Imm)) \
284
2.53k
      return MCDisassembler_Fail; \
285
2.53k
    MCOperand_CreateImm0(Inst, (Imm)); \
286
2.53k
    return MCDisassembler_Success; \
287
2.53k
  }
RISCVDisassembler.c:decodeUImmOperand_4
Line
Count
Source
282
3.57k
  { \
283
3.57k
    if (!isUIntN(N, Imm)) \
284
3.57k
      return MCDisassembler_Fail; \
285
3.57k
    MCOperand_CreateImm0(Inst, (Imm)); \
286
3.57k
    return MCDisassembler_Success; \
287
3.57k
  }
RISCVDisassembler.c:decodeUImmOperand_20
Line
Count
Source
282
1.07k
  { \
283
1.07k
    if (!isUIntN(N, Imm)) \
284
1.07k
      return MCDisassembler_Fail; \
285
1.07k
    MCOperand_CreateImm0(Inst, (Imm)); \
286
1.07k
    return MCDisassembler_Success; \
287
1.07k
  }
RISCVDisassembler.c:decodeUImmOperand_5
Line
Count
Source
282
4.92k
  { \
283
4.92k
    if (!isUIntN(N, Imm)) \
284
4.92k
      return MCDisassembler_Fail; \
285
4.92k
    MCOperand_CreateImm0(Inst, (Imm)); \
286
4.92k
    return MCDisassembler_Success; \
287
4.92k
  }
RISCVDisassembler.c:decodeUImmOperand_6
Line
Count
Source
282
909
  { \
283
909
    if (!isUIntN(N, Imm)) \
284
909
      return MCDisassembler_Fail; \
285
909
    MCOperand_CreateImm0(Inst, (Imm)); \
286
909
    return MCDisassembler_Success; \
287
909
  }
RISCVDisassembler.c:decodeUImmOperand_11
Line
Count
Source
282
2.50k
  { \
283
2.50k
    if (!isUIntN(N, Imm)) \
284
2.50k
      return MCDisassembler_Fail; \
285
2.50k
    MCOperand_CreateImm0(Inst, (Imm)); \
286
2.50k
    return MCDisassembler_Success; \
287
2.50k
  }
RISCVDisassembler.c:decodeUImmOperand_10
Line
Count
Source
282
5.10k
  { \
283
5.10k
    if (!isUIntN(N, Imm)) \
284
5.10k
      return MCDisassembler_Fail; \
285
5.10k
    MCOperand_CreateImm0(Inst, (Imm)); \
286
5.10k
    return MCDisassembler_Success; \
287
5.10k
  }
RISCVDisassembler.c:decodeUImmOperand_12
Line
Count
Source
282
2.43k
  { \
283
2.43k
    if (!isUIntN(N, Imm)) \
284
2.43k
      return MCDisassembler_Fail; \
285
2.43k
    MCOperand_CreateImm0(Inst, (Imm)); \
286
2.43k
    return MCDisassembler_Success; \
287
2.43k
  }
RISCVDisassembler.c:decodeUImmOperand_3
Line
Count
Source
282
37
  { \
283
37
    if (!isUIntN(N, Imm)) \
284
37
      return MCDisassembler_Fail; \
285
37
    MCOperand_CreateImm0(Inst, (Imm)); \
286
35
    return MCDisassembler_Success; \
287
37
  }
Unexecuted instantiation: RISCVDisassembler.c:decodeUImmOperand_1
288
DEFINE_decodeUImmOperand(6);
289
DEFINE_decodeUImmOperand(2);
290
DEFINE_decodeUImmOperand(8);
291
DEFINE_decodeUImmOperand(9);
292
DEFINE_decodeUImmOperand(7);
293
DEFINE_decodeUImmOperand(4);
294
DEFINE_decodeUImmOperand(20);
295
DEFINE_decodeUImmOperand(5);
296
DEFINE_decodeUImmOperand(11);
297
DEFINE_decodeUImmOperand(10);
298
DEFINE_decodeUImmOperand(12);
299
DEFINE_decodeUImmOperand(3);
300
DEFINE_decodeUImmOperand(1);
301
302
#define DEFINE_decodeUImmNonZeroOperand(N) \
303
  static DecodeStatus CONCAT(decodeUImmNonZeroOperand, \
304
           N)(MCInst * Inst, uint32_t Imm, \
305
              int64_t Address, const void *Decoder) \
306
4.59k
  { \
307
4.59k
    if (Imm == 0) \
308
4.59k
      return MCDisassembler_Fail; \
309
4.59k
    return CONCAT(decodeUImmOperand, N)(Inst, Imm, Address, \
310
4.59k
                Decoder); \
311
4.59k
  }
312
DEFINE_decodeUImmNonZeroOperand(10);
313
314
#define DEFINE_decodeSImmOperand(N) \
315
  static DecodeStatus CONCAT(decodeSImmOperand, \
316
           N)(MCInst * Inst, uint32_t Imm, \
317
              int64_t Address, const void *Decoder) \
318
11.4k
  { \
319
11.4k
    CS_ASSERT(isUIntN(N, Imm) && "Invalid immediate"); \
320
11.4k
\
321
11.4k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
322
11.4k
    return MCDisassembler_Success; \
323
11.4k
  }
RISCVDisassembler.c:decodeSImmOperand_6
Line
Count
Source
318
6.47k
  { \
319
6.47k
    CS_ASSERT(isUIntN(N, Imm) && "Invalid immediate"); \
320
6.47k
\
321
6.47k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
322
6.47k
    return MCDisassembler_Success; \
323
6.47k
  }
RISCVDisassembler.c:decodeSImmOperand_10
Line
Count
Source
318
329
  { \
319
329
    CS_ASSERT(isUIntN(N, Imm) && "Invalid immediate"); \
320
329
\
321
329
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
322
329
    return MCDisassembler_Success; \
323
329
  }
RISCVDisassembler.c:decodeSImmOperand_12
Line
Count
Source
318
3.83k
  { \
319
3.83k
    CS_ASSERT(isUIntN(N, Imm) && "Invalid immediate"); \
320
3.83k
\
321
3.83k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
322
3.83k
    return MCDisassembler_Success; \
323
3.83k
  }
RISCVDisassembler.c:decodeSImmOperand_5
Line
Count
Source
318
795
  { \
319
795
    CS_ASSERT(isUIntN(N, Imm) && "Invalid immediate"); \
320
795
\
321
795
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm), N))); \
322
795
    return MCDisassembler_Success; \
323
795
  }
324
DEFINE_decodeSImmOperand(6);
325
DEFINE_decodeSImmOperand(12);
326
DEFINE_decodeSImmOperand(5);
327
DEFINE_decodeSImmOperand(10);
328
329
#define DEFINE_decodeSImmNonZeroOperand(N) \
330
  static DecodeStatus CONCAT(decodeSImmNonZeroOperand, \
331
           N)(MCInst * Inst, uint32_t Imm, \
332
              int64_t Address, const void *Decoder) \
333
3.00k
  { \
334
3.00k
    if (Imm == 0) \
335
3.00k
      return MCDisassembler_Fail; \
336
3.00k
    return CONCAT(decodeSImmOperand, N)(Inst, Imm, Address, \
337
3.00k
                Decoder); \
338
3.00k
  }
RISCVDisassembler.c:decodeSImmNonZeroOperand_6
Line
Count
Source
333
2.67k
  { \
334
2.67k
    if (Imm == 0) \
335
2.67k
      return MCDisassembler_Fail; \
336
2.67k
    return CONCAT(decodeSImmOperand, N)(Inst, Imm, Address, \
337
2.67k
                Decoder); \
338
2.67k
  }
RISCVDisassembler.c:decodeSImmNonZeroOperand_10
Line
Count
Source
333
330
  { \
334
330
    if (Imm == 0) \
335
330
      return MCDisassembler_Fail; \
336
330
    return CONCAT(decodeSImmOperand, N)(Inst, Imm, Address, \
337
329
                Decoder); \
338
330
  }
339
DEFINE_decodeSImmNonZeroOperand(6);
340
DEFINE_decodeSImmNonZeroOperand(10);
341
342
#define DEFINE_decodeSImmOperandAndLsl1(N) \
343
  static DecodeStatus CONCAT(decodeSImmOperandAndLsl1, \
344
           N)(MCInst * Inst, uint32_t Imm, \
345
              int64_t Address, const void *Decoder) \
346
5.02k
  { \
347
5.02k
    CS_ASSERT(isUIntN(N, Imm) && "Invalid immediate"); \
348
5.02k
\
349
5.02k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm << 1), N))); \
350
5.02k
    return MCDisassembler_Success; \
351
5.02k
  }
RISCVDisassembler.c:decodeSImmOperandAndLsl1_12
Line
Count
Source
346
1.90k
  { \
347
1.90k
    CS_ASSERT(isUIntN(N, Imm) && "Invalid immediate"); \
348
1.90k
\
349
1.90k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm << 1), N))); \
350
1.90k
    return MCDisassembler_Success; \
351
1.90k
  }
RISCVDisassembler.c:decodeSImmOperandAndLsl1_9
Line
Count
Source
346
1.60k
  { \
347
1.60k
    CS_ASSERT(isUIntN(N, Imm) && "Invalid immediate"); \
348
1.60k
\
349
1.60k
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm << 1), N))); \
350
1.60k
    return MCDisassembler_Success; \
351
1.60k
  }
RISCVDisassembler.c:decodeSImmOperandAndLsl1_13
Line
Count
Source
346
630
  { \
347
630
    CS_ASSERT(isUIntN(N, Imm) && "Invalid immediate"); \
348
630
\
349
630
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm << 1), N))); \
350
630
    return MCDisassembler_Success; \
351
630
  }
RISCVDisassembler.c:decodeSImmOperandAndLsl1_21
Line
Count
Source
346
886
  { \
347
886
    CS_ASSERT(isUIntN(N, Imm) && "Invalid immediate"); \
348
886
\
349
886
    MCOperand_CreateImm0(Inst, (SignExtend64((Imm << 1), N))); \
350
886
    return MCDisassembler_Success; \
351
886
  }
352
DEFINE_decodeSImmOperandAndLsl1(12);
353
DEFINE_decodeSImmOperandAndLsl1(9);
354
DEFINE_decodeSImmOperandAndLsl1(13);
355
DEFINE_decodeSImmOperandAndLsl1(21);
356
357
static DecodeStatus decodeCLUIImmOperand(MCInst *Inst, uint32_t Imm,
358
           int64_t Address, const void *Decoder)
359
1.12k
{
360
1.12k
  CS_ASSERT(isUIntN(6, Imm) && "Invalid immediate");
361
1.12k
  if (Imm > 31) {
362
562
    Imm = (SignExtend64((Imm), 6) & 0xfffff);
363
562
  }
364
1.12k
  MCOperand_CreateImm0(Inst, (Imm));
365
1.12k
  return MCDisassembler_Success;
366
1.12k
}
367
368
static DecodeStatus decodeFRMArg(MCInst *Inst, uint32_t Imm, int64_t Address,
369
         const void *Decoder)
370
4.70k
{
371
4.70k
  CS_ASSERT(isUIntN(3, Imm) && "Invalid immediate");
372
4.70k
  if (!RISCVFPRndMode_isValidRoundingMode(Imm))
373
8
    return MCDisassembler_Fail;
374
375
4.69k
  MCOperand_CreateImm0(Inst, (Imm));
376
4.69k
  return MCDisassembler_Success;
377
4.70k
}
378
379
static DecodeStatus decodeRVCInstrRdRs1ImmZero(MCInst *Inst, uint32_t Insn,
380
                 uint64_t Address,
381
                 const void *Decoder);
382
383
static DecodeStatus decodeRVCInstrRdSImm(MCInst *Inst, uint32_t Insn,
384
           uint64_t Address, const void *Decoder);
385
386
static DecodeStatus decodeRVCInstrRdRs1UImm(MCInst *Inst, uint32_t Insn,
387
              uint64_t Address,
388
              const void *Decoder);
389
390
static DecodeStatus decodeRVCInstrRdRs2(MCInst *Inst, uint32_t Insn,
391
          uint64_t Address, const void *Decoder);
392
393
static DecodeStatus decodeRVCInstrRdRs1Rs2(MCInst *Inst, uint32_t Insn,
394
             uint64_t Address,
395
             const void *Decoder);
396
397
static DecodeStatus decodeXTHeadMemPair(MCInst *Inst, uint32_t Insn,
398
          uint64_t Address, const void *Decoder);
399
400
static DecodeStatus decodeZcmpRlist(MCInst *Inst, unsigned Imm,
401
            uint64_t Address, const void *Decoder);
402
403
static DecodeStatus decodeRegReg(MCInst *Inst, uint32_t Insn, uint64_t Address,
404
         const void *Decoder);
405
406
static DecodeStatus decodeZcmpSpimm(MCInst *Inst, unsigned Imm,
407
            uint64_t Address, const void *Decoder);
408
409
static DecodeStatus decodeCSSPushPopchk(MCInst *Inst, uint32_t Insn,
410
          uint64_t Address, const void *Decoder);
411
412
static DecodeStatus decodeUImmLog2XLenOperand(MCInst *Inst, uint32_t Imm,
413
                int64_t Address,
414
                const void *Decoder)
415
3.20k
{
416
3.20k
  CS_ASSERT(isUIntN(6, Imm) && "Invalid immediate");
417
418
3.20k
  if (!RISCV_getFeatureBits(Inst->csh->mode, RISCV_Feature64Bit) &&
419
947
      !isUIntN(5, Imm))
420
6
    return MCDisassembler_Fail;
421
422
3.20k
  MCOperand_CreateImm0(Inst, (Imm));
423
3.20k
  return MCDisassembler_Success;
424
3.20k
}
425
426
static DecodeStatus decodeUImmLog2XLenNonZeroOperand(MCInst *Inst, uint32_t Imm,
427
                 int64_t Address,
428
                 const void *Decoder)
429
2.92k
{
430
2.92k
  if (Imm == 0)
431
0
    return MCDisassembler_Fail;
432
2.92k
  return decodeUImmLog2XLenOperand(Inst, Imm, Address, Decoder);
433
2.92k
}
434
435
#include "RISCVGenDisassemblerTables.inc"
436
437
static DecodeStatus decodeRVCInstrRdRs1ImmZero(MCInst *Inst, uint32_t Insn,
438
                 uint64_t Address,
439
                 const void *Decoder)
440
312
{
441
312
  uint32_t Rd = fieldFromInstruction_4(Insn, 7, 5);
442
312
  if (DecodeGPRNoX0RegisterClass(Inst, Rd, Address, Decoder) ==
443
312
      MCDisassembler_Fail)
444
0
    return MCDisassembler_Fail;
445
312
  MCInst_addOperand2(Inst, (MCInst_getOperand(Inst, (0))));
446
312
  MCOperand_CreateImm0(Inst, (0));
447
312
  return MCDisassembler_Success;
448
312
}
449
450
static DecodeStatus decodeCSSPushPopchk(MCInst *Inst, uint32_t Insn,
451
          uint64_t Address, const void *Decoder)
452
0
{
453
0
  uint32_t Rs1 = fieldFromInstruction_4(Insn, 7, 5);
454
0
  if (DecodeGPRX1X5RegisterClass(Inst, Rs1, Address, Decoder) ==
455
0
      MCDisassembler_Fail)
456
0
    return MCDisassembler_Fail;
457
0
  return MCDisassembler_Success;
458
0
}
459
460
static DecodeStatus decodeRVCInstrRdSImm(MCInst *Inst, uint32_t Insn,
461
           uint64_t Address, const void *Decoder)
462
930
{
463
930
  MCOperand_CreateReg0(Inst, (RISCV_X0));
464
930
  uint32_t SImm6 = fieldFromInstruction_4(Insn, 12, 1) << 5 |
465
930
       fieldFromInstruction_4(Insn, 2, 5);
466
930
  DecodeStatus Result =
467
930
    CONCAT(decodeSImmOperand, 6)(Inst, SImm6, Address, Decoder);
468
930
  (void)Result;
469
930
  CS_ASSERT(Result == MCDisassembler_Success && "Invalid immediate");
470
930
  return MCDisassembler_Success;
471
930
}
472
473
static DecodeStatus decodeRVCInstrRdRs1UImm(MCInst *Inst, uint32_t Insn,
474
              uint64_t Address,
475
              const void *Decoder)
476
337
{
477
337
  MCOperand_CreateReg0(Inst, (RISCV_X0));
478
337
  MCInst_addOperand2(Inst, (MCInst_getOperand(Inst, (0))));
479
337
  uint32_t UImm6 = fieldFromInstruction_4(Insn, 12, 1) << 5 |
480
337
       fieldFromInstruction_4(Insn, 2, 5);
481
337
  DecodeStatus Result =
482
337
    CONCAT(decodeUImmOperand, 6)(Inst, UImm6, Address, Decoder);
483
337
  (void)Result;
484
337
  CS_ASSERT(Result == MCDisassembler_Success && "Invalid immediate");
485
337
  return MCDisassembler_Success;
486
337
}
487
488
static DecodeStatus decodeRVCInstrRdRs2(MCInst *Inst, uint32_t Insn,
489
          uint64_t Address, const void *Decoder)
490
211
{
491
211
  uint32_t Rd = fieldFromInstruction_4(Insn, 7, 5);
492
211
  uint32_t Rs2 = fieldFromInstruction_4(Insn, 2, 5);
493
211
  if (DecodeGPRRegisterClass(Inst, Rd, Address, Decoder) ==
494
211
      MCDisassembler_Fail)
495
0
    return MCDisassembler_Fail;
496
211
  if (DecodeGPRRegisterClass(Inst, Rs2, Address, Decoder) ==
497
211
      MCDisassembler_Fail)
498
0
    return MCDisassembler_Fail;
499
211
  return MCDisassembler_Success;
500
211
}
501
502
static DecodeStatus decodeRVCInstrRdRs1Rs2(MCInst *Inst, uint32_t Insn,
503
             uint64_t Address,
504
             const void *Decoder)
505
198
{
506
198
  uint32_t Rd = fieldFromInstruction_4(Insn, 7, 5);
507
198
  uint32_t Rs2 = fieldFromInstruction_4(Insn, 2, 5);
508
198
  if (DecodeGPRRegisterClass(Inst, Rd, Address, Decoder) ==
509
198
      MCDisassembler_Fail)
510
0
    return MCDisassembler_Fail;
511
198
  MCInst_addOperand2(Inst, (MCInst_getOperand(Inst, (0))));
512
198
  if (DecodeGPRRegisterClass(Inst, Rs2, Address, Decoder) ==
513
198
      MCDisassembler_Fail)
514
0
    return MCDisassembler_Fail;
515
198
  return MCDisassembler_Success;
516
198
}
517
518
static DecodeStatus decodeXTHeadMemPair(MCInst *Inst, uint32_t Insn,
519
          uint64_t Address, const void *Decoder)
520
0
{
521
0
  uint32_t Rd1 = fieldFromInstruction_4(Insn, 7, 5);
522
0
  uint32_t Rs1 = fieldFromInstruction_4(Insn, 15, 5);
523
0
  uint32_t Rd2 = fieldFromInstruction_4(Insn, 20, 5);
524
0
  uint32_t UImm2 = fieldFromInstruction_4(Insn, 25, 2);
525
0
  if (DecodeGPRRegisterClass(Inst, Rd1, Address, Decoder) ==
526
0
      MCDisassembler_Fail)
527
0
    return MCDisassembler_Fail;
528
0
  if (DecodeGPRRegisterClass(Inst, Rd2, Address, Decoder) ==
529
0
      MCDisassembler_Fail)
530
0
    return MCDisassembler_Fail;
531
0
  if (DecodeGPRRegisterClass(Inst, Rs1, Address, Decoder) ==
532
0
      MCDisassembler_Fail)
533
0
    return MCDisassembler_Fail;
534
0
  DecodeStatus Result =
535
0
    CONCAT(decodeUImmOperand, 2)(Inst, UImm2, Address, Decoder);
536
0
  (void)Result;
537
0
  CS_ASSERT(Result == MCDisassembler_Success && "Invalid immediate");
538
539
  // Disassemble the final operand which is implicit.
540
0
  unsigned Opcode = MCInst_getOpcode(Inst);
541
0
  bool IsWordOp = (Opcode == RISCV_TH_LWD || Opcode == RISCV_TH_LWUD ||
542
0
       Opcode == RISCV_TH_SWD);
543
0
  if (IsWordOp)
544
0
    MCOperand_CreateImm0(Inst, (3));
545
0
  else
546
0
    MCOperand_CreateImm0(Inst, (4));
547
548
0
  return MCDisassembler_Success;
549
0
}
550
551
static DecodeStatus decodeZcmpRlist(MCInst *Inst, unsigned Imm,
552
            uint64_t Address, const void *Decoder)
553
0
{
554
0
  if (Imm <= 3)
555
0
    return MCDisassembler_Fail;
556
0
  MCOperand_CreateImm0(Inst, (Imm));
557
0
  return MCDisassembler_Success;
558
0
}
559
560
static DecodeStatus decodeRegReg(MCInst *Inst, uint32_t Insn, uint64_t Address,
561
         const void *Decoder)
562
356
{
563
356
  uint32_t Rs1 = fieldFromInstruction_4(Insn, 0, 5);
564
356
  uint32_t Rs2 = fieldFromInstruction_4(Insn, 5, 5);
565
356
  if (DecodeGPRRegisterClass(Inst, Rs1, Address, Decoder) ==
566
356
      MCDisassembler_Fail)
567
0
    return MCDisassembler_Fail;
568
356
  if (DecodeGPRRegisterClass(Inst, Rs2, Address, Decoder) ==
569
356
      MCDisassembler_Fail)
570
0
    return MCDisassembler_Fail;
571
356
  return MCDisassembler_Success;
572
356
}
573
574
static DecodeStatus decodeZcmpSpimm(MCInst *Inst, unsigned Imm,
575
            uint64_t Address, const void *Decoder)
576
0
{
577
0
  MCOperand_CreateImm0(Inst, (Imm));
578
0
  return MCDisassembler_Success;
579
0
}
580
581
// Add implied SP operand for C.*SP compressed instructions. The SP operand
582
// isn't explicitly encoded in the instruction.
583
void addSPOperands(MCInst *MI)
584
43.3k
{
585
43.3k
  const MCInstrDesc *MCID = MCInstrDesc_get(MCInst_getOpcode(MI),
586
43.3k
              RISCVDescs.Insts,
587
43.3k
              ARR_SIZE(RISCVDescs.Insts));
588
43.3k
  MCOperand SPReg;
589
43.3k
  SPReg.MachineOperandType = kRegister;
590
43.3k
  SPReg.Kind = kRegister;
591
43.3k
  SPReg.RegVal = RISCV_X2;
592
141k
  for (unsigned i = 0; i < MCID->NumOperands; i++)
593
97.7k
    if (MCID->OpInfo[i].RegClass == RISCV_SPRegClassID)
594
10.0k
      MCInst_insert0(MI, i, &SPReg);
595
43.3k
}
596
597
DecodeStatus RISCV_getInstruction(MCInst *MI, uint16_t *Size,
598
          const uint8_t *Bytes, size_t BytesLen,
599
          uint64_t Address, SStream *CS)
600
85.1k
{
601
  // TODO: This will need modification when supporting instruction set
602
  // extensions with instructions > 32-bits (up to 176 bits wide).
603
85.1k
  uint32_t Insn;
604
85.1k
  DecodeStatus Result;
605
606
85.1k
#define TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION( \
607
85.1k
  width, FEATURE_CHECKS, DECODER_TABLE, DESC, ADDITIONAL_OPERATION) \
608
1.35M
  do { \
609
1.47M
    if (FEATURE_CHECKS) { \
610
353k
      Result = decodeInstruction_##width( \
611
353k
        DECODER_TABLE, MI, Insn, Address, NULL); \
612
353k
      if (Result != MCDisassembler_Fail) { \
613
84.3k
        ADDITIONAL_OPERATION; \
614
84.3k
        return Result; \
615
84.3k
      } \
616
353k
    } \
617
1.35M
  } while (false)
618
85.1k
#define TRY_TO_DECODE_AND_ADD_SP(width, FEATURE_CHECKS, DECODER_TABLE, DESC) \
619
86.1k
  TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION( \
620
86.1k
    width, FEATURE_CHECKS, DECODER_TABLE, DESC, addSPOperands(MI))
621
85.1k
#define TRY_TO_DECODE(width, FEATURE_CHECKS, DECODER_TABLE, DESC) \
622
1.26M
  TRY_TO_DECODE_WITH_ADDITIONAL_OPERATION( \
623
1.26M
    width, FEATURE_CHECKS, DECODER_TABLE, DESC, (void)NULL)
624
85.1k
#define TRY_TO_DECODE_FEATURE(width, FEATURE, DECODER_TABLE, DESC) \
625
1.14M
  TRY_TO_DECODE(width, RISCV_getFeatureBits(MI->csh->mode, FEATURE), \
626
1.14M
          DECODER_TABLE, DESC)
627
628
  // It's a 32 bit instruction if bit 0 and 1 are 1.
629
85.1k
  if ((Bytes[0] & 0x3) == 0x3) {
630
41.4k
    if (BytesLen < 4) {
631
250
      *Size = 0;
632
250
      return MCDisassembler_Fail;
633
250
    }
634
41.2k
    *Size = 4;
635
636
41.2k
    Insn = readBytes32(MI, Bytes);
637
638
41.2k
    TRY_TO_DECODE(4,
639
41.2k
            RISCV_getFeatureBits(MI->csh->mode,
640
41.2k
               RISCV_FeatureStdExtZdinx) &&
641
41.2k
              !RISCV_getFeatureBits(MI->csh->mode,
642
41.2k
                  RISCV_Feature64Bit),
643
41.2k
            DecoderTableRV32Zdinx32,
644
41.2k
            "RV32Zdinx table (Double in Integer and rv32)");
645
41.2k
    TRY_TO_DECODE(4,
646
41.1k
            RISCV_getFeatureBits(MI->csh->mode,
647
41.1k
               RISCV_FeatureStdExtZacas) &&
648
41.1k
              !RISCV_getFeatureBits(MI->csh->mode,
649
41.1k
                  RISCV_Feature64Bit),
650
41.1k
            DecoderTableRV32Zacas32,
651
41.1k
            "RV32Zacas table (Compare-And-Swap and rv32)");
652
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureStdExtZfinx,
653
41.1k
              DecoderTableRVZfinx32,
654
41.1k
              "RVZfinx table (Float in Integer)");
655
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXVentanaCondOps,
656
41.1k
              DecoderTableXVentana32,
657
41.1k
              "Ventana custom opcode table");
658
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXTHeadBa,
659
41.1k
              DecoderTableXTHeadBa32,
660
41.1k
              "XTHeadBa custom opcode table");
661
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXTHeadBb,
662
41.1k
              DecoderTableXTHeadBb32,
663
41.1k
              "XTHeadBb custom opcode table");
664
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXTHeadBs,
665
41.1k
              DecoderTableXTHeadBs32,
666
41.1k
              "XTHeadBs custom opcode table");
667
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXTHeadCondMov,
668
41.1k
              DecoderTableXTHeadCondMov32,
669
41.1k
              "XTHeadCondMov custom opcode table");
670
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXTHeadCmo,
671
41.1k
              DecoderTableXTHeadCmo32,
672
41.1k
              "XTHeadCmo custom opcode table");
673
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXTHeadFMemIdx,
674
41.1k
              DecoderTableXTHeadFMemIdx32,
675
41.1k
              "XTHeadFMemIdx custom opcode table");
676
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXTHeadMac,
677
41.1k
              DecoderTableXTHeadMac32,
678
41.1k
              "XTHeadMac custom opcode table");
679
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXTHeadMemIdx,
680
41.1k
              DecoderTableXTHeadMemIdx32,
681
41.1k
              "XTHeadMemIdx custom opcode table");
682
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXTHeadMemPair,
683
41.1k
              DecoderTableXTHeadMemPair32,
684
41.1k
              "XTHeadMemPair custom opcode table");
685
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXTHeadSync,
686
41.1k
              DecoderTableXTHeadSync32,
687
41.1k
              "XTHeadSync custom opcode table");
688
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXTHeadVdot,
689
41.1k
              DecoderTableXTHeadVdot32,
690
41.1k
              "XTHeadVdot custom opcode table");
691
41.1k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXSfvcp,
692
41.1k
              DecoderTableXSfvcp32,
693
41.1k
              "SiFive VCIX custom opcode table");
694
41.1k
    TRY_TO_DECODE_FEATURE(
695
41.1k
      4, RISCV_FeatureVendorXSfvqmaccdod,
696
41.1k
      DecoderTableXSfvqmaccdod32,
697
41.1k
      "SiFive Matrix Multiplication (2x8 and 8x2) Instruction opcode table");
698
41.1k
    TRY_TO_DECODE_FEATURE(
699
41.1k
      4, RISCV_FeatureVendorXSfvqmaccqoq,
700
41.1k
      DecoderTableXSfvqmaccqoq32,
701
41.1k
      "SiFive Matrix Multiplication (4x8 and 8x4) Instruction opcode table");
702
41.1k
    TRY_TO_DECODE_FEATURE(
703
41.1k
      4, RISCV_FeatureVendorXSfvfwmaccqqq,
704
41.1k
      DecoderTableXSfvfwmaccqqq32,
705
41.1k
      "SiFive Matrix Multiplication Instruction opcode table");
706
41.1k
    TRY_TO_DECODE_FEATURE(
707
41.1k
      4, RISCV_FeatureVendorXSfvfnrclipxfqf,
708
41.1k
      DecoderTableXSfvfnrclipxfqf32,
709
41.1k
      "SiFive FP32-to-int8 Ranged Clip Instructions opcode table");
710
41.1k
    TRY_TO_DECODE_FEATURE(
711
40.5k
      4, RISCV_FeatureVendorXCVbitmanip,
712
40.5k
      DecoderTableXCVbitmanip32,
713
40.5k
      "CORE-V Bit Manipulation custom opcode table");
714
40.5k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXCVelw,
715
40.5k
              DecoderTableXCVelw32,
716
40.5k
              "CORE-V Event load custom opcode table");
717
40.5k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXCVmac,
718
39.9k
              DecoderTableXCVmac32,
719
39.9k
              "CORE-V MAC custom opcode table");
720
39.9k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXCVmem,
721
38.7k
              DecoderTableXCVmem32,
722
38.7k
              "CORE-V MEM custom opcode table");
723
38.7k
    TRY_TO_DECODE_FEATURE(4, RISCV_FeatureVendorXCValu,
724
38.5k
              DecoderTableXCValu32,
725
38.5k
              "CORE-V ALU custom opcode table");
726
38.5k
    TRY_TO_DECODE_FEATURE(
727
37.9k
      4, RISCV_FeatureVendorXCVsimd, DecoderTableXCVsimd32,
728
37.9k
      "CORE-V SIMD extensions custom opcode table");
729
37.9k
    TRY_TO_DECODE_FEATURE(
730
37.7k
      4, RISCV_FeatureVendorXCVbi, DecoderTableXCVbi32,
731
37.7k
      "CORE-V Immediate Branching custom opcode table");
732
37.7k
    TRY_TO_DECODE(4, true, DecoderTable32, "RISCV32 table");
733
734
223
    return MCDisassembler_Fail;
735
37.7k
  }
736
737
43.7k
  if (BytesLen < 2) {
738
228
    *Size = 0;
739
228
    return MCDisassembler_Fail;
740
228
  }
741
43.5k
  *Size = 2;
742
743
43.5k
  Insn = readBytes16(MI, Bytes);
744
43.5k
  TRY_TO_DECODE_AND_ADD_SP(
745
42.6k
    2, !RISCV_getFeatureBits(MI->csh->mode, RISCV_Feature64Bit),
746
42.6k
    DecoderTableRISCV32Only_16,
747
42.6k
    "RISCV32Only_16 table (16-bit Instruction)");
748
42.6k
  TRY_TO_DECODE_FEATURE(2, RISCV_FeatureStdExtZicfiss,
749
42.6k
            DecoderTableZicfiss16,
750
42.6k
            "RVZicfiss table (Shadow Stack)");
751
42.6k
  TRY_TO_DECODE_FEATURE(2, RISCV_FeatureStdExtZcmt, DecoderTableRVZcmt16,
752
42.6k
            "Zcmt table (16-bit Table Jump Instructions)");
753
42.6k
  TRY_TO_DECODE_FEATURE(
754
42.6k
    2, RISCV_FeatureStdExtZcmp, DecoderTableRVZcmp16,
755
42.6k
    "Zcmp table (16-bit Push/Pop & Double Move Instructions)");
756
42.6k
  TRY_TO_DECODE_AND_ADD_SP(2, true, DecoderTable16,
757
153
         "RISCV_C table (16-bit Instruction)");
758
759
153
  return MCDisassembler_Fail;
760
42.6k
}
761
762
bool RISCV_LLVM_getInstruction(csh handle, const uint8_t *Bytes, size_t ByteLen,
763
             MCInst *MI, uint16_t *Size, uint64_t Address,
764
             void *Info)
765
85.1k
{
766
85.1k
  RISCV_init_cs_detail(MI);
767
85.1k
  MI->MRI = (MCRegisterInfo *)Info;
768
85.1k
  DecodeStatus ret =
769
85.1k
    RISCV_getInstruction(MI, Size, Bytes, ByteLen, Address, NULL);
770
771
85.1k
  MCInst_handleWriteback(MI, RISCVDescs.Insts,
772
85.1k
             ARR_SIZE(RISCVDescs.Insts));
773
774
85.1k
  return ret != MCDisassembler_Fail;
775
85.1k
}