/src/capstonev5/arch/RISCV/RISCVDisassembler.c
Line  | Count  | Source  | 
1  |  | //===-- RISCVDisassembler.cpp - Disassembler for RISCV --------------------===//  | 
2  |  | //  | 
3  |  | //                     The LLVM Compiler Infrastructure  | 
4  |  | //  | 
5  |  | // This file is distributed under the University of Illinois Open Source  | 
6  |  | // License. See LICENSE.TXT for details.  | 
7  |  | //  | 
8  |  | //===----------------------------------------------------------------------===//  | 
9  |  |  | 
10  |  | /* Capstone Disassembly Engine */  | 
11  |  | /* RISC-V Backend By Rodrigo Cortes Porto <porto703@gmail.com> &   | 
12  |  |    Shawn Chang <citypw@gmail.com>, HardenedLinux@2018 */  | 
13  |  |       | 
14  |  | #ifdef CAPSTONE_HAS_RISCV  | 
15  |  |  | 
16  |  | #include <stdio.h>    // DEBUG  | 
17  |  | #include <stdlib.h>  | 
18  |  | #include <string.h>  | 
19  |  |  | 
20  |  | #include "../../cs_priv.h"  | 
21  |  | #include "../../utils.h"  | 
22  |  |  | 
23  |  | #include "../../MCInst.h"  | 
24  |  | #include "../../MCInstrDesc.h"  | 
25  |  | #include "../../MCFixedLenDisassembler.h"  | 
26  |  | #include "../../MCRegisterInfo.h"  | 
27  |  | #include "../../MCDisassembler.h"  | 
28  |  | #include "../../MathExtras.h"  | 
29  |  | #include "RISCVBaseInfo.h"  | 
30  |  | #include "RISCVDisassembler.h"  | 
31  |  |  | 
32  |  |  | 
33  |  | /* Need the feature infos define in   | 
34  |  |   RISCVGenSubtargetInfo.inc. */  | 
35  |  | #define GET_SUBTARGETINFO_ENUM  | 
36  |  | #include "RISCVGenSubtargetInfo.inc"  | 
37  |  |  | 
38  |  | /* When we specify the RISCV64 mode, It means It is RV64IMAFD.  | 
39  |  |   Similar, RISCV32 means RV32IMAFD.  | 
40  |  | */  | 
41  |  | static uint64_t getFeatureBits(int mode)   | 
42  | 148k  | { | 
43  | 148k  |   uint64_t ret = RISCV_FeatureStdExtM | RISCV_FeatureStdExtA |  | 
44  | 148k  |            RISCV_FeatureStdExtF | RISCV_FeatureStdExtD ;  | 
45  |  |  | 
46  | 148k  |   if (mode & CS_MODE_RISCV64)  | 
47  | 75.4k  |     ret |= RISCV_Feature64Bit;  | 
48  | 148k  |   if (mode & CS_MODE_RISCVC)  | 
49  | 0  |     ret |= RISCV_FeatureStdExtC;  | 
50  |  |  | 
51  | 148k  |   return ret;  | 
52  | 148k  | }  | 
53  |  |  | 
54  |  | #define GET_REGINFO_ENUM  | 
55  |  | #define GET_REGINFO_MC_DESC  | 
56  |  | #include "RISCVGenRegisterInfo.inc"  | 
57  |  | #define GET_INSTRINFO_ENUM  | 
58  |  | #include "RISCVGenInstrInfo.inc"  | 
59  |  |  | 
60  |  | static const unsigned GPRDecoderTable[] = { | 
61  |  |     RISCV_X0,  RISCV_X1,  RISCV_X2,  RISCV_X3,  | 
62  |  |     RISCV_X4,  RISCV_X5,  RISCV_X6,  RISCV_X7,  | 
63  |  |     RISCV_X8,  RISCV_X9,  RISCV_X10, RISCV_X11,  | 
64  |  |     RISCV_X12, RISCV_X13, RISCV_X14, RISCV_X15,  | 
65  |  |     RISCV_X16, RISCV_X17, RISCV_X18, RISCV_X19,  | 
66  |  |     RISCV_X20, RISCV_X21, RISCV_X22, RISCV_X23,  | 
67  |  |     RISCV_X24, RISCV_X25, RISCV_X26, RISCV_X27,  | 
68  |  |     RISCV_X28, RISCV_X29, RISCV_X30, RISCV_X31  | 
69  |  | };  | 
70  |  |  | 
71  |  | static DecodeStatus DecodeGPRRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
72  |  |             uint64_t Address, const void *Decoder)   | 
73  | 198k  | { | 
74  | 198k  |     unsigned Reg = 0;  | 
75  |  |  | 
76  | 198k  |     if (RegNo >= ARR_SIZE(GPRDecoderTable))  | 
77  | 0  |         return MCDisassembler_Fail;  | 
78  |  |  | 
79  |  |     // We must define our own mapping from RegNo to register identifier.  | 
80  |  |     // Accessing index RegNo in the register class will work in the case that  | 
81  |  |     // registers were added in ascending order, but not in general.  | 
82  | 198k  |     Reg = GPRDecoderTable[RegNo];  | 
83  |  |     //Inst.addOperand(MCOperand::createReg(Reg));  | 
84  | 198k  |     MCOperand_CreateReg0(Inst, Reg);  | 
85  | 198k  |     return MCDisassembler_Success;  | 
86  | 198k  | }  | 
87  |  |  | 
88  |  | static const unsigned FPR32DecoderTable[] = { | 
89  |  |     RISCV_F0_32,  RISCV_F1_32,  RISCV_F2_32,  RISCV_F3_32,  | 
90  |  |     RISCV_F4_32,  RISCV_F5_32,  RISCV_F6_32,  RISCV_F7_32,  | 
91  |  |     RISCV_F8_32,  RISCV_F9_32,  RISCV_F10_32, RISCV_F11_32,  | 
92  |  |     RISCV_F12_32, RISCV_F13_32, RISCV_F14_32, RISCV_F15_32,  | 
93  |  |     RISCV_F16_32, RISCV_F17_32, RISCV_F18_32, RISCV_F19_32,  | 
94  |  |     RISCV_F20_32, RISCV_F21_32, RISCV_F22_32, RISCV_F23_32,  | 
95  |  |     RISCV_F24_32, RISCV_F25_32, RISCV_F26_32, RISCV_F27_32,  | 
96  |  |     RISCV_F28_32, RISCV_F29_32, RISCV_F30_32, RISCV_F31_32  | 
97  |  | };  | 
98  |  |  | 
99  |  | static DecodeStatus DecodeFPR32RegisterClass(MCInst *Inst, uint64_t RegNo,  | 
100  |  |        uint64_t Address, const void *Decoder)   | 
101  | 43.0k  | { | 
102  | 43.0k  |     unsigned Reg = 0;  | 
103  |  |  | 
104  | 43.0k  |     if (RegNo >= ARR_SIZE(FPR32DecoderTable))  | 
105  | 0  |         return MCDisassembler_Fail;  | 
106  |  |  | 
107  |  |     // We must define our own mapping from RegNo to register identifier.  | 
108  |  |     // Accessing index RegNo in the register class will work in the case that  | 
109  |  |     // registers were added in ascending order, but not in general.  | 
110  | 43.0k  |     Reg = FPR32DecoderTable[RegNo];  | 
111  | 43.0k  |     MCOperand_CreateReg0(Inst, Reg);  | 
112  | 43.0k  |     return MCDisassembler_Success;  | 
113  | 43.0k  | }  | 
114  |  |  | 
115  |  | static DecodeStatus DecodeFPR32CRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
116  |  |                                               uint64_t Address,  | 
117  |  |                                               const void *Decoder)   | 
118  | 0  | { | 
119  | 0  |     unsigned Reg = 0;  | 
120  |  | 
  | 
121  | 0  |     if (RegNo > 8)   | 
122  | 0  |         return MCDisassembler_Fail;  | 
123  | 0  |     Reg = FPR32DecoderTable[RegNo + 8];  | 
124  | 0  |     MCOperand_CreateReg0(Inst, Reg);  | 
125  | 0  |     return MCDisassembler_Success;  | 
126  | 0  | }  | 
127  |  |  | 
128  |  | static const unsigned FPR64DecoderTable[] = { | 
129  |  |     RISCV_F0_64,  RISCV_F1_64,  RISCV_F2_64,  RISCV_F3_64,  | 
130  |  |     RISCV_F4_64,  RISCV_F5_64,  RISCV_F6_64,  RISCV_F7_64,  | 
131  |  |     RISCV_F8_64,  RISCV_F9_64,  RISCV_F10_64, RISCV_F11_64,  | 
132  |  |     RISCV_F12_64, RISCV_F13_64, RISCV_F14_64, RISCV_F15_64,  | 
133  |  |     RISCV_F16_64, RISCV_F17_64, RISCV_F18_64, RISCV_F19_64,  | 
134  |  |     RISCV_F20_64, RISCV_F21_64, RISCV_F22_64, RISCV_F23_64,  | 
135  |  |     RISCV_F24_64, RISCV_F25_64, RISCV_F26_64, RISCV_F27_64,  | 
136  |  |     RISCV_F28_64, RISCV_F29_64, RISCV_F30_64, RISCV_F31_64  | 
137  |  | };  | 
138  |  |  | 
139  |  | static DecodeStatus DecodeFPR64RegisterClass(MCInst *Inst, uint64_t RegNo,  | 
140  |  |        uint64_t Address, const void *Decoder)   | 
141  | 24.5k  | { | 
142  | 24.5k  |     unsigned Reg = 0;  | 
143  |  |  | 
144  | 24.5k  |     if (RegNo >= ARR_SIZE(FPR64DecoderTable))  | 
145  | 0  |         return MCDisassembler_Fail;  | 
146  |  |  | 
147  |  |   // We must define our own mapping from RegNo to register identifier.  | 
148  |  |     // Accessing index RegNo in the register class will work in the case that  | 
149  |  |     // registers were added in ascending order, but not in general.  | 
150  | 24.5k  |     Reg = FPR64DecoderTable[RegNo];  | 
151  | 24.5k  |     MCOperand_CreateReg0(Inst, Reg);  | 
152  | 24.5k  |     return MCDisassembler_Success;  | 
153  | 24.5k  | }  | 
154  |  |  | 
155  |  | static DecodeStatus DecodeFPR64CRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
156  |  |                                               uint64_t Address,  | 
157  |  |                                               const void *Decoder)   | 
158  | 0  | { | 
159  | 0  |     unsigned Reg = 0;  | 
160  |  | 
  | 
161  | 0  |     if (RegNo > 8)  | 
162  | 0  |         return MCDisassembler_Fail;  | 
163  | 0  |     Reg = FPR64DecoderTable[RegNo + 8];  | 
164  | 0  |     MCOperand_CreateReg0(Inst, Reg);  | 
165  | 0  |     return MCDisassembler_Success;  | 
166  | 0  | }  | 
167  |  |  | 
168  |  | static DecodeStatus DecodeGPRNoX0RegisterClass(MCInst *Inst, uint64_t RegNo,  | 
169  |  |                                                uint64_t Address,  | 
170  |  |                                                const void *Decoder)   | 
171  | 0  | { | 
172  | 0  |     if (RegNo == 0)  | 
173  | 0  |         return MCDisassembler_Fail;  | 
174  | 0  |     return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);  | 
175  | 0  | }  | 
176  |  |  | 
177  |  | static DecodeStatus DecodeGPRNoX0X2RegisterClass(MCInst *Inst, uint64_t RegNo,  | 
178  |  |                                                  uint64_t Address,  | 
179  |  |                                                  const void *Decoder)   | 
180  | 0  | { | 
181  | 0  |     if (RegNo == 2)  | 
182  | 0  |         return MCDisassembler_Fail;  | 
183  | 0  |     return DecodeGPRNoX0RegisterClass(Inst, RegNo, Address, Decoder);  | 
184  | 0  | }  | 
185  |  |  | 
186  |  | static DecodeStatus DecodeGPRCRegisterClass(MCInst *Inst, uint64_t RegNo,  | 
187  |  |                                             uint64_t Address,  | 
188  |  |                                             const void *Decoder)   | 
189  | 0  | { | 
190  | 0  |     unsigned Reg = 0;  | 
191  |  | 
  | 
192  | 0  |     if (RegNo > 8)  | 
193  | 0  |         return MCDisassembler_Fail;  | 
194  |  |  | 
195  | 0  |     Reg = GPRDecoderTable[RegNo + 8];  | 
196  | 0  |     MCOperand_CreateReg0(Inst, Reg);  | 
197  | 0  |     return MCDisassembler_Success;  | 
198  | 0  | }  | 
199  |  |  | 
200  |  | // Add implied SP operand for instructions *SP compressed instructions. The SP  | 
201  |  | // operand isn't explicitly encoded in the instruction.  | 
202  |  | static void addImplySP(MCInst *Inst, int64_t Address, const void *Decoder)   | 
203  | 152k  | { | 
204  | 152k  |     if (MCInst_getOpcode(Inst) == RISCV_C_LWSP ||   | 
205  | 152k  |             MCInst_getOpcode(Inst) == RISCV_C_SWSP ||  | 
206  | 152k  |             MCInst_getOpcode(Inst) == RISCV_C_LDSP ||   | 
207  | 152k  |             MCInst_getOpcode(Inst) == RISCV_C_SDSP ||  | 
208  | 152k  |             MCInst_getOpcode(Inst) == RISCV_C_FLWSP ||  | 
209  | 152k  |             MCInst_getOpcode(Inst) == RISCV_C_FSWSP ||  | 
210  | 152k  |             MCInst_getOpcode(Inst) == RISCV_C_FLDSP ||  | 
211  | 152k  |             MCInst_getOpcode(Inst) == RISCV_C_FSDSP ||  | 
212  | 152k  |             MCInst_getOpcode(Inst) == RISCV_C_ADDI4SPN) { | 
213  | 0  |     DecodeGPRRegisterClass(Inst, 2, Address, Decoder);  | 
214  | 0  |     }  | 
215  |  |  | 
216  | 152k  |     if (MCInst_getOpcode(Inst) == RISCV_C_ADDI16SP) { | 
217  | 0  |         DecodeGPRRegisterClass(Inst, 2, Address, Decoder);  | 
218  | 0  |         DecodeGPRRegisterClass(Inst, 2, Address, Decoder);  | 
219  | 0  |     }  | 
220  | 152k  | }  | 
221  |  |  | 
222  |  | static DecodeStatus decodeUImmOperand(MCInst *Inst, uint64_t Imm,  | 
223  |  |                                       int64_t Address, const void *Decoder,  | 
224  |  |               unsigned N)   | 
225  | 146k  | { | 
226  |  |     //CS_ASSERT(isUInt<N>(Imm) && "Invalid immediate");  | 
227  | 146k  |     addImplySP(Inst, Address, Decoder);  | 
228  |  |     //Inst.addOperand(MCOperand::createImm(Imm));  | 
229  | 146k  |     MCOperand_CreateImm0(Inst, Imm);  | 
230  | 146k  |     return MCDisassembler_Success;  | 
231  | 146k  | }  | 
232  |  |  | 
233  |  | static DecodeStatus decodeUImmNonZeroOperand(MCInst *Inst, uint64_t Imm,  | 
234  |  |                                              int64_t Address,  | 
235  |  |                                              const void *Decoder,   | 
236  |  |                unsigned N)   | 
237  | 0  | { | 
238  | 0  |     if (Imm == 0)  | 
239  | 0  |         return MCDisassembler_Fail;  | 
240  | 0  |     return decodeUImmOperand(Inst, Imm, Address, Decoder, N);  | 
241  | 0  | }  | 
242  |  |  | 
243  |  | static DecodeStatus decodeSImmOperand(MCInst *Inst, uint64_t Imm,  | 
244  |  |                                       int64_t Address, const void *Decoder,  | 
245  |  |               unsigned N)   | 
246  | 6.36k  | { | 
247  |  |     //CS_ASSERT(isUInt<N>(Imm) && "Invalid immediate");  | 
248  | 6.36k  |     addImplySP(Inst, Address, Decoder);  | 
249  |  |     // Sign-extend the number in the bottom N bits of Imm  | 
250  |  |     //Inst.addOperand(MCOperand::createImm(SignExtend64<N>(Imm)));  | 
251  | 6.36k  |     MCOperand_CreateImm0(Inst, SignExtend64(Imm, N));  | 
252  | 6.36k  |     return MCDisassembler_Success;  | 
253  | 6.36k  | }  | 
254  |  |  | 
255  |  | static DecodeStatus decodeSImmNonZeroOperand(MCInst *Inst, uint64_t Imm,  | 
256  |  |                                              int64_t Address,  | 
257  |  |                                              const void *Decoder,  | 
258  |  |                unsigned N)   | 
259  | 0  | { | 
260  | 0  |     if (Imm == 0)  | 
261  | 0  |         return MCDisassembler_Fail;  | 
262  | 0  |     return decodeSImmOperand(Inst, Imm, Address, Decoder, N);  | 
263  | 0  | }  | 
264  |  |  | 
265  |  | static DecodeStatus decodeSImmOperandAndLsl1(MCInst *Inst, uint64_t Imm,  | 
266  |  |                                              int64_t Address,  | 
267  |  |                                              const void *Decoder,  | 
268  |  |                unsigned N)   | 
269  | 3.20k  | { | 
270  |  |     //CS_ASSERT(isUInt<N>(Imm) && "Invalid immediate");  | 
271  |  |     // Sign-extend the number in the bottom N bits of Imm after accounting for  | 
272  |  |     // the fact that the N bit immediate is stored in N-1 bits (the LSB is  | 
273  |  |     // always zero)  | 
274  |  |     //Inst.addOperand(MCOperand::createImm(SignExtend64<N>(Imm << 1)));  | 
275  | 3.20k  |     MCOperand_CreateImm0(Inst, SignExtend64(Imm << 1, N));  | 
276  | 3.20k  |     return MCDisassembler_Success;  | 
277  | 3.20k  | }  | 
278  |  |  | 
279  |  | static DecodeStatus decodeCLUIImmOperand(MCInst *Inst, uint64_t Imm,  | 
280  |  |                                          int64_t Address,  | 
281  |  |                                          const void *Decoder)   | 
282  | 0  | { | 
283  |  |     //CS_ASSERT(isUInt<6>(Imm) && "Invalid immediate");  | 
284  | 0  |     if (Imm > 31) { | 
285  | 0  |         Imm = (SignExtend64(Imm, 6) & 0xfffff);  | 
286  | 0  |     }  | 
287  |  |     //Inst.addOperand(MCOperand::createImm(Imm));  | 
288  | 0  |     MCOperand_CreateImm0(Inst, Imm);  | 
289  | 0  |     return MCDisassembler_Success;  | 
290  | 0  | }  | 
291  |  |  | 
292  |  | static DecodeStatus decodeFRMArg(MCInst *Inst, uint64_t Imm,  | 
293  |  |                                  int64_t Address,  | 
294  |  |                                  const void *Decoder)   | 
295  | 24.1k  | { | 
296  |  |     //CS_ASSERT(isUInt<3>(Imm) && "Invalid immediate");  | 
297  | 24.1k  |     if (!RISCVFPRndMode_isValidRoundingMode(Imm))  | 
298  | 14  |         return MCDisassembler_Fail;  | 
299  |  |  | 
300  |  |     //Inst.addOperand(MCOperand::createImm(Imm));  | 
301  | 24.1k  |     MCOperand_CreateImm0(Inst, Imm);  | 
302  | 24.1k  |     return MCDisassembler_Success;  | 
303  | 24.1k  | }  | 
304  |  |  | 
305  |  |  | 
306  |  | #include "RISCVGenDisassemblerTables.inc"  | 
307  |  |  | 
308  |  | static void init_MI_insn_detail(MCInst *MI)   | 
309  | 147k  | { | 
310  | 147k  |     if (MI->flat_insn->detail) { | 
311  | 147k  |         memset(MI->flat_insn->detail, 0, sizeof(cs_detail));  | 
312  | 147k  |     }  | 
313  |  |  | 
314  | 147k  |     return;  | 
315  | 147k  | }  | 
316  |  |  | 
317  |  | // mark the load/store instructions through the opcode.  | 
318  |  | static void markLSInsn(MCInst *MI, uint32_t in)  | 
319  | 146k  | { | 
320  |  |   /*   | 
321  |  |      I   ld 0000011 = 0x03  | 
322  |  |          st 0100011 = 0x23  | 
323  |  |      F/D ld 0000111 = 0x07  | 
324  |  |          st 0100111 = 0x27  | 
325  |  |   */  | 
326  | 146k  | #define MASK_LS_INSN 0x0000007f  | 
327  | 146k  |   uint32_t opcode = in & MASK_LS_INSN;  | 
328  | 146k  |   if (0 == (opcode ^ 0x03) || 0 == (opcode ^ 0x07) ||  | 
329  | 146k  |       0 == (opcode ^ 0x23) || 0 == (opcode ^ 0x27))  | 
330  | 1.45k  |     MI->flat_insn->detail->riscv.need_effective_addr = true;  | 
331  | 146k  | #undef MASK_LS_INSN  | 
332  | 146k  |   return;  | 
333  | 146k  | }  | 
334  |  |  | 
335  |  | static DecodeStatus RISCVDisassembler_getInstruction(int mode, MCInst *MI,  | 
336  |  |          const uint8_t *code, size_t code_len,  | 
337  |  |          uint16_t *Size, uint64_t Address,  | 
338  |  |          MCRegisterInfo *MRI)   | 
339  | 148k  | { | 
340  |  |     // TODO: This will need modification when supporting instruction set  | 
341  |  |     // extensions with instructions > 32-bits (up to 176 bits wide).  | 
342  | 148k  |     uint32_t Inst = 0;  | 
343  | 148k  |     DecodeStatus Result;  | 
344  |  |  | 
345  |  |     // It's a 32 bit instruction if bit 0 and 1 are 1.  | 
346  | 148k  |     if ((code[0] & 0x3) == 0x3) { | 
347  | 147k  |           if (code_len < 4) { | 
348  | 396  |             *Size = 0;  | 
349  | 396  |             return MCDisassembler_Fail;  | 
350  | 396  |           }  | 
351  |  |  | 
352  | 146k  |           *Size = 4;  | 
353  |  |           // Get the four bytes of the instruction.  | 
354  |  |           //Encoded as little endian 32 bits.  | 
355  | 146k  |           Inst = code[0] | (code[1] << 8) | (code[2] << 16) | ((uint32_t)code[3] << 24);  | 
356  | 146k  |     init_MI_insn_detail(MI);  | 
357  |  |     // Now we need mark what instruction need fix effective address output.  | 
358  | 146k  |         if (MI->csh->detail)   | 
359  | 146k  |       markLSInsn(MI, Inst);  | 
360  | 146k  |           Result = decodeInstruction(DecoderTable32, MI, Inst, Address, MRI, mode);  | 
361  | 146k  |     } else { | 
362  | 758  |         if (code_len < 2) { | 
363  | 226  |             *Size = 0;  | 
364  | 226  |             return MCDisassembler_Fail;  | 
365  | 226  |         }  | 
366  |  |  | 
367  |  |     // If not b4bit.  | 
368  | 532  |         if (! (getFeatureBits(mode) & ((uint64_t)RISCV_Feature64Bit))) { | 
369  |  |             // Trying RISCV32Only_16 table (16-bit Instruction)  | 
370  | 266  |             Inst = code[0] | (code[1] << 8);  | 
371  | 266  |             init_MI_insn_detail(MI);  | 
372  | 266  |             Result = decodeInstruction(DecoderTableRISCV32Only_16, MI, Inst, Address,  | 
373  | 266  |                                          MRI, mode);  | 
374  | 266  |             if (Result != MCDisassembler_Fail) { | 
375  | 0  |               *Size = 2;  | 
376  | 0  |               return Result;  | 
377  | 0  |             }  | 
378  | 266  |         }  | 
379  |  |       | 
380  |  |         // Trying RISCV_C table (16-bit Instruction)  | 
381  | 532  |         Inst = code[0] | (code[1] << 8);  | 
382  | 532  |         init_MI_insn_detail(MI);  | 
383  |  |         // Calling the auto-generated decoder function.  | 
384  | 532  |         Result = decodeInstruction(DecoderTable16, MI, Inst, Address, MRI, mode);  | 
385  | 532  |         *Size = 2;  | 
386  | 532  |     }  | 
387  |  |  | 
388  | 147k  |     return Result;  | 
389  | 148k  | }  | 
390  |  |  | 
391  |  | bool RISCV_getInstruction(csh ud, const uint8_t *code, size_t code_len,  | 
392  |  |               MCInst *instr, uint16_t *size, uint64_t address,  | 
393  |  |               void *info)   | 
394  | 148k  | { | 
395  | 148k  |     cs_struct *handle = (cs_struct *)(uintptr_t)ud;  | 
396  |  |  | 
397  | 148k  |     return MCDisassembler_Success ==   | 
398  | 148k  |       RISCVDisassembler_getInstruction(handle->mode, instr,  | 
399  | 148k  |                        code, code_len,  | 
400  | 148k  |                              size, address,  | 
401  | 148k  |                              (MCRegisterInfo *)info);  | 
402  |  |  | 
403  | 148k  | }  | 
404  |  |  | 
405  |  | void RISCV_init(MCRegisterInfo * MRI)   | 
406  | 3.07k  | { | 
407  |  |     /*  | 
408  |  |     InitMCRegisterInfo(RISCVRegDesc, 97, RA, PC,  | 
409  |  |                      RISCVMCRegisterClasses, 11,  | 
410  |  |                      RISCVRegUnitRoots,  | 
411  |  |                      64,  | 
412  |  |                      RISCVRegDiffLists,  | 
413  |  |                      RISCVLaneMaskLists,  | 
414  |  |                      RISCVRegStrings,  | 
415  |  |                      RISCVRegClassStrings,  | 
416  |  |                      RISCVSubRegIdxLists,  | 
417  |  |                      2,  | 
418  |  |                      RISCVSubRegIdxRanges,  | 
419  |  |                      RISCVRegEncodingTable);  | 
420  |  |     */  | 
421  |  |  | 
422  | 3.07k  |     MCRegisterInfo_InitMCRegisterInfo(MRI, RISCVRegDesc, 97, 0, 0,  | 
423  | 3.07k  |                 RISCVMCRegisterClasses, 11,  | 
424  | 3.07k  |                   0,   | 
425  | 3.07k  |                   0,  | 
426  | 3.07k  |                   RISCVRegDiffLists,  | 
427  | 3.07k  |                   0,   | 
428  | 3.07k  |                   RISCVSubRegIdxLists,   | 
429  | 3.07k  |                   2,   | 
430  | 3.07k  |                   0);  | 
431  | 3.07k  | }  | 
432  |  |  | 
433  |  | #endif  |