Coverage Report

Created: 2025-07-11 06:32

/src/capstonenext/arch/Mips/MipsMapping.c
Line
Count
Source (jump to first uncovered line)
1
/* Capstone Disassembly Engine */
2
/* By Giovanni Dante Grazioli, deroad <wargio@libero.it>, 2024 */
3
4
#ifdef CAPSTONE_HAS_MIPS
5
6
#include <stdio.h>
7
#include <string.h>
8
9
#include <capstone/capstone.h>
10
#include <capstone/mips.h>
11
12
#include "../../Mapping.h"
13
#include "../../MCDisassembler.h"
14
#include "../../cs_priv.h"
15
#include "../../cs_simple_types.h"
16
17
#include "MipsMapping.h"
18
#include "MipsLinkage.h"
19
#include "MipsDisassembler.h"
20
21
#define GET_REGINFO_ENUM
22
#define GET_REGINFO_MC_DESC
23
#include "MipsGenRegisterInfo.inc"
24
25
#define GET_INSTRINFO_ENUM
26
#include "MipsGenInstrInfo.inc"
27
28
void Mips_init_mri(MCRegisterInfo *MRI)
29
3.66k
{
30
3.66k
  MCRegisterInfo_InitMCRegisterInfo(MRI, MipsRegDesc, sizeof(MipsRegDesc),
31
3.66k
            0, 0, MipsMCRegisterClasses,
32
3.66k
            ARR_SIZE(MipsMCRegisterClasses), 0, 0,
33
3.66k
            MipsRegDiffLists, 0,
34
3.66k
            MipsSubRegIdxLists,
35
3.66k
            ARR_SIZE(MipsSubRegIdxLists), 0);
36
3.66k
}
37
38
const char *Mips_reg_name(csh handle, unsigned int reg)
39
25.0k
{
40
25.0k
  int syntax_opt = ((cs_struct *)(uintptr_t)handle)->syntax;
41
25.0k
  return Mips_LLVM_getRegisterName(reg,
42
25.0k
           syntax_opt & CS_OPT_SYNTAX_NOREGNAME);
43
25.0k
}
44
45
void Mips_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id)
46
102k
{
47
  // Not used by Mips. Information is set after disassembly.
48
102k
}
49
50
static const char *const insn_name_maps[] = {
51
#include "MipsGenCSMappingInsnName.inc"
52
};
53
54
#ifndef CAPSTONE_DIET
55
static const name_map insn_alias_mnem_map[] = {
56
#include "MipsGenCSAliasMnemMap.inc"
57
  // The followings aliases are not generated by LLVM table gen.
58
  { MIPS_INS_ALIAS_B, "b" }, // beq
59
  { MIPS_INS_ALIAS_BEQZ, "beqz" }, // beq
60
  { MIPS_INS_ALIAS_BNEZ, "bnez" }, // bne
61
  { MIPS_INS_ALIAS_LI, "li" }, // addiu
62
  { MIPS_INS_ALIAS_END, NULL },
63
};
64
#endif
65
const char *Mips_insn_name(csh handle, unsigned int id)
66
102k
{
67
102k
#ifndef CAPSTONE_DIET
68
102k
  if (id < MIPS_INS_ALIAS_END && id > MIPS_INS_ALIAS_BEGIN) {
69
0
    if (id - MIPS_INS_ALIAS_BEGIN >= ARR_SIZE(insn_alias_mnem_map))
70
0
      return NULL;
71
72
0
    return insn_alias_mnem_map[id - MIPS_INS_ALIAS_BEGIN - 1].name;
73
0
  }
74
102k
  if (id >= MIPS_INS_ENDING)
75
0
    return NULL;
76
77
102k
  if (id < ARR_SIZE(insn_name_maps))
78
102k
    return insn_name_maps[id];
79
  // not found
80
0
  return NULL;
81
#else
82
  return NULL;
83
#endif
84
102k
}
85
86
#ifndef CAPSTONE_DIET
87
static const name_map group_name_maps[] = {
88
  { MIPS_GRP_INVALID, NULL },
89
90
  { MIPS_GRP_JUMP, "jump" },
91
  { MIPS_GRP_CALL, "call" },
92
  { MIPS_GRP_RET, "return" },
93
  { MIPS_GRP_INT, "int" },
94
  { MIPS_GRP_IRET, "iret" },
95
  { MIPS_GRP_PRIVILEGE, "privilege" },
96
  { MIPS_GRP_BRANCH_RELATIVE, "branch_relative" },
97
98
// architecture-specific groups
99
#include "MipsGenCSFeatureName.inc"
100
};
101
#endif
102
103
const char *Mips_group_name(csh handle, unsigned int id)
104
315k
{
105
315k
#ifndef CAPSTONE_DIET
106
315k
  return id2name(group_name_maps, ARR_SIZE(group_name_maps), id);
107
#else
108
  return NULL;
109
#endif
110
315k
}
111
112
const insn_map mips_insns[] = {
113
#include "MipsGenCSMappingInsn.inc"
114
};
115
116
void Mips_reg_access(const cs_insn *insn, cs_regs regs_read,
117
         uint8_t *regs_read_count, cs_regs regs_write,
118
         uint8_t *regs_write_count)
