1 /* Capstone Disassembly Engine */
2 /* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2015 */
3 
4 #ifdef CAPSTONE_HAS_MIPS
5 
6 #include <stdio.h>	// debug
7 #include <string.h>
8 
9 #include "../../utils.h"
10 
11 #include "MipsMapping.h"
12 
13 #define GET_INSTRINFO_ENUM
14 #include "MipsGenInstrInfo.inc"
15 
16 #ifndef CAPSTONE_DIET
17 static const name_map reg_name_maps[] = {
18 	{ MIPS_REG_INVALID, NULL },
19 
20 	{ MIPS_REG_PC, "pc"},
21 
22 	//{ MIPS_REG_0, "0"},
23 	{ MIPS_REG_0, "zero"},
24 	{ MIPS_REG_1, "at"},
25 	//{ MIPS_REG_1, "1"},
26 	{ MIPS_REG_2, "v0"},
27 	//{ MIPS_REG_2, "2"},
28 	{ MIPS_REG_3, "v1"},
29 	//{ MIPS_REG_3, "3"},
30 	{ MIPS_REG_4, "a0"},
31 	//{ MIPS_REG_4, "4"},
32 	{ MIPS_REG_5, "a1"},
33 	//{ MIPS_REG_5, "5"},
34 	{ MIPS_REG_6, "a2"},
35 	//{ MIPS_REG_6, "6"},
36 	{ MIPS_REG_7, "a3"},
37 	//{ MIPS_REG_7, "7"},
38 	{ MIPS_REG_8, "t0"},
39 	//{ MIPS_REG_8, "8"},
40 	{ MIPS_REG_9, "t1"},
41 	//{ MIPS_REG_9, "9"},
42 	{ MIPS_REG_10, "t2"},
43 	//{ MIPS_REG_10, "10"},
44 	{ MIPS_REG_11, "t3"},
45 	//{ MIPS_REG_11, "11"},
46 	{ MIPS_REG_12, "t4"},
47 	//{ MIPS_REG_12, "12"},
48 	{ MIPS_REG_13, "t5"},
49 	//{ MIPS_REG_13, "13"},
50 	{ MIPS_REG_14, "t6"},
51 	//{ MIPS_REG_14, "14"},
52 	{ MIPS_REG_15, "t7"},
53 	//{ MIPS_REG_15, "15"},
54 	{ MIPS_REG_16, "s0"},
55 	//{ MIPS_REG_16, "16"},
56 	{ MIPS_REG_17, "s1"},
57 	//{ MIPS_REG_17, "17"},
58 	{ MIPS_REG_18, "s2"},
59 	//{ MIPS_REG_18, "18"},
60 	{ MIPS_REG_19, "s3"},
61 	//{ MIPS_REG_19, "19"},
62 	{ MIPS_REG_20, "s4"},
63 	//{ MIPS_REG_20, "20"},
64 	{ MIPS_REG_21, "s5"},
65 	//{ MIPS_REG_21, "21"},
66 	{ MIPS_REG_22, "s6"},
67 	//{ MIPS_REG_22, "22"},
68 	{ MIPS_REG_23, "s7"},
69 	//{ MIPS_REG_23, "23"},
70 	{ MIPS_REG_24, "t8"},
71 	//{ MIPS_REG_24, "24"},
72 	{ MIPS_REG_25, "t9"},
73 	//{ MIPS_REG_25, "25"},
74 	{ MIPS_REG_26, "k0"},
75 	//{ MIPS_REG_26, "26"},
76 	{ MIPS_REG_27, "k1"},
77 	//{ MIPS_REG_27, "27"},
78 	{ MIPS_REG_28, "gp"},
79 	//{ MIPS_REG_28, "28"},
80 	{ MIPS_REG_29, "sp"},
81 	//{ MIPS_REG_29, "29"},
82 	{ MIPS_REG_30, "fp"},
83 	//{ MIPS_REG_30, "30"},
84 	{ MIPS_REG_31, "ra"},
85 	//{ MIPS_REG_31, "31"},
86 
87 	{ MIPS_REG_DSPCCOND, "dspccond"},
88 	{ MIPS_REG_DSPCARRY, "dspcarry"},
89 	{ MIPS_REG_DSPEFI, "dspefi"},
90 	{ MIPS_REG_DSPOUTFLAG, "dspoutflag"},
91 	{ MIPS_REG_DSPOUTFLAG16_19, "dspoutflag16_19"},
92 	{ MIPS_REG_DSPOUTFLAG20, "dspoutflag20"},
93 	{ MIPS_REG_DSPOUTFLAG21, "dspoutflag21"},
94 	{ MIPS_REG_DSPOUTFLAG22, "dspoutflag22"},
95 	{ MIPS_REG_DSPOUTFLAG23, "dspoutflag23"},
96 	{ MIPS_REG_DSPPOS, "dsppos"},
97 	{ MIPS_REG_DSPSCOUNT, "dspscount"},
98 
99 	{ MIPS_REG_AC0, "ac0"},
100 	{ MIPS_REG_AC1, "ac1"},
101 	{ MIPS_REG_AC2, "ac2"},
102 	{ MIPS_REG_AC3, "ac3"},
103 
104 	{ MIPS_REG_CC0, "cc0"},
105 	{ MIPS_REG_CC1, "cc1"},
106 	{ MIPS_REG_CC2, "cc2"},
107 	{ MIPS_REG_CC3, "cc3"},
108 	{ MIPS_REG_CC4, "cc4"},
109 	{ MIPS_REG_CC5, "cc5"},
110 	{ MIPS_REG_CC6, "cc6"},
111 	{ MIPS_REG_CC7, "cc7"},
112 
113 	{ MIPS_REG_F0, "f0"},
114 	{ MIPS_REG_F1, "f1"},
115 	{ MIPS_REG_F2, "f2"},
116 	{ MIPS_REG_F3, "f3"},
117 	{ MIPS_REG_F4, "f4"},
118 	{ MIPS_REG_F5, "f5"},
119 	{ MIPS_REG_F6, "f6"},
120 	{ MIPS_REG_F7, "f7"},
121 	{ MIPS_REG_F8, "f8"},
122 	{ MIPS_REG_F9, "f9"},
123 	{ MIPS_REG_F10, "f10"},
124 	{ MIPS_REG_F11, "f11"},
125 	{ MIPS_REG_F12, "f12"},
126 	{ MIPS_REG_F13, "f13"},
127 	{ MIPS_REG_F14, "f14"},
128 	{ MIPS_REG_F15, "f15"},
129 	{ MIPS_REG_F16, "f16"},
130 	{ MIPS_REG_F17, "f17"},
131 	{ MIPS_REG_F18, "f18"},
132 	{ MIPS_REG_F19, "f19"},
133 	{ MIPS_REG_F20, "f20"},
134 	{ MIPS_REG_F21, "f21"},
135 	{ MIPS_REG_F22, "f22"},
136 	{ MIPS_REG_F23, "f23"},
137 	{ MIPS_REG_F24, "f24"},
138 	{ MIPS_REG_F25, "f25"},
139 	{ MIPS_REG_F26, "f26"},
140 	{ MIPS_REG_F27, "f27"},
141 	{ MIPS_REG_F28, "f28"},
142 	{ MIPS_REG_F29, "f29"},
143 	{ MIPS_REG_F30, "f30"},
144 	{ MIPS_REG_F31, "f31"},
145 
146 	{ MIPS_REG_FCC0, "fcc0"},
147 	{ MIPS_REG_FCC1, "fcc1"},
148 	{ MIPS_REG_FCC2, "fcc2"},
149 	{ MIPS_REG_FCC3, "fcc3"},
150 	{ MIPS_REG_FCC4, "fcc4"},
151 	{ MIPS_REG_FCC5, "fcc5"},
152 	{ MIPS_REG_FCC6, "fcc6"},
153 	{ MIPS_REG_FCC7, "fcc7"},
154 
155 	{ MIPS_REG_W0, "w0"},
156 	{ MIPS_REG_W1, "w1"},
157 	{ MIPS_REG_W2, "w2"},
158 	{ MIPS_REG_W3, "w3"},
159 	{ MIPS_REG_W4, "w4"},
160 	{ MIPS_REG_W5, "w5"},
161 	{ MIPS_REG_W6, "w6"},
162 	{ MIPS_REG_W7, "w7"},
163 	{ MIPS_REG_W8, "w8"},
164 	{ MIPS_REG_W9, "w9"},
165 	{ MIPS_REG_W10, "w10"},
166 	{ MIPS_REG_W11, "w11"},
167 	{ MIPS_REG_W12, "w12"},
168 	{ MIPS_REG_W13, "w13"},
169 	{ MIPS_REG_W14, "w14"},
170 	{ MIPS_REG_W15, "w15"},
171 	{ MIPS_REG_W16, "w16"},
172 	{ MIPS_REG_W17, "w17"},
173 	{ MIPS_REG_W18, "w18"},
174 	{ MIPS_REG_W19, "w19"},
175 	{ MIPS_REG_W20, "w20"},
176 	{ MIPS_REG_W21, "w21"},
177 	{ MIPS_REG_W22, "w22"},
178 	{ MIPS_REG_W23, "w23"},
179 	{ MIPS_REG_W24, "w24"},
180 	{ MIPS_REG_W25, "w25"},
181 	{ MIPS_REG_W26, "w26"},
182 	{ MIPS_REG_W27, "w27"},
183 	{ MIPS_REG_W28, "w28"},
184 	{ MIPS_REG_W29, "w29"},
185 	{ MIPS_REG_W30, "w30"},
186 	{ MIPS_REG_W31, "w31"},
187 
188 	{ MIPS_REG_HI, "hi"},
189 	{ MIPS_REG_LO, "lo"},
190 
191 	{ MIPS_REG_P0, "p0"},
192 	{ MIPS_REG_P1, "p1"},
193 	{ MIPS_REG_P2, "p2"},
194 
195 	{ MIPS_REG_MPL0, "mpl0"},
196 	{ MIPS_REG_MPL1, "mpl1"},
197 	{ MIPS_REG_MPL2, "mpl2"},
198 };
199 #endif
200 
Mips_reg_name(csh handle,unsigned int reg)201 const char *Mips_reg_name(csh handle, unsigned int reg)
202 {
203 #ifndef CAPSTONE_DIET
204 	if (reg >= ARR_SIZE(reg_name_maps))
205 		return NULL;
206 
207 	return reg_name_maps[reg].name;
208 #else
209 	return NULL;
210 #endif
211 }
212 
213 static insn_map insns[] = {
214 	// dummy item
215 	{
216 		0, 0,
217 #ifndef CAPSTONE_DIET
218 		{ 0 }, { 0 }, { 0 }, 0, 0
219 #endif
220 	},
221 
222 #include "MipsMappingInsn.inc"
223 };
224 
225 // given internal insn id, return public instruction info
Mips_get_insn_id(cs_struct * h,cs_insn * insn,unsigned int id)226 void Mips_get_insn_id(cs_struct *h, cs_insn *insn, unsigned int id)
227 {
228 	unsigned int i;
229 
230 	i = insn_find(insns, ARR_SIZE(insns), id, &h->insn_cache);
231 	if (i != 0) {
232 		insn->id = insns[i].mapid;
233 
234 		if (h->detail) {
235 #ifndef CAPSTONE_DIET
236 			memcpy(insn->detail->regs_read, insns[i].regs_use, sizeof(insns[i].regs_use));
237 			insn->detail->regs_read_count = (uint8_t)count_positive(insns[i].regs_use);
238 
239 			memcpy(insn->detail->regs_write, insns[i].regs_mod, sizeof(insns[i].regs_mod));
240 			insn->detail->regs_write_count = (uint8_t)count_positive(insns[i].regs_mod);
241 
242 			memcpy(insn->detail->groups, insns[i].groups, sizeof(insns[i].groups));
243 			insn->detail->groups_count = (uint8_t)count_positive8(insns[i].groups);
244 
245 			if (insns[i].branch || insns[i].indirect_branch) {
246 				// this insn also belongs to JUMP group. add JUMP group
247 				insn->detail->groups[insn->detail->groups_count] = MIPS_GRP_JUMP;
248 				insn->detail->groups_count++;
249 			}
250 #endif
251 		}
252 	}
253 }
254 
255 static const name_map insn_name_maps[] = {
256 	{ MIPS_INS_INVALID, NULL },
257 
258 	{ MIPS_INS_ABSQ_S, "absq_s" },
259 	{ MIPS_INS_ADD, "add" },
260 	{ MIPS_INS_ADDIUPC, "addiupc" },
261 	{ MIPS_INS_ADDIUR1SP, "addiur1sp" },
262 	{ MIPS_INS_ADDIUR2, "addiur2" },
263 	{ MIPS_INS_ADDIUS5, "addius5" },
264 	{ MIPS_INS_ADDIUSP, "addiusp" },
265 	{ MIPS_INS_ADDQH, "addqh" },
266 	{ MIPS_INS_ADDQH_R, "addqh_r" },
267 	{ MIPS_INS_ADDQ, "addq" },
268 	{ MIPS_INS_ADDQ_S, "addq_s" },
269 	{ MIPS_INS_ADDSC, "addsc" },
270 	{ MIPS_INS_ADDS_A, "adds_a" },
271 	{ MIPS_INS_ADDS_S, "adds_s" },
272 	{ MIPS_INS_ADDS_U, "adds_u" },
273 	{ MIPS_INS_ADDU16, "addu16" },
274 	{ MIPS_INS_ADDUH, "adduh" },
275 	{ MIPS_INS_ADDUH_R, "adduh_r" },
276 	{ MIPS_INS_ADDU, "addu" },
277 	{ MIPS_INS_ADDU_S, "addu_s" },
278 	{ MIPS_INS_ADDVI, "addvi" },
279 	{ MIPS_INS_ADDV, "addv" },
280 	{ MIPS_INS_ADDWC, "addwc" },
281 	{ MIPS_INS_ADD_A, "add_a" },
282 	{ MIPS_INS_ADDI, "addi" },
283 	{ MIPS_INS_ADDIU, "addiu" },
284 	{ MIPS_INS_ALIGN, "align" },
285 	{ MIPS_INS_ALUIPC, "aluipc" },
286 	{ MIPS_INS_AND, "and" },
287 	{ MIPS_INS_AND16, "and16" },
288 	{ MIPS_INS_ANDI16, "andi16" },
289 	{ MIPS_INS_ANDI, "andi" },
290 	{ MIPS_INS_APPEND, "append" },
291 	{ MIPS_INS_ASUB_S, "asub_s" },
292 	{ MIPS_INS_ASUB_U, "asub_u" },
293 	{ MIPS_INS_AUI, "aui" },
294 	{ MIPS_INS_AUIPC, "auipc" },
295 	{ MIPS_INS_AVER_S, "aver_s" },
296 	{ MIPS_INS_AVER_U, "aver_u" },
297 	{ MIPS_INS_AVE_S, "ave_s" },
298 	{ MIPS_INS_AVE_U, "ave_u" },
299 	{ MIPS_INS_B16, "b16" },
300 	{ MIPS_INS_BADDU, "baddu" },
301 	{ MIPS_INS_BAL, "bal" },
302 	{ MIPS_INS_BALC, "balc" },
303 	{ MIPS_INS_BALIGN, "balign" },
304 	{ MIPS_INS_BBIT0, "bbit0" },
305 	{ MIPS_INS_BBIT032, "bbit032" },
306 	{ MIPS_INS_BBIT1, "bbit1" },
307 	{ MIPS_INS_BBIT132, "bbit132" },
308 	{ MIPS_INS_BC, "bc" },
309 	{ MIPS_INS_BC0F, "bc0f" },
310 	{ MIPS_INS_BC0FL, "bc0fl" },
311 	{ MIPS_INS_BC0T, "bc0t" },
312 	{ MIPS_INS_BC0TL, "bc0tl" },
313 	{ MIPS_INS_BC1EQZ, "bc1eqz" },
314 	{ MIPS_INS_BC1F, "bc1f" },
315 	{ MIPS_INS_BC1FL, "bc1fl" },
316 	{ MIPS_INS_BC1NEZ, "bc1nez" },
317 	{ MIPS_INS_BC1T, "bc1t" },
318 	{ MIPS_INS_BC1TL, "bc1tl" },
319 	{ MIPS_INS_BC2EQZ, "bc2eqz" },
320 	{ MIPS_INS_BC2F, "bc2f" },
321 	{ MIPS_INS_BC2FL, "bc2fl" },
322 	{ MIPS_INS_BC2NEZ, "bc2nez" },
323 	{ MIPS_INS_BC2T, "bc2t" },
324 	{ MIPS_INS_BC2TL, "bc2tl" },
325 	{ MIPS_INS_BC3F, "bc3f" },
326 	{ MIPS_INS_BC3FL, "bc3fl" },
327 	{ MIPS_INS_BC3T, "bc3t" },
328 	{ MIPS_INS_BC3TL, "bc3tl" },
329 	{ MIPS_INS_BCLRI, "bclri" },
330 	{ MIPS_INS_BCLR, "bclr" },
331 	{ MIPS_INS_BEQ, "beq" },
332 	{ MIPS_INS_BEQC, "beqc" },
333 	{ MIPS_INS_BEQL, "beql" },
334 	{ MIPS_INS_BEQZ16, "beqz16" },
335 	{ MIPS_INS_BEQZALC, "beqzalc" },
336 	{ MIPS_INS_BEQZC, "beqzc" },
337 	{ MIPS_INS_BGEC, "bgec" },
338 	{ MIPS_INS_BGEUC, "bgeuc" },
339 	{ MIPS_INS_BGEZ, "bgez" },
340 	{ MIPS_INS_BGEZAL, "bgezal" },
341 	{ MIPS_INS_BGEZALC, "bgezalc" },
342 	{ MIPS_INS_BGEZALL, "bgezall" },
343 	{ MIPS_INS_BGEZALS, "bgezals" },
344 	{ MIPS_INS_BGEZC, "bgezc" },
345 	{ MIPS_INS_BGEZL, "bgezl" },
346 	{ MIPS_INS_BGTZ, "bgtz" },
347 	{ MIPS_INS_BGTZALC, "bgtzalc" },
348 	{ MIPS_INS_BGTZC, "bgtzc" },
349 	{ MIPS_INS_BGTZL, "bgtzl" },
350 	{ MIPS_INS_BINSLI, "binsli" },
351 	{ MIPS_INS_BINSL, "binsl" },
352 	{ MIPS_INS_BINSRI, "binsri" },
353 	{ MIPS_INS_BINSR, "binsr" },
354 	{ MIPS_INS_BITREV, "bitrev" },
355 	{ MIPS_INS_BITSWAP, "bitswap" },
356 	{ MIPS_INS_BLEZ, "blez" },
357 	{ MIPS_INS_BLEZALC, "blezalc" },
358 	{ MIPS_INS_BLEZC, "blezc" },
359 	{ MIPS_INS_BLEZL, "blezl" },
360 	{ MIPS_INS_BLTC, "bltc" },
361 	{ MIPS_INS_BLTUC, "bltuc" },
362 	{ MIPS_INS_BLTZ, "bltz" },
363 	{ MIPS_INS_BLTZAL, "bltzal" },
364 	{ MIPS_INS_BLTZALC, "bltzalc" },
365 	{ MIPS_INS_BLTZALL, "bltzall" },
366 	{ MIPS_INS_BLTZALS, "bltzals" },
367 	{ MIPS_INS_BLTZC, "bltzc" },
368 	{ MIPS_INS_BLTZL, "bltzl" },
369 	{ MIPS_INS_BMNZI, "bmnzi" },
370 	{ MIPS_INS_BMNZ, "bmnz" },
371 	{ MIPS_INS_BMZI, "bmzi" },
372 	{ MIPS_INS_BMZ, "bmz" },
373 	{ MIPS_INS_BNE, "bne" },
374 	{ MIPS_INS_BNEC, "bnec" },
375 	{ MIPS_INS_BNEGI, "bnegi" },
376 	{ MIPS_INS_BNEG, "bneg" },
377 	{ MIPS_INS_BNEL, "bnel" },
378 	{ MIPS_INS_BNEZ16, "bnez16" },
379 	{ MIPS_INS_BNEZALC, "bnezalc" },
380 	{ MIPS_INS_BNEZC, "bnezc" },
381 	{ MIPS_INS_BNVC, "bnvc" },
382 	{ MIPS_INS_BNZ, "bnz" },
383 	{ MIPS_INS_BOVC, "bovc" },
384 	{ MIPS_INS_BPOSGE32, "bposge32" },
385 	{ MIPS_INS_BREAK, "break" },
386 	{ MIPS_INS_BREAK16, "break16" },
387 	{ MIPS_INS_BSELI, "bseli" },
388 	{ MIPS_INS_BSEL, "bsel" },
389 	{ MIPS_INS_BSETI, "bseti" },
390 	{ MIPS_INS_BSET, "bset" },
391 	{ MIPS_INS_BZ, "bz" },
392 	{ MIPS_INS_BEQZ, "beqz" },
393 	{ MIPS_INS_B, "b" },
394 	{ MIPS_INS_BNEZ, "bnez" },
395 	{ MIPS_INS_BTEQZ, "bteqz" },
396 	{ MIPS_INS_BTNEZ, "btnez" },
397 	{ MIPS_INS_CACHE, "cache" },
398 	{ MIPS_INS_CEIL, "ceil" },
399 	{ MIPS_INS_CEQI, "ceqi" },
400 	{ MIPS_INS_CEQ, "ceq" },
401 	{ MIPS_INS_CFC1, "cfc1" },
402 	{ MIPS_INS_CFCMSA, "cfcmsa" },
403 	{ MIPS_INS_CINS, "cins" },
404 	{ MIPS_INS_CINS32, "cins32" },
405 	{ MIPS_INS_CLASS, "class" },
406 	{ MIPS_INS_CLEI_S, "clei_s" },
407 	{ MIPS_INS_CLEI_U, "clei_u" },
408 	{ MIPS_INS_CLE_S, "cle_s" },
409 	{ MIPS_INS_CLE_U, "cle_u" },
410 	{ MIPS_INS_CLO, "clo" },
411 	{ MIPS_INS_CLTI_S, "clti_s" },
412 	{ MIPS_INS_CLTI_U, "clti_u" },
413 	{ MIPS_INS_CLT_S, "clt_s" },
414 	{ MIPS_INS_CLT_U, "clt_u" },
415 	{ MIPS_INS_CLZ, "clz" },
416 	{ MIPS_INS_CMPGDU, "cmpgdu" },
417 	{ MIPS_INS_CMPGU, "cmpgu" },
418 	{ MIPS_INS_CMPU, "cmpu" },
419 	{ MIPS_INS_CMP, "cmp" },
420 	{ MIPS_INS_COPY_S, "copy_s" },
421 	{ MIPS_INS_COPY_U, "copy_u" },
422 	{ MIPS_INS_CTC1, "ctc1" },
423 	{ MIPS_INS_CTCMSA, "ctcmsa" },
424 	{ MIPS_INS_CVT, "cvt" },
425 	{ MIPS_INS_C, "c" },
426 	{ MIPS_INS_CMPI, "cmpi" },
427 	{ MIPS_INS_DADD, "dadd" },
428 	{ MIPS_INS_DADDI, "daddi" },
429 	{ MIPS_INS_DADDIU, "daddiu" },
430 	{ MIPS_INS_DADDU, "daddu" },
431 	{ MIPS_INS_DAHI, "dahi" },
432 	{ MIPS_INS_DALIGN, "dalign" },
433 	{ MIPS_INS_DATI, "dati" },
434 	{ MIPS_INS_DAUI, "daui" },
435 	{ MIPS_INS_DBITSWAP, "dbitswap" },
436 	{ MIPS_INS_DCLO, "dclo" },
437 	{ MIPS_INS_DCLZ, "dclz" },
438 	{ MIPS_INS_DDIV, "ddiv" },
439 	{ MIPS_INS_DDIVU, "ddivu" },
440 	{ MIPS_INS_DERET, "deret" },
441 	{ MIPS_INS_DEXT, "dext" },
442 	{ MIPS_INS_DEXTM, "dextm" },
443 	{ MIPS_INS_DEXTU, "dextu" },
444 	{ MIPS_INS_DI, "di" },
445 	{ MIPS_INS_DINS, "dins" },
446 	{ MIPS_INS_DINSM, "dinsm" },
447 	{ MIPS_INS_DINSU, "dinsu" },
448 	{ MIPS_INS_DIV, "div" },
449 	{ MIPS_INS_DIVU, "divu" },
450 	{ MIPS_INS_DIV_S, "div_s" },
451 	{ MIPS_INS_DIV_U, "div_u" },
452 	{ MIPS_INS_DLSA, "dlsa" },
453 	{ MIPS_INS_DMFC0, "dmfc0" },
454 	{ MIPS_INS_DMFC1, "dmfc1" },
455 	{ MIPS_INS_DMFC2, "dmfc2" },
456 	{ MIPS_INS_DMOD, "dmod" },
457 	{ MIPS_INS_DMODU, "dmodu" },
458 	{ MIPS_INS_DMTC0, "dmtc0" },
459 	{ MIPS_INS_DMTC1, "dmtc1" },
460 	{ MIPS_INS_DMTC2, "dmtc2" },
461 	{ MIPS_INS_DMUH, "dmuh" },
462 	{ MIPS_INS_DMUHU, "dmuhu" },
463 	{ MIPS_INS_DMUL, "dmul" },
464 	{ MIPS_INS_DMULT, "dmult" },
465 	{ MIPS_INS_DMULTU, "dmultu" },
466 	{ MIPS_INS_DMULU, "dmulu" },
467 	{ MIPS_INS_DOTP_S, "dotp_s" },
468 	{ MIPS_INS_DOTP_U, "dotp_u" },
469 	{ MIPS_INS_DPADD_S, "dpadd_s" },
470 	{ MIPS_INS_DPADD_U, "dpadd_u" },
471 	{ MIPS_INS_DPAQX_SA, "dpaqx_sa" },
472 	{ MIPS_INS_DPAQX_S, "dpaqx_s" },
473 	{ MIPS_INS_DPAQ_SA, "dpaq_sa" },
474 	{ MIPS_INS_DPAQ_S, "dpaq_s" },
475 	{ MIPS_INS_DPAU, "dpau" },
476 	{ MIPS_INS_DPAX, "dpax" },
477 	{ MIPS_INS_DPA, "dpa" },
478 	{ MIPS_INS_DPOP, "dpop" },
479 	{ MIPS_INS_DPSQX_SA, "dpsqx_sa" },
480 	{ MIPS_INS_DPSQX_S, "dpsqx_s" },
481 	{ MIPS_INS_DPSQ_SA, "dpsq_sa" },
482 	{ MIPS_INS_DPSQ_S, "dpsq_s" },
483 	{ MIPS_INS_DPSUB_S, "dpsub_s" },
484 	{ MIPS_INS_DPSUB_U, "dpsub_u" },
485 	{ MIPS_INS_DPSU, "dpsu" },
486 	{ MIPS_INS_DPSX, "dpsx" },
487 	{ MIPS_INS_DPS, "dps" },
488 	{ MIPS_INS_DROTR, "drotr" },
489 	{ MIPS_INS_DROTR32, "drotr32" },
490 	{ MIPS_INS_DROTRV, "drotrv" },
491 	{ MIPS_INS_DSBH, "dsbh" },
492 	{ MIPS_INS_DSHD, "dshd" },
493 	{ MIPS_INS_DSLL, "dsll" },
494 	{ MIPS_INS_DSLL32, "dsll32" },
495 	{ MIPS_INS_DSLLV, "dsllv" },
496 	{ MIPS_INS_DSRA, "dsra" },
497 	{ MIPS_INS_DSRA32, "dsra32" },
498 	{ MIPS_INS_DSRAV, "dsrav" },
499 	{ MIPS_INS_DSRL, "dsrl" },
500 	{ MIPS_INS_DSRL32, "dsrl32" },
501 	{ MIPS_INS_DSRLV, "dsrlv" },
502 	{ MIPS_INS_DSUB, "dsub" },
503 	{ MIPS_INS_DSUBU, "dsubu" },
504 	{ MIPS_INS_EHB, "ehb" },
505 	{ MIPS_INS_EI, "ei" },
506 	{ MIPS_INS_ERET, "eret" },
507 	{ MIPS_INS_EXT, "ext" },
508 	{ MIPS_INS_EXTP, "extp" },
509 	{ MIPS_INS_EXTPDP, "extpdp" },
510 	{ MIPS_INS_EXTPDPV, "extpdpv" },
511 	{ MIPS_INS_EXTPV, "extpv" },
512 	{ MIPS_INS_EXTRV_RS, "extrv_rs" },
513 	{ MIPS_INS_EXTRV_R, "extrv_r" },
514 	{ MIPS_INS_EXTRV_S, "extrv_s" },
515 	{ MIPS_INS_EXTRV, "extrv" },
516 	{ MIPS_INS_EXTR_RS, "extr_rs" },
517 	{ MIPS_INS_EXTR_R, "extr_r" },
518 	{ MIPS_INS_EXTR_S, "extr_s" },
519 	{ MIPS_INS_EXTR, "extr" },
520 	{ MIPS_INS_EXTS, "exts" },
521 	{ MIPS_INS_EXTS32, "exts32" },
522 	{ MIPS_INS_ABS, "abs" },
523 	{ MIPS_INS_FADD, "fadd" },
524 	{ MIPS_INS_FCAF, "fcaf" },
525 	{ MIPS_INS_FCEQ, "fceq" },
526 	{ MIPS_INS_FCLASS, "fclass" },
527 	{ MIPS_INS_FCLE, "fcle" },
528 	{ MIPS_INS_FCLT, "fclt" },
529 	{ MIPS_INS_FCNE, "fcne" },
530 	{ MIPS_INS_FCOR, "fcor" },
531 	{ MIPS_INS_FCUEQ, "fcueq" },
532 	{ MIPS_INS_FCULE, "fcule" },
533 	{ MIPS_INS_FCULT, "fcult" },
534 	{ MIPS_INS_FCUNE, "fcune" },
535 	{ MIPS_INS_FCUN, "fcun" },
536 	{ MIPS_INS_FDIV, "fdiv" },
537 	{ MIPS_INS_FEXDO, "fexdo" },
538 	{ MIPS_INS_FEXP2, "fexp2" },
539 	{ MIPS_INS_FEXUPL, "fexupl" },
540 	{ MIPS_INS_FEXUPR, "fexupr" },
541 	{ MIPS_INS_FFINT_S, "ffint_s" },
542 	{ MIPS_INS_FFINT_U, "ffint_u" },
543 	{ MIPS_INS_FFQL, "ffql" },
544 	{ MIPS_INS_FFQR, "ffqr" },
545 	{ MIPS_INS_FILL, "fill" },
546 	{ MIPS_INS_FLOG2, "flog2" },
547 	{ MIPS_INS_FLOOR, "floor" },
548 	{ MIPS_INS_FMADD, "fmadd" },
549 	{ MIPS_INS_FMAX_A, "fmax_a" },
550 	{ MIPS_INS_FMAX, "fmax" },
551 	{ MIPS_INS_FMIN_A, "fmin_a" },
552 	{ MIPS_INS_FMIN, "fmin" },
553 	{ MIPS_INS_MOV, "mov" },
554 	{ MIPS_INS_FMSUB, "fmsub" },
555 	{ MIPS_INS_FMUL, "fmul" },
556 	{ MIPS_INS_MUL, "mul" },
557 	{ MIPS_INS_NEG, "neg" },
558 	{ MIPS_INS_FRCP, "frcp" },
559 	{ MIPS_INS_FRINT, "frint" },
560 	{ MIPS_INS_FRSQRT, "frsqrt" },
561 	{ MIPS_INS_FSAF, "fsaf" },
562 	{ MIPS_INS_FSEQ, "fseq" },
563 	{ MIPS_INS_FSLE, "fsle" },
564 	{ MIPS_INS_FSLT, "fslt" },
565 	{ MIPS_INS_FSNE, "fsne" },
566 	{ MIPS_INS_FSOR, "fsor" },
567 	{ MIPS_INS_FSQRT, "fsqrt" },
568 	{ MIPS_INS_SQRT, "sqrt" },
569 	{ MIPS_INS_FSUB, "fsub" },
570 	{ MIPS_INS_SUB, "sub" },
571 	{ MIPS_INS_FSUEQ, "fsueq" },
572 	{ MIPS_INS_FSULE, "fsule" },
573 	{ MIPS_INS_FSULT, "fsult" },
574 	{ MIPS_INS_FSUNE, "fsune" },
575 	{ MIPS_INS_FSUN, "fsun" },
576 	{ MIPS_INS_FTINT_S, "ftint_s" },
577 	{ MIPS_INS_FTINT_U, "ftint_u" },
578 	{ MIPS_INS_FTQ, "ftq" },
579 	{ MIPS_INS_FTRUNC_S, "ftrunc_s" },
580 	{ MIPS_INS_FTRUNC_U, "ftrunc_u" },
581 	{ MIPS_INS_HADD_S, "hadd_s" },
582 	{ MIPS_INS_HADD_U, "hadd_u" },
583 	{ MIPS_INS_HSUB_S, "hsub_s" },
584 	{ MIPS_INS_HSUB_U, "hsub_u" },
585 	{ MIPS_INS_ILVEV, "ilvev" },
586 	{ MIPS_INS_ILVL, "ilvl" },
587 	{ MIPS_INS_ILVOD, "ilvod" },
588 	{ MIPS_INS_ILVR, "ilvr" },
589 	{ MIPS_INS_INS, "ins" },
590 	{ MIPS_INS_INSERT, "insert" },
591 	{ MIPS_INS_INSV, "insv" },
592 	{ MIPS_INS_INSVE, "insve" },
593 	{ MIPS_INS_J, "j" },
594 	{ MIPS_INS_JAL, "jal" },
595 	{ MIPS_INS_JALR, "jalr" },
596 	{ MIPS_INS_JALRS16, "jalrs16" },
597 	{ MIPS_INS_JALRS, "jalrs" },
598 	{ MIPS_INS_JALS, "jals" },
599 	{ MIPS_INS_JALX, "jalx" },
600 	{ MIPS_INS_JIALC, "jialc" },
601 	{ MIPS_INS_JIC, "jic" },
602 	{ MIPS_INS_JR, "jr" },
603 	{ MIPS_INS_JR16, "jr16" },
604 	{ MIPS_INS_JRADDIUSP, "jraddiusp" },
605 	{ MIPS_INS_JRC, "jrc" },
606 	{ MIPS_INS_JALRC, "jalrc" },
607 	{ MIPS_INS_LB, "lb" },
608 	{ MIPS_INS_LBU16, "lbu16" },
609 	{ MIPS_INS_LBUX, "lbux" },
610 	{ MIPS_INS_LBU, "lbu" },
611 	{ MIPS_INS_LD, "ld" },
612 	{ MIPS_INS_LDC1, "ldc1" },
613 	{ MIPS_INS_LDC2, "ldc2" },
614 	{ MIPS_INS_LDC3, "ldc3" },
615 	{ MIPS_INS_LDI, "ldi" },
616 	{ MIPS_INS_LDL, "ldl" },
617 	{ MIPS_INS_LDPC, "ldpc" },
618 	{ MIPS_INS_LDR, "ldr" },
619 	{ MIPS_INS_LDXC1, "ldxc1" },
620 	{ MIPS_INS_LH, "lh" },
621 	{ MIPS_INS_LHU16, "lhu16" },
622 	{ MIPS_INS_LHX, "lhx" },
623 	{ MIPS_INS_LHU, "lhu" },
624 	{ MIPS_INS_LI16, "li16" },
625 	{ MIPS_INS_LL, "ll" },
626 	{ MIPS_INS_LLD, "lld" },
627 	{ MIPS_INS_LSA, "lsa" },
628 	{ MIPS_INS_LUXC1, "luxc1" },
629 	{ MIPS_INS_LUI, "lui" },
630 	{ MIPS_INS_LW, "lw" },
631 	{ MIPS_INS_LW16, "lw16" },
632 	{ MIPS_INS_LWC1, "lwc1" },
633 	{ MIPS_INS_LWC2, "lwc2" },
634 	{ MIPS_INS_LWC3, "lwc3" },
635 	{ MIPS_INS_LWL, "lwl" },
636 	{ MIPS_INS_LWM16, "lwm16" },
637 	{ MIPS_INS_LWM32, "lwm32" },
638 	{ MIPS_INS_LWPC, "lwpc" },
639 	{ MIPS_INS_LWP, "lwp" },
640 	{ MIPS_INS_LWR, "lwr" },
641 	{ MIPS_INS_LWUPC, "lwupc" },
642 	{ MIPS_INS_LWU, "lwu" },
643 	{ MIPS_INS_LWX, "lwx" },
644 	{ MIPS_INS_LWXC1, "lwxc1" },
645 	{ MIPS_INS_LWXS, "lwxs" },
646 	{ MIPS_INS_LI, "li" },
647 	{ MIPS_INS_MADD, "madd" },
648 	{ MIPS_INS_MADDF, "maddf" },
649 	{ MIPS_INS_MADDR_Q, "maddr_q" },
650 	{ MIPS_INS_MADDU, "maddu" },
651 	{ MIPS_INS_MADDV, "maddv" },
652 	{ MIPS_INS_MADD_Q, "madd_q" },
653 	{ MIPS_INS_MAQ_SA, "maq_sa" },
654 	{ MIPS_INS_MAQ_S, "maq_s" },
655 	{ MIPS_INS_MAXA, "maxa" },
656 	{ MIPS_INS_MAXI_S, "maxi_s" },
657 	{ MIPS_INS_MAXI_U, "maxi_u" },
658 	{ MIPS_INS_MAX_A, "max_a" },
659 	{ MIPS_INS_MAX, "max" },
660 	{ MIPS_INS_MAX_S, "max_s" },
661 	{ MIPS_INS_MAX_U, "max_u" },
662 	{ MIPS_INS_MFC0, "mfc0" },
663 	{ MIPS_INS_MFC1, "mfc1" },
664 	{ MIPS_INS_MFC2, "mfc2" },
665 	{ MIPS_INS_MFHC1, "mfhc1" },
666 	{ MIPS_INS_MFHI, "mfhi" },
667 	{ MIPS_INS_MFLO, "mflo" },
668 	{ MIPS_INS_MINA, "mina" },
669 	{ MIPS_INS_MINI_S, "mini_s" },
670 	{ MIPS_INS_MINI_U, "mini_u" },
671 	{ MIPS_INS_MIN_A, "min_a" },
672 	{ MIPS_INS_MIN, "min" },
673 	{ MIPS_INS_MIN_S, "min_s" },
674 	{ MIPS_INS_MIN_U, "min_u" },
675 	{ MIPS_INS_MOD, "mod" },
676 	{ MIPS_INS_MODSUB, "modsub" },
677 	{ MIPS_INS_MODU, "modu" },
678 	{ MIPS_INS_MOD_S, "mod_s" },
679 	{ MIPS_INS_MOD_U, "mod_u" },
680 	{ MIPS_INS_MOVE, "move" },
681 	{ MIPS_INS_MOVEP, "movep" },
682 	{ MIPS_INS_MOVF, "movf" },
683 	{ MIPS_INS_MOVN, "movn" },
684 	{ MIPS_INS_MOVT, "movt" },
685 	{ MIPS_INS_MOVZ, "movz" },
686 	{ MIPS_INS_MSUB, "msub" },
687 	{ MIPS_INS_MSUBF, "msubf" },
688 	{ MIPS_INS_MSUBR_Q, "msubr_q" },
689 	{ MIPS_INS_MSUBU, "msubu" },
690 	{ MIPS_INS_MSUBV, "msubv" },
691 	{ MIPS_INS_MSUB_Q, "msub_q" },
692 	{ MIPS_INS_MTC0, "mtc0" },
693 	{ MIPS_INS_MTC1, "mtc1" },
694 	{ MIPS_INS_MTC2, "mtc2" },
695 	{ MIPS_INS_MTHC1, "mthc1" },
696 	{ MIPS_INS_MTHI, "mthi" },
697 	{ MIPS_INS_MTHLIP, "mthlip" },
698 	{ MIPS_INS_MTLO, "mtlo" },
699 	{ MIPS_INS_MTM0, "mtm0" },
700 	{ MIPS_INS_MTM1, "mtm1" },
701 	{ MIPS_INS_MTM2, "mtm2" },
702 	{ MIPS_INS_MTP0, "mtp0" },
703 	{ MIPS_INS_MTP1, "mtp1" },
704 	{ MIPS_INS_MTP2, "mtp2" },
705 	{ MIPS_INS_MUH, "muh" },
706 	{ MIPS_INS_MUHU, "muhu" },
707 	{ MIPS_INS_MULEQ_S, "muleq_s" },
708 	{ MIPS_INS_MULEU_S, "muleu_s" },
709 	{ MIPS_INS_MULQ_RS, "mulq_rs" },
710 	{ MIPS_INS_MULQ_S, "mulq_s" },
711 	{ MIPS_INS_MULR_Q, "mulr_q" },
712 	{ MIPS_INS_MULSAQ_S, "mulsaq_s" },
713 	{ MIPS_INS_MULSA, "mulsa" },
714 	{ MIPS_INS_MULT, "mult" },
715 	{ MIPS_INS_MULTU, "multu" },
716 	{ MIPS_INS_MULU, "mulu" },
717 	{ MIPS_INS_MULV, "mulv" },
718 	{ MIPS_INS_MUL_Q, "mul_q" },
719 	{ MIPS_INS_MUL_S, "mul_s" },
720 	{ MIPS_INS_NLOC, "nloc" },
721 	{ MIPS_INS_NLZC, "nlzc" },
722 	{ MIPS_INS_NMADD, "nmadd" },
723 	{ MIPS_INS_NMSUB, "nmsub" },
724 	{ MIPS_INS_NOR, "nor" },
725 	{ MIPS_INS_NORI, "nori" },
726 	{ MIPS_INS_NOT16, "not16" },
727 	{ MIPS_INS_NOT, "not" },
728 	{ MIPS_INS_OR, "or" },
729 	{ MIPS_INS_OR16, "or16" },
730 	{ MIPS_INS_ORI, "ori" },
731 	{ MIPS_INS_PACKRL, "packrl" },
732 	{ MIPS_INS_PAUSE, "pause" },
733 	{ MIPS_INS_PCKEV, "pckev" },
734 	{ MIPS_INS_PCKOD, "pckod" },
735 	{ MIPS_INS_PCNT, "pcnt" },
736 	{ MIPS_INS_PICK, "pick" },
737 	{ MIPS_INS_POP, "pop" },
738 	{ MIPS_INS_PRECEQU, "precequ" },
739 	{ MIPS_INS_PRECEQ, "preceq" },
740 	{ MIPS_INS_PRECEU, "preceu" },
741 	{ MIPS_INS_PRECRQU_S, "precrqu_s" },
742 	{ MIPS_INS_PRECRQ, "precrq" },
743 	{ MIPS_INS_PRECRQ_RS, "precrq_rs" },
744 	{ MIPS_INS_PRECR, "precr" },
745 	{ MIPS_INS_PRECR_SRA, "precr_sra" },
746 	{ MIPS_INS_PRECR_SRA_R, "precr_sra_r" },
747 	{ MIPS_INS_PREF, "pref" },
748 	{ MIPS_INS_PREPEND, "prepend" },
749 	{ MIPS_INS_RADDU, "raddu" },
750 	{ MIPS_INS_RDDSP, "rddsp" },
751 	{ MIPS_INS_RDHWR, "rdhwr" },
752 	{ MIPS_INS_REPLV, "replv" },
753 	{ MIPS_INS_REPL, "repl" },
754 	{ MIPS_INS_RINT, "rint" },
755 	{ MIPS_INS_ROTR, "rotr" },
756 	{ MIPS_INS_ROTRV, "rotrv" },
757 	{ MIPS_INS_ROUND, "round" },
758 	{ MIPS_INS_SAT_S, "sat_s" },
759 	{ MIPS_INS_SAT_U, "sat_u" },
760 	{ MIPS_INS_SB, "sb" },
761 	{ MIPS_INS_SB16, "sb16" },
762 	{ MIPS_INS_SC, "sc" },
763 	{ MIPS_INS_SCD, "scd" },
764 	{ MIPS_INS_SD, "sd" },
765 	{ MIPS_INS_SDBBP, "sdbbp" },
766 	{ MIPS_INS_SDBBP16, "sdbbp16" },
767 	{ MIPS_INS_SDC1, "sdc1" },
768 	{ MIPS_INS_SDC2, "sdc2" },
769 	{ MIPS_INS_SDC3, "sdc3" },
770 	{ MIPS_INS_SDL, "sdl" },
771 	{ MIPS_INS_SDR, "sdr" },
772 	{ MIPS_INS_SDXC1, "sdxc1" },
773 	{ MIPS_INS_SEB, "seb" },
774 	{ MIPS_INS_SEH, "seh" },
775 	{ MIPS_INS_SELEQZ, "seleqz" },
776 	{ MIPS_INS_SELNEZ, "selnez" },
777 	{ MIPS_INS_SEL, "sel" },
778 	{ MIPS_INS_SEQ, "seq" },
779 	{ MIPS_INS_SEQI, "seqi" },
780 	{ MIPS_INS_SH, "sh" },
781 	{ MIPS_INS_SH16, "sh16" },
782 	{ MIPS_INS_SHF, "shf" },
783 	{ MIPS_INS_SHILO, "shilo" },
784 	{ MIPS_INS_SHILOV, "shilov" },
785 	{ MIPS_INS_SHLLV, "shllv" },
786 	{ MIPS_INS_SHLLV_S, "shllv_s" },
787 	{ MIPS_INS_SHLL, "shll" },
788 	{ MIPS_INS_SHLL_S, "shll_s" },
789 	{ MIPS_INS_SHRAV, "shrav" },
790 	{ MIPS_INS_SHRAV_R, "shrav_r" },
791 	{ MIPS_INS_SHRA, "shra" },
792 	{ MIPS_INS_SHRA_R, "shra_r" },
793 	{ MIPS_INS_SHRLV, "shrlv" },
794 	{ MIPS_INS_SHRL, "shrl" },
795 	{ MIPS_INS_SLDI, "sldi" },
796 	{ MIPS_INS_SLD, "sld" },
797 	{ MIPS_INS_SLL, "sll" },
798 	{ MIPS_INS_SLL16, "sll16" },
799 	{ MIPS_INS_SLLI, "slli" },
800 	{ MIPS_INS_SLLV, "sllv" },
801 	{ MIPS_INS_SLT, "slt" },
802 	{ MIPS_INS_SLTI, "slti" },
803 	{ MIPS_INS_SLTIU, "sltiu" },
804 	{ MIPS_INS_SLTU, "sltu" },
805 	{ MIPS_INS_SNE, "sne" },
806 	{ MIPS_INS_SNEI, "snei" },
807 	{ MIPS_INS_SPLATI, "splati" },
808 	{ MIPS_INS_SPLAT, "splat" },
809 	{ MIPS_INS_SRA, "sra" },
810 	{ MIPS_INS_SRAI, "srai" },
811 	{ MIPS_INS_SRARI, "srari" },
812 	{ MIPS_INS_SRAR, "srar" },
813 	{ MIPS_INS_SRAV, "srav" },
814 	{ MIPS_INS_SRL, "srl" },
815 	{ MIPS_INS_SRL16, "srl16" },
816 	{ MIPS_INS_SRLI, "srli" },
817 	{ MIPS_INS_SRLRI, "srlri" },
818 	{ MIPS_INS_SRLR, "srlr" },
819 	{ MIPS_INS_SRLV, "srlv" },
820 	{ MIPS_INS_SSNOP, "ssnop" },
821 	{ MIPS_INS_ST, "st" },
822 	{ MIPS_INS_SUBQH, "subqh" },
823 	{ MIPS_INS_SUBQH_R, "subqh_r" },
824 	{ MIPS_INS_SUBQ, "subq" },
825 	{ MIPS_INS_SUBQ_S, "subq_s" },
826 	{ MIPS_INS_SUBSUS_U, "subsus_u" },
827 	{ MIPS_INS_SUBSUU_S, "subsuu_s" },
828 	{ MIPS_INS_SUBS_S, "subs_s" },
829 	{ MIPS_INS_SUBS_U, "subs_u" },
830 	{ MIPS_INS_SUBU16, "subu16" },
831 	{ MIPS_INS_SUBUH, "subuh" },
832 	{ MIPS_INS_SUBUH_R, "subuh_r" },
833 	{ MIPS_INS_SUBU, "subu" },
834 	{ MIPS_INS_SUBU_S, "subu_s" },
835 	{ MIPS_INS_SUBVI, "subvi" },
836 	{ MIPS_INS_SUBV, "subv" },
837 	{ MIPS_INS_SUXC1, "suxc1" },
838 	{ MIPS_INS_SW, "sw" },
839 	{ MIPS_INS_SW16, "sw16" },
840 	{ MIPS_INS_SWC1, "swc1" },
841 	{ MIPS_INS_SWC2, "swc2" },
842 	{ MIPS_INS_SWC3, "swc3" },
843 	{ MIPS_INS_SWL, "swl" },
844 	{ MIPS_INS_SWM16, "swm16" },
845 	{ MIPS_INS_SWM32, "swm32" },
846 	{ MIPS_INS_SWP, "swp" },
847 	{ MIPS_INS_SWR, "swr" },
848 	{ MIPS_INS_SWXC1, "swxc1" },
849 	{ MIPS_INS_SYNC, "sync" },
850 	{ MIPS_INS_SYNCI, "synci" },
851 	{ MIPS_INS_SYSCALL, "syscall" },
852 	{ MIPS_INS_TEQ, "teq" },
853 	{ MIPS_INS_TEQI, "teqi" },
854 	{ MIPS_INS_TGE, "tge" },
855 	{ MIPS_INS_TGEI, "tgei" },
856 	{ MIPS_INS_TGEIU, "tgeiu" },
857 	{ MIPS_INS_TGEU, "tgeu" },
858 	{ MIPS_INS_TLBP, "tlbp" },
859 	{ MIPS_INS_TLBR, "tlbr" },
860 	{ MIPS_INS_TLBWI, "tlbwi" },
861 	{ MIPS_INS_TLBWR, "tlbwr" },
862 	{ MIPS_INS_TLT, "tlt" },
863 	{ MIPS_INS_TLTI, "tlti" },
864 	{ MIPS_INS_TLTIU, "tltiu" },
865 	{ MIPS_INS_TLTU, "tltu" },
866 	{ MIPS_INS_TNE, "tne" },
867 	{ MIPS_INS_TNEI, "tnei" },
868 	{ MIPS_INS_TRUNC, "trunc" },
869 	{ MIPS_INS_V3MULU, "v3mulu" },
870 	{ MIPS_INS_VMM0, "vmm0" },
871 	{ MIPS_INS_VMULU, "vmulu" },
872 	{ MIPS_INS_VSHF, "vshf" },
873 	{ MIPS_INS_WAIT, "wait" },
874 	{ MIPS_INS_WRDSP, "wrdsp" },
875 	{ MIPS_INS_WSBH, "wsbh" },
876 	{ MIPS_INS_XOR, "xor" },
877 	{ MIPS_INS_XOR16, "xor16" },
878 	{ MIPS_INS_XORI, "xori" },
879 
880 	// alias instructions
881 	{ MIPS_INS_NOP, "nop" },
882 	{ MIPS_INS_NEGU, "negu" },
883 
884 	{ MIPS_INS_JALR_HB, "jalr.hb" },
885 	{ MIPS_INS_JR_HB, "jr.hb" },
886 };
887 
Mips_insn_name(csh handle,unsigned int id)888 const char *Mips_insn_name(csh handle, unsigned int id)
889 {
890 #ifndef CAPSTONE_DIET
891 	if (id >= MIPS_INS_ENDING)
892 		return NULL;
893 
894 	return insn_name_maps[id].name;
895 #else
896 	return NULL;
897 #endif
898 }
899 
900 #ifndef CAPSTONE_DIET
901 static const name_map group_name_maps[] = {
902 	// generic groups
903 	{ MIPS_GRP_INVALID, NULL },
904 	{ MIPS_GRP_JUMP, "jump" },
905 	{ MIPS_GRP_CALL, "call" },
906 	{ MIPS_GRP_RET, "ret" },
907 	{ MIPS_GRP_INT, "int" },
908 	{ MIPS_GRP_IRET, "iret" },
909 	{ MIPS_GRP_PRIVILEGE, "privileged" },
910 	{ MIPS_GRP_BRANCH_RELATIVE, "branch_relative" },
911 
912 	// architecture-specific groups
913 	{ MIPS_GRP_BITCOUNT, "bitcount" },
914 	{ MIPS_GRP_DSP, "dsp" },
915 	{ MIPS_GRP_DSPR2, "dspr2" },
916 	{ MIPS_GRP_FPIDX, "fpidx" },
917 	{ MIPS_GRP_MSA, "msa" },
918 	{ MIPS_GRP_MIPS32R2, "mips32r2" },
919 	{ MIPS_GRP_MIPS64, "mips64" },
920 	{ MIPS_GRP_MIPS64R2, "mips64r2" },
921 	{ MIPS_GRP_SEINREG, "seinreg" },
922 	{ MIPS_GRP_STDENC, "stdenc" },
923 	{ MIPS_GRP_SWAP, "swap" },
924 	{ MIPS_GRP_MICROMIPS, "micromips" },
925 	{ MIPS_GRP_MIPS16MODE, "mips16mode" },
926 	{ MIPS_GRP_FP64BIT, "fp64bit" },
927 	{ MIPS_GRP_NONANSFPMATH, "nonansfpmath" },
928 	{ MIPS_GRP_NOTFP64BIT, "notfp64bit" },
929 	{ MIPS_GRP_NOTINMICROMIPS, "notinmicromips" },
930 	{ MIPS_GRP_NOTNACL, "notnacl" },
931 
932 	{ MIPS_GRP_NOTMIPS32R6, "notmips32r6" },
933 	{ MIPS_GRP_NOTMIPS64R6, "notmips64r6" },
934 	{ MIPS_GRP_CNMIPS, "cnmips" },
935 
936 	{ MIPS_GRP_MIPS32, "mips32" },
937 	{ MIPS_GRP_MIPS32R6, "mips32r6" },
938 	{ MIPS_GRP_MIPS64R6, "mips64r6" },
939 
940 	{ MIPS_GRP_MIPS2, "mips2" },
941 	{ MIPS_GRP_MIPS3, "mips3" },
942 	{ MIPS_GRP_MIPS3_32, "mips3_32"},
943 	{ MIPS_GRP_MIPS3_32R2, "mips3_32r2" },
944 
945 	{ MIPS_GRP_MIPS4_32, "mips4_32" },
946 	{ MIPS_GRP_MIPS4_32R2, "mips4_32r2" },
947 	{ MIPS_GRP_MIPS5_32R2, "mips5_32r2" },
948 
949 	{ MIPS_GRP_GP32BIT, "gp32bit" },
950 	{ MIPS_GRP_GP64BIT, "gp64bit" },
951 };
952 #endif
953 
Mips_group_name(csh handle,unsigned int id)954 const char *Mips_group_name(csh handle, unsigned int id)
955 {
956 #ifndef CAPSTONE_DIET
957 	return id2name(group_name_maps, ARR_SIZE(group_name_maps), id);
958 #else
959 	return NULL;
960 #endif
961 }
962 
963 // map instruction name to public instruction ID
Mips_map_insn(const char * name)964 mips_reg Mips_map_insn(const char *name)
965 {
966 	// handle special alias first
967 	unsigned int i;
968 
969 	// NOTE: skip first NULL name in insn_name_maps
970 	i = name2id(&insn_name_maps[1], ARR_SIZE(insn_name_maps) - 1, name);
971 
972 	return (i != -1)? i : MIPS_REG_INVALID;
973 }
974 
975 // map internal raw register to 'public' register
Mips_map_register(unsigned int r)976 mips_reg Mips_map_register(unsigned int r)
977 {
978 	// for some reasons different Mips modes can map different register number to
979 	// the same Mips register. this function handles the issue for exposing Mips
980 	// operands by mapping internal registers to 'public' register.
981 	static const unsigned int map[] = { 0,
982 		MIPS_REG_AT, MIPS_REG_DSPCCOND, MIPS_REG_DSPCARRY, MIPS_REG_DSPEFI, MIPS_REG_DSPOUTFLAG,
983 		MIPS_REG_DSPPOS, MIPS_REG_DSPSCOUNT, MIPS_REG_FP, MIPS_REG_GP, MIPS_REG_2,
984 		MIPS_REG_1, MIPS_REG_0, MIPS_REG_6, MIPS_REG_4, MIPS_REG_5,
985 		MIPS_REG_3, MIPS_REG_7, MIPS_REG_PC, MIPS_REG_RA, MIPS_REG_SP,
986 		MIPS_REG_ZERO, MIPS_REG_A0, MIPS_REG_A1, MIPS_REG_A2, MIPS_REG_A3,
987 		MIPS_REG_AC0, MIPS_REG_AC1, MIPS_REG_AC2, MIPS_REG_AC3, MIPS_REG_AT,
988 		MIPS_REG_CC0, MIPS_REG_CC1, MIPS_REG_CC2, MIPS_REG_CC3, MIPS_REG_CC4,
989 		MIPS_REG_CC5, MIPS_REG_CC6, MIPS_REG_CC7, MIPS_REG_0, MIPS_REG_1,
990 		MIPS_REG_2, MIPS_REG_3, MIPS_REG_4, MIPS_REG_5, MIPS_REG_6,
991 		MIPS_REG_7, MIPS_REG_8, MIPS_REG_9, MIPS_REG_0, MIPS_REG_1,
992 		MIPS_REG_2, MIPS_REG_3, MIPS_REG_4, MIPS_REG_5, MIPS_REG_6,
993 		MIPS_REG_7, MIPS_REG_8, MIPS_REG_9, MIPS_REG_10, MIPS_REG_11,
994 		MIPS_REG_12, MIPS_REG_13, MIPS_REG_14, MIPS_REG_15, MIPS_REG_16,
995 		MIPS_REG_17, MIPS_REG_18, MIPS_REG_19, MIPS_REG_20, MIPS_REG_21,
996 		MIPS_REG_22, MIPS_REG_23, MIPS_REG_24, MIPS_REG_25, MIPS_REG_26,
997 		MIPS_REG_27, MIPS_REG_28, MIPS_REG_29, MIPS_REG_30, MIPS_REG_31,
998 		MIPS_REG_10, MIPS_REG_11, MIPS_REG_12, MIPS_REG_13, MIPS_REG_14,
999 		MIPS_REG_15, MIPS_REG_16, MIPS_REG_17, MIPS_REG_18, MIPS_REG_19,
1000 		MIPS_REG_20, MIPS_REG_21, MIPS_REG_22, MIPS_REG_23, MIPS_REG_24,
1001 		MIPS_REG_25, MIPS_REG_26, MIPS_REG_27, MIPS_REG_28, MIPS_REG_29,
1002 		MIPS_REG_30, MIPS_REG_31, MIPS_REG_F0, MIPS_REG_F2, MIPS_REG_F4,
1003 		MIPS_REG_F6, MIPS_REG_F8, MIPS_REG_F10, MIPS_REG_F12, MIPS_REG_F14,
1004 		MIPS_REG_F16, MIPS_REG_F18, MIPS_REG_F20, MIPS_REG_F22, MIPS_REG_F24,
1005 		MIPS_REG_F26, MIPS_REG_F28, MIPS_REG_F30, MIPS_REG_DSPOUTFLAG20, MIPS_REG_DSPOUTFLAG21,
1006 		MIPS_REG_DSPOUTFLAG22, MIPS_REG_DSPOUTFLAG23, MIPS_REG_F0, MIPS_REG_F1, MIPS_REG_F2,
1007 		MIPS_REG_F3, MIPS_REG_F4, MIPS_REG_F5, MIPS_REG_F6, MIPS_REG_F7,
1008 		MIPS_REG_F8, MIPS_REG_F9, MIPS_REG_F10, MIPS_REG_F11, MIPS_REG_F12,
1009 		MIPS_REG_F13, MIPS_REG_F14, MIPS_REG_F15, MIPS_REG_F16, MIPS_REG_F17,
1010 		MIPS_REG_F18, MIPS_REG_F19, MIPS_REG_F20, MIPS_REG_F21, MIPS_REG_F22,
1011 		MIPS_REG_F23, MIPS_REG_F24, MIPS_REG_F25, MIPS_REG_F26, MIPS_REG_F27,
1012 		MIPS_REG_F28, MIPS_REG_F29, MIPS_REG_F30, MIPS_REG_F31, MIPS_REG_FCC0,
1013 		MIPS_REG_FCC1, MIPS_REG_FCC2, MIPS_REG_FCC3, MIPS_REG_FCC4, MIPS_REG_FCC5,
1014 		MIPS_REG_FCC6, MIPS_REG_FCC7, MIPS_REG_0, MIPS_REG_1, MIPS_REG_2,
1015 		MIPS_REG_3, MIPS_REG_4, MIPS_REG_5, MIPS_REG_6, MIPS_REG_7,
1016 		MIPS_REG_8, MIPS_REG_9, MIPS_REG_10, MIPS_REG_11, MIPS_REG_12,
1017 		MIPS_REG_13, MIPS_REG_14, MIPS_REG_15, MIPS_REG_16, MIPS_REG_17,
1018 		MIPS_REG_18, MIPS_REG_19, MIPS_REG_20, MIPS_REG_21, MIPS_REG_22,
1019 		MIPS_REG_23, MIPS_REG_24, MIPS_REG_25, MIPS_REG_26, MIPS_REG_27,
1020 		MIPS_REG_28, MIPS_REG_29, MIPS_REG_30, MIPS_REG_31, MIPS_REG_FP,
1021 		MIPS_REG_F0, MIPS_REG_F1, MIPS_REG_F2, MIPS_REG_F3, MIPS_REG_F4,
1022 		MIPS_REG_F5, MIPS_REG_F6, MIPS_REG_F7, MIPS_REG_F8, MIPS_REG_F9,
1023 		MIPS_REG_F10, MIPS_REG_F11, MIPS_REG_F12, MIPS_REG_F13, MIPS_REG_F14,
1024 		MIPS_REG_F15, MIPS_REG_F16, MIPS_REG_F17, MIPS_REG_F18, MIPS_REG_F19,
1025 		MIPS_REG_F20, MIPS_REG_F21, MIPS_REG_F22, MIPS_REG_F23, MIPS_REG_F24,
1026 		MIPS_REG_F25, MIPS_REG_F26, MIPS_REG_F27, MIPS_REG_F28, MIPS_REG_F29,
1027 		MIPS_REG_F30, MIPS_REG_F31, MIPS_REG_GP, MIPS_REG_AC0, MIPS_REG_AC1,
1028 		MIPS_REG_AC2, MIPS_REG_AC3, 0, 0, 0,
1029 		0, MIPS_REG_4, MIPS_REG_5, MIPS_REG_6, MIPS_REG_7,
1030 		MIPS_REG_8, MIPS_REG_9, MIPS_REG_10, MIPS_REG_11, MIPS_REG_12,
1031 		MIPS_REG_13, MIPS_REG_14, MIPS_REG_15, MIPS_REG_16, MIPS_REG_17,
1032 		MIPS_REG_18, MIPS_REG_19, MIPS_REG_20, MIPS_REG_21, MIPS_REG_22,
1033 		MIPS_REG_23, MIPS_REG_24, MIPS_REG_25, MIPS_REG_26, MIPS_REG_27,
1034 		MIPS_REG_28, MIPS_REG_29, MIPS_REG_30, MIPS_REG_31, MIPS_REG_K0,
1035 		MIPS_REG_K1, MIPS_REG_AC0, MIPS_REG_AC1, MIPS_REG_AC2, MIPS_REG_AC3,
1036 		MIPS_REG_MPL0, MIPS_REG_MPL1, MIPS_REG_MPL2, MIPS_REG_P0, MIPS_REG_P1,
1037 		MIPS_REG_P2, MIPS_REG_RA, MIPS_REG_S0, MIPS_REG_S1, MIPS_REG_S2,
1038 		MIPS_REG_S3, MIPS_REG_S4, MIPS_REG_S5, MIPS_REG_S6, MIPS_REG_S7,
1039 		MIPS_REG_SP, MIPS_REG_T0, MIPS_REG_T1, MIPS_REG_T2, MIPS_REG_T3,
1040 		MIPS_REG_T4, MIPS_REG_T5, MIPS_REG_T6, MIPS_REG_T7, MIPS_REG_T8,
1041 		MIPS_REG_T9, MIPS_REG_V0, MIPS_REG_V1, MIPS_REG_W0, MIPS_REG_W1,
1042 		MIPS_REG_W2, MIPS_REG_W3, MIPS_REG_W4, MIPS_REG_W5, MIPS_REG_W6,
1043 		MIPS_REG_W7, MIPS_REG_W8, MIPS_REG_W9, MIPS_REG_W10, MIPS_REG_W11,
1044 		MIPS_REG_W12, MIPS_REG_W13, MIPS_REG_W14, MIPS_REG_W15, MIPS_REG_W16,
1045 		MIPS_REG_W17, MIPS_REG_W18, MIPS_REG_W19, MIPS_REG_W20, MIPS_REG_W21,
1046 		MIPS_REG_W22, MIPS_REG_W23, MIPS_REG_W24, MIPS_REG_W25, MIPS_REG_W26,
1047 		MIPS_REG_W27, MIPS_REG_W28, MIPS_REG_W29, MIPS_REG_W30, MIPS_REG_W31,
1048 		MIPS_REG_ZERO, MIPS_REG_A0, MIPS_REG_A1, MIPS_REG_A2, MIPS_REG_A3,
1049 		MIPS_REG_AC0, MIPS_REG_F0, MIPS_REG_F1, MIPS_REG_F2, MIPS_REG_F3,
1050 		MIPS_REG_F4, MIPS_REG_F5, MIPS_REG_F6, MIPS_REG_F7, MIPS_REG_F8,
1051 		MIPS_REG_F9, MIPS_REG_F10, MIPS_REG_F11, MIPS_REG_F12, MIPS_REG_F13,
1052 		MIPS_REG_F14, MIPS_REG_F15, MIPS_REG_F16, MIPS_REG_F17, MIPS_REG_F18,
1053 		MIPS_REG_F19, MIPS_REG_F20, MIPS_REG_F21, MIPS_REG_F22, MIPS_REG_F23,
1054 		MIPS_REG_F24, MIPS_REG_F25, MIPS_REG_F26, MIPS_REG_F27, MIPS_REG_F28,
1055 		MIPS_REG_F29, MIPS_REG_F30, MIPS_REG_F31, MIPS_REG_DSPOUTFLAG16_19, MIPS_REG_HI,
1056 		MIPS_REG_K0, MIPS_REG_K1, MIPS_REG_LO, MIPS_REG_S0, MIPS_REG_S1,
1057 		MIPS_REG_S2, MIPS_REG_S3, MIPS_REG_S4, MIPS_REG_S5, MIPS_REG_S6,
1058 		MIPS_REG_S7, MIPS_REG_T0, MIPS_REG_T1, MIPS_REG_T2, MIPS_REG_T3,
1059 		MIPS_REG_T4, MIPS_REG_T5, MIPS_REG_T6, MIPS_REG_T7, MIPS_REG_T8,
1060 		MIPS_REG_T9, MIPS_REG_V0, MIPS_REG_V1
1061 	};
1062 
1063 	if (r < ARR_SIZE(map))
1064 		return map[r];
1065 
1066 	// cannot find this register
1067 	return 0;
1068 }
1069 
1070 #endif
1071