mirror of
https://github.com/Decompollaborate/rabbitizer.git
synced 2025-01-29 21:32:45 +00:00
Implement mfc2, mtc2, cfc2 and ctc2
This commit is contained in:
parent
716d21f8ea
commit
eb11d93da9
@ -19,6 +19,7 @@ cpu_ft,
|
||||
cpu_fd,
|
||||
cpu_cop1cs,
|
||||
cpu_cop2t,
|
||||
cpu_cop2cd,
|
||||
cpu_op,
|
||||
cpu_code,
|
||||
cpu_code_lower,
|
||||
|
@ -238,6 +238,10 @@ cpu_cvt_s_w,
|
||||
cpu_cvt_d_w,
|
||||
cpu_cvt_s_l,
|
||||
cpu_cvt_d_l,
|
||||
cpu_mfc2,
|
||||
cpu_mtc2,
|
||||
cpu_cfc2,
|
||||
cpu_ctc2,
|
||||
cpu_USERDEF_00,
|
||||
cpu_USERDEF_01,
|
||||
cpu_USERDEF_02,
|
||||
|
@ -238,6 +238,10 @@ RABBITIZER_INSTR_ID_cpu_cvt_s_w,
|
||||
RABBITIZER_INSTR_ID_cpu_cvt_d_w,
|
||||
RABBITIZER_INSTR_ID_cpu_cvt_s_l,
|
||||
RABBITIZER_INSTR_ID_cpu_cvt_d_l,
|
||||
RABBITIZER_INSTR_ID_cpu_mfc2,
|
||||
RABBITIZER_INSTR_ID_cpu_mtc2,
|
||||
RABBITIZER_INSTR_ID_cpu_cfc2,
|
||||
RABBITIZER_INSTR_ID_cpu_ctc2,
|
||||
RABBITIZER_INSTR_ID_cpu_USERDEF_00,
|
||||
RABBITIZER_INSTR_ID_cpu_USERDEF_01,
|
||||
RABBITIZER_INSTR_ID_cpu_USERDEF_02,
|
||||
|
@ -19,6 +19,7 @@ RAB_OPERAND_cpu_ft,
|
||||
RAB_OPERAND_cpu_fd,
|
||||
RAB_OPERAND_cpu_cop1cs,
|
||||
RAB_OPERAND_cpu_cop2t,
|
||||
RAB_OPERAND_cpu_cop2cd,
|
||||
RAB_OPERAND_cpu_op,
|
||||
RAB_OPERAND_cpu_code,
|
||||
RAB_OPERAND_cpu_code_lower,
|
||||
|
@ -17,6 +17,7 @@ size_t RabbitizerOperandType_process_cpu_ft (const struct RabbitizerInstruction
|
||||
size_t RabbitizerOperandType_process_cpu_fd (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength);
|
||||
size_t RabbitizerOperandType_process_cpu_cop1cs (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength);
|
||||
size_t RabbitizerOperandType_process_cpu_cop2t (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength);
|
||||
size_t RabbitizerOperandType_process_cpu_cop2cd (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength);
|
||||
size_t RabbitizerOperandType_process_cpu_op (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength);
|
||||
size_t RabbitizerOperandType_process_cpu_code (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength);
|
||||
size_t RabbitizerOperandType_process_cpu_code_lower (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength);
|
||||
|
@ -64,6 +64,7 @@ typedef struct RabbitizerInstruction {
|
||||
#define RAB_INSTR_GET_cond(self) (SHIFTR((self)->word, 0, 4))
|
||||
|
||||
#define RAB_INSTR_GET_cop2t(self) (SHIFTR((self)->word, 16, 5))
|
||||
#define RAB_INSTR_GET_cop2cd(self) (SHIFTR((self)->word, 11, 5))
|
||||
|
||||
#define RAB_INSTR_GET_tf(self) (SHIFTR((self)->word, 16, 1))
|
||||
#define RAB_INSTR_GET_nd(self) (SHIFTR((self)->word, 17, 1))
|
||||
@ -102,6 +103,7 @@ typedef struct RabbitizerInstruction {
|
||||
#define RAB_INSTR_PACK_op(word, value) (BITREPACK((word), (value), 16, 5))
|
||||
|
||||
#define RAB_INSTR_PACK_cop2t(word, value) (BITREPACK((word), (value), 16, 5))
|
||||
#define RAB_INSTR_PACK_cop2cd(word, value) (BITREPACK((word), value, 11, 5))
|
||||
|
||||
#define RAB_INSTR_PACK_tf(word, value) (BITREPACK((word), (value), 16, 1))
|
||||
#define RAB_INSTR_PACK_nd(word, value) (BITREPACK((word), (value), 17, 1))
|
||||
|
@ -18,6 +18,7 @@ RABBITIZER_DEF_INSTR_ID(
|
||||
#include "cpu/cpu_cop1_fpu_d.inc"
|
||||
#include "cpu/cpu_cop1_fpu_w.inc"
|
||||
#include "cpu/cpu_cop1_fpu_l.inc"
|
||||
#include "cpu/cpu_cop2.inc"
|
||||
|
||||
RABBITIZER_DEF_INSTR_ID(
|
||||
cpu, , USERDEF_00,
|
||||
|
26
include/instructions/instr_id/cpu/cpu_cop2.inc
Normal file
26
include/instructions/instr_id/cpu/cpu_cop2.inc
Normal file
@ -0,0 +1,26 @@
|
||||
/* SPDX-FileCopyrightText: © 2022 Decompollaborate */
|
||||
/* SPDX-License-Identifier: MIT */
|
||||
|
||||
// OP rt, cop2cd
|
||||
RABBITIZER_DEF_INSTR_ID(
|
||||
cpu, 0x00, mfc2,
|
||||
.operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop2cd},
|
||||
.modifiesRt=true
|
||||
)
|
||||
RABBITIZER_DEF_INSTR_ID(
|
||||
cpu, 0x04, mtc2,
|
||||
.operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop2cd},
|
||||
.readsRt=true
|
||||
)
|
||||
|
||||
// OP rt, cop2cd
|
||||
RABBITIZER_DEF_INSTR_ID(
|
||||
cpu, 0x02, cfc2,
|
||||
.operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop2cd},
|
||||
.modifiesRt=true
|
||||
)
|
||||
RABBITIZER_DEF_INSTR_ID(
|
||||
cpu, 0x06, ctc2,
|
||||
.operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop2cd},
|
||||
.readsRt=true
|
||||
)
|
@ -13,6 +13,7 @@ RAB_DEF_OPERAND(cpu, ft)
|
||||
RAB_DEF_OPERAND(cpu, fd)
|
||||
RAB_DEF_OPERAND(cpu, cop1cs) // Coprocessor 1 control fs
|
||||
RAB_DEF_OPERAND(cpu, cop2t)
|
||||
RAB_DEF_OPERAND(cpu, cop2cd) // Coprocessor 2 control rd
|
||||
RAB_DEF_OPERAND(cpu, op)
|
||||
RAB_DEF_OPERAND(cpu, code)
|
||||
RAB_DEF_OPERAND(cpu, code_lower)
|
||||
|
@ -228,6 +228,10 @@ class InstrId:
|
||||
cpu_cvt_d_s: Enum
|
||||
cpu_cvt_d_w: Enum
|
||||
cpu_cvt_d_l: Enum
|
||||
cpu_mfc2: Enum
|
||||
cpu_mtc2: Enum
|
||||
cpu_cfc2: Enum
|
||||
cpu_ctc2: Enum
|
||||
cpu_cvt_w_s: Enum
|
||||
cpu_cvt_w_d: Enum
|
||||
cpu_cvt_l_s: Enum
|
||||
|
@ -238,6 +238,10 @@ cpu_cvt_s_w,
|
||||
cpu_cvt_d_w,
|
||||
cpu_cvt_s_l,
|
||||
cpu_cvt_d_l,
|
||||
cpu_mfc2,
|
||||
cpu_mtc2,
|
||||
cpu_cfc2,
|
||||
cpu_ctc2,
|
||||
cpu_USERDEF_00,
|
||||
cpu_USERDEF_01,
|
||||
cpu_USERDEF_02,
|
||||
|
@ -19,6 +19,7 @@ cpu_ft,
|
||||
cpu_fd,
|
||||
cpu_cop1cs,
|
||||
cpu_cop2t,
|
||||
cpu_cop2cd,
|
||||
cpu_op,
|
||||
cpu_code,
|
||||
cpu_code_lower,
|
||||
|
@ -238,6 +238,10 @@ const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[] = {
|
||||
[RABBITIZER_INSTR_ID_cpu_cvt_d_w] = { .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .isDouble=true, .modifiesFd=true, .readsFs=true },
|
||||
[RABBITIZER_INSTR_ID_cpu_cvt_s_l] = { .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .modifiesFd=true, .readsFs=true },
|
||||
[RABBITIZER_INSTR_ID_cpu_cvt_d_l] = { .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .isDouble=true, .modifiesFd=true, .readsFs=true },
|
||||
[RABBITIZER_INSTR_ID_cpu_mfc2] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop2cd}, .modifiesRt=true },
|
||||
[RABBITIZER_INSTR_ID_cpu_mtc2] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop2cd}, .readsRt=true },
|
||||
[RABBITIZER_INSTR_ID_cpu_cfc2] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop2cd}, .modifiesRt=true },
|
||||
[RABBITIZER_INSTR_ID_cpu_ctc2] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop2cd}, .readsRt=true },
|
||||
[RABBITIZER_INSTR_ID_cpu_USERDEF_00] = { .operands={0} },
|
||||
[RABBITIZER_INSTR_ID_cpu_USERDEF_01] = { .operands={0} },
|
||||
[RABBITIZER_INSTR_ID_cpu_USERDEF_02] = { .operands={0} },
|
||||
|
@ -238,6 +238,10 @@ const char *RabbitizerInstrId_Names[] = {
|
||||
[RABBITIZER_INSTR_ID_cpu_cvt_d_w] = "cvt.d.w",
|
||||
[RABBITIZER_INSTR_ID_cpu_cvt_s_l] = "cvt.s.l",
|
||||
[RABBITIZER_INSTR_ID_cpu_cvt_d_l] = "cvt.d.l",
|
||||
[RABBITIZER_INSTR_ID_cpu_mfc2] = "mfc2",
|
||||
[RABBITIZER_INSTR_ID_cpu_mtc2] = "mtc2",
|
||||
[RABBITIZER_INSTR_ID_cpu_cfc2] = "cfc2",
|
||||
[RABBITIZER_INSTR_ID_cpu_ctc2] = "ctc2",
|
||||
[RABBITIZER_INSTR_ID_cpu_USERDEF_00] = "USERDEF_00",
|
||||
[RABBITIZER_INSTR_ID_cpu_USERDEF_01] = "USERDEF_01",
|
||||
[RABBITIZER_INSTR_ID_cpu_USERDEF_02] = "USERDEF_02",
|
||||
|
@ -91,6 +91,7 @@ bool RabbitizerInstrDescriptor_hasOperandAlias(const RabbitizerInstrDescriptor *
|
||||
case RAB_OPERAND_cpu_fd:
|
||||
case RAB_OPERAND_cpu_cop1cs:
|
||||
case RAB_OPERAND_cpu_cop2t:
|
||||
case RAB_OPERAND_cpu_cop2cd:
|
||||
case RAB_OPERAND_cpu_op:
|
||||
break;
|
||||
|
||||
|
@ -151,6 +151,10 @@ void RabbitizerInstruction_blankOut(RabbitizerInstruction *self) {
|
||||
self->word = RAB_INSTR_PACK_cop2t(self->word, 0);
|
||||
break;
|
||||
|
||||
case RAB_OPERAND_cpu_cop2cd:
|
||||
self->word = RAB_INSTR_PACK_cop2cd(self->word, 0);
|
||||
break;
|
||||
|
||||
case RAB_OPERAND_cpu_op:
|
||||
self->word = RAB_INSTR_PACK_op(self->word, 0);
|
||||
break;
|
||||
|
@ -201,6 +201,10 @@ uint32_t RabbitizerInstruction_getValidBits(const RabbitizerInstruction *self) {
|
||||
validbits = RAB_INSTR_PACK_cop2t(validbits, ~0);
|
||||
break;
|
||||
|
||||
case RAB_OPERAND_cpu_cop2cd:
|
||||
validbits = RAB_INSTR_PACK_cop2cd(validbits, ~0);
|
||||
break;
|
||||
|
||||
case RAB_OPERAND_cpu_op:
|
||||
validbits = RAB_INSTR_PACK_op(validbits, ~0);
|
||||
break;
|
||||
|
@ -268,8 +268,19 @@ void RabbitizerInstruction_processUniqueId_Coprocessor1(RabbitizerInstruction *s
|
||||
}
|
||||
|
||||
void RabbitizerInstruction_processUniqueId_Coprocessor2(RabbitizerInstruction *self) {
|
||||
uint32_t fmt = RAB_INSTR_GET_fmt(self);
|
||||
|
||||
self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt);
|
||||
|
||||
self->_handwrittenCategory = true;
|
||||
|
||||
switch (fmt) {
|
||||
#include "instructions/instr_id/cpu/cpu_cop2.inc"
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,7 @@ const OperandCallback instrOpercandCallbacks[] = {
|
||||
[RAB_OPERAND_cpu_fd] = RabbitizerOperandType_process_cpu_fd,
|
||||
[RAB_OPERAND_cpu_cop1cs] = RabbitizerOperandType_process_cpu_cop1cs,
|
||||
[RAB_OPERAND_cpu_cop2t] = RabbitizerOperandType_process_cpu_cop2t,
|
||||
[RAB_OPERAND_cpu_cop2cd] = RabbitizerOperandType_process_cpu_cop2cd,
|
||||
[RAB_OPERAND_cpu_op] = RabbitizerOperandType_process_cpu_op,
|
||||
[RAB_OPERAND_cpu_code] = RabbitizerOperandType_process_cpu_code,
|
||||
[RAB_OPERAND_cpu_code_lower] = RabbitizerOperandType_process_cpu_code_lower,
|
||||
|
@ -101,6 +101,15 @@ size_t RabbitizerOperandType_process_cpu_cop2t(const RabbitizerInstruction *self
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
size_t RabbitizerOperandType_process_cpu_cop2cd(const RabbitizerInstruction *self, char *dst,
|
||||
UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
const char *reg = RabbitizerRegister_getNameCop2(RAB_INSTR_GET_cop2cd(self));
|
||||
|
||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
size_t RabbitizerOperandType_process_cpu_sa(const RabbitizerInstruction *self, char *dst,
|
||||
UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user