Skip to content

Commit

Permalink
Implement a bunch of vfpu0 instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed Apr 14, 2024
1 parent 6112604 commit cb35200
Show file tree
Hide file tree
Showing 14 changed files with 396 additions and 13 deletions.
31 changes: 31 additions & 0 deletions adsf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3

def vt(x: int) -> int:
assert x in range(1<<7)
return x << 16

def vs(x: int) -> int:
assert x in range(1<<7)
return x << 8

def vd(x: int) -> int:
assert x in range(1<<7)
return x << 0

VFPU0 = 0b011000 << 26

def vfpu0_fmt_tp(x: int) -> int:
assert x in range(1<<5)
fmt = (x & 0b11100) >> 2
t = (x & 0b00010) >> 1
p = (x & 0b00001) >> 0
return (fmt << 23) | (t << 15) | (p << 7)

VT = vt(0)
VS = vs(1 << 4)
VD = vd(1 << 6)

print(" # VFPU0")

for i in range(1<<5):
print(f" .word 0x{VFPU0:08X} | 0x{vfpu0_fmt_tp(i):08X} | 0x{VT:08X} | 0x{VS:08X} | 0x{VD:08X}")
34 changes: 33 additions & 1 deletion asdf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7704,5 +7704,37 @@ tests/c/instruction_checks/r4000allegrex_vfpu_disasm.c: Error on word '0xD001FFF
InstrIdType: 'R4000ALLEGREX_VFPU4'
gnuMode 'true'

tests/c/instruction_checks/r4000allegrex_vfpu_disasm.c: 1925 errors out of 2162 entries
tests/c/instruction_checks/r4000allegrex_vfpu_disasm.c: Error on word '0x600010C0'. Expected 'vadd.p C002, C400, C000', got '.word 0x600010C0 # INVALID $zero, $zero, 0x10C0 # 00000000 <InstrIdType: R4000ALLEGREX_VFPU0>'
InstrIdType: 'R4000ALLEGREX_VFPU0'
gnuMode 'true'

tests/c/instruction_checks/r4000allegrex_vfpu_disasm.c: Error on word '0x60009040'. Expected 'vadd.t C001, C400, C000', got '.word 0x60009040 # INVALID $zero, $zero, -0x6FC0 # 00000000 <InstrIdType: R4000ALLEGREX_VFPU0>'
InstrIdType: 'R4000ALLEGREX_VFPU0'
gnuMode 'true'

tests/c/instruction_checks/r4000allegrex_vfpu_disasm.c: Error on word '0x608010C0'. Expected 'vsub.p C002, C400, C000', got '.word 0x608010C0 # INVALID $a0, $zero, 0x10C0 # 00000000 <InstrIdType: R4000ALLEGREX_VFPU0>'
InstrIdType: 'R4000ALLEGREX_VFPU0'
gnuMode 'true'

tests/c/instruction_checks/r4000allegrex_vfpu_disasm.c: Error on word '0x60809040'. Expected 'vsub.t C001, C400, C000', got '.word 0x60809040 # INVALID $a0, $zero, -0x6FC0 # 00000000 <InstrIdType: R4000ALLEGREX_VFPU0>'
InstrIdType: 'R4000ALLEGREX_VFPU0'
gnuMode 'true'

tests/c/instruction_checks/r4000allegrex_vfpu_disasm.c: Error on word '0x63801040'. Expected 'vdiv.s S002, S400, S000', got '.word 0x63801040 # INVALID $gp, $zero, 0x1040 # 00000000 <InstrIdType: R4000ALLEGREX_VFPU0>'
InstrIdType: 'R4000ALLEGREX_VFPU0'
gnuMode 'true'

tests/c/instruction_checks/r4000allegrex_vfpu_disasm.c: Error on word '0x638010C0'. Expected 'vdiv.p C002, C400, C000', got '.word 0x638010C0 # INVALID $gp, $zero, 0x10C0 # 00000000 <InstrIdType: R4000ALLEGREX_VFPU0>'
InstrIdType: 'R4000ALLEGREX_VFPU0'
gnuMode 'true'

