From 2c5e2cfc26b280e5ae9c0aee17abb593f19c8ffb Mon Sep 17 00:00:00 2001 From: Angie Date: Sat, 13 Jul 2024 17:30:13 -0400 Subject: [PATCH 1/5] Implement `rfe` --- CHANGELOG.md | 4 ++++ README.md | 1 + cplusplus/include/generated/UniqueId_enum_class.hpp | 1 + include/generated/InstrDescriptor_Descriptors_array.h | 1 + include/generated/InstrId_Names_array.h | 1 + include/generated/InstrId_enum.h | 1 + rabbitizer/InstrId.pyi | 1 + rust/src/instr_id_enum.rs | 1 + tables/tables/instr_id/cpu/cpu_cop0_tlb.inc | 9 ++++++++- tests/c/instruction_checks/plain_disassembly.c | 2 ++ 10 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2aa63351..eaa969e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Implement the `rfe` ("Restore From Exception") instruction. + ## [1.11.1] - 2024-07-12 ### Added diff --git a/README.md b/README.md index 71fcb424..eef5ddec 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ See this crate at . - MIPS IV Instruction Set (Revision 3.2): - MIPS Calling Convention Summary: - mipt-mips pseudo instructions: + - IDT R30xx Family Software Reference Manual, page 325 (for `rfe`): - N64's RSP (Reality Signal Processor): - Nintendo Ultra64 RSP Programmer’s Guide: diff --git a/cplusplus/include/generated/UniqueId_enum_class.hpp b/cplusplus/include/generated/UniqueId_enum_class.hpp index 8c2acd6f..5b15ddb0 100644 --- a/cplusplus/include/generated/UniqueId_enum_class.hpp +++ b/cplusplus/include/generated/UniqueId_enum_class.hpp @@ -154,6 +154,7 @@ enum class UniqueId { cpu_tlbwi, cpu_tlbwr, cpu_tlbp, + cpu_rfe, cpu_eret, cpu_mfc1, cpu_dmfc1, diff --git a/include/generated/InstrDescriptor_Descriptors_array.h b/include/generated/InstrDescriptor_Descriptors_array.h index 13ffc1c3..ce9fa5d8 100644 --- a/include/generated/InstrDescriptor_Descriptors_array.h +++ b/include/generated/InstrDescriptor_Descriptors_array.h @@ -154,6 +154,7 @@ const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[] = { [RABBITIZER_INSTR_ID_cpu_tlbwi] = { .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmittedByCompilers=true }, [RABBITIZER_INSTR_ID_cpu_tlbwr] = { .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN }, [RABBITIZER_INSTR_ID_cpu_tlbp] = { .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmittedByCompilers=true }, + [RABBITIZER_INSTR_ID_cpu_rfe] = { .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmittedByCompilers=true }, [RABBITIZER_INSTR_ID_cpu_eret] = { .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmittedByCompilers=true }, [RABBITIZER_INSTR_ID_cpu_mfc1] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .modifiesRt=true, .readsFs=true }, [RABBITIZER_INSTR_ID_cpu_dmfc1] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .modifiesRt=true, .readsFs=true }, diff --git a/include/generated/InstrId_Names_array.h b/include/generated/InstrId_Names_array.h index 40d39179..97f0dddc 100644 --- a/include/generated/InstrId_Names_array.h +++ b/include/generated/InstrId_Names_array.h @@ -154,6 +154,7 @@ const char *RabbitizerInstrId_Names[] = { [RABBITIZER_INSTR_ID_cpu_tlbwi] = "tlbwi", [RABBITIZER_INSTR_ID_cpu_tlbwr] = "tlbwr", [RABBITIZER_INSTR_ID_cpu_tlbp] = "tlbp", + [RABBITIZER_INSTR_ID_cpu_rfe] = "rfe", [RABBITIZER_INSTR_ID_cpu_eret] = "eret", [RABBITIZER_INSTR_ID_cpu_mfc1] = "mfc1", [RABBITIZER_INSTR_ID_cpu_dmfc1] = "dmfc1", diff --git a/include/generated/InstrId_enum.h b/include/generated/InstrId_enum.h index c46e4d6f..6e3f42be 100644 --- a/include/generated/InstrId_enum.h +++ b/include/generated/InstrId_enum.h @@ -154,6 +154,7 @@ typedef enum RabbitizerInstrId { RABBITIZER_INSTR_ID_cpu_tlbwi, RABBITIZER_INSTR_ID_cpu_tlbwr, RABBITIZER_INSTR_ID_cpu_tlbp, + RABBITIZER_INSTR_ID_cpu_rfe, RABBITIZER_INSTR_ID_cpu_eret, RABBITIZER_INSTR_ID_cpu_mfc1, RABBITIZER_INSTR_ID_cpu_dmfc1, diff --git a/rabbitizer/InstrId.pyi b/rabbitizer/InstrId.pyi index a2ca86b4..e35d6ebc 100644 --- a/rabbitizer/InstrId.pyi +++ b/rabbitizer/InstrId.pyi @@ -155,6 +155,7 @@ class InstrId: cpu_tlbwi: Enum cpu_tlbwr: Enum cpu_tlbp: Enum + cpu_rfe: Enum cpu_eret: Enum cpu_mfc1: Enum cpu_dmfc1: Enum diff --git a/rust/src/instr_id_enum.rs b/rust/src/instr_id_enum.rs index 47577247..6100f97d 100644 --- a/rust/src/instr_id_enum.rs +++ b/rust/src/instr_id_enum.rs @@ -154,6 +154,7 @@ pub enum InstrId { cpu_tlbwi, cpu_tlbwr, cpu_tlbp, + cpu_rfe, cpu_eret, cpu_mfc1, cpu_dmfc1, diff --git a/tables/tables/instr_id/cpu/cpu_cop0_tlb.inc b/tables/tables/instr_id/cpu/cpu_cop0_tlb.inc index a20818b0..d6aa6b7e 100644 --- a/tables/tables/instr_id/cpu/cpu_cop0_tlb.inc +++ b/tables/tables/instr_id/cpu/cpu_cop0_tlb.inc @@ -8,7 +8,7 @@ |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 000 | --- | TLBR | TLBWI | --- | --- | --- | TLBWR | --- | 001 | TLBP | --- | --- | --- | --- | --- | --- | --- | -010 | --- | --- | --- | --- | --- | --- | --- | --- | +010 | RFE | --- | --- | --- | --- | --- | --- | --- | 011 | ERET | --- | --- | --- | --- | --- | --- | --- | 100 | --- | --- | --- | --- | --- | --- | --- | --- | 101 | --- | --- | --- | --- | --- | --- | --- | --- | @@ -44,6 +44,13 @@ .notEmittedByCompilers=true ) // Probe TLB for Matching Entry + RABBITIZER_DEF_INSTR_ID( + cpu, 0x10, rfe, + .operands={0}, + .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, + .notEmittedByCompilers=true + ) // Restore From Exception + RABBITIZER_DEF_INSTR_ID( cpu, 0x18, eret, .operands={0}, diff --git a/tests/c/instruction_checks/plain_disassembly.c b/tests/c/instruction_checks/plain_disassembly.c index 4a76ac43..e31c73ff 100644 --- a/tests/c/instruction_checks/plain_disassembly.c +++ b/tests/c/instruction_checks/plain_disassembly.c @@ -50,6 +50,8 @@ const TestEntry test_entries[] = { TEST_ENTRY_C(0x00E41823, NULL, "subu $v1, $a3, $a0"), TEST_ENTRY_C(0x00041823, NULL, "negu $v1, $a0"), + TEST_ENTRY_C(0x42000010, NULL, "rfe"), + // Invalid instructions TEST_ENTRY_C(0x44444444, NULL, ".word 0x44444444 # cfc1 $a0, $8 # 00000444 "), TEST_ENTRY_C(0x77777777, NULL, ".word 0x77777777 # INVALID $k1, $s7, 0x7777 # 00000000 "), From ef2598d2c7dd8197771b97fb8fcd3b51d63b9d83 Mon Sep 17 00:00:00 2001 From: Angie Date: Mon, 15 Jul 2024 16:05:53 -0400 Subject: [PATCH 2/5] Fix `pmfhl` and `pmthl` missing the `.fmt` specifier --- CHANGELOG.md | 4 ++ .../generated/InstrIdType_enum_class.hpp | 2 + .../include/generated/UniqueId_enum_class.hpp | 8 +++- .../InstrDescriptor_Descriptors_array.h | 8 +++- include/generated/InstrIdType_Names_array.h | 2 + include/generated/InstrIdType_enum.h | 2 + include/generated/InstrId_Names_array.h | 8 +++- include/generated/InstrId_enum.h | 8 +++- rabbitizer/InstrId.pyi | 8 +++- rabbitizer/InstrIdType.pyi | 2 + rust/src/instr_id_enum.rs | 8 +++- rust/src/instr_id_type_enum.rs | 2 + ...bbitizerInstructionR5900_ProcessUniqueId.c | 29 +++++++++++ .../instr_id/RabbitizerInstrId_r5900.inc | 2 + tables/tables/instr_id/r5900/r5900_mmi.inc | 22 +++------ .../tables/instr_id/r5900/r5900_mmi_pmfhl.inc | 48 +++++++++++++++++++ .../tables/instr_id/r5900/r5900_mmi_pmthl.inc | 24 ++++++++++ .../instr_id_types/InstrIdType_r5900.inc | 2 + tests/c/instruction_checks/r5900_disasm.c | 24 ++++++++++ tests/run_instruction_checks.sh | 1 + 20 files changed, 187 insertions(+), 27 deletions(-) create mode 100644 tables/tables/instr_id/r5900/r5900_mmi_pmfhl.inc create mode 100644 tables/tables/instr_id/r5900/r5900_mmi_pmthl.inc create mode 100644 tests/c/instruction_checks/r5900_disasm.c diff --git a/CHANGELOG.md b/CHANGELOG.md index eaa969e0..1185b2b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cplusplus/include/generated/InstrIdType_enum_class.hpp b/cplusplus/include/generated/InstrIdType_enum_class.hpp index 2453c441..a9a3e836 100644 --- a/cplusplus/include/generated/InstrIdType_enum_class.hpp +++ b/cplusplus/include/generated/InstrIdType_enum_class.hpp @@ -103,6 +103,8 @@ enum class IdType { R5900_MMI_1, R5900_MMI_2, R5900_MMI_3, + R5900_MMI_PMFHL, + R5900_MMI_PMTHL, ALL_MAX, }; diff --git a/cplusplus/include/generated/UniqueId_enum_class.hpp b/cplusplus/include/generated/UniqueId_enum_class.hpp index 5b15ddb0..a95e9f47 100644 --- a/cplusplus/include/generated/UniqueId_enum_class.hpp +++ b/cplusplus/include/generated/UniqueId_enum_class.hpp @@ -799,8 +799,6 @@ enum class UniqueId { r5900_divu1, r5900_madd1, r5900_maddu1, - r5900_pmfhl, - r5900_pmthl, r5900_psllh, r5900_psrlh, r5900_psrah, @@ -885,6 +883,12 @@ enum class UniqueId { r5900_pexch, r5900_pcpyh, r5900_pexcw, + r5900_pmfhl_lw, + r5900_pmfhl_uw, + r5900_pmfhl_slw, + r5900_pmfhl_lh, + r5900_pmfhl_sh, + r5900_pmthl_lw, r5900_ei, r5900_di, r5900_c1__sqrt_s, diff --git a/include/generated/InstrDescriptor_Descriptors_array.h b/include/generated/InstrDescriptor_Descriptors_array.h index ce9fa5d8..53d21a7f 100644 --- a/include/generated/InstrDescriptor_Descriptors_array.h +++ b/include/generated/InstrDescriptor_Descriptors_array.h @@ -799,8 +799,6 @@ const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[] = { [RABBITIZER_INSTR_ID_r5900_divu1] = { .operands={RAB_OPERAND_cpu_zero, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .readsRs=true, .readsRt=true }, [RABBITIZER_INSTR_ID_r5900_madd1] = { .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true, .readsRs=true, .readsRt=true }, [RABBITIZER_INSTR_ID_r5900_maddu1] = { .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true, .readsRs=true, .readsRt=true }, - [RABBITIZER_INSTR_ID_r5900_pmfhl] = { .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true }, - [RABBITIZER_INSTR_ID_r5900_pmthl] = { .operands={RAB_OPERAND_cpu_rs}, .readsRs=true }, [RABBITIZER_INSTR_ID_r5900_psllh] = { .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .modifiesRd=true, .readsRt=true }, [RABBITIZER_INSTR_ID_r5900_psrlh] = { .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .modifiesRd=true, .readsRt=true }, [RABBITIZER_INSTR_ID_r5900_psrah] = { .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .modifiesRd=true, .readsRt=true }, @@ -885,6 +883,12 @@ const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[] = { [RABBITIZER_INSTR_ID_r5900_pexch] = { .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true, .readsRt=true }, [RABBITIZER_INSTR_ID_r5900_pcpyh] = { .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true, .readsRt=true }, [RABBITIZER_INSTR_ID_r5900_pexcw] = { .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true, .readsRt=true }, + [RABBITIZER_INSTR_ID_r5900_pmfhl_lw] = { .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true }, + [RABBITIZER_INSTR_ID_r5900_pmfhl_uw] = { .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true }, + [RABBITIZER_INSTR_ID_r5900_pmfhl_slw] = { .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true }, + [RABBITIZER_INSTR_ID_r5900_pmfhl_lh] = { .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true }, + [RABBITIZER_INSTR_ID_r5900_pmfhl_sh] = { .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true }, + [RABBITIZER_INSTR_ID_r5900_pmthl_lw] = { .operands={RAB_OPERAND_cpu_rs}, .readsRs=true }, [RABBITIZER_INSTR_ID_r5900_ei] = { .operands={0} }, [RABBITIZER_INSTR_ID_r5900_di] = { .operands={0} }, [RABBITIZER_INSTR_ID_r5900_c1__sqrt_s] = { .operands={RAB_OPERAND_cpu_copraw} }, diff --git a/include/generated/InstrIdType_Names_array.h b/include/generated/InstrIdType_Names_array.h index 574a9b82..06b0fa88 100644 --- a/include/generated/InstrIdType_Names_array.h +++ b/include/generated/InstrIdType_Names_array.h @@ -103,6 +103,8 @@ const char *RabInstrIdType_Names[] = { [RAB_INSTR_ID_TYPE_R5900_MMI_1] = "R5900" "_" "MMI_1", [RAB_INSTR_ID_TYPE_R5900_MMI_2] = "R5900" "_" "MMI_2", [RAB_INSTR_ID_TYPE_R5900_MMI_3] = "R5900" "_" "MMI_3", + [RAB_INSTR_ID_TYPE_R5900_MMI_PMFHL] = "R5900" "_" "MMI_PMFHL", + [RAB_INSTR_ID_TYPE_R5900_MMI_PMTHL] = "R5900" "_" "MMI_PMTHL", [RAB_INSTR_ID_TYPE_ALL_MAX] = "ALL" "_" "MAX", }; diff --git a/include/generated/InstrIdType_enum.h b/include/generated/InstrIdType_enum.h index 04a21191..aee529e6 100644 --- a/include/generated/InstrIdType_enum.h +++ b/include/generated/InstrIdType_enum.h @@ -103,6 +103,8 @@ typedef enum RabInstrIdType { RAB_INSTR_ID_TYPE_R5900_MMI_1, RAB_INSTR_ID_TYPE_R5900_MMI_2, RAB_INSTR_ID_TYPE_R5900_MMI_3, + RAB_INSTR_ID_TYPE_R5900_MMI_PMFHL, + RAB_INSTR_ID_TYPE_R5900_MMI_PMTHL, RAB_INSTR_ID_TYPE_ALL_MAX, } RabInstrIdType; diff --git a/include/generated/InstrId_Names_array.h b/include/generated/InstrId_Names_array.h index 97f0dddc..49f6aae0 100644 --- a/include/generated/InstrId_Names_array.h +++ b/include/generated/InstrId_Names_array.h @@ -799,8 +799,6 @@ const char *RabbitizerInstrId_Names[] = { [RABBITIZER_INSTR_ID_r5900_divu1] = "divu1", [RABBITIZER_INSTR_ID_r5900_madd1] = "madd1", [RABBITIZER_INSTR_ID_r5900_maddu1] = "maddu1", - [RABBITIZER_INSTR_ID_r5900_pmfhl] = "pmfhl", - [RABBITIZER_INSTR_ID_r5900_pmthl] = "pmthl", [RABBITIZER_INSTR_ID_r5900_psllh] = "psllh", [RABBITIZER_INSTR_ID_r5900_psrlh] = "psrlh", [RABBITIZER_INSTR_ID_r5900_psrah] = "psrah", @@ -885,6 +883,12 @@ const char *RabbitizerInstrId_Names[] = { [RABBITIZER_INSTR_ID_r5900_pexch] = "pexch", [RABBITIZER_INSTR_ID_r5900_pcpyh] = "pcpyh", [RABBITIZER_INSTR_ID_r5900_pexcw] = "pexcw", + [RABBITIZER_INSTR_ID_r5900_pmfhl_lw] = "pmfhl.lw", + [RABBITIZER_INSTR_ID_r5900_pmfhl_uw] = "pmfhl.uw", + [RABBITIZER_INSTR_ID_r5900_pmfhl_slw] = "pmfhl.slw", + [RABBITIZER_INSTR_ID_r5900_pmfhl_lh] = "pmfhl.lh", + [RABBITIZER_INSTR_ID_r5900_pmfhl_sh] = "pmfhl.sh", + [RABBITIZER_INSTR_ID_r5900_pmthl_lw] = "pmthl.lw", [RABBITIZER_INSTR_ID_r5900_ei] = "ei", [RABBITIZER_INSTR_ID_r5900_di] = "di", [RABBITIZER_INSTR_ID_r5900_c1__sqrt_s] = "c1", diff --git a/include/generated/InstrId_enum.h b/include/generated/InstrId_enum.h index 6e3f42be..6cba5e72 100644 --- a/include/generated/InstrId_enum.h +++ b/include/generated/InstrId_enum.h @@ -799,8 +799,6 @@ typedef enum RabbitizerInstrId { RABBITIZER_INSTR_ID_r5900_divu1, RABBITIZER_INSTR_ID_r5900_madd1, RABBITIZER_INSTR_ID_r5900_maddu1, - RABBITIZER_INSTR_ID_r5900_pmfhl, - RABBITIZER_INSTR_ID_r5900_pmthl, RABBITIZER_INSTR_ID_r5900_psllh, RABBITIZER_INSTR_ID_r5900_psrlh, RABBITIZER_INSTR_ID_r5900_psrah, @@ -885,6 +883,12 @@ typedef enum RabbitizerInstrId { RABBITIZER_INSTR_ID_r5900_pexch, RABBITIZER_INSTR_ID_r5900_pcpyh, RABBITIZER_INSTR_ID_r5900_pexcw, + RABBITIZER_INSTR_ID_r5900_pmfhl_lw, + RABBITIZER_INSTR_ID_r5900_pmfhl_uw, + RABBITIZER_INSTR_ID_r5900_pmfhl_slw, + RABBITIZER_INSTR_ID_r5900_pmfhl_lh, + RABBITIZER_INSTR_ID_r5900_pmfhl_sh, + RABBITIZER_INSTR_ID_r5900_pmthl_lw, RABBITIZER_INSTR_ID_r5900_ei, RABBITIZER_INSTR_ID_r5900_di, RABBITIZER_INSTR_ID_r5900_c1__sqrt_s, diff --git a/rabbitizer/InstrId.pyi b/rabbitizer/InstrId.pyi index e35d6ebc..40ea29bf 100644 --- a/rabbitizer/InstrId.pyi +++ b/rabbitizer/InstrId.pyi @@ -720,8 +720,6 @@ class InstrId: r5900_divu1: Enum r5900_madd1: Enum r5900_maddu1: Enum - r5900_pmfhl: Enum - r5900_pmthl: Enum r5900_psllh: Enum r5900_psrlh: Enum r5900_psrah: Enum @@ -806,6 +804,12 @@ class InstrId: r5900_pexch: Enum r5900_pcpyh: Enum r5900_pexcw: Enum + r5900_pmfhl_lw: Enum + r5900_pmfhl_uw: Enum + r5900_pmfhl_slw: Enum + r5900_pmfhl_lh: Enum + r5900_pmfhl_sh: Enum + r5900_pmthl_lw: Enum r5900_ei: Enum r5900_di: Enum r5900_c1__sqrt_s: Enum diff --git a/rabbitizer/InstrIdType.pyi b/rabbitizer/InstrIdType.pyi index f818c97d..54e3a006 100644 --- a/rabbitizer/InstrIdType.pyi +++ b/rabbitizer/InstrIdType.pyi @@ -104,4 +104,6 @@ class InstrIdType: R5900_MMI_1: Enum R5900_MMI_2: Enum R5900_MMI_3: Enum + R5900_MMI_PMFHL: Enum + R5900_MMI_PMTHL: Enum ALL_MAX: Enum diff --git a/rust/src/instr_id_enum.rs b/rust/src/instr_id_enum.rs index 6100f97d..b60978d0 100644 --- a/rust/src/instr_id_enum.rs +++ b/rust/src/instr_id_enum.rs @@ -799,8 +799,6 @@ pub enum InstrId { r5900_divu1, r5900_madd1, r5900_maddu1, - r5900_pmfhl, - r5900_pmthl, r5900_psllh, r5900_psrlh, r5900_psrah, @@ -885,6 +883,12 @@ pub enum InstrId { r5900_pexch, r5900_pcpyh, r5900_pexcw, + r5900_pmfhl_lw, + r5900_pmfhl_uw, + r5900_pmfhl_slw, + r5900_pmfhl_lh, + r5900_pmfhl_sh, + r5900_pmthl_lw, r5900_ei, r5900_di, r5900_c1__sqrt_s, diff --git a/rust/src/instr_id_type_enum.rs b/rust/src/instr_id_type_enum.rs index baa8b6bf..fcbe4900 100644 --- a/rust/src/instr_id_type_enum.rs +++ b/rust/src/instr_id_type_enum.rs @@ -103,5 +103,7 @@ pub enum InstrIdType { R5900_MMI_1, R5900_MMI_2, R5900_MMI_3, + R5900_MMI_PMFHL, + R5900_MMI_PMTHL, ALL_MAX, } diff --git a/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c b/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c index e9d07af5..d7f003cd 100644 --- a/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c +++ b/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c @@ -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); @@ -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]; diff --git a/tables/tables/instr_id/RabbitizerInstrId_r5900.inc b/tables/tables/instr_id/RabbitizerInstrId_r5900.inc index f9203488..3a85e544 100644 --- a/tables/tables/instr_id/RabbitizerInstrId_r5900.inc +++ b/tables/tables/instr_id/RabbitizerInstrId_r5900.inc @@ -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" diff --git a/tables/tables/instr_id/r5900/r5900_mmi.inc b/tables/tables/instr_id/r5900/r5900_mmi.inc index 32668337..d26ba137 100644 --- a/tables/tables/instr_id/r5900/r5900_mmi.inc +++ b/tables/tables/instr_id/r5900/r5900_mmi.inc @@ -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( @@ -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}, diff --git a/tables/tables/instr_id/r5900/r5900_mmi_pmfhl.inc b/tables/tables/instr_id/r5900/r5900_mmi_pmfhl.inc new file mode 100644 index 00000000..12599a91 --- /dev/null +++ b/tables/tables/instr_id/r5900/r5900_mmi_pmfhl.inc @@ -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 diff --git a/tables/tables/instr_id/r5900/r5900_mmi_pmthl.inc b/tables/tables/instr_id/r5900/r5900_mmi_pmthl.inc new file mode 100644 index 00000000..5c3b0bd4 --- /dev/null +++ b/tables/tables/instr_id/r5900/r5900_mmi_pmthl.inc @@ -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 diff --git a/tables/tables/instr_id_types/InstrIdType_r5900.inc b/tables/tables/instr_id_types/InstrIdType_r5900.inc index c331d88b..027eaaa4 100644 --- a/tables/tables/instr_id_types/InstrIdType_r5900.inc +++ b/tables/tables/instr_id_types/InstrIdType_r5900.inc @@ -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) diff --git a/tests/c/instruction_checks/r5900_disasm.c b/tests/c/instruction_checks/r5900_disasm.c new file mode 100644 index 00000000..9197af72 --- /dev/null +++ b/tests/c/instruction_checks/r5900_disasm.c @@ -0,0 +1,24 @@ +/* SPDX-FileCopyrightText: © 2024 Decompollaborate */ +/* SPDX-License-Identifier: MIT */ + +#include "rabbitizer.h" + +#include +#include +#include + +#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); diff --git a/tests/run_instruction_checks.sh b/tests/run_instruction_checks.sh index cb57d5cf..b6e44f4e 100755 --- a/tests/run_instruction_checks.sh +++ b/tests/run_instruction_checks.sh @@ -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 From fc2e1098ecf62a07fbcbdcadb2e35d0b19bddcbc Mon Sep 17 00:00:00 2001 From: Angie Date: Mon, 15 Jul 2024 20:28:41 -0400 Subject: [PATCH 3/5] Fix `vilwr` and `viswr` --- CHANGELOG.md | 2 +- .../generated/InstrIdType_enum_class.hpp | 2 + .../generated/OperandType_enum_class.hpp | 1 + .../include/generated/UniqueId_enum_class.hpp | 10 ++- .../InstrDescriptor_Descriptors_array.h | 10 ++- include/generated/InstrIdType_Names_array.h | 2 + include/generated/InstrIdType_enum.h | 2 + include/generated/InstrId_Names_array.h | 10 ++- include/generated/InstrId_enum.h | 10 ++- include/generated/OperandType_enum.h | 1 + .../OperandType_function_declarations.h | 1 + .../generated/instrOpercandCallbacks_array.h | 1 + .../instructions/RabbitizerInstructionR5900.h | 8 ++ rabbitizer/InstrId.pyi | 10 ++- rabbitizer/InstrIdType.pyi | 2 + rabbitizer/OperandType.pyi | 1 + rust/src/instr_id_enum.rs | 10 ++- rust/src/instr_id_type_enum.rs | 2 + rust/src/operand_type_enum.rs | 1 + src/instructions/RabbitizerInstrDescriptor.c | 9 ++ .../RabbitizerInstruction.c | 4 + .../RabbitizerInstruction_Examination.c | 4 + .../RabbitizerInstructionR5900_OperandType.c | 14 ++++ ...bbitizerInstructionR5900_ProcessUniqueId.c | 54 +++++++----- .../instr_id/RabbitizerInstrId_r5900.inc | 1 + .../instr_id/r5900/r5900_cop2_special1.inc | 6 +- .../instr_id/r5900/r5900_cop2_special2.inc | 53 ++---------- .../tables/instr_id/r5900/r5900_cop2_viwr.inc | 84 +++++++++++++++++++ .../instr_id_types/InstrIdType_r5900.inc | 2 + .../operands/RabbitizerOperandType_r5900.inc | 1 + tests/c/instruction_checks/r5900_disasm.c | 21 +++++ tests/c/instruction_checks/r5900_vcallms.c | 28 ------- tests/run_instruction_checks.sh | 3 +- 33 files changed, 256 insertions(+), 114 deletions(-) create mode 100644 tables/tables/instr_id/r5900/r5900_cop2_viwr.inc delete mode 100644 tests/c/instruction_checks/r5900_vcallms.c diff --git a/CHANGELOG.md b/CHANGELOG.md index 1185b2b0..29741785 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Fix `pmfhl` and `pmthl` missing the `.fmt` specifier. +- Fix `pmfhl`, `pmthl`, `vilwr` and `viswr` missing the `.fmt` specifier. ## [1.11.1] - 2024-07-12 diff --git a/cplusplus/include/generated/InstrIdType_enum_class.hpp b/cplusplus/include/generated/InstrIdType_enum_class.hpp index a9a3e836..9bab839a 100644 --- a/cplusplus/include/generated/InstrIdType_enum_class.hpp +++ b/cplusplus/include/generated/InstrIdType_enum_class.hpp @@ -95,9 +95,11 @@ enum class IdType { R5900_COP1, R5900_COP1_FPUS, R5900_COP2, + R5900_COP2_NOHIGHBIT, R5900_COP2_BC2, R5900_COP2_SPECIAL1, R5900_COP2_SPECIAL2, + R5900_COP2_VIWR, R5900_MMI, R5900_MMI_0, R5900_MMI_1, diff --git a/cplusplus/include/generated/OperandType_enum_class.hpp b/cplusplus/include/generated/OperandType_enum_class.hpp index aab88819..9492444d 100644 --- a/cplusplus/include/generated/OperandType_enum_class.hpp +++ b/cplusplus/include/generated/OperandType_enum_class.hpp @@ -138,6 +138,7 @@ enum class OperandType { r5900_vis_postincr, r5900_vit_postincr, r5900_vid_postincr, + r5900_vis_parenthesis, r5900_immediate5, r5900_immediate15, ALL_MAX, diff --git a/cplusplus/include/generated/UniqueId_enum_class.hpp b/cplusplus/include/generated/UniqueId_enum_class.hpp index a95e9f47..7192535f 100644 --- a/cplusplus/include/generated/UniqueId_enum_class.hpp +++ b/cplusplus/include/generated/UniqueId_enum_class.hpp @@ -1026,12 +1026,18 @@ enum class UniqueId { r5900_vwaitq, r5900_vmtir, r5900_vmfir, - r5900_vilwr, - r5900_viswr, r5900_vrnext, r5900_vrget, r5900_vrinit, r5900_vrxor, + r5900_vilwr_w, + r5900_vilwr_z, + r5900_vilwr_y, + r5900_vilwr_x, + r5900_viswr_w, + r5900_viswr_z, + r5900_viswr_y, + r5900_viswr_x, r5900_USERDEF_00, r5900_USERDEF_01, r5900_USERDEF_02, diff --git a/include/generated/InstrDescriptor_Descriptors_array.h b/include/generated/InstrDescriptor_Descriptors_array.h index 53d21a7f..caf28dae 100644 --- a/include/generated/InstrDescriptor_Descriptors_array.h +++ b/include/generated/InstrDescriptor_Descriptors_array.h @@ -1026,12 +1026,18 @@ const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[] = { [RABBITIZER_INSTR_ID_r5900_vwaitq] = { .operands={0} }, [RABBITIZER_INSTR_ID_r5900_vmtir] = { .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vfsl} }, [RABBITIZER_INSTR_ID_r5900_vmfir] = { .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vis}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true }, - [RABBITIZER_INSTR_ID_r5900_vilwr] = { .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis}, .isFloat=true, .doesDereference=true, .doesLoad=true }, - [RABBITIZER_INSTR_ID_r5900_viswr] = { .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis}, .isFloat=true, .doesDereference=true, .doesStore=true }, [RABBITIZER_INSTR_ID_r5900_vrnext] = { .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_R}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true }, [RABBITIZER_INSTR_ID_r5900_vrget] = { .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_R}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true }, [RABBITIZER_INSTR_ID_r5900_vrinit] = { .operands={RAB_OPERAND_r5900_R, RAB_OPERAND_r5900_vfsl} }, [RABBITIZER_INSTR_ID_r5900_vrxor] = { .operands={RAB_OPERAND_r5900_R, RAB_OPERAND_r5900_vfsl} }, + [RABBITIZER_INSTR_ID_r5900_vilwr_w] = { .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, .isFloat=true, .doesDereference=true, .doesLoad=true }, + [RABBITIZER_INSTR_ID_r5900_vilwr_z] = { .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, .isFloat=true, .doesDereference=true, .doesLoad=true }, + [RABBITIZER_INSTR_ID_r5900_vilwr_y] = { .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, .isFloat=true, .doesDereference=true, .doesLoad=true }, + [RABBITIZER_INSTR_ID_r5900_vilwr_x] = { .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, .isFloat=true, .doesDereference=true, .doesLoad=true }, + [RABBITIZER_INSTR_ID_r5900_viswr_w] = { .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, .isFloat=true, .doesDereference=true, .doesLoad=true }, + [RABBITIZER_INSTR_ID_r5900_viswr_z] = { .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, .isFloat=true, .doesDereference=true, .doesLoad=true }, + [RABBITIZER_INSTR_ID_r5900_viswr_y] = { .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, .isFloat=true, .doesDereference=true, .doesLoad=true }, + [RABBITIZER_INSTR_ID_r5900_viswr_x] = { .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, .isFloat=true, .doesDereference=true, .doesLoad=true }, [RABBITIZER_INSTR_ID_r5900_USERDEF_00] = { .operands={0} }, [RABBITIZER_INSTR_ID_r5900_USERDEF_01] = { .operands={0} }, [RABBITIZER_INSTR_ID_r5900_USERDEF_02] = { .operands={0} }, diff --git a/include/generated/InstrIdType_Names_array.h b/include/generated/InstrIdType_Names_array.h index 06b0fa88..6063db18 100644 --- a/include/generated/InstrIdType_Names_array.h +++ b/include/generated/InstrIdType_Names_array.h @@ -95,9 +95,11 @@ const char *RabInstrIdType_Names[] = { [RAB_INSTR_ID_TYPE_R5900_COP1] = "R5900" "_" "COP1", [RAB_INSTR_ID_TYPE_R5900_COP1_FPUS] = "R5900" "_" "COP1_FPUS", [RAB_INSTR_ID_TYPE_R5900_COP2] = "R5900" "_" "COP2", + [RAB_INSTR_ID_TYPE_R5900_COP2_NOHIGHBIT] = "R5900" "_" "COP2_NOHIGHBIT", [RAB_INSTR_ID_TYPE_R5900_COP2_BC2] = "R5900" "_" "COP2_BC2", [RAB_INSTR_ID_TYPE_R5900_COP2_SPECIAL1] = "R5900" "_" "COP2_SPECIAL1", [RAB_INSTR_ID_TYPE_R5900_COP2_SPECIAL2] = "R5900" "_" "COP2_SPECIAL2", + [RAB_INSTR_ID_TYPE_R5900_COP2_VIWR] = "R5900" "_" "COP2_VIWR", [RAB_INSTR_ID_TYPE_R5900_MMI] = "R5900" "_" "MMI", [RAB_INSTR_ID_TYPE_R5900_MMI_0] = "R5900" "_" "MMI_0", [RAB_INSTR_ID_TYPE_R5900_MMI_1] = "R5900" "_" "MMI_1", diff --git a/include/generated/InstrIdType_enum.h b/include/generated/InstrIdType_enum.h index aee529e6..cbcd2e4d 100644 --- a/include/generated/InstrIdType_enum.h +++ b/include/generated/InstrIdType_enum.h @@ -95,9 +95,11 @@ typedef enum RabInstrIdType { RAB_INSTR_ID_TYPE_R5900_COP1, RAB_INSTR_ID_TYPE_R5900_COP1_FPUS, RAB_INSTR_ID_TYPE_R5900_COP2, + RAB_INSTR_ID_TYPE_R5900_COP2_NOHIGHBIT, RAB_INSTR_ID_TYPE_R5900_COP2_BC2, RAB_INSTR_ID_TYPE_R5900_COP2_SPECIAL1, RAB_INSTR_ID_TYPE_R5900_COP2_SPECIAL2, + RAB_INSTR_ID_TYPE_R5900_COP2_VIWR, RAB_INSTR_ID_TYPE_R5900_MMI, RAB_INSTR_ID_TYPE_R5900_MMI_0, RAB_INSTR_ID_TYPE_R5900_MMI_1, diff --git a/include/generated/InstrId_Names_array.h b/include/generated/InstrId_Names_array.h index 49f6aae0..736140ec 100644 --- a/include/generated/InstrId_Names_array.h +++ b/include/generated/InstrId_Names_array.h @@ -1026,12 +1026,18 @@ const char *RabbitizerInstrId_Names[] = { [RABBITIZER_INSTR_ID_r5900_vwaitq] = "vwaitq", [RABBITIZER_INSTR_ID_r5900_vmtir] = "vmtir", [RABBITIZER_INSTR_ID_r5900_vmfir] = "vmfir", - [RABBITIZER_INSTR_ID_r5900_vilwr] = "vilwr", - [RABBITIZER_INSTR_ID_r5900_viswr] = "viswr", [RABBITIZER_INSTR_ID_r5900_vrnext] = "vrnext", [RABBITIZER_INSTR_ID_r5900_vrget] = "vrget", [RABBITIZER_INSTR_ID_r5900_vrinit] = "vrinit", [RABBITIZER_INSTR_ID_r5900_vrxor] = "vrxor", + [RABBITIZER_INSTR_ID_r5900_vilwr_w] = "vilwr.w", + [RABBITIZER_INSTR_ID_r5900_vilwr_z] = "vilwr.z", + [RABBITIZER_INSTR_ID_r5900_vilwr_y] = "vilwr.y", + [RABBITIZER_INSTR_ID_r5900_vilwr_x] = "vilwr.x", + [RABBITIZER_INSTR_ID_r5900_viswr_w] = "viswr.w", + [RABBITIZER_INSTR_ID_r5900_viswr_z] = "viswr.z", + [RABBITIZER_INSTR_ID_r5900_viswr_y] = "viswr.y", + [RABBITIZER_INSTR_ID_r5900_viswr_x] = "viswr.x", [RABBITIZER_INSTR_ID_r5900_USERDEF_00] = "USERDEF_00", [RABBITIZER_INSTR_ID_r5900_USERDEF_01] = "USERDEF_01", [RABBITIZER_INSTR_ID_r5900_USERDEF_02] = "USERDEF_02", diff --git a/include/generated/InstrId_enum.h b/include/generated/InstrId_enum.h index 6cba5e72..a4f44188 100644 --- a/include/generated/InstrId_enum.h +++ b/include/generated/InstrId_enum.h @@ -1026,12 +1026,18 @@ typedef enum RabbitizerInstrId { RABBITIZER_INSTR_ID_r5900_vwaitq, RABBITIZER_INSTR_ID_r5900_vmtir, RABBITIZER_INSTR_ID_r5900_vmfir, - RABBITIZER_INSTR_ID_r5900_vilwr, - RABBITIZER_INSTR_ID_r5900_viswr, RABBITIZER_INSTR_ID_r5900_vrnext, RABBITIZER_INSTR_ID_r5900_vrget, RABBITIZER_INSTR_ID_r5900_vrinit, RABBITIZER_INSTR_ID_r5900_vrxor, + RABBITIZER_INSTR_ID_r5900_vilwr_w, + RABBITIZER_INSTR_ID_r5900_vilwr_z, + RABBITIZER_INSTR_ID_r5900_vilwr_y, + RABBITIZER_INSTR_ID_r5900_vilwr_x, + RABBITIZER_INSTR_ID_r5900_viswr_w, + RABBITIZER_INSTR_ID_r5900_viswr_z, + RABBITIZER_INSTR_ID_r5900_viswr_y, + RABBITIZER_INSTR_ID_r5900_viswr_x, RABBITIZER_INSTR_ID_r5900_USERDEF_00, RABBITIZER_INSTR_ID_r5900_USERDEF_01, RABBITIZER_INSTR_ID_r5900_USERDEF_02, diff --git a/include/generated/OperandType_enum.h b/include/generated/OperandType_enum.h index 5f05de87..0570ec1c 100644 --- a/include/generated/OperandType_enum.h +++ b/include/generated/OperandType_enum.h @@ -138,6 +138,7 @@ typedef enum RabbitizerOperandType { RAB_OPERAND_r5900_vis_postincr, RAB_OPERAND_r5900_vit_postincr, RAB_OPERAND_r5900_vid_postincr, + RAB_OPERAND_r5900_vis_parenthesis, RAB_OPERAND_r5900_immediate5, RAB_OPERAND_r5900_immediate15, RAB_OPERAND_ALL_MAX, diff --git a/include/generated/OperandType_function_declarations.h b/include/generated/OperandType_function_declarations.h index 749e2139..d3518e53 100644 --- a/include/generated/OperandType_function_declarations.h +++ b/include/generated/OperandType_function_declarations.h @@ -136,6 +136,7 @@ size_t RabbitizerOperandType_process_r5900_vis_postincr (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); size_t RabbitizerOperandType_process_r5900_vit_postincr (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); size_t RabbitizerOperandType_process_r5900_vid_postincr (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); + size_t RabbitizerOperandType_process_r5900_vis_parenthesis (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); size_t RabbitizerOperandType_process_r5900_immediate5 (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); size_t RabbitizerOperandType_process_r5900_immediate15 (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); diff --git a/include/generated/instrOpercandCallbacks_array.h b/include/generated/instrOpercandCallbacks_array.h index f5855aeb..730393bf 100644 --- a/include/generated/instrOpercandCallbacks_array.h +++ b/include/generated/instrOpercandCallbacks_array.h @@ -137,6 +137,7 @@ const OperandCallback instrOpercandCallbacks[] = { [RAB_OPERAND_r5900_vis_postincr] = RabbitizerOperandType_process_r5900_vis_postincr, [RAB_OPERAND_r5900_vit_postincr] = RabbitizerOperandType_process_r5900_vit_postincr, [RAB_OPERAND_r5900_vid_postincr] = RabbitizerOperandType_process_r5900_vid_postincr, + [RAB_OPERAND_r5900_vis_parenthesis] = RabbitizerOperandType_process_r5900_vis_parenthesis, [RAB_OPERAND_r5900_immediate5] = RabbitizerOperandType_process_r5900_immediate5, [RAB_OPERAND_r5900_immediate15] = RabbitizerOperandType_process_r5900_immediate15, }; diff --git a/include/instructions/RabbitizerInstructionR5900.h b/include/instructions/RabbitizerInstructionR5900.h index 0e194fa4..e1d66367 100644 --- a/include/instructions/RabbitizerInstructionR5900.h +++ b/include/instructions/RabbitizerInstructionR5900.h @@ -12,8 +12,12 @@ extern "C" { #endif +#define RAB_INSTR_R5900_GET_cop2_highbit(self) (SHIFTR((self)->word, 25, 1)) +#define RAB_INSTR_R5900_GET_cop2_nohighbit_fmt(self) (SHIFTR((self)->word, 21, 4)) + #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_viwr_fhilo(self) ((SHIFTR((self)->word, 21, 4) << 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)) @@ -35,8 +39,12 @@ extern "C" { #define RAB_INSTR_R5900_GET_imm15(self) (SHIFTR((self)->word, 6, 15)) +#define RAB_INSTR_R5900_PACK_cop2_highbit(word, value) (BITREPACK((word), (value), 25, 1)) +#define RAB_INSTR_R5900_PACK_cop2_nohighbit_fmt(word, value) (BITREPACK((word), (value), 21, 4)) + #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_viwr_fhilo(word, value) (BITREPACK(BITREPACK((word), (value) >> 2, 21, 4), (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)) diff --git a/rabbitizer/InstrId.pyi b/rabbitizer/InstrId.pyi index 40ea29bf..7ed46930 100644 --- a/rabbitizer/InstrId.pyi +++ b/rabbitizer/InstrId.pyi @@ -947,11 +947,17 @@ class InstrId: r5900_vwaitq: Enum r5900_vmtir: Enum r5900_vmfir: Enum - r5900_vilwr: Enum - r5900_viswr: Enum r5900_vrnext: Enum r5900_vrget: Enum r5900_vrinit: Enum r5900_vrxor: Enum + r5900_vilwr_w: Enum + r5900_vilwr_z: Enum + r5900_vilwr_y: Enum + r5900_vilwr_x: Enum + r5900_viswr_w: Enum + r5900_viswr_z: Enum + r5900_viswr_y: Enum + r5900_viswr_x: Enum r5900_MAX: Enum ALL_MAX: Enum diff --git a/rabbitizer/InstrIdType.pyi b/rabbitizer/InstrIdType.pyi index 54e3a006..89d61d10 100644 --- a/rabbitizer/InstrIdType.pyi +++ b/rabbitizer/InstrIdType.pyi @@ -96,9 +96,11 @@ class InstrIdType: R5900_COP1: Enum R5900_COP1_FPUS: Enum R5900_COP2: Enum + R5900_COP2_NOHIGHBIT: Enum R5900_COP2_BC2: Enum R5900_COP2_SPECIAL1: Enum R5900_COP2_SPECIAL2: Enum + R5900_COP2_VIWR: Enum R5900_MMI: Enum R5900_MMI_0: Enum R5900_MMI_1: Enum diff --git a/rabbitizer/OperandType.pyi b/rabbitizer/OperandType.pyi index e03efef0..eae16fd0 100644 --- a/rabbitizer/OperandType.pyi +++ b/rabbitizer/OperandType.pyi @@ -139,6 +139,7 @@ class OperandType: r5900_vis_postincr: Enum r5900_vit_postincr: Enum r5900_vid_postincr: Enum + r5900_vis_parenthesis: Enum r5900_immediate5: Enum r5900_immediate15: Enum ALL_MAX: Enum diff --git a/rust/src/instr_id_enum.rs b/rust/src/instr_id_enum.rs index b60978d0..144428c9 100644 --- a/rust/src/instr_id_enum.rs +++ b/rust/src/instr_id_enum.rs @@ -1026,12 +1026,18 @@ pub enum InstrId { r5900_vwaitq, r5900_vmtir, r5900_vmfir, - r5900_vilwr, - r5900_viswr, r5900_vrnext, r5900_vrget, r5900_vrinit, r5900_vrxor, + r5900_vilwr_w, + r5900_vilwr_z, + r5900_vilwr_y, + r5900_vilwr_x, + r5900_viswr_w, + r5900_viswr_z, + r5900_viswr_y, + r5900_viswr_x, r5900_USERDEF_00, r5900_USERDEF_01, r5900_USERDEF_02, diff --git a/rust/src/instr_id_type_enum.rs b/rust/src/instr_id_type_enum.rs index fcbe4900..f8ddcb2c 100644 --- a/rust/src/instr_id_type_enum.rs +++ b/rust/src/instr_id_type_enum.rs @@ -95,9 +95,11 @@ pub enum InstrIdType { R5900_COP1, R5900_COP1_FPUS, R5900_COP2, + R5900_COP2_NOHIGHBIT, R5900_COP2_BC2, R5900_COP2_SPECIAL1, R5900_COP2_SPECIAL2, + R5900_COP2_VIWR, R5900_MMI, R5900_MMI_0, R5900_MMI_1, diff --git a/rust/src/operand_type_enum.rs b/rust/src/operand_type_enum.rs index 790577c7..3dd0e4f4 100644 --- a/rust/src/operand_type_enum.rs +++ b/rust/src/operand_type_enum.rs @@ -138,6 +138,7 @@ pub enum OperandType { r5900_vis_postincr, r5900_vit_postincr, r5900_vid_postincr, + r5900_vis_parenthesis, r5900_immediate5, r5900_immediate15, ALL_MAX, diff --git a/src/instructions/RabbitizerInstrDescriptor.c b/src/instructions/RabbitizerInstrDescriptor.c index 544d61c3..03fa11f1 100644 --- a/src/instructions/RabbitizerInstrDescriptor.c +++ b/src/instructions/RabbitizerInstrDescriptor.c @@ -573,6 +573,9 @@ bool RabbitizerInstrDescriptor_hasOperandAlias(const RabbitizerInstrDescriptor * if (RabbitizerInstrDescriptor_hasSpecificOperand(self, RAB_OPERAND_r5900_vis_postincr)) { return true; } + if (RabbitizerInstrDescriptor_hasSpecificOperand(self, RAB_OPERAND_r5900_vis_parenthesis)) { + return true; + } break; case RAB_OPERAND_r5900_vit: @@ -629,6 +632,12 @@ bool RabbitizerInstrDescriptor_hasOperandAlias(const RabbitizerInstrDescriptor * } break; + case RAB_OPERAND_r5900_vis_parenthesis: + if (RabbitizerInstrDescriptor_hasOperandAlias(self, RAB_OPERAND_r5900_vis)) { + return true; + } + break; + case RAB_OPERAND_r5900_immediate5: break; diff --git a/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c b/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c index 4e774737..413daa6d 100644 --- a/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c +++ b/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c @@ -637,6 +637,10 @@ void RabbitizerInstruction_blankOut(RabbitizerInstruction *self) { self->word = RAB_INSTR_R5900_PACK_vid(self->word, 0); break; + case RAB_OPERAND_r5900_vis_parenthesis: + self->word = RAB_INSTR_R5900_PACK_vis(self->word, 0); + break; + case RAB_OPERAND_r5900_immediate5: self->word = RAB_INSTR_R5900_PACK_imm5(self->word, 0); break; diff --git a/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c b/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c index ab161ae9..ed4231b1 100644 --- a/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c +++ b/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c @@ -709,6 +709,10 @@ uint32_t RabbitizerInstruction_getValidBits(const RabbitizerInstruction *self) { validbits = RAB_INSTR_R5900_PACK_vid(validbits, ~0); break; + case RAB_OPERAND_r5900_vis_parenthesis: + validbits = RAB_INSTR_R5900_PACK_vis(validbits, ~0); + break; + case RAB_OPERAND_r5900_immediate5: validbits = RAB_INSTR_R5900_PACK_imm5(validbits, ~0); break; diff --git a/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_OperandType.c b/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_OperandType.c index e3340aa3..36398a34 100644 --- a/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_OperandType.c +++ b/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_OperandType.c @@ -487,6 +487,20 @@ size_t RabbitizerOperandType_process_r5900_vid_postincr(const RabbitizerInstruct return totalSize; } +size_t RabbitizerOperandType_process_r5900_vis_parenthesis(const RabbitizerInstruction *self, char *dst, + const char *immOverride, size_t immOverrideLength) { + size_t totalSize = 0; + + RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '('); + + RABUTILS_BUFFER_ADVANCE(dst, totalSize, + RabbitizerOperandType_process_r5900_vis(self, dst, immOverride, immOverrideLength)); + + RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')'); + + return totalSize; +} + size_t RabbitizerOperandType_process_r5900_immediate5(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { size_t totalSize = 0; diff --git a/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c b/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c index d7f003cd..aa642da1 100644 --- a/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c +++ b/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c @@ -177,6 +177,17 @@ void RabbitizerInstruction_processUniqueId_Coprocessor2_BC2(RabbitizerInstructio } } +void RabbitizerInstructionR5900_processUniqueId_Coprocessor2_viwr(RabbitizerInstruction *self) { + uint32_t fhiflo = RAB_INSTR_R5900_GET_viwr_fhilo(self); + + self->_mandatorybits = RAB_INSTR_R5900_PACK_viwr_fhilo(self->_mandatorybits, fhiflo); + self->instrIdType = RAB_INSTR_ID_TYPE_R5900_COP2_VIWR; + + switch (fhiflo) { +#include "tables/instr_id/r5900/r5900_cop2_viwr.inc" + } +} + void RabbitizerInstructionR5900_processUniqueId_Coprocessor2_Special2(RabbitizerInstruction *self) { uint32_t fhiflo = RAB_INSTR_R5900_GET_fhi_flo(self); @@ -185,6 +196,11 @@ void RabbitizerInstructionR5900_processUniqueId_Coprocessor2_Special2(Rabbitizer switch (fhiflo) { #include "tables/instr_id/r5900/r5900_cop2_special2.inc" + + case 0x3E: + case 0x3F: + RabbitizerInstructionR5900_processUniqueId_Coprocessor2_viwr(self); + break; } } @@ -206,11 +222,11 @@ void RabbitizerInstructionR5900_processUniqueId_Coprocessor2_Special1(Rabbitizer } } -void RabbitizerInstructionR5900_processUniqueId_Coprocessor2(RabbitizerInstruction *self) { - uint8_t fmt = RAB_INSTR_GET_fmt(self); +void RabbitizerInstructionR5900_processUniqueId_Coprocessor2_nohighbit(RabbitizerInstruction *self) { + uint8_t fmt = RAB_INSTR_R5900_GET_cop2_nohighbit_fmt(self); - self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt); - self->instrIdType = RAB_INSTR_ID_TYPE_R5900_COP2; + self->_mandatorybits = RAB_INSTR_R5900_PACK_cop2_nohighbit_fmt(self->_mandatorybits, fmt); + self->instrIdType = RAB_INSTR_ID_TYPE_R5900_COP2_NOHIGHBIT; switch (fmt) { #include "tables/instr_id/r5900/r5900_cop2.inc" @@ -218,23 +234,21 @@ void RabbitizerInstructionR5900_processUniqueId_Coprocessor2(RabbitizerInstructi case 0x08: RabbitizerInstruction_processUniqueId_Coprocessor2_BC2(self); break; + } +} + +void RabbitizerInstructionR5900_processUniqueId_Coprocessor2(RabbitizerInstruction *self) { + uint8_t fmt = RAB_INSTR_R5900_GET_cop2_highbit(self); + + self->_mandatorybits = RAB_INSTR_R5900_PACK_cop2_highbit(self->_mandatorybits, fmt); + self->instrIdType = RAB_INSTR_ID_TYPE_R5900_COP2; + + switch (fmt) { + case 0x00: + RabbitizerInstructionR5900_processUniqueId_Coprocessor2_nohighbit(self); + break; - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: + case 0x01: RabbitizerInstructionR5900_processUniqueId_Coprocessor2_Special1(self); break; } diff --git a/tables/tables/instr_id/RabbitizerInstrId_r5900.inc b/tables/tables/instr_id/RabbitizerInstrId_r5900.inc index 3a85e544..d30131f5 100644 --- a/tables/tables/instr_id/RabbitizerInstrId_r5900.inc +++ b/tables/tables/instr_id/RabbitizerInstrId_r5900.inc @@ -27,6 +27,7 @@ #include "r5900/r5900_cop2_bc2.inc" #include "r5900/r5900_cop2_special1.inc" #include "r5900/r5900_cop2_special2.inc" + #include "r5900/r5900_cop2_viwr.inc" #ifndef INSTRID_AVOID_USERDEF RABBITIZER_DEF_INSTR_ID( diff --git a/tables/tables/instr_id/r5900/r5900_cop2_special1.inc b/tables/tables/instr_id/r5900/r5900_cop2_special1.inc index 6f37e929..6aa8bf43 100644 --- a/tables/tables/instr_id/r5900/r5900_cop2_special1.inc +++ b/tables/tables/instr_id/r5900/r5900_cop2_special1.inc @@ -2,9 +2,9 @@ /* SPDX-License-Identifier: MIT */ /* - 31---------26-25-----21-20-----------------------------5--------0 - | =COP2 | Special1 | |function| - ------6----------5------------------------------------------6---- + 31-------26-25-----------------------------------------5--------0 + | =COP2 |1| |function| + ------6-----1-----------------------------------------------6---- |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 000 |VADDx |VADDy |VADDz |VADDw |VSUBx |VSUBy |VSUBz |VSUBw | 001 |VMADDx |VMADDy |VMADDz |VMADDw |VMSUBx |VMSUBy |VMSUBz |VMSUBw | diff --git a/tables/tables/instr_id/r5900/r5900_cop2_special2.inc b/tables/tables/instr_id/r5900/r5900_cop2_special2.inc index c78392c9..669630b9 100644 --- a/tables/tables/instr_id/r5900/r5900_cop2_special2.inc +++ b/tables/tables/instr_id/r5900/r5900_cop2_special2.inc @@ -2,12 +2,9 @@ /* SPDX-License-Identifier: MIT */ /* - 31---------26-25-----21-20------------------11-10------6-5-2-1--0 - | =COP2 | Special2 | | fhi |1111|flo| - ------6----------5----------------------------------------------- -Note: opcode is flo | ( - fhi * 4 -). + 31--------26-25----------------------------10------6-5-----2-1--0 + | COP2 |1| | fhi |1 1 1 1|flo| + ------6------1---------------------------------5--------4-----2-- |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 0000 |VADDAx |VADDAy |VADDAz |VADDAw |VSUBAx |VSUBAy |VSUBAz |VSUBAw | 0001 |VMADDAx|VMADDAy|VMADDAz|VMADDAw|VMSUBAx|VMSUBAy|VMSUBAz|VMSUBAw| @@ -16,7 +13,7 @@ Note: opcode is flo | ( 0100 |VADDAq |VMADDAq|VADDAi |VMADDAi|VSUBAq |VMSUBAq|VSUBAi |VMSUBAi| 0101 |VADDA |VMADDA |VMULA | --- |VSUBA |VMSUBA |VOPMULA|VNOP | 0110 |VMOVE |VMR32 | --- | --- |VLQI |VSQI |VLQD |VSQD | -0111 |VDIV |VSQRT |VRSQRT |VWAITQ |VMTIR |VMFIR |VILWR |VISWR | +0111 |VDIV |VSQRT |VRSQRT |VWAITQ |VMTIR |VMFIR | *1 | *1 | 1000 |VRNEXT |VRGET |VRINIT |VRXOR | --- | --- | --- | --- | 1001 | --- | --- | --- | --- | --- | --- | --- | --- | 1010 | --- | --- | --- | --- | --- | --- | --- | --- | @@ -26,6 +23,7 @@ Note: opcode is flo | ( 1110 | --- | --- | --- | --- | --- | --- | --- | --- | 1111 | --- | --- | --- | --- | --- | --- | --- | --- | hi |-------|-------|-------|-------|-------|-------|-------|-------| + *1 = VIWR list */ // TODO: operands and properties @@ -378,47 +376,6 @@ Note: opcode is flo | ( .isFloat=true ) // Move from integer register - RABBITIZER_DEF_INSTR_ID( - r5900, 0x3E, vilwr, - .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis}, - .isFloat=true, - .doesDereference=true, - .doesLoad=true - ) // Integer load word register - RABBITIZER_DEF_INSTR_ID( - r5900, 0x3F, viswr, - .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis}, - .isFloat=true, - .doesDereference=true, - .doesStore=true - ) // Integer store word register - /* - "vilwr.w", RAB_OPERAND_r5900_vit,( - RAB_OPERAND_r5900_vis - ) - "vilwr.x", RAB_OPERAND_r5900_vit,( - RAB_OPERAND_r5900_vis - ) - "vilwr.y", RAB_OPERAND_r5900_vit,( - RAB_OPERAND_r5900_vis - ) - "vilwr.z", RAB_OPERAND_r5900_vit,( - RAB_OPERAND_r5900_vis - ) - "viswr.w", RAB_OPERAND_r5900_vit,( - RAB_OPERAND_r5900_vis - ) - "viswr.x", RAB_OPERAND_r5900_vit,( - RAB_OPERAND_r5900_vis - ) - "viswr.y", RAB_OPERAND_r5900_vit,( - RAB_OPERAND_r5900_vis - ) - "viswr.z", RAB_OPERAND_r5900_vit,( - RAB_OPERAND_r5900_vis - ) - */ - RABBITIZER_DEF_INSTR_ID( r5900, 0x40, vrnext, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_R}, diff --git a/tables/tables/instr_id/r5900/r5900_cop2_viwr.inc b/tables/tables/instr_id/r5900/r5900_cop2_viwr.inc new file mode 100644 index 00000000..d50425a3 --- /dev/null +++ b/tables/tables/instr_id/r5900/r5900_cop2_viwr.inc @@ -0,0 +1,84 @@ +/* SPDX-FileCopyrightText: © 2024 Decompollaborate */ +/* SPDX-License-Identifier: MIT */ + +/* + 31--------26-25-24--21---------------------10--------------2-1--0 + | COP2 |1| fhi | |0 1 1 1 1 1 1 1 1|flo| + ------6------1----4--------------------------------9----------2-- + |---00--|---01--|---10--|---11--| lo +0000 | --- | --- | --- | --- | +0001 | --- | --- |VILWR.W|VISWR.W| +0010 | --- | --- |VILWR.Z|VISWR.Z| +0011 | --- | --- | --- | --- | +0100 | --- | --- |VILWR.Y|VISWR.Y| +0101 | --- | --- | --- | --- | +0110 | --- | --- | --- | --- | +0111 | --- | --- | --- | --- | +1000 | --- | --- |VILWR.X|VISWR.X| +1001 | --- | --- | --- | --- | +1010 | --- | --- | --- | --- | +1011 | --- | --- | --- | --- | +1100 | --- | --- | --- | --- | +1101 | --- | --- | --- | --- | +1110 | --- | --- | --- | --- | +1111 | --- | --- | --- | --- | + hi |-------|-------|-------|-------| +*/ + + RABBITIZER_DEF_INSTR_ID_ALTNAME( + r5900, (0x01 << 2) | 0x02, vilwr_w, vilwr.w, + .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, + .isFloat=true, + .doesDereference=true, + .doesLoad=true + ) // Integer load word register + RABBITIZER_DEF_INSTR_ID_ALTNAME( + r5900, (0x02 << 2) | 0x02, vilwr_z, vilwr.z, + .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, + .isFloat=true, + .doesDereference=true, + .doesLoad=true + ) // Integer load word register + RABBITIZER_DEF_INSTR_ID_ALTNAME( + r5900, (0x04 << 2) | 0x02, vilwr_y, vilwr.y, + .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, + .isFloat=true, + .doesDereference=true, + .doesLoad=true + ) // Integer load word register + RABBITIZER_DEF_INSTR_ID_ALTNAME( + r5900, (0x08 << 2) | 0x02, vilwr_x, vilwr.x, + .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, + .isFloat=true, + .doesDereference=true, + .doesLoad=true + ) // Integer load word register + + RABBITIZER_DEF_INSTR_ID_ALTNAME( + r5900, (0x01 << 2) | 0x03, viswr_w, viswr.w, + .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, + .isFloat=true, + .doesDereference=true, + .doesLoad=true + ) // Integer store word register + RABBITIZER_DEF_INSTR_ID_ALTNAME( + r5900, (0x02 << 2) | 0x03, viswr_z, viswr.z, + .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, + .isFloat=true, + .doesDereference=true, + .doesLoad=true + ) // Integer store word register + RABBITIZER_DEF_INSTR_ID_ALTNAME( + r5900, (0x04 << 2) | 0x03, viswr_y, viswr.y, + .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, + .isFloat=true, + .doesDereference=true, + .doesLoad=true + ) // Integer store word register + RABBITIZER_DEF_INSTR_ID_ALTNAME( + r5900, (0x08 << 2) | 0x03, viswr_x, viswr.x, + .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis_parenthesis}, + .isFloat=true, + .doesDereference=true, + .doesLoad=true + ) // Integer store word register diff --git a/tables/tables/instr_id_types/InstrIdType_r5900.inc b/tables/tables/instr_id_types/InstrIdType_r5900.inc index 027eaaa4..be188970 100644 --- a/tables/tables/instr_id_types/InstrIdType_r5900.inc +++ b/tables/tables/instr_id_types/InstrIdType_r5900.inc @@ -16,9 +16,11 @@ RABBITIZER_DEF_INSTR_ID_TYPE(R5900, COP1_FPUS) RABBITIZER_DEF_INSTR_ID_TYPE(R5900, COP2) + RABBITIZER_DEF_INSTR_ID_TYPE(R5900, COP2_NOHIGHBIT) RABBITIZER_DEF_INSTR_ID_TYPE(R5900, COP2_BC2) RABBITIZER_DEF_INSTR_ID_TYPE(R5900, COP2_SPECIAL1) RABBITIZER_DEF_INSTR_ID_TYPE(R5900, COP2_SPECIAL2) + RABBITIZER_DEF_INSTR_ID_TYPE(R5900, COP2_VIWR) RABBITIZER_DEF_INSTR_ID_TYPE(R5900, MMI) RABBITIZER_DEF_INSTR_ID_TYPE(R5900, MMI_0) diff --git a/tables/tables/operands/RabbitizerOperandType_r5900.inc b/tables/tables/operands/RabbitizerOperandType_r5900.inc index 215f9395..be5c54ef 100644 --- a/tables/tables/operands/RabbitizerOperandType_r5900.inc +++ b/tables/tables/operands/RabbitizerOperandType_r5900.inc @@ -30,5 +30,6 @@ RAB_DEF_OPERAND(r5900, vis_postincr) RAB_DEF_OPERAND(r5900, vit_postincr) RAB_DEF_OPERAND(r5900, vid_postincr) + RAB_DEF_OPERAND(r5900, vis_parenthesis) RAB_DEF_OPERAND(r5900, immediate5) RAB_DEF_OPERAND(r5900, immediate15) diff --git a/tests/c/instruction_checks/r5900_disasm.c b/tests/c/instruction_checks/r5900_disasm.c index 9197af72..7b97ef04 100644 --- a/tests/c/instruction_checks/r5900_disasm.c +++ b/tests/c/instruction_checks/r5900_disasm.c @@ -13,12 +13,33 @@ // TODO: fill const TestEntry test_entries[] = { + TEST_ENTRY_C(0x4A000038, NULL, "vcallms 0x0"), + TEST_ENTRY_C(0x4A004038, NULL, "vcallms 0x800"), + TEST_ENTRY_C(0x4A008038, NULL, "vcallms 0x1000"), + TEST_ENTRY_C(0x4A008838, NULL, "vcallms 0x1100"), + TEST_ENTRY_C(0x4A009038, NULL, "vcallms 0x1200"), + TEST_ENTRY_C(0x4A009838, NULL, "vcallms 0x1300"), + TEST_ENTRY_C(0x4A00a038, NULL, "vcallms 0x1400"), + TEST_ENTRY_C(0x4A07FFF8, NULL, "vcallms 0xFFF8"), + TEST_ENTRY_C(0x4A080038, NULL, "vcallms 0x10000"), + TEST_ENTRY_C(0x4A1F8038, NULL, "vcallms 0x3F000"), + TEST_ENTRY_C(0x4A1FFFB8, NULL, "vcallms 0x3FFF0"), + 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"), + + TEST_ENTRY_C(0x4B020BFE, NULL, "vilwr.x $vi2, ($vi1)"), + TEST_ENTRY_C(0x4A820BFE, NULL, "vilwr.y $vi2, ($vi1)"), + TEST_ENTRY_C(0x4A420BFE, NULL, "vilwr.z $vi2, ($vi1)"), + TEST_ENTRY_C(0x4A220BFE, NULL, "vilwr.w $vi2, ($vi1)"), + TEST_ENTRY_C(0x4B020BFF, NULL, "viswr.x $vi2, ($vi1)"), + TEST_ENTRY_C(0x4A820BFF, NULL, "viswr.y $vi2, ($vi1)"), + TEST_ENTRY_C(0x4A420BFF, NULL, "viswr.z $vi2, ($vi1)"), + TEST_ENTRY_C(0x4A220BFF, NULL, "viswr.w $vi2, ($vi1)"), }; size_t test_entries_len = ARRAY_COUNT(test_entries); diff --git a/tests/c/instruction_checks/r5900_vcallms.c b/tests/c/instruction_checks/r5900_vcallms.c deleted file mode 100644 index f95e3d13..00000000 --- a/tests/c/instruction_checks/r5900_vcallms.c +++ /dev/null @@ -1,28 +0,0 @@ -/* SPDX-FileCopyrightText: © 2023-2024 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "rabbitizer.h" - -#include -#include -#include - -#include "expected_disasm_utils.h" - -#define TEST_ENTRY_C(word, imm, expected) TEST_ENTRY(RABBITIZER_INSTRCAT_R5900, word, imm, expected,) - -const TestEntry test_entries[] = { - TEST_ENTRY_C(0x4A000038, NULL, "vcallms 0x0"), - TEST_ENTRY_C(0x4A004038, NULL, "vcallms 0x800"), - TEST_ENTRY_C(0x4A008038, NULL, "vcallms 0x1000"), - TEST_ENTRY_C(0x4A008838, NULL, "vcallms 0x1100"), - TEST_ENTRY_C(0x4A009038, NULL, "vcallms 0x1200"), - TEST_ENTRY_C(0x4A009838, NULL, "vcallms 0x1300"), - TEST_ENTRY_C(0x4A00a038, NULL, "vcallms 0x1400"), - TEST_ENTRY_C(0x4A07FFF8, NULL, "vcallms 0xFFF8"), - TEST_ENTRY_C(0x4A080038, NULL, "vcallms 0x10000"), - TEST_ENTRY_C(0x4A1F8038, NULL, "vcallms 0x3F000"), - TEST_ENTRY_C(0x4A1FFFB8, NULL, "vcallms 0x3FFF0"), -}; - -size_t test_entries_len = ARRAY_COUNT(test_entries); diff --git a/tests/run_instruction_checks.sh b/tests/run_instruction_checks.sh index b6e44f4e..22761cab 100755 --- a/tests/run_instruction_checks.sh +++ b/tests/run_instruction_checks.sh @@ -10,6 +10,5 @@ set -e ./build/tests/c/instruction_checks/r3000gte_disasm.elf ./build/tests/c/instruction_checks/r4000allegrex_disasm.elf ./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 +./build/tests/c/instruction_checks/r5900_trunc_cvt.elf From 5e63140407d3a349b7b30a02c20e8e2e4565683f Mon Sep 17 00:00:00 2001 From: Angie Date: Mon, 15 Jul 2024 20:32:51 -0400 Subject: [PATCH 4/5] fix ci --- .github/workflows/make.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/make.yml b/.github/workflows/make.yml index ee58d7f4..c6be84b9 100644 --- a/.github/workflows/make.yml +++ b/.github/workflows/make.yml @@ -212,8 +212,8 @@ jobs: - name: Run instruction check - r5900_trunc_cvt run: ./build/tests/c/instruction_checks/r5900_trunc_cvt.elf - instruction_checks_r5900_vcallms: - name: Test - instruction_checks_r5900_vcallms + instruction_checks_r5900_disasm: + name: Test - instruction_checks_r5900_disasm needs: [build_repo] runs-on: ubuntu-latest @@ -230,5 +230,5 @@ jobs: - name: Make tests executable run: chmod --recursive +x build/ - - name: Run instruction check - r5900_vcallms - run: ./build/tests/c/instruction_checks/r5900_vcallms.elf + - name: Run instruction check - r5900_disasm + run: ./build/tests/c/instruction_checks/r5900_disasm.elf From f28fba1cc52606be64396147a8257c615bcfbe84 Mon Sep 17 00:00:00 2001 From: angie Date: Tue, 16 Jul 2024 21:15:37 -0400 Subject: [PATCH 5/5] version bump --- CHANGELOG.md | 3 +++ Cargo.toml | 3 +-- README.md | 4 ++-- include/common/RabbitizerVersion.h | 2 +- pyproject.toml | 2 +- tests/c/instruction_checks/r5900_disasm.c | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29741785..6862ad14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.11.2] - 2024-07-16 + ### Added - Implement the `rfe` ("Restore From Exception") instruction. @@ -641,6 +643,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - First version [unreleased]: https://github.com/Decompollaborate/rabbitizer/compare/master...develop +[1.11.2]: https://github.com/Decompollaborate/rabbitizer/compare/1.11.1...1.11.2 [1.11.1]: https://github.com/Decompollaborate/rabbitizer/compare/1.11.0...1.11.1 [1.11.0]: https://github.com/Decompollaborate/rabbitizer/compare/1.10.0...1.11.0 [1.10.0]: https://github.com/Decompollaborate/rabbitizer/compare/1.9.5...1.10.0 diff --git a/Cargo.toml b/Cargo.toml index 9982b370..85188108 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,12 +4,11 @@ [package] name = "rabbitizer" # Version should be synced with include/common/RabbitizerVersion.h -version = "1.11.1" +version = "1.11.2" edition = "2021" authors = ["Anghelo Carvajal "] description = "MIPS instruction decoder" readme = "README.md" -homepage = "https://github.com/Decompollaborate/rabbitizer" repository = "https://github.com/Decompollaborate/rabbitizer" license-file = "LICENSE" keywords = ["MIPS", "decoder"] diff --git a/README.md b/README.md index eef5ddec..7a29e5ed 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ If you use a `requirements.txt` file in your repository, then you can add this library with the following line: ```txt -rabbitizer>=1.11.1,<2.0.0 +rabbitizer>=1.11.2,<2.0.0 ``` ### Development version @@ -109,7 +109,7 @@ cargo add rabbitizer Or you can add it manually to your `Cargo.toml`: ```toml -rabbitizer = "1.11.1" +rabbitizer = "1.11.2" ``` See this crate at . diff --git a/include/common/RabbitizerVersion.h b/include/common/RabbitizerVersion.h index 9a7c7852..9f92b730 100644 --- a/include/common/RabbitizerVersion.h +++ b/include/common/RabbitizerVersion.h @@ -14,7 +14,7 @@ extern "C" { // Header version #define RAB_VERSION_MAJOR 1 #define RAB_VERSION_MINOR 11 -#define RAB_VERSION_PATCH 1 +#define RAB_VERSION_PATCH 2 #define RAB_VERSION_STR RAB_STRINGIFY(RAB_VERSION_MAJOR) "." RAB_STRINGIFY(RAB_VERSION_MINOR) "." RAB_STRINGIFY(RAB_VERSION_PATCH) diff --git a/pyproject.toml b/pyproject.toml index daa20193..752ff3d0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ [project] name = "rabbitizer" # Version should be synced with include/common/RabbitizerVersion.h -version = "1.11.1" +version = "1.11.2" description = "MIPS instruction decoder" # license = "MIT" readme = "README.md" diff --git a/tests/c/instruction_checks/r5900_disasm.c b/tests/c/instruction_checks/r5900_disasm.c index 7b97ef04..fa8c0336 100644 --- a/tests/c/instruction_checks/r5900_disasm.c +++ b/tests/c/instruction_checks/r5900_disasm.c @@ -1,4 +1,4 @@ -/* SPDX-FileCopyrightText: © 2024 Decompollaborate */ +/* SPDX-FileCopyrightText: © 2023-2024 Decompollaborate */ /* SPDX-License-Identifier: MIT */ #include "rabbitizer.h"