119
0
{
120
0
  uint8_t i;
121
0
  uint8_t read_count, write_count;
122
0
  cs_mips *mips = &(insn->detail->mips);
123
124
0
  read_count = insn->detail->regs_read_count;
125
0
  write_count = insn->detail->regs_write_count;
126
127
  // implicit registers
128
0
  memcpy(regs_read, insn->detail->regs_read,
129
0
         read_count * sizeof(insn->detail->regs_read[0]));
130
0
  memcpy(regs_write, insn->detail->regs_write,
131
0
         write_count * sizeof(insn->detail->regs_write[0]));
132
133
  // explicit registers
134
0
  for (i = 0; i < mips->op_count; i++) {
135
0
    cs_mips_op *op = &(mips->operands[i]);
136
0
    switch ((int)op->type) {
137
0
    case MIPS_OP_REG:
138
0
      if ((op->access & CS_AC_READ) &&
139
0
          !arr_exist(regs_read, read_count, op->reg)) {
140
0
        regs_read[read_count] = (uint16_t)op->reg;
141
0
        read_count++;
142
0
      }
143
0
      if ((op->access & CS_AC_WRITE) &&
144
0
          !arr_exist(regs_write, write_count, op->reg)) {
145
0
        regs_write[write_count] = (uint16_t)op->reg;
146
0
        write_count++;
147
0
      }
148
0
      break;
149
0
    case MIPS_OP_MEM:
150
      // registers appeared in memory references always being read
151
0
      if ((op->mem.base != MIPS_REG_INVALID) &&
152
0
          !arr_exist(regs_read, read_count, op->mem.base)) {
153
0
        regs_read[read_count] = (uint16_t)op->mem.base;
154
0
        read_count++;
155
0
      }
156
0
      if ((insn->detail->writeback) &&
157
0
          (op->mem.base != MIPS_REG_INVALID) &&
158
0
          !arr_exist(regs_write, write_count, op->mem.base)) {
159
0
        regs_write[write_count] =
160
0
          (uint16_t)op->mem.base;
161
0
        write_count++;
162
0
      }
163
0
    default:
164
0
      break;
165
0
    }
166
0
  }
167
168
0
  *regs_read_count = read_count;
169
0
  *regs_write_count = write_count;
170
0
}
171
172
void Mips_set_instr_map_data(MCInst *MI)
173
102k
{
174
  // Fixes for missing groups.
175
102k
  if (MCInst_getOpcode(MI) == Mips_JR) {
176
39
    unsigned Reg = MCInst_getOpVal(MI, 0);
177
39
    switch (Reg) {
178
19
    case MIPS_REG_RA:
179
19
    case MIPS_REG_RA_64:
180
19
      add_group(MI, MIPS_GRP_RET);
181
19
      break;
182
39
    }
183
39
  }
184
185
102k
  map_cs_id(MI, mips_insns, ARR_SIZE(mips_insns));
186
102k
  map_implicit_reads(MI, mips_insns);
187
102k
  map_implicit_writes(MI, mips_insns);
188
102k
  map_groups(MI, mips_insns);
189
102k
}
190
191
bool Mips_getInstruction(csh handle, const uint8_t *code, size_t code_len,
192
       MCInst *instr, uint16_t *size, uint64_t address,
193
       void *info)