tests/c/instruction_checks/r4000allegrex_vfpu_disasm.c: Error on word '0x63809040'. Expected 'vdiv.t C001, C400, C000', got '.word 0x63809040 # INVALID $gp, $zero, -0x6FC0 # 00000000 <InstrIdType: R4000ALLEGREX_VFPU0>'
InstrIdType: 'R4000ALLEGREX_VFPU0'
gnuMode 'true'

tests/c/instruction_checks/r4000allegrex_vfpu_disasm.c: Error on word '0x638090C0'. Expected 'vdiv.q C002, C400, C000', got '.word 0x638090C0 # INVALID $gp, $zero, -0x6F40 # 00000000 <InstrIdType: R4000ALLEGREX_VFPU0>'
InstrIdType: 'R4000ALLEGREX_VFPU0'
gnuMode 'true'

tests/c/instruction_checks/r4000allegrex_vfpu_disasm.c: 1933 errors out of 2194 entries

6 changes: 6 additions & 0 deletions cplusplus/include/generated/UniqueId_enum_class.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions include/generated/InstrDescriptor_Descriptors_array.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions include/generated/InstrId_Names_array.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions include/generated/InstrId_enum.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions include/instructions/RabbitizerInstructionR4000Allegrex.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ extern "C" {
#define RAB_INSTR_R4000ALLEGREX_GET_offset14(self) (SHIFTR((self)->word, 2, 14))
#define RAB_INSTR_R4000ALLEGREX_GET_wb(self) (SHIFTR((self)->word, 1, 1))

#define RAB_INSTR_R4000ALLEGREX_GET_vfpu0_fmt_tp(self) ((SHIFTR((self)->word, 23, 3) << 2) | (SHIFTR((self)->word, 15, 1) << 1) | (SHIFTR((self)->word, 7, 1)))


#define RAB_INSTR_R4000ALLEGREX_PACK_vt(word, value) (BITREPACK((word), (value), 16, 7))
#define RAB_INSTR_R4000ALLEGREX_PACK_vs(word, value) (BITREPACK((word), (value), 8, 7))
Expand All @@ -51,6 +53,8 @@ extern "C" {
#define RAB_INSTR_R4000ALLEGREX_PACK_offset14(word, value) (BITREPACK((word), (value), 2, 14))
#define RAB_INSTR_R4000ALLEGREX_PACK_wb(word, value) (BITREPACK((word), (value), 1, 1))

#define RAB_INSTR_R4000ALLEGREX_PACK_vfpu0_fmt_tp(word, value) (BITREPACK(BITREPACK(BITREPACK((word), (value) >> 2, 23, 3), (value) >> 1, 15, 1), (value), 7, 1))


NON_NULL(1)
void RabbitizerInstructionR4000Allegrex_init(RabbitizerInstruction *self, uint32_t word, uint32_t vram);
Expand Down
6 changes: 6 additions & 0 deletions rabbitizer/InstrId.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions rust/src/instr_id_enum.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -406,24 +406,25 @@ void RabbitizerInstructionR4000Allegrex_processUniqueId_Coprocessor2_BC2(Rabbiti
}

void RabbitizerInstructionR4000Allegrex_processUniqueId_Vfpu0(RabbitizerInstruction *self) {
//! TODO
// uint32_t fmt = RAB_INSTR_GET_fmt(self);
uint32_t fmt = RAB_INSTR_R4000ALLEGREX_GET_vfpu0_fmt_tp(self);
bool fetchDescriptor = true;

// self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt);
self->_mandatorybits = RAB_INSTR_R4000ALLEGREX_PACK_vfpu0_fmt_tp(self->_mandatorybits, fmt);
self->instrIdType = RAB_INSTR_ID_TYPE_R4000ALLEGREX_VFPU0;

#if 0
switch (fmt) {
#include "tables/instr_id/r4000allegrex/r4000allegrex_vfpu0.inc"
}

self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
#endif
if (fetchDescriptor) {
self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
}
}

void RabbitizerInstructionR4000Allegrex_processUniqueId_Vfpu1(RabbitizerInstruction *self) {
//! TODO
// uint32_t fmt = RAB_INSTR_GET_fmt(self);
// bool fetchDescriptor = true;

// self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt);
self->instrIdType = RAB_INSTR_ID_TYPE_R4000ALLEGREX_VFPU1;
Expand All @@ -433,13 +434,16 @@ void RabbitizerInstructionR4000Allegrex_processUniqueId_Vfpu1(RabbitizerInstruct
#include "tables/instr_id/r4000allegrex/r4000allegrex_vfpu1.inc"
}

self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
if (fetchDescriptor) {
self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
}
#endif
}

void RabbitizerInstructionR4000Allegrex_processUniqueId_Vfpu3(RabbitizerInstruction *self) {
//! TODO
// uint32_t fmt = RAB_INSTR_GET_fmt(self);
// bool fetchDescriptor = true;

// self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt);
self->instrIdType = RAB_INSTR_ID_TYPE_R4000ALLEGREX_VFPU3;
Expand All @@ -449,13 +453,16 @@ void RabbitizerInstructionR4000Allegrex_processUniqueId_Vfpu3(RabbitizerInstruct
#include "tables/instr_id/r4000allegrex/r4000allegrex_vfpu3.inc"
}

self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
if (fetchDescriptor) {
self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
}
#endif
}

void RabbitizerInstructionR4000Allegrex_processUniqueId_Vfpu4(RabbitizerInstruction *self) {
//! TODO
// uint32_t fmt = RAB_INSTR_GET_fmt(self);
// bool fetchDescriptor = true;

// self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt);
self->instrIdType = RAB_INSTR_ID_TYPE_R4000ALLEGREX_VFPU4;
Expand All @@ -465,13 +472,16 @@ void RabbitizerInstructionR4000Allegrex_processUniqueId_Vfpu4(RabbitizerInstruct
#include "tables/instr_id/r4000allegrex/r4000allegrex_vfpu4.inc"
}

self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
if (fetchDescriptor) {
self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
}
#endif
}

void RabbitizerInstructionR4000Allegrex_processUniqueId_Vfpu5(RabbitizerInstruction *self) {
//! TODO
// uint32_t fmt = RAB_INSTR_GET_fmt(self);
// bool fetchDescriptor = true;

// self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt);
self->instrIdType = RAB_INSTR_ID_TYPE_R4000ALLEGREX_VFPU5;
Expand All @@ -481,13 +491,16 @@ void RabbitizerInstructionR4000Allegrex_processUniqueId_Vfpu5(RabbitizerInstruct
#include "tables/instr_id/r4000allegrex/r4000allegrex_vfpu5.inc"
}

self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
if (fetchDescriptor) {
self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
}
#endif
}

void RabbitizerInstructionR4000Allegrex_processUniqueId_Vfpu6(RabbitizerInstruction *self) {
//! TODO
// uint32_t fmt = RAB_INSTR_GET_fmt(self);
// bool fetchDescriptor = true;

// self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt);
self->instrIdType = RAB_INSTR_ID_TYPE_R4000ALLEGREX_VFPU6;
Expand All @@ -497,13 +510,16 @@ void RabbitizerInstructionR4000Allegrex_processUniqueId_Vfpu6(RabbitizerInstruct
#include "tables/instr_id/r4000allegrex/r4000allegrex_vfpu6.inc"
}

self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
if (fetchDescriptor) {
self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
}
#endif
}

void RabbitizerInstructionR4000Allegrex_processUniqueId_Vfpu7(RabbitizerInstruction *self) {
//! TODO
// uint32_t fmt = RAB_INSTR_GET_fmt(self);
// bool fetchDescriptor = true;

// self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt);
self->instrIdType = RAB_INSTR_ID_TYPE_R4000ALLEGREX_VFPU7;
Expand All @@ -513,7 +529,9 @@ void RabbitizerInstructionR4000Allegrex_processUniqueId_Vfpu7(RabbitizerInstruct
#include "tables/instr_id/r4000allegrex/r4000allegrex_vfpu7.inc"
}

self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
if (fetchDescriptor) {
self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
}
#endif
}

Expand Down
Loading

0 comments on commit cb35200

Please sign in to comment.