Skip to content

Commit

Permalink
Fix pmfhl and pmthl missing the .fmt specifier
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed Jul 15, 2024
1 parent 2c5e2cf commit ef2598d
Show file tree
Hide file tree
Showing 20 changed files with 187 additions and 27 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Implement the `rfe` ("Restore From Exception") instruction.

### Fixed

- Fix `pmfhl` and `pmthl` missing the `.fmt` specifier.

## [1.11.1] - 2024-07-12

### Added
Expand Down
2 changes: 2 additions & 0 deletions cplusplus/include/generated/InstrIdType_enum_class.hpp

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

8 changes: 6 additions & 2 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.

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

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

2 changes: 2 additions & 0 deletions include/generated/InstrIdType_Names_array.h

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

2 changes: 2 additions & 0 deletions include/generated/InstrIdType_enum.h

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

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

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

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

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

8 changes: 6 additions & 2 deletions rabbitizer/InstrId.pyi

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

2 changes: 2 additions & 0 deletions rabbitizer/InstrIdType.pyi

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

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

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

2 changes: 2 additions & 0 deletions rust/src/instr_id_type_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 @@ -286,6 +286,28 @@ void RabbitizerInstructionR5900_processUniqueId_MMI_3(RabbitizerInstruction *sel
}
}

void RabbitizerInstructionR5900_processUniqueId_MMI_PMFHL(RabbitizerInstruction *self) {
uint32_t function = RAB_INSTR_R5900_GET_mmi_function(self);

self->_mandatorybits = RAB_INSTR_R5900_PACK_mmi_function(self->_mandatorybits, function);
self->instrIdType = RAB_INSTR_ID_TYPE_R5900_MMI_PMFHL;

switch (function) {
#include "tables/instr_id/r5900/r5900_mmi_pmfhl.inc"
}
}

void RabbitizerInstructionR5900_processUniqueId_MMI_PMTHL(RabbitizerInstruction *self) {
uint32_t function = RAB_INSTR_R5900_GET_mmi_function(self);

self->_mandatorybits = RAB_INSTR_R5900_PACK_mmi_function(self->_mandatorybits, function);
self->instrIdType = RAB_INSTR_ID_TYPE_R5900_MMI_PMTHL;

switch (function) {
#include "tables/instr_id/r5900/r5900_mmi_pmthl.inc"
}
}

void RabbitizerInstructionR5900_processUniqueId_MMI(RabbitizerInstruction *self) {
uint32_t function = RAB_INSTR_GET_function(self);

Expand All @@ -307,6 +329,13 @@ void RabbitizerInstructionR5900_processUniqueId_MMI(RabbitizerInstruction *self)
case 0x29:
RabbitizerInstructionR5900_processUniqueId_MMI_3(self);
break;

case 0x30:
RabbitizerInstructionR5900_processUniqueId_MMI_PMFHL(self);
break;
case 0x31:
RabbitizerInstructionR5900_processUniqueId_MMI_PMTHL(self);
break;
}

self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId];
Expand Down
2 changes: 2 additions & 0 deletions tables/tables/instr_id/RabbitizerInstrId_r5900.inc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "r5900/r5900_mmi_1.inc"
#include "r5900/r5900_mmi_2.inc"
#include "r5900/r5900_mmi_3.inc"
#include "r5900/r5900_mmi_pmfhl.inc"
#include "r5900/r5900_mmi_pmthl.inc"

#include "r5900/r5900_cop0_tlb.inc"

Expand Down
22 changes: 7 additions & 15 deletions tables/tables/instr_id/r5900/r5900_mmi.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@
011 | MULT1 | MULTU1| DIV1 | DIVU1 | --- | --- | --- | --- |
100 | MADD1 | MADDU1| --- | --- | --- | --- | --- | --- |
101 | *3 | *4 | --- | --- | --- | --- | --- | --- |
110 | PMFHL | PMTHL | --- | --- | PSLLH | --- | PSRLH | PSRAH |
110 | *5 | *6 | --- | --- | PSLLH | --- | PSRLH | PSRAH |
111 | --- | --- | --- | --- | PSLLW | --- | PSRLW | PSRAW |
hi |-------|-------|-------|-------|-------|-------|-------|-------|
*1 = MMI0 list *2 = MMI2 list
*3 = MMI1 list *4 = MMI3 list
*1 = MMI0 list
*2 = MMI2 list
*3 = MMI1 list
*4 = MMI3 list
*5 = PMFHL list
*6 = PMTHL list
*/

RABBITIZER_DEF_INSTR_ID(
Expand Down Expand Up @@ -103,18 +107,6 @@
.readsRt=true
) // Multiply-ADD Unsigned word pipeline 1

// TODO: check this two instruction, it is supposed to have an extra .fmt
RABBITIZER_DEF_INSTR_ID(
r5900, 0x30, pmfhl,
.operands={RAB_OPERAND_cpu_rd},
.modifiesRd=true
) // Parallel Move From Hi/Lo register
RABBITIZER_DEF_INSTR_ID(
r5900, 0x31, pmthl,
.operands={RAB_OPERAND_cpu_rs},
.readsRs=true
) // Parallel Move To Hi/Lo register

RABBITIZER_DEF_INSTR_ID(
r5900, 0x34, psllh,
.operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa},
Expand Down
48 changes: 48 additions & 0 deletions tables/tables/instr_id/r5900/r5900_mmi_pmfhl.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* SPDX-FileCopyrightText: © 2024 Decompollaborate */
/* SPDX-License-Identifier: MIT */