194
104k
{
195
104k
  uint64_t size64;
196
104k
  Mips_init_cs_detail(instr);
197
104k
  instr->MRI = (MCRegisterInfo *)info;
198
104k
  map_set_fill_detail_ops(instr, true);
199
200
104k
  DecodeStatus Result = Mips_LLVM_getInstruction(instr, &size64, code, code_len,
201
104k
                 address,
202
104k
                 info);
203
104k
  *size = size64;
204
104k
  if (Result != MCDisassembler_Fail) {
205
102k
    Mips_set_instr_map_data(instr);
206
102k
  }
207
104k
  if (Result == MCDisassembler_SoftFail) {
208
0
    MCInst_setSoftFail(instr);
209
0
  }
210
104k
  return Result != MCDisassembler_Fail;
211
104k
}
212
213
void Mips_printer(MCInst *MI, SStream *O, void * /* MCRegisterInfo* */ info)
214
102k
{
215
102k
  MCRegisterInfo *MRI = (MCRegisterInfo *)info;
216
102k
  MI->MRI = MRI;
217
218
102k
  Mips_LLVM_printInst(MI, MI->address, O);
219
102k
#ifndef CAPSTONE_DIET
220
102k
  map_set_alias_id(MI, O, insn_alias_mnem_map,
221
102k
       ARR_SIZE(insn_alias_mnem_map));
222
102k
#endif
223
102k
}
224
225
static void Mips_setup_op(cs_mips_op *op)
226
1.04M
{
227
1.04M
  memset(op, 0, sizeof(cs_mips_op));
228
1.04M
  op->type = MIPS_OP_INVALID;
229
1.04M
}
230
231
void Mips_init_cs_detail(MCInst *MI)
232
104k
{
233
104k
  if (detail_is_set(MI)) {
234
104k
    unsigned int i;
235
236
104k
    memset(get_detail(MI), 0,
237
104k
           offsetof(cs_detail, mips) + sizeof(cs_mips));
238
239
1.15M
    for (i = 0; i < ARR_SIZE(Mips_get_detail(MI)->operands); i++)
240
1.04M
      Mips_setup_op(&Mips_get_detail(MI)->operands[i]);
241
104k
  }
242
104k
}
243
244
static const map_insn_ops insn_operands[] = {
245
#include "MipsGenCSMappingInsnOp.inc"
246
};
247
248
static void Mips_set_detail_op_mem_reg(MCInst *MI, unsigned OpNum, mips_reg Reg)
249
29.1k
{
250
29.1k
  Mips_get_detail_op(MI, 0)->type = MIPS_OP_MEM;
251
29.1k
  Mips_get_detail_op(MI, 0)->mem.base = Reg;
252
29.1k
  Mips_get_detail_op(MI, 0)->access = map_get_op_access(MI, OpNum);
253
29.1k
}
254
255
static void Mips_set_detail_op_mem_disp(MCInst *MI, unsigned OpNum, int64_t Imm)
256
29.5k
{
257
29.5k
  Mips_get_detail_op(MI, 0)->type = MIPS_OP_MEM;
258
29.5k
  Mips_get_detail_op(MI, 0)->mem.disp = Imm;
259
29.5k
  Mips_get_detail_op(MI, 0)->access = map_get_op_access(MI, OpNum);
260
29.5k
}
261
262
static void Mips_set_detail_op_imm(MCInst *MI, unsigned OpNum, int64_t Imm)
263
45.0k
{
264
45.0k
  if (!detail_is_set(MI))
265
0
    return;
266
267
45.0k
  if (doing_mem(MI)) {
268
29.5k
    Mips_set_detail_op_mem_disp(MI, OpNum, Imm);
269
29.5k
    return;
270
29.5k
  }
271
272
15.5k
  Mips_get_detail_op(MI, 0)->type = MIPS_OP_IMM;
273
15.5k
  Mips_get_detail_op(MI, 0)->imm = Imm;
274
15.5k
  Mips_get_detail_op(MI, 0)->access = map_get_op_access(MI, OpNum);
275
15.5k
  Mips_inc_op_count(MI);
276
15.5k
}
277
278
static void Mips_set_detail_op_uimm(MCInst *MI, unsigned OpNum, uint64_t Imm)
279
36.6k
{
280
36.6k
  if (!detail_is_set(MI))
281
0
    return;
282
283
36.6k
  if (doing_mem(MI)) {
284
0
    Mips_set_detail_op_mem_disp(MI, OpNum, Imm);
285
0
    return;
286
0
  }
287
288
36.6k
  Mips_get_detail_op(MI, 0)->type = MIPS_OP_IMM;
289
36.6k
  Mips_get_detail_op(MI, 0)->uimm = Imm;
290
36.6k
  Mips_get_detail_op(MI, 0)->is_unsigned = true;
291
36.6k
  Mips_get_detail_op(MI, 0)->access = map_get_op_access(MI, OpNum);
292
36.6k
  Mips_inc_op_count(MI);
293
36.6k
}
294
295
static void Mips_set_detail_op_reg(MCInst *MI, unsigned OpNum, mips_reg Reg,
296
           bool is_reglist)
