Bug in var->Def
[pspdecompiler.git] / allegrex.h
blobd236bdf601673df6c577f6623ebd418d66e3e09a
1 /**
2 * Author: Humberto Naves (hsnaves@gmail.com)
3 */
5 #ifndef __ALLEGREX_H
6 #define __ALLEGREX_H
8 #define INSN_READ_GPR_S 0x00000001
9 #define INSN_READ_GPR_T 0x00000002
10 #define INSN_READ_GPR_D 0x00000004
11 #define INSN_READ_FPR_S 0x00000008
12 #define INSN_READ_FPR_T 0x00000010
13 #define INSN_READ_COND_CODE 0x00000020
14 #define INSN_READ_HI 0x00000040
15 #define INSN_READ_LO 0x00000080
16 #define INSN_WRITE_GPR_D 0x00000100
17 #define INSN_WRITE_GPR_T 0x00000200
18 #define INSN_WRITE_FPR_D 0x00000400
19 #define INSN_WRITE_FPR_T 0x00000800
20 #define INSN_WRITE_COND_CODE 0x00001000
21 #define INSN_WRITE_HI 0x00002000
22 #define INSN_WRITE_LO 0x00004000
23 #define INSN_JUMP 0x00008000
24 #define INSN_BRANCH 0x00010000
25 #define INSN_BRANCHLIKELY 0x00020000
26 #define INSN_LINK 0x00040000
27 #define INSN_LOAD 0x00080000
28 #define INSN_STORE 0x00100000
30 #define INSN_ALLEGREX 0x00000000
31 #define INSN_SPECIAL 0x01000000
32 #define INSN_DEBUG 0x02000000
33 #define INSN_COP0 0x03000000
34 #define INSN_FPU 0x04000000
35 #define INSN_VFPU 0x05000000
37 #define INSN_TYPE(flags) ((flags) & 0x0F000000)
39 #define INSN_ALIAS 0x80000000
41 enum allegrex_insn {
42 I_INVALID,
43 I_ADD,
44 I_ADDI,
45 I_ADDIU,
46 I_ADDU,
47 I_AND,
48 I_ANDI,
49 I_BEQ,
50 I_BEQL,
51 I_BGEZ,
52 I_BGEZAL,
53 I_BGEZL,
54 I_BGTZ,
55 I_BGTZL,
56 I_BITREV,
57 I_BLEZ,
58 I_BLEZL,
59 I_BLTZ,
60 I_BLTZL,
61 I_BLTZAL,
62 I_BLTZALL,
63 I_BNE,
64 I_BNEL,
65 I_BREAK,
66 I_CACHE,
67 I_CFC0,
68 I_CLO,
69 I_CLZ,
70 I_CTC0,
71 I_MAX,
72 I_MIN,
73 I_DBREAK,
74 I_DIV,
75 I_DIVU,
76 I_DRET,
77 I_ERET,
78 I_EXT,
79 I_INS,
80 I_J,
81 I_JR,
82 I_JALR,
83 I_JAL,
84 I_LB,
85 I_LBU,
86 I_LH,
87 I_LHU,
88 I_LL,
89 I_LUI,
90 I_LW,
91 I_LWL,
92 I_LWR,
93 I_MADD,
94 I_MADDU,
95 I_MFC0,
96 I_MFDR,
97 I_MFHI,
98 I_MFIC,
99 I_MFLO,
100 I_MOVN,
101 I_MOVZ,
102 I_MSUB,
103 I_MSUBU,
104 I_MTC0,
105 I_MTDR,
106 I_MTIC,
107 I_HALT,
108 I_MTHI,
109 I_MTLO,
110 I_MULT,
111 I_MULTU,
112 I_NOR,
113 I_OR,
114 I_ORI,
115 I_ROTR,
116 I_ROTV,
117 I_SEB,
118 I_SEH,
119 I_SB,
120 I_SC,
121 I_SH,
122 I_SLLV,
123 I_SLL,
124 I_SLT,
125 I_SLTI,
126 I_SLTIU,
127 I_SLTU,
128 I_SRA,
129 I_SRAV,
130 I_SRLV,
131 I_SRL,
132 I_SW,
133 I_SWL,
134 I_SWR,
135 I_SUB,
136 I_SUBU,
137 I_SYNC,
138 I_SYSCALL,
139 I_XOR,
140 I_XORI,
141 I_WSBH,
142 I_WSBW,
143 I_ABS_S,
144 I_ADD_S,
145 I_BC1F,
146 I_BC1FL,
147 I_BC1T,
148 I_BC1TL,
149 I_C_F_S,
150 I_C_UN_S,
151 I_C_EQ_S,
152 I_C_UEQ_S,
153 I_C_OLT_S,
154 I_C_ULT_S,
155 I_C_OLE_S,
156 I_C_ULE_S,
157 I_C_SF_S,
158 I_C_NGLE_S,
159 I_C_SEQ_S,
160 I_C_NGL_S,
161 I_C_LT_S,
162 I_C_NGE_S,
163 I_C_LE_S,
164 I_C_NGT_S,
165 I_CEIL_W_S,
166 I_CFC1,
167 I_CTC1,
168 I_CVT_S_W,
169 I_CVT_W_S,
170 I_DIV_S,
171 I_FLOOR_W_S,
172 I_LWC1,
173 I_MFC1,
174 I_MOV_S,
175 I_MTC1,
176 I_MUL_S,
177 I_NEG_S,
178 I_ROUND_W_S,
179 I_SQRT_S,
180 I_SUB_S,
181 I_SWC1,
182 I_TRUNC_W_S,
183 I_BVF,
184 I_BVFL,
185 I_BVT,
186 I_BVTL,
187 I_LV_Q,
188 I_LV_S,
189 I_LVL_Q,
190 I_LVR_Q,
191 I_MFV,
192 I_MFVC,
193 I_MTV,
194 I_MTVC,
195 I_SV_Q,
196 I_SV_S,
197 I_SVL_Q,
198 I_SVR_Q,
199 I_VABS_P,
200 I_VABS_Q,
201 I_VABS_S,
202 I_VABS_T,
203 I_VADD_P,
204 I_VADD_Q,
205 I_VADD_S,
206 I_VADD_T,
207 I_VASIN_P,
208 I_VASIN_Q,
209 I_VASIN_S,
210 I_VASIN_T,
211 I_VAVG_P,
212 I_VAVG_Q,
213 I_VAVG_T,
214 I_VBFY1_P,
215 I_VBFY1_Q,
216 I_VBFY2_Q,
217 I_VCMOVF_P,
218 I_VCMOVF_Q,
219 I_VCMOVF_S,
220 I_VCMOVF_T,
221 I_VCMOVT_P,
222 I_VCMOVT_Q,
223 I_VCMOVT_S,
224 I_VCMOVT_T,
225 I_VCMP_P,
226 I_VCMP_Q,
227 I_VCMP_S,
228 I_VCMP_T,
229 I_VCOS_P,
230 I_VCOS_Q,
231 I_VCOS_S,
232 I_VCOS_T,
233 I_VCRS_T,
234 I_VCRSP_T,
235 I_VCST_P,
236 I_VCST_Q,
237 I_VCST_S,
238 I_VCST_T,
239 I_VDET_P,
240 I_VDIV_P,
241 I_VDIV_Q,
242 I_VDIV_S,
243 I_VDIV_T,
244 I_VDOT_P,
245 I_VDOT_Q,
246 I_VDOT_T,
247 I_VEXP2_P,
248 I_VEXP2_Q,
249 I_VEXP2_S,
250 I_VEXP2_T,
251 I_VF2H_P,
252 I_VF2H_Q,
253 I_VF2ID_P,
254 I_VF2ID_Q,
255 I_VF2ID_S,
256 I_VF2ID_T,
257 I_VF2IN_P,
258 I_VF2IN_Q,
259 I_VF2IN_S,
260 I_VF2IN_T,
261 I_VF2IU_P,
262 I_VF2IU_Q,
263 I_VF2IU_S,
264 I_VF2IU_T,
265 I_VF2IZ_P,
266 I_VF2IZ_Q,
267 I_VF2IZ_S,
268 I_VF2IZ_T,
269 I_VFAD_P,
270 I_VFAD_Q,
271 I_VFAD_T,
272 I_VFIM_S,
273 I_VFLUSH,
274 I_VH2F_P,
275 I_VH2F_S,
276 I_VHDP_P,
277 I_VHDP_Q,
278 I_VHDP_T,
279 I_VHTFM2_P,
280 I_VHTFM3_T,
281 I_VHTFM4_Q,
282 I_VI2C_Q,
283 I_VI2F_P,
284 I_VI2F_Q,
285 I_VI2F_S,
286 I_VI2F_T,
287 I_VI2S_P,
288 I_VI2S_Q,
289 I_VI2UC_Q,
290 I_VI2US_P,
291 I_VI2US_Q,
292 I_VIDT_P,
293 I_VIDT_Q,
294 I_VIIM_S,
295 I_VLGB_S,
296 I_VLOG2_P,
297 I_VLOG2_Q,
298 I_VLOG2_S,
299 I_VLOG2_T,
300 I_VMAX_P,
301 I_VMAX_Q,
302 I_VMAX_S,
303 I_VMAX_T,
304 I_VMFVC,
305 I_VMIDT_P,
306 I_VMIDT_Q,
307 I_VMIDT_T,
308 I_VMIN_P,
309 I_VMIN_Q,
310 I_VMIN_S,
311 I_VMIN_T,
312 I_VMMOV_P,
313 I_VMMOV_Q,
314 I_VMMOV_T,
315 I_VMMUL_P,
316 I_VMMUL_Q,
317 I_VMMUL_T,
318 I_VMONE_P,
319 I_VMONE_Q,
320 I_VMONE_T,
321 I_VMOV_P,
322 I_VMOV_Q,
323 I_VMOV_S,
324 I_VMOV_T,
325 I_VMSCL_P,
326 I_VMSCL_Q,
327 I_VMSCL_T,
328 I_VMTVC,
329 I_VMUL_P,
330 I_VMUL_Q,
331 I_VMUL_S,
332 I_VMUL_T,
333 I_VMZERO_P,
334 I_VMZERO_Q,
335 I_VMZERO_T,
336 I_VNEG_P,
337 I_VNEG_Q,
338 I_VNEG_S,
339 I_VNEG_T,
340 I_VNOP,
341 I_VNRCP_P,
342 I_VNRCP_Q,
343 I_VNRCP_S,
344 I_VNRCP_T,
345 I_VNSIN_P,
346 I_VNSIN_Q,
347 I_VNSIN_S,
348 I_VNSIN_T,
349 I_VOCP_P,
350 I_VOCP_Q,
351 I_VOCP_S,
352 I_VOCP_T,
353 I_VONE_P,
354 I_VONE_Q,
355 I_VONE_S,
356 I_VONE_T,
357 I_VPFXD,
358 I_VPFXS,
359 I_VPFXT,
360 I_VQMUL_Q,
361 I_VRCP_P,
362 I_VRCP_Q,
363 I_VRCP_S,
364 I_VRCP_T,
365 I_VREXP2_P,
366 I_VREXP2_Q,
367 I_VREXP2_S,
368 I_VREXP2_T,
369 I_VRNDF1_P,
370 I_VRNDF1_Q,
371 I_VRNDF1_S,
372 I_VRNDF1_T,
373 I_VRNDF2_P,
374 I_VRNDF2_Q,
375 I_VRNDF2_S,
376 I_VRNDF2_T,
377 I_VRNDI_P,
378 I_VRNDI_Q,
379 I_VRNDI_S,
380 I_VRNDI_T,
381 I_VRNDS_S,
382 I_VROT_P,
383 I_VROT_Q,
384 I_VROT_T,
385 I_VRSQ_P,
386 I_VRSQ_Q,
387 I_VRSQ_S,
388 I_VRSQ_T,
389 I_VS2I_P,
390 I_VS2I_S,
391 I_VSAT0_P,
392 I_VSAT0_Q,
393 I_VSAT0_S,
394 I_VSAT0_T,
395 I_VSAT1_P,
396 I_VSAT1_Q,
397 I_VSAT1_S,
398 I_VSAT1_T,
399 I_VSBN_S,
400 I_VSBZ_S,
401 I_VSCL_P,
402 I_VSCL_Q,
403 I_VSCL_T,
404 I_VSCMP_P,
405 I_VSCMP_Q,
406 I_VSCMP_S,
407 I_VSCMP_T,
408 I_VSGE_P,
409 I_VSGE_Q,
410 I_VSGE_S,
411 I_VSGE_T,
412 I_VSGN_P,
413 I_VSGN_Q,
414 I_VSGN_S,
415 I_VSGN_T,
416 I_VSIN_P,
417 I_VSIN_Q,
418 I_VSIN_S,
419 I_VSIN_T,
420 I_VSLT_P,
421 I_VSLT_Q,
422 I_VSLT_S,
423 I_VSLT_T,
424 I_VSOCP_P,
425 I_VSOCP_S,
426 I_VSQRT_P,
427 I_VSQRT_Q,
428 I_VSQRT_S,
429 I_VSQRT_T,
430 I_VSRT1_Q,
431 I_VSRT2_Q,
432 I_VSRT3_Q,
433 I_VSRT4_Q,
434 I_VSUB_P,
435 I_VSUB_Q,
436 I_VSUB_S,
437 I_VSUB_T,
438 I_VSYNC,
439 I_VT4444_Q,
440 I_VT5551_Q,
441 I_VT5650_Q,
442 I_VTFM2_P,
443 I_VTFM3_T,
444 I_VTFM4_Q,
445 I_VUS2I_P,
446 I_VUS2I_S,
447 I_VWB_Q,
448 I_VWBN_S,
449 I_VZERO_P,
450 I_VZERO_Q,
451 I_VZERO_S,
452 I_VZERO_T,
453 I_MFVME,
454 I_MTVME
457 struct allegrex_instruction
459 enum allegrex_insn insn;
460 const char *name;
461 unsigned int opcode;
462 unsigned int mask;
463 const char *fmt;
464 unsigned int flags;
467 extern const char *gpr_names[];
469 char *allegrex_disassemble (unsigned int opcode, unsigned int PC, int prtall);
470 const struct allegrex_instruction *allegrex_decode (unsigned int opcode, int allowalias);
472 #endif /* __ALLEGREX_H */