/*
31---------26------------------------------10------6-5----------0
|0 1 1 1 0 0| | fmt |1 1 0 0 0 0|
------6----------------------------------------5----------6------
|-------00------|-------01------|-------10------|-------11------|
000 | PMFHL.LW | PMFHL.UW | PMFHL.SLW | PMFHL.LH |
001 | PMFHL.SH | --- | --- | --- |
010 | --- | --- | --- | --- |
011 | --- | --- | --- | --- |
100 | --- | --- | --- | --- |
101 | --- | --- | --- | --- |
110 | --- | --- | --- | --- |
111 | --- | --- | --- | --- |
hi |---------------|---------------|---------------|---------------|
*/

RABBITIZER_DEF_INSTR_ID_ALTNAME(
r5900, 0x00, pmfhl_lw, pmfhl.lw,
.operands={RAB_OPERAND_cpu_rd},
.modifiesRd=true
) // Parallel Move From Hi/Lo register

RABBITIZER_DEF_INSTR_ID_ALTNAME(
r5900, 0x01, pmfhl_uw, pmfhl.uw,
.operands={RAB_OPERAND_cpu_rd},
.modifiesRd=true
) // Parallel Move From Hi/Lo register

RABBITIZER_DEF_INSTR_ID_ALTNAME(
r5900, 0x02, pmfhl_slw, pmfhl.slw,
.operands={RAB_OPERAND_cpu_rd},
.modifiesRd=true
) // Parallel Move From Hi/Lo register

RABBITIZER_DEF_INSTR_ID_ALTNAME(
r5900, 0x03, pmfhl_lh, pmfhl.lh,
.operands={RAB_OPERAND_cpu_rd},
.modifiesRd=true
) // Parallel Move From Hi/Lo register

RABBITIZER_DEF_INSTR_ID_ALTNAME(
r5900, 0x04, pmfhl_sh, pmfhl.sh,
.operands={RAB_OPERAND_cpu_rd},
.modifiesRd=true
) // Parallel Move From Hi/Lo register
24 changes: 24 additions & 0 deletions tables/tables/instr_id/r5900/r5900_mmi_pmthl.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* SPDX-FileCopyrightText: © 2024 Decompollaborate */
/* SPDX-License-Identifier: MIT */

/*
31---------26------------------------------10------6-5----------0
|0 1 1 1 0 0| | fmt |1 1 0 0 0 1|
------6----------------------------------------5----------6------
|-------00------|-------01------|-------10------|-------11------|
000 | PMTHL.LW | --- | --- | --- |
001 | --- | --- | --- | --- |
010 | --- | --- | --- | --- |
011 | --- | --- | --- | --- |
100 | --- | --- | --- | --- |
101 | --- | --- | --- | --- |
110 | --- | --- | --- | --- |
111 | --- | --- | --- | --- |
hi |---------------|---------------|---------------|---------------|
*/

RABBITIZER_DEF_INSTR_ID_ALTNAME(
r5900, 0x00, pmthl_lw, pmthl.lw,
.operands={RAB_OPERAND_cpu_rs},
.readsRs=true
) // Parallel Move To Hi/Lo register
2 changes: 2 additions & 0 deletions tables/tables/instr_id_types/InstrIdType_r5900.inc
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@
RABBITIZER_DEF_INSTR_ID_TYPE(R5900, MMI_1)
RABBITIZER_DEF_INSTR_ID_TYPE(R5900, MMI_2)
RABBITIZER_DEF_INSTR_ID_TYPE(R5900, MMI_3)
RABBITIZER_DEF_INSTR_ID_TYPE(R5900, MMI_PMFHL)
RABBITIZER_DEF_INSTR_ID_TYPE(R5900, MMI_PMTHL)
24 changes: 24 additions & 0 deletions tests/c/instruction_checks/r5900_disasm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* SPDX-FileCopyrightText: © 2024 Decompollaborate */
/* SPDX-License-Identifier: MIT */

#include "rabbitizer.h"

#include <string.h>
#include <stdlib.h>
#include <assert.h>

#include "expected_disasm_utils.h"

#define TEST_ENTRY_C(word, imm, expected) TEST_ENTRY(RABBITIZER_INSTRCAT_R5900, word, imm, expected,)

// TODO: fill
const TestEntry test_entries[] = {
TEST_ENTRY_C(0x70001030, NULL, "pmfhl.lw $v0"),
TEST_ENTRY_C(0x70001070, NULL, "pmfhl.uw $v0"),
TEST_ENTRY_C(0x700010B0, NULL, "pmfhl.slw $v0"),
TEST_ENTRY_C(0x700010F0, NULL, "pmfhl.lh $v0"),
TEST_ENTRY_C(0x70001130, NULL, "pmfhl.sh $v0"),
TEST_ENTRY_C(0x70000031, NULL, "pmthl.lw $zero"),
};

size_t test_entries_len = ARRAY_COUNT(test_entries);
1 change: 1 addition & 0 deletions tests/run_instruction_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ set -e
./build/tests/c/instruction_checks/r4000allegrex_vfpu_disasm.elf
./build/tests/c/instruction_checks/r5900_trunc_cvt.elf
./build/tests/c/instruction_checks/r5900_vcallms.elf
./build/tests/c/instruction_checks/r5900_disasm.elf

0 comments on commit ef2598d

Please sign in to comment.