297
184k
{
298
184k
  if (!detail_is_set(MI))
299
0
    return;
300
301
184k
  if (doing_mem(MI)) {
302
29.1k
    Mips_set_detail_op_mem_reg(MI, OpNum, Reg);
303
29.1k
    return;
304
29.1k
  }
305
306
155k
  CS_ASSERT((map_get_op_type(MI, OpNum) & ~CS_OP_MEM) == CS_OP_REG);
307
155k
  Mips_get_detail_op(MI, 0)->type = MIPS_OP_REG;
308
155k
  Mips_get_detail_op(MI, 0)->reg = Reg;
309
155k
  Mips_get_detail_op(MI, 0)->is_reglist = is_reglist;
310
155k
  Mips_get_detail_op(MI, 0)->access = map_get_op_access(MI, OpNum);
311
155k
  Mips_inc_op_count(MI);
312
155k
}
313
314
static void Mips_set_detail_op_operand(MCInst *MI, unsigned OpNum)
315
226k
{
316
226k
  cs_op_type op_type = map_get_op_type(MI, OpNum) & ~CS_OP_MEM;
317
226k
  int64_t value = MCInst_getOpVal(MI, OpNum);
318
226k
  if (op_type == CS_OP_IMM) {
319
45.0k
    Mips_set_detail_op_imm(MI, OpNum, value);
320
181k
  } else if (op_type == CS_OP_REG) {
321
179k
    Mips_set_detail_op_reg(MI, OpNum, value, false);
322
179k
  } else
323
1.91k
    printf("Operand type %d not handled!\n", op_type);
324
226k
}
325
326
static void Mips_set_detail_op_jump(MCInst *MI, unsigned OpNum)
327
2.14k
{
328
2.14k
  cs_op_type op_type = map_get_op_type(MI, OpNum) & ~CS_OP_MEM;
329
2.14k
  if (op_type == CS_OP_IMM) {
330
2.14k
    uint64_t Base = MI->address & ~0x0fffffffull;
331
2.14k
    uint64_t Target = Base | (uint64_t)MCInst_getOpVal(MI, OpNum);
332
2.14k
    Mips_set_detail_op_uimm(MI, OpNum, Target);
333
2.14k
  } else if (op_type == CS_OP_REG) {
334
0
    Mips_set_detail_op_reg(MI, OpNum, MCInst_getOpVal(MI, OpNum),
335
0
               false);
336
0
  } else
337
0
    printf("Operand type %d not handled!\n", op_type);
338
2.14k
}
339
340
static void Mips_set_detail_op_branch(MCInst *MI, unsigned OpNum)
341
20.6k
{
342
20.6k
  cs_op_type op_type = map_get_op_type(MI, OpNum) & ~CS_OP_MEM;
343
20.6k
  if (op_type == CS_OP_IMM) {
344
20.0k
    uint64_t Target = MI->address + MCInst_getOpVal(MI, OpNum);
345
20.0k
    Mips_set_detail_op_uimm(MI, OpNum, Target);
346
20.0k
  } else if (op_type == CS_OP_REG) {
347
531
    Mips_set_detail_op_reg(MI, OpNum, MCInst_getOpVal(MI, OpNum),
348
531
               false);
349
531
  } else
350
0
    printf("Operand type %d not handled!\n", op_type);
351
20.6k
}
352
353
static void Mips_set_detail_op_unsigned(MCInst *MI, unsigned OpNum)
354
0
{
355
0
  Mips_set_detail_op_uimm(MI, OpNum, MCInst_getOpVal(MI, OpNum));
356
0
}
357
358
static void Mips_set_detail_op_unsigned_offset(MCInst *MI, unsigned OpNum,
359
                 unsigned Bits, uint64_t Offset)
