rabbitizer/include/instructions/RabbitizerInstructionR5900.h
Anghelo Carvajal 136fb7a09a
Add R5900 support (#5)
* starting r5900 stuff

* operands of pmaddh

* expose R5900 to python

* fix merge issues

* move to subtables

* mmi0 and mmi3

* the rest of mmi instructions

* normal, special, regimm and cop0

* fpu_s

* cop2 special1

* starting cop2 special2

* the rest of special2

* operands for normal, special, mmi and mmi0

* mmi1 and mmi2

* Fix mmi

* sync.p

* mmi3 and cop1

* add r5900 opcodes to InstrId.pyi

* add invalid bits to unknown instruction comment

* progress on cop2 special1

* kinda finish cop2 special1

* cop2 special2 progress

* Special case for R5900 cvt.w.s -> trunc.w.s

* R5900 c.olt.s and c.ole.s

* Fix a bunch of VU0 instructions

* I'm getting tired of this bullshit

* vlqi, vsqi, vlqd, vsqd

* fix some operands

* fix div1

* lqc2 and sqc2

* sqrt.s and mult

* fix mtsa and bc2

* Remove redundant .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN

* RabbitizerInstrSuffix

* Impleme instr suffix type

* add instr suffix to remaining instructions

* ifdef out xyzw suffix from registers

* format

* fix warnings

* uncomment stuff on InstrId.pyi

* readme
2022-08-27 12:22:48 -04:00

79 lines
4.1 KiB
C

/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
/* SPDX-License-Identifier: MIT */
#ifndef RABBITIZER_INSTRUCTION_R5900_H
#define RABBITIZER_INSTRUCTION_R5900_H
#pragma once
#include "RabbitizerInstruction.h"
#define RAB_INSTR_R5900_GET_mmi_function(self) (SHIFTR((self)->word, 6, 5))
#define RAB_INSTR_R5900_GET_fhi_flo(self) ((SHIFTR((self)->word, 6, 5) << 2) | SHIFTR((self)->word, 0, 2))
#define RAB_INSTR_R5900_GET_vfs(self) (SHIFTR((self)->word, 11, 5))
#define RAB_INSTR_R5900_GET_vft(self) (SHIFTR((self)->word, 16, 5))
#define RAB_INSTR_R5900_GET_vfd(self) (SHIFTR((self)->word, 6, 5))
#define RAB_INSTR_R5900_GET_xyzw_x(self) (SHIFTR((self)->word, 24, 1))
#define RAB_INSTR_R5900_GET_xyzw_y(self) (SHIFTR((self)->word, 23, 1))
#define RAB_INSTR_R5900_GET_xyzw_z(self) (SHIFTR((self)->word, 22, 1))
#define RAB_INSTR_R5900_GET_xyzw_w(self) (SHIFTR((self)->word, 21, 1))
#define RAB_INSTR_R5900_GET_n(self) (SHIFTR((self)->word, 0, 2))
#define RAB_INSTR_R5900_GET_l(self) (SHIFTR((self)->word, 21, 2))
#define RAB_INSTR_R5900_GET_m(self) (SHIFTR((self)->word, 23, 2))
#define RAB_INSTR_R5900_GET_vis(self) (SHIFTR((self)->word, 11, 5))
#define RAB_INSTR_R5900_GET_vit(self) (SHIFTR((self)->word, 16, 5))
#define RAB_INSTR_R5900_GET_vid(self) (SHIFTR((self)->word, 6, 5))
#define RAB_INSTR_R5900_GET_imm5(self) (SHIFTR((self)->word, 6, 5))
#define RAB_INSTR_R5900_PACK_mmi_function(word, value) (BITREPACK((word), (value), 6, 5))
#define RAB_INSTR_R5900_PACK_fhi_flo(word, value) (BITREPACK(BITREPACK((word), (value) >> 2, 6, 5), (value), 0, 2))
#define RAB_INSTR_R5900_PACK_vfs(word, value) (BITREPACK((word), (value), 11, 5))
#define RAB_INSTR_R5900_PACK_vft(word, value) (BITREPACK((word), (value), 16, 5))
#define RAB_INSTR_R5900_PACK_vfd(word, value) (BITREPACK((word), (value), 6, 5))
#define RAB_INSTR_R5900_PACK_xyzw_x(word, value) (BITREPACK((word), (value), 24, 1))
#define RAB_INSTR_R5900_PACK_xyzw_y(word, value) (BITREPACK((word), (value), 23, 1))
#define RAB_INSTR_R5900_PACK_xyzw_z(word, value) (BITREPACK((word), (value), 22, 1))
#define RAB_INSTR_R5900_PACK_xyzw_w(word, value) (BITREPACK((word), (value), 21, 1))
#define RAB_INSTR_R5900_PACK_n(word, value) (BITREPACK((word), (value), 0, 2))
#define RAB_INSTR_R5900_PACK_l(word, value) (BITREPACK((word), (value), 21, 2))
#define RAB_INSTR_R5900_PACK_m(word, value) (BITREPACK((word), (value), 23, 2))
#define RAB_INSTR_R5900_PACK_vis(word, value) (BITREPACK((word), (value), 11, 5))
#define RAB_INSTR_R5900_PACK_vit(word, value) (BITREPACK((word), (value), 16, 5))
#define RAB_INSTR_R5900_PACK_vid(word, value) (BITREPACK((word), (value), 6, 5))
#define RAB_INSTR_R5900_PACK_imm5(word, value) (BITREPACK((word), (value), 6, 5))
NON_NULL(1)
void RabbitizerInstructionR5900_init(RabbitizerInstruction *self, uint32_t word, uint32_t vram);
NON_NULL(1)
void RabbitizerInstructionR5900_destroy(RabbitizerInstruction *self);
NON_NULL(1)
void RabbitizerInstructionR5900_processUniqueId_Normal(RabbitizerInstruction *self);
NON_NULL(1)
void RabbitizerInstructionR5900_processUniqueId_Special(RabbitizerInstruction *self);
NON_NULL(1)
void RabbitizerInstructionR5900_processUniqueId_Regimm(RabbitizerInstruction *self);
NON_NULL(1)
void RabbitizerInstructionR5900_processUniqueId_Coprocessor0(RabbitizerInstruction *self);
NON_NULL(1)
void RabbitizerInstructionR5900_processUniqueId_Coprocessor1(RabbitizerInstruction *self);
NON_NULL(1)
void RabbitizerInstructionR5900_processUniqueId_Coprocessor2(RabbitizerInstruction *self);
NON_NULL(1)
void RabbitizerInstructionR5900_processUniqueId_MMI(RabbitizerInstruction *self);
NON_NULL(1)
void RabbitizerInstructionR5900_processUniqueId(RabbitizerInstruction *self);
#endif