360
14.3k
{
361
14.3k
  uint64_t Imm = MCInst_getOpVal(MI, OpNum);
362
14.3k
  Imm -= Offset;
363
14.3k
  Imm &= (((uint64_t)1) << Bits) - 1;
364
14.3k
  Imm += Offset;
365
14.3k
  Mips_set_detail_op_uimm(MI, OpNum, Imm);
366
14.3k
}
367
368
static void Mips_set_detail_op_mem_nanomips(MCInst *MI, unsigned OpNum)
369
0
{
370
0
  CS_ASSERT(doing_mem(MI));
371
372
0
  MCOperand *Op = MCInst_getOperand(MI, OpNum);
373
0
  Mips_get_detail_op(MI, 0)->type = MIPS_OP_MEM;
374
  // Base is a register, but nanoMips uses the Imm value as register.
375
0
  Mips_get_detail_op(MI, 0)->mem.base = MCOperand_getImm(Op);
376
0
  Mips_get_detail_op(MI, 0)->access = map_get_op_access(MI, OpNum);
377
0
}
378
379
static void Mips_set_detail_op_reglist(MCInst *MI, unsigned OpNum,
380
               bool isNanoMips)
381
1.23k
{
382
1.23k
  if (isNanoMips) {
383
0
    for (unsigned i = OpNum; i < MCInst_getNumOperands(MI); i++) {
384
0
      Mips_set_detail_op_reg(MI, i, MCInst_getOpVal(MI, i),
385
0
                 true);
386
0
    }
387
0
    return;
388
0
  }
389
  // -2 because register List is always first operand of instruction
390
  // and it is always followed by memory operand (base + offset).
391
5.73k
  for (unsigned i = OpNum, e = MCInst_getNumOperands(MI) - 2; i != e;
392
4.50k
       ++i) {
393
4.50k
    Mips_set_detail_op_reg(MI, i, MCInst_getOpVal(MI, i), true);
394
4.50k
  }
395
1.23k
}
396
397
static void Mips_set_detail_op_unsigned_address(MCInst *MI, unsigned OpNum)
398
0
{
399
0
  uint64_t Target = MI->address + (uint64_t)MCInst_getOpVal(MI, OpNum);
400
0
  Mips_set_detail_op_imm(MI, OpNum, Target);
401
0
}
402
403
void Mips_add_cs_detail(MCInst *MI, mips_op_group op_group, va_list args)
404
264k
{
405
264k
  if (!detail_is_set(MI) || !map_fill_detail_ops(MI))
406
0
    return;
407
408
264k
  unsigned OpNum = va_arg(args, unsigned);
409
410
264k
  switch (op_group) {
411
0
  default:
412
0
    printf("Operand group %d not handled!\n", op_group);
413
0
    return;
414
0
  case Mips_OP_GROUP_MemOperand:
415
    // this is only used by nanoMips.
416
0
    return Mips_set_detail_op_mem_nanomips(MI, OpNum);
417
20.6k
  case Mips_OP_GROUP_BranchOperand:
418
20.6k
    return Mips_set_detail_op_branch(MI, OpNum);
419
2.14k
  case Mips_OP_GROUP_JumpOperand:
420
2.14k
    return Mips_set_detail_op_jump(MI, OpNum);
421
226k
  case Mips_OP_GROUP_Operand:
422
226k
    return Mips_set_detail_op_operand(MI, OpNum);
423
403
  case Mips_OP_GROUP_UImm_1_0:
424
403
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 1, 0);
425
784
  case Mips_OP_GROUP_UImm_2_0:
426
784
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 2, 0);
427
1.67k
  case Mips_OP_GROUP_UImm_3_0:
428
1.67k
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 3, 0);
429
0
  case Mips_OP_GROUP_UImm_32_0:
430
0
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 32, 0);
431
4.06k
  case Mips_OP_GROUP_UImm_16_0:
432
4.06k
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 16, 0);
433
396
  case Mips_OP_GROUP_UImm_8_0:
434
396
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 8, 0);
435
2.63k
  case Mips_OP_GROUP_UImm_5_0:
436
2.63k
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 5, 0);
437
283
  case Mips_OP_GROUP_UImm_6_0:
438
283
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 6, 0);
439
818
  case Mips_OP_GROUP_UImm_4_0:
440
818
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 4, 0);
441
306
  case Mips_OP_GROUP_UImm_7_0:
442
306
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 7, 0);
443
1.92k
  case Mips_OP_GROUP_UImm_10_0:
444
1.92k
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 10, 0);
445
0
  case Mips_OP_GROUP_UImm_6_1:
446
0
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 6, 1);
447
352
  case Mips_OP_GROUP_UImm_5_1:
448
352
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 5, 1);
449
0
  case Mips_OP_GROUP_UImm_5_33:
450
0
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 5, 33);
451
0
  case Mips_OP_GROUP_UImm_5_32:
452
0
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 5, 32);
453
0
  case Mips_OP_GROUP_UImm_6_2:
454
0
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 6, 2);
455
203
  case Mips_OP_GROUP_UImm_2_1:
456
203
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 2, 1);
457
308
  case Mips_OP_GROUP_UImm_0_0:
458
308
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 0, 0);
459
0
  case Mips_OP_GROUP_UImm_26_0:
460
0
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 26, 0);
461
0
  case Mips_OP_GROUP_UImm_12_0:
462
0
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 12, 0);
463
227
  case Mips_OP_GROUP_UImm_20_0:
464
227
    return Mips_set_detail_op_unsigned_offset(MI, OpNum, 20, 0);
465
1.23k
  case Mips_OP_GROUP_RegisterList:
466
1.23k
    return Mips_set_detail_op_reglist(MI, OpNum, false);
467
0
  case Mips_OP_GROUP_NanoMipsRegisterList:
468
0
    return Mips_set_detail_op_reglist(MI, OpNum, true);
469
0
  case Mips_OP_GROUP_PCRel:
470
    /* fall-thru */
471
0
  case Mips_OP_GROUP_Hi20PCRel:
472
0
    return Mips_set_detail_op_unsigned_address(MI, OpNum);
473
0
  case Mips_OP_GROUP_Hi20:
474
0
    return Mips_set_detail_op_unsigned(MI, OpNum);
475
264k
  }
476
264k
}
477
478
void Mips_set_mem_access(MCInst *MI, bool status)
479
60.5k
{
480
60.5k
  if (!detail_is_set(MI))
481
0
    return;
482
60.5k
  set_doing_mem(MI, status);
483
60.5k
  if (status) {
484
30.2k
    if (Mips_get_detail(MI)->op_count > 0 &&
485
30.2k
        Mips_get_detail_op(MI, -1)->type == MIPS_OP_MEM &&
486
30.2k
        Mips_get_detail_op(MI, -1)->mem.disp == 0) {
487
      // Previous memory operand not done yet. Select it.
488
0
      Mips_dec_op_count(MI);
489
0
      return;
490
0
    }
491
492
    // Init a new one.
493
30.2k
    Mips_get_detail_op(MI, 0)->type = MIPS_OP_MEM;
494
30.2k
    Mips_get_detail_op(MI, 0)->mem.base = MIPS_REG_INVALID;
495
30.2k
    Mips_get_detail_op(MI, 0)->mem.disp = 0;
496
497
30.2k
#ifndef CAPSTONE_DIET
498
30.2k
    uint8_t access =
499
30.2k
      map_get_op_access(MI, Mips_get_detail(MI)->op_count);
500
30.2k
    Mips_get_detail_op(MI, 0)->access = access;
501
30.2k
#endif
502
30.2k
  } else {
503
    // done, select the next operand slot
504
30.2k
    Mips_inc_op_count(MI);
505
30.2k
  }
506
60.5k
}
507
508
#endif