From c4360efe4315b457548b18562ade3d63ea84a501 Mon Sep 17 00:00:00 2001 From: Angie Date: Sun, 10 Mar 2024 16:56:29 -0300 Subject: [PATCH 1/6] Fix `pref` --- CHANGELOG.md | 4 ++++ .../include/generated/OperandType_enum_class.hpp | 1 + .../InstrDescriptor_Descriptors_array.h | 2 +- include/generated/OperandType_enum.h | 1 + .../OperandType_function_declarations.h | 1 + include/generated/instrOpercandCallbacks_array.h | 1 + include/instructions/RabbitizerInstruction.h | 2 ++ rabbitizer/OperandType.pyi | 1 + rust/src/operand_type_enum.rs | 1 + src/instructions/RabbitizerInstrDescriptor.c | 1 + .../RabbitizerInstruction.c | 4 ++++ .../RabbitizerInstruction_Examination.c | 4 ++++ .../RabbitizerInstructionCpu_OperandType.c | 16 ++++++++++++++++ tables/tables/instr_id/cpu/cpu_normal.inc | 2 +- .../operands/RabbitizerOperandType_cpu.inc | 1 + 15 files changed, 40 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0398b85..cc8c90a7 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] +### Fixed + +- Fix the disassembly of `pref` + ## [1.9.2] - 2024-03-10 ### Fixed diff --git a/cplusplus/include/generated/OperandType_enum_class.hpp b/cplusplus/include/generated/OperandType_enum_class.hpp index 8ce4443f..679bd39a 100644 --- a/cplusplus/include/generated/OperandType_enum_class.hpp +++ b/cplusplus/include/generated/OperandType_enum_class.hpp @@ -21,6 +21,7 @@ enum class OperandType { cpu_cop2t, cpu_cop2cd, cpu_op, + cpu_hint, cpu_code, cpu_code_lower, cpu_copraw, diff --git a/include/generated/InstrDescriptor_Descriptors_array.h b/include/generated/InstrDescriptor_Descriptors_array.h index 1ea79b10..19942f2b 100644 --- a/include/generated/InstrDescriptor_Descriptors_array.h +++ b/include/generated/InstrDescriptor_Descriptors_array.h @@ -46,7 +46,7 @@ const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[] = { [RABBITIZER_INSTR_ID_cpu_sdr] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true, .canBeLo=true, .doesDereference=true, .doesStore=true }, [RABBITIZER_INSTR_ID_cpu_swr] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true, .canBeLo=true, .doesDereference=true, .doesStore=true }, [RABBITIZER_INSTR_ID_cpu_ll] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .readsRs=true, .notEmittedByCompilers=true, .canBeLo=true, .doesDereference=true, .doesLoad=true }, - [RABBITIZER_INSTR_ID_cpu_pref] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true }, + [RABBITIZER_INSTR_ID_cpu_pref] = { .operands={RAB_OPERAND_cpu_hint, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true }, [RABBITIZER_INSTR_ID_cpu_lld] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .readsRs=true, .notEmittedByCompilers=true, .canBeLo=true, .doesDereference=true, .doesLoad=true }, [RABBITIZER_INSTR_ID_cpu_ld] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .readsRs=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .accessType=RAB_ACCESSTYPE_DOUBLEWORD }, [RABBITIZER_INSTR_ID_cpu_sc] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true, .notEmittedByCompilers=true, .canBeLo=true, .doesDereference=true, .doesStore=true }, diff --git a/include/generated/OperandType_enum.h b/include/generated/OperandType_enum.h index 2f6eb8ab..826a3cf8 100644 --- a/include/generated/OperandType_enum.h +++ b/include/generated/OperandType_enum.h @@ -21,6 +21,7 @@ typedef enum RabbitizerOperandType { RAB_OPERAND_cpu_cop2t, RAB_OPERAND_cpu_cop2cd, RAB_OPERAND_cpu_op, + RAB_OPERAND_cpu_hint, RAB_OPERAND_cpu_code, RAB_OPERAND_cpu_code_lower, RAB_OPERAND_cpu_copraw, diff --git a/include/generated/OperandType_function_declarations.h b/include/generated/OperandType_function_declarations.h index 49873ab3..c1e3ccc5 100644 --- a/include/generated/OperandType_function_declarations.h +++ b/include/generated/OperandType_function_declarations.h @@ -19,6 +19,7 @@ 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_hint (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); size_t RabbitizerOperandType_process_cpu_copraw (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 f19bb434..5daae1fb 100644 --- a/include/generated/instrOpercandCallbacks_array.h +++ b/include/generated/instrOpercandCallbacks_array.h @@ -20,6 +20,7 @@ const OperandCallback instrOpercandCallbacks[] = { [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_hint] = RabbitizerOperandType_process_cpu_hint, [RAB_OPERAND_cpu_code] = RabbitizerOperandType_process_cpu_code, [RAB_OPERAND_cpu_code_lower] = RabbitizerOperandType_process_cpu_code_lower, [RAB_OPERAND_cpu_copraw] = RabbitizerOperandType_process_cpu_copraw, diff --git a/include/instructions/RabbitizerInstruction.h b/include/instructions/RabbitizerInstruction.h index 426dadfb..6acf7549 100644 --- a/include/instructions/RabbitizerInstruction.h +++ b/include/instructions/RabbitizerInstruction.h @@ -85,6 +85,7 @@ typedef struct RabbitizerInstruction { #define RAB_INSTR_GET_cop1cs(self) (SHIFTR((self)->word, 11, 5)) #define RAB_INSTR_GET_op(self) (SHIFTR((self)->word, 16, 5)) +#define RAB_INSTR_GET_hint(self) (SHIFTR((self)->word, 16, 5)) #define RAB_INSTR_GET_code(self) (SHIFTR((self)->word, 6, 20)) #define RAB_INSTR_GET_code_upper(self) (SHIFTR((self)->word, 16, 10)) @@ -134,6 +135,7 @@ typedef struct RabbitizerInstruction { #define RAB_INSTR_PACK_cop1cs(word, value) (BITREPACK((word), (value), 11, 5)) #define RAB_INSTR_PACK_op(word, value) (BITREPACK((word), (value), 16, 5)) +#define RAB_INSTR_PACK_hint(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)) diff --git a/rabbitizer/OperandType.pyi b/rabbitizer/OperandType.pyi index f488ee14..f80b2d95 100644 --- a/rabbitizer/OperandType.pyi +++ b/rabbitizer/OperandType.pyi @@ -22,6 +22,7 @@ class OperandType: cpu_cop2t: Enum cpu_cop2cd: Enum cpu_op: Enum + cpu_hint: Enum cpu_code: Enum cpu_code_lower: Enum cpu_copraw: Enum diff --git a/rust/src/operand_type_enum.rs b/rust/src/operand_type_enum.rs index f3c498d6..9a9e3b0e 100644 --- a/rust/src/operand_type_enum.rs +++ b/rust/src/operand_type_enum.rs @@ -21,6 +21,7 @@ pub enum OperandType { cpu_cop2t, cpu_cop2cd, cpu_op, + cpu_hint, cpu_code, cpu_code_lower, cpu_copraw, diff --git a/src/instructions/RabbitizerInstrDescriptor.c b/src/instructions/RabbitizerInstrDescriptor.c index 0af12272..98412227 100644 --- a/src/instructions/RabbitizerInstrDescriptor.c +++ b/src/instructions/RabbitizerInstrDescriptor.c @@ -93,6 +93,7 @@ bool RabbitizerInstrDescriptor_hasOperandAlias(const RabbitizerInstrDescriptor * case RAB_OPERAND_cpu_cop2t: case RAB_OPERAND_cpu_cop2cd: case RAB_OPERAND_cpu_op: + case RAB_OPERAND_cpu_hint: break; case RAB_OPERAND_cpu_code: diff --git a/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c b/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c index 27846284..48815a97 100644 --- a/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c +++ b/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c @@ -218,6 +218,10 @@ void RabbitizerInstruction_blankOut(RabbitizerInstruction *self) { self->word = RAB_INSTR_PACK_op(self->word, 0); break; + case RAB_OPERAND_cpu_hint: + self->word = RAB_INSTR_PACK_hint(self->word, 0); + break; + case RAB_OPERAND_cpu_code: self->word = RAB_INSTR_PACK_code(self->word, 0); break; diff --git a/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c b/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c index f6ad03a7..f75513ce 100644 --- a/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c +++ b/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c @@ -264,6 +264,10 @@ uint32_t RabbitizerInstruction_getValidBits(const RabbitizerInstruction *self) { validbits = RAB_INSTR_PACK_op(validbits, ~0); break; + case RAB_OPERAND_cpu_hint: + validbits = RAB_INSTR_PACK_hint(validbits, ~0); + break; + case RAB_OPERAND_cpu_code: validbits = RAB_INSTR_PACK_code(validbits, ~0); break; diff --git a/src/instructions/RabbitizerInstructionCpu/RabbitizerInstructionCpu_OperandType.c b/src/instructions/RabbitizerInstructionCpu/RabbitizerInstructionCpu_OperandType.c index 438d8084..ca7604d2 100644 --- a/src/instructions/RabbitizerInstructionCpu/RabbitizerInstructionCpu_OperandType.c +++ b/src/instructions/RabbitizerInstructionCpu/RabbitizerInstructionCpu_OperandType.c @@ -142,6 +142,22 @@ size_t RabbitizerOperandType_process_cpu_op(const RabbitizerInstruction *self, c return totalSize; } +size_t RabbitizerOperandType_process_cpu_hint(const RabbitizerInstruction *self, char *dst, + UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { + size_t totalSize = 0; + +// TODO: consider making this a proper configuration +#if 0 + if (RAB_INSTR_GET_hint(self) < 10) { + RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", RAB_INSTR_GET_hint(self)); + } else { + RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", RAB_INSTR_GET_hint(self)); + } +#endif + RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%02X", RAB_INSTR_GET_hint(self)); + return totalSize; +} + size_t RabbitizerOperandType_process_cpu_code(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { size_t totalSize = 0; diff --git a/tables/tables/instr_id/cpu/cpu_normal.inc b/tables/tables/instr_id/cpu/cpu_normal.inc index 9c6f7d23..4e2d3f5f 100644 --- a/tables/tables/instr_id/cpu/cpu_normal.inc +++ b/tables/tables/instr_id/cpu/cpu_normal.inc @@ -366,7 +366,7 @@ ) // Load Linked word RABBITIZER_DEF_INSTR_ID( cpu, 0x33, pref, - .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, + .operands={RAB_OPERAND_cpu_hint, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true diff --git a/tables/tables/operands/RabbitizerOperandType_cpu.inc b/tables/tables/operands/RabbitizerOperandType_cpu.inc index c38aa47e..7cfc3a3a 100644 --- a/tables/tables/operands/RabbitizerOperandType_cpu.inc +++ b/tables/tables/operands/RabbitizerOperandType_cpu.inc @@ -15,6 +15,7 @@ RAB_DEF_OPERAND(cpu, cop2t) RAB_DEF_OPERAND(cpu, cop2cd) // Coprocessor 2 control rd RAB_DEF_OPERAND(cpu, op) + RAB_DEF_OPERAND(cpu, hint) RAB_DEF_OPERAND(cpu, code) RAB_DEF_OPERAND(cpu, code_lower) RAB_DEF_OPERAND(cpu, copraw) From 13d5c1b069682ca5a7b3540a695253b23fe933f7 Mon Sep 17 00:00:00 2001 From: angie Date: Mon, 11 Mar 2024 09:17:29 -0300 Subject: [PATCH 2/6] Fix `c.seq.d` --- CHANGELOG.md | 4 +++- Makefile | 5 ++++- cplusplus/include/generated/UniqueId_enum_class.hpp | 2 +- include/generated/InstrDescriptor_Descriptors_array.h | 2 +- include/generated/InstrId_Names_array.h | 2 +- include/generated/InstrId_enum.h | 2 +- rabbitizer/InstrId.pyi | 2 +- rust/src/instr_id_enum.rs | 2 +- tables/tables/instr_id/cpu/cpu_cop1_fpu_d.inc | 2 +- 9 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc8c90a7..cf8c1b5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Fix the disassembly of `pref` +- Fix the disassembly of `pref`. +- Fix typo on `c.seq.d`. + - Was typed as `c.deq.d`. ## [1.9.2] - 2024-03-10 diff --git a/Makefile b/Makefile index 1572e691..c8da32cf 100644 --- a/Makefile +++ b/Makefile @@ -103,6 +103,9 @@ dynamic: $(DYNAMIC_LIB) $(DYNAMIC_LIB_XX) tables: make -C tables +cleantables: + make -C tables distclean + clean: $(RM) -rf build @@ -121,7 +124,7 @@ tidy: tests: $(TESTS_ELFS) -.PHONY: all static dynamic tables clean distclean format tidy tests +.PHONY: all static dynamic tables distclean clean distclean format tidy tests .DEFAULT_GOAL := all .SECONDARY: diff --git a/cplusplus/include/generated/UniqueId_enum_class.hpp b/cplusplus/include/generated/UniqueId_enum_class.hpp index fad5c9ac..090858ab 100644 --- a/cplusplus/include/generated/UniqueId_enum_class.hpp +++ b/cplusplus/include/generated/UniqueId_enum_class.hpp @@ -229,7 +229,7 @@ enum class UniqueId { cpu_c_ule_d, cpu_c_df_d, cpu_c_ngle_d, - cpu_c_deq_d, + cpu_c_seq_d, cpu_c_ngl_d, cpu_c_lt_d, cpu_c_nge_d, diff --git a/include/generated/InstrDescriptor_Descriptors_array.h b/include/generated/InstrDescriptor_Descriptors_array.h index 19942f2b..81b39feb 100644 --- a/include/generated/InstrDescriptor_Descriptors_array.h +++ b/include/generated/InstrDescriptor_Descriptors_array.h @@ -229,7 +229,7 @@ const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[] = { [RABBITIZER_INSTR_ID_cpu_c_ule_d] = { .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .readsFs=true, .readsFt=true }, [RABBITIZER_INSTR_ID_cpu_c_df_d] = { .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .readsFs=true, .readsFt=true }, [RABBITIZER_INSTR_ID_cpu_c_ngle_d] = { .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .readsFs=true, .readsFt=true }, - [RABBITIZER_INSTR_ID_cpu_c_deq_d] = { .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .readsFs=true, .readsFt=true }, + [RABBITIZER_INSTR_ID_cpu_c_seq_d] = { .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .readsFs=true, .readsFt=true }, [RABBITIZER_INSTR_ID_cpu_c_ngl_d] = { .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .readsFs=true, .readsFt=true }, [RABBITIZER_INSTR_ID_cpu_c_lt_d] = { .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .readsFs=true, .readsFt=true }, [RABBITIZER_INSTR_ID_cpu_c_nge_d] = { .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .readsFs=true, .readsFt=true }, diff --git a/include/generated/InstrId_Names_array.h b/include/generated/InstrId_Names_array.h index 5aae7a05..a43c453e 100644 --- a/include/generated/InstrId_Names_array.h +++ b/include/generated/InstrId_Names_array.h @@ -229,7 +229,7 @@ const char *RabbitizerInstrId_Names[] = { [RABBITIZER_INSTR_ID_cpu_c_ule_d] = "c.ule.d", [RABBITIZER_INSTR_ID_cpu_c_df_d] = "c.df.d", [RABBITIZER_INSTR_ID_cpu_c_ngle_d] = "c.ngle.d", - [RABBITIZER_INSTR_ID_cpu_c_deq_d] = "c.deq.d", + [RABBITIZER_INSTR_ID_cpu_c_seq_d] = "c.seq.d", [RABBITIZER_INSTR_ID_cpu_c_ngl_d] = "c.ngl.d", [RABBITIZER_INSTR_ID_cpu_c_lt_d] = "c.lt.d", [RABBITIZER_INSTR_ID_cpu_c_nge_d] = "c.nge.d", diff --git a/include/generated/InstrId_enum.h b/include/generated/InstrId_enum.h index 31e4efa7..8135e7a7 100644 --- a/include/generated/InstrId_enum.h +++ b/include/generated/InstrId_enum.h @@ -229,7 +229,7 @@ typedef enum RabbitizerInstrId { RABBITIZER_INSTR_ID_cpu_c_ule_d, RABBITIZER_INSTR_ID_cpu_c_df_d, RABBITIZER_INSTR_ID_cpu_c_ngle_d, - RABBITIZER_INSTR_ID_cpu_c_deq_d, + RABBITIZER_INSTR_ID_cpu_c_seq_d, RABBITIZER_INSTR_ID_cpu_c_ngl_d, RABBITIZER_INSTR_ID_cpu_c_lt_d, RABBITIZER_INSTR_ID_cpu_c_nge_d, diff --git a/rabbitizer/InstrId.pyi b/rabbitizer/InstrId.pyi index 48658bfa..0fa2b0ba 100644 --- a/rabbitizer/InstrId.pyi +++ b/rabbitizer/InstrId.pyi @@ -230,7 +230,7 @@ class InstrId: cpu_c_ule_d: Enum cpu_c_df_d: Enum cpu_c_ngle_d: Enum - cpu_c_deq_d: Enum + cpu_c_seq_d: Enum cpu_c_ngl_d: Enum cpu_c_lt_d: Enum cpu_c_nge_d: Enum diff --git a/rust/src/instr_id_enum.rs b/rust/src/instr_id_enum.rs index 776dd507..55faa3e6 100644 --- a/rust/src/instr_id_enum.rs +++ b/rust/src/instr_id_enum.rs @@ -229,7 +229,7 @@ pub enum InstrId { cpu_c_ule_d, cpu_c_df_d, cpu_c_ngle_d, - cpu_c_deq_d, + cpu_c_seq_d, cpu_c_ngl_d, cpu_c_lt_d, cpu_c_nge_d, diff --git a/tables/tables/instr_id/cpu/cpu_cop1_fpu_d.inc b/tables/tables/instr_id/cpu/cpu_cop1_fpu_d.inc index f180c90b..4d8a9954 100644 --- a/tables/tables/instr_id/cpu/cpu_cop1_fpu_d.inc +++ b/tables/tables/instr_id/cpu/cpu_cop1_fpu_d.inc @@ -251,7 +251,7 @@ .readsFt=true ) RABBITIZER_DEF_INSTR_ID_ALTNAME( - cpu, 0x3A, c_deq_d, c.deq.d, + cpu, 0x3A, c_seq_d, c.seq.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, From 904a226fc52b2bf51d4c020d8d1129fdf9d59d25 Mon Sep 17 00:00:00 2001 From: angie Date: Mon, 11 Mar 2024 09:20:46 -0300 Subject: [PATCH 3/6] Fix test --- include/generated/InstrDescriptor_Descriptors_array.h | 2 +- tables/tables/instr_id/cpu/cpu_normal.inc | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/generated/InstrDescriptor_Descriptors_array.h b/include/generated/InstrDescriptor_Descriptors_array.h index 81b39feb..ab9b0183 100644 --- a/include/generated/InstrDescriptor_Descriptors_array.h +++ b/include/generated/InstrDescriptor_Descriptors_array.h @@ -46,7 +46,7 @@ const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[] = { [RABBITIZER_INSTR_ID_cpu_sdr] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true, .canBeLo=true, .doesDereference=true, .doesStore=true }, [RABBITIZER_INSTR_ID_cpu_swr] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true, .canBeLo=true, .doesDereference=true, .doesStore=true }, [RABBITIZER_INSTR_ID_cpu_ll] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .readsRs=true, .notEmittedByCompilers=true, .canBeLo=true, .doesDereference=true, .doesLoad=true }, - [RABBITIZER_INSTR_ID_cpu_pref] = { .operands={RAB_OPERAND_cpu_hint, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true }, + [RABBITIZER_INSTR_ID_cpu_pref] = { .operands={RAB_OPERAND_cpu_hint, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true }, [RABBITIZER_INSTR_ID_cpu_lld] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .readsRs=true, .notEmittedByCompilers=true, .canBeLo=true, .doesDereference=true, .doesLoad=true }, [RABBITIZER_INSTR_ID_cpu_ld] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .readsRs=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .accessType=RAB_ACCESSTYPE_DOUBLEWORD }, [RABBITIZER_INSTR_ID_cpu_sc] = { .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true, .notEmittedByCompilers=true, .canBeLo=true, .doesDereference=true, .doesStore=true }, diff --git a/tables/tables/instr_id/cpu/cpu_normal.inc b/tables/tables/instr_id/cpu/cpu_normal.inc index 4e2d3f5f..0879ab75 100644 --- a/tables/tables/instr_id/cpu/cpu_normal.inc +++ b/tables/tables/instr_id/cpu/cpu_normal.inc @@ -368,8 +368,7 @@ cpu, 0x33, pref, .operands={RAB_OPERAND_cpu_hint, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, - .readsRs=true, - .readsRt=true + .readsRs=true ) // Prefetch RABBITIZER_DEF_INSTR_ID( cpu, 0x34, lld, From 757bb8d3805689e160c3d8c3204d3a3a0b30e357 Mon Sep 17 00:00:00 2001 From: angie Date: Mon, 11 Mar 2024 09:30:45 -0300 Subject: [PATCH 4/6] Fix rsp pref too --- .../include/generated/OperandType_enum_class.hpp | 1 + .../InstrDescriptor_Descriptors_array.h | 2 +- include/generated/OperandType_enum.h | 1 + .../OperandType_function_declarations.h | 1 + include/generated/instrOpercandCallbacks_array.h | 1 + include/instructions/RabbitizerInstructionRsp.h | 4 ++++ rabbitizer/OperandType.pyi | 1 + rust/src/operand_type_enum.rs | 1 + src/instructions/RabbitizerInstrDescriptor.c | 3 +++ .../RabbitizerInstruction.c | 4 ++++ .../RabbitizerInstruction_Examination.c | 4 ++++ .../RabbitizerInstructionRsp_OperandType.c | 16 ++++++++++++++++ tables/tables/instr_id/rsp/rsp_normal.inc | 5 ++--- .../operands/RabbitizerOperandType_rsp.inc | 1 + 14 files changed, 41 insertions(+), 4 deletions(-) diff --git a/cplusplus/include/generated/OperandType_enum_class.hpp b/cplusplus/include/generated/OperandType_enum_class.hpp index 679bd39a..6427962d 100644 --- a/cplusplus/include/generated/OperandType_enum_class.hpp +++ b/cplusplus/include/generated/OperandType_enum_class.hpp @@ -39,6 +39,7 @@ enum class OperandType { rsp_vs, rsp_vt, rsp_vd, + rsp_hint, rsp_vt_elementhigh, rsp_vt_elementlow, rsp_vd_de, diff --git a/include/generated/InstrDescriptor_Descriptors_array.h b/include/generated/InstrDescriptor_Descriptors_array.h index ab9b0183..2503a627 100644 --- a/include/generated/InstrDescriptor_Descriptors_array.h +++ b/include/generated/InstrDescriptor_Descriptors_array.h @@ -358,7 +358,7 @@ const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[] = { [RABBITIZER_INSTR_ID_rsp_sb] = { .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true, .canBeLo=true, .doesDereference=true, .doesStore=true, .accessType=RAB_ACCESSTYPE_BYTE }, [RABBITIZER_INSTR_ID_rsp_sh] = { .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true, .canBeLo=true, .doesDereference=true, .doesStore=true, .accessType=RAB_ACCESSTYPE_SHORT }, [RABBITIZER_INSTR_ID_rsp_sw] = { .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true, .canBeLo=true, .doesDereference=true, .doesStore=true, .accessType=RAB_ACCESSTYPE_WORD }, - [RABBITIZER_INSTR_ID_rsp_pref] = { .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true, .readsRt=true }, + [RABBITIZER_INSTR_ID_rsp_pref] = { .operands={RAB_OPERAND_rsp_hint, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .readsRs=true }, [RABBITIZER_INSTR_ID_rsp_b] = { .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true }, [RABBITIZER_INSTR_ID_rsp_beqz] = { .operands={RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .readsRs=true, .isBranch=true }, [RABBITIZER_INSTR_ID_rsp_bnez] = { .operands={RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .readsRs=true, .isBranch=true }, diff --git a/include/generated/OperandType_enum.h b/include/generated/OperandType_enum.h index 826a3cf8..40859853 100644 --- a/include/generated/OperandType_enum.h +++ b/include/generated/OperandType_enum.h @@ -39,6 +39,7 @@ typedef enum RabbitizerOperandType { RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt, RAB_OPERAND_rsp_vd, + RAB_OPERAND_rsp_hint, RAB_OPERAND_rsp_vt_elementhigh, RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_vd_de, diff --git a/include/generated/OperandType_function_declarations.h b/include/generated/OperandType_function_declarations.h index c1e3ccc5..4c3e549b 100644 --- a/include/generated/OperandType_function_declarations.h +++ b/include/generated/OperandType_function_declarations.h @@ -37,6 +37,7 @@ size_t RabbitizerOperandType_process_rsp_vs (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); size_t RabbitizerOperandType_process_rsp_vt (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); size_t RabbitizerOperandType_process_rsp_vd (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); + size_t RabbitizerOperandType_process_rsp_hint (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); size_t RabbitizerOperandType_process_rsp_vt_elementhigh (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); size_t RabbitizerOperandType_process_rsp_vt_elementlow (const struct RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); size_t RabbitizerOperandType_process_rsp_vd_de (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 5daae1fb..2285172c 100644 --- a/include/generated/instrOpercandCallbacks_array.h +++ b/include/generated/instrOpercandCallbacks_array.h @@ -38,6 +38,7 @@ const OperandCallback instrOpercandCallbacks[] = { [RAB_OPERAND_rsp_vs] = RabbitizerOperandType_process_rsp_vs, [RAB_OPERAND_rsp_vt] = RabbitizerOperandType_process_rsp_vt, [RAB_OPERAND_rsp_vd] = RabbitizerOperandType_process_rsp_vd, + [RAB_OPERAND_rsp_hint] = RabbitizerOperandType_process_rsp_hint, [RAB_OPERAND_rsp_vt_elementhigh] = RabbitizerOperandType_process_rsp_vt_elementhigh, [RAB_OPERAND_rsp_vt_elementlow] = RabbitizerOperandType_process_rsp_vt_elementlow, [RAB_OPERAND_rsp_vd_de] = RabbitizerOperandType_process_rsp_vd_de, diff --git a/include/instructions/RabbitizerInstructionRsp.h b/include/instructions/RabbitizerInstructionRsp.h index 3e8460bf..36e56a53 100644 --- a/include/instructions/RabbitizerInstructionRsp.h +++ b/include/instructions/RabbitizerInstructionRsp.h @@ -19,6 +19,8 @@ extern "C" { #define RAB_INSTR_RSP_GET_vt(self) (SHIFTR((self)->word, 16, 5)) #define RAB_INSTR_RSP_GET_vd(self) (SHIFTR((self)->word, 6, 5)) +#define RAB_INSTR_RSP_GET_hint(self) (SHIFTR((self)->word, 16, 5)) + #define RAB_INSTR_RSP_GET_elementhigh(self) (SHIFTR((self)->word, 21, 4)) #define RAB_INSTR_RSP_GET_elementlow(self) (SHIFTR((self)->word, 7, 4)) #define RAB_INSTR_RSP_GET_OFFSET_VECTOR_RAW(self) (SHIFTR((self)->word, 0, 7)) @@ -34,6 +36,8 @@ extern "C" { #define RAB_INSTR_RSP_PACK_vt(word, value) (BITREPACK((word), value, 16, 5)) #define RAB_INSTR_RSP_PACK_vd(word, value) (BITREPACK((word), value, 6, 5)) +#define RAB_INSTR_RSP_PACK_hint(word, value) (BITREPACK((word), (value), 16, 5)) + #define RAB_INSTR_RSP_PACK_elementhigh(word, value) (BITREPACK((word), value, 21, 4)) #define RAB_INSTR_RSP_PACK_elementlow(word, value) (BITREPACK((word), value, 7, 4)) diff --git a/rabbitizer/OperandType.pyi b/rabbitizer/OperandType.pyi index f80b2d95..0b234e28 100644 --- a/rabbitizer/OperandType.pyi +++ b/rabbitizer/OperandType.pyi @@ -40,6 +40,7 @@ class OperandType: rsp_vs: Enum rsp_vt: Enum rsp_vd: Enum + rsp_hint: Enum rsp_vt_elementhigh: Enum rsp_vt_elementlow: Enum rsp_vd_de: Enum diff --git a/rust/src/operand_type_enum.rs b/rust/src/operand_type_enum.rs index 9a9e3b0e..f18b05aa 100644 --- a/rust/src/operand_type_enum.rs +++ b/rust/src/operand_type_enum.rs @@ -39,6 +39,7 @@ pub enum OperandType { rsp_vs, rsp_vt, rsp_vd, + rsp_hint, rsp_vt_elementhigh, rsp_vt_elementlow, rsp_vd_de, diff --git a/src/instructions/RabbitizerInstrDescriptor.c b/src/instructions/RabbitizerInstrDescriptor.c index 98412227..e466108f 100644 --- a/src/instructions/RabbitizerInstrDescriptor.c +++ b/src/instructions/RabbitizerInstrDescriptor.c @@ -174,6 +174,9 @@ bool RabbitizerInstrDescriptor_hasOperandAlias(const RabbitizerInstrDescriptor * case RAB_OPERAND_rsp_cop2cd: break; + case RAB_OPERAND_rsp_hint: + break; + // case RAB_OPERAND_rsp_elementhigh: // case RAB_OPERAND_rsp_elementlow: // case RAB_OPERAND_rsp_index: diff --git a/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c b/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c index 48815a97..36de8723 100644 --- a/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c +++ b/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c @@ -281,6 +281,10 @@ void RabbitizerInstruction_blankOut(RabbitizerInstruction *self) { self->word = RAB_INSTR_RSP_PACK_cop2cd(self->word, 0); break; + case RAB_OPERAND_rsp_hint: + self->word = RAB_INSTR_RSP_PACK_hint(self->word, 0); + break; + case RAB_OPERAND_rsp_vs: self->word = RAB_INSTR_RSP_PACK_vs(self->word, 0); break; diff --git a/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c b/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c index f75513ce..40c4391e 100644 --- a/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c +++ b/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c @@ -327,6 +327,10 @@ uint32_t RabbitizerInstruction_getValidBits(const RabbitizerInstruction *self) { validbits = RAB_INSTR_RSP_PACK_cop2cd(validbits, ~0); break; + case RAB_OPERAND_rsp_hint: + validbits = RAB_INSTR_RSP_PACK_hint(validbits, ~0); + break; + case RAB_OPERAND_rsp_vs: validbits = RAB_INSTR_RSP_PACK_vs(validbits, ~0); break; diff --git a/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_OperandType.c b/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_OperandType.c index 0b8599d5..55d70476 100644 --- a/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_OperandType.c +++ b/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_OperandType.c @@ -92,6 +92,22 @@ size_t RabbitizerOperandType_process_rsp_vd(const RabbitizerInstruction *self, c return totalSize; } +size_t RabbitizerOperandType_process_rsp_hint(const RabbitizerInstruction *self, char *dst, + UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { + size_t totalSize = 0; + +// TODO: consider making this a proper configuration +#if 0 + if (RAB_INSTR_RSP_GET_hint(self) < 10) { + RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", RAB_INSTR_RSP_GET_hint(self)); + } else { + RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", RAB_INSTR_RSP_GET_hint(self)); + } +#endif + RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%02X", RAB_INSTR_RSP_GET_hint(self)); + return totalSize; +} + size_t RabbitizerOperandType_process_rsp_vt_elementhigh(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { size_t totalSize = 0; diff --git a/tables/tables/instr_id/rsp/rsp_normal.inc b/tables/tables/instr_id/rsp/rsp_normal.inc index 17cce02a..1a593d02 100644 --- a/tables/tables/instr_id/rsp/rsp_normal.inc +++ b/tables/tables/instr_id/rsp/rsp_normal.inc @@ -213,10 +213,9 @@ ) // Store Word RABBITIZER_DEF_INSTR_ID( rsp, 0x33, pref, - .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, + .operands={RAB_OPERAND_rsp_hint, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, - .readsRs=true, - .readsRt=true + .readsRs=true ) // Prefetch diff --git a/tables/tables/operands/RabbitizerOperandType_rsp.inc b/tables/tables/operands/RabbitizerOperandType_rsp.inc index 9879644d..f3fdd0a9 100644 --- a/tables/tables/operands/RabbitizerOperandType_rsp.inc +++ b/tables/tables/operands/RabbitizerOperandType_rsp.inc @@ -10,6 +10,7 @@ RAB_DEF_OPERAND(rsp, vs) RAB_DEF_OPERAND(rsp, vt) RAB_DEF_OPERAND(rsp, vd) + RAB_DEF_OPERAND(rsp, hint) // RAB_DEF_OPERAND(rsp, elementhigh) // RAB_DEF_OPERAND(rsp, elementlow) // RAB_DEF_OPERAND(rsp, index) From ebf82b91d94e2a7e687346d48e61ded51e7ef734 Mon Sep 17 00:00:00 2001 From: angie Date: Sun, 17 Mar 2024 11:18:13 -0300 Subject: [PATCH 5/6] version bump --- CHANGELOG.md | 3 +++ Cargo.toml | 2 +- README.md | 2 +- include/common/RabbitizerVersion.h | 2 +- pyproject.toml | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf8c1b5c..755c8d34 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.9.3] - 2024-03-17 + ### Fixed - Fix the disassembly of `pref`. @@ -560,6 +562,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.9.3]: https://github.com/Decompollaborate/rabbitizer/compare/1.9.2...1.9.3 [1.9.2]: https://github.com/Decompollaborate/rabbitizer/compare/1.9.1...1.9.2 [1.9.1]: https://github.com/Decompollaborate/rabbitizer/compare/1.9.0...1.9.1 [1.9.0]: https://github.com/Decompollaborate/rabbitizer/compare/1.8.3...1.9.0 diff --git a/Cargo.toml b/Cargo.toml index 1f22ee4a..233ab704 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "rabbitizer" # Version should be synced with include/common/RabbitizerVersion.h -version = "1.9.2" +version = "1.9.3" edition = "2021" authors = ["Anghelo Carvajal "] description = "MIPS instruction decoder" diff --git a/README.md b/README.md index 626a7e11..dd9bfe37 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ cargo add rabbitizer Or you can add it manually to your `Cargo.toml`: ```toml -rabbitizer = "1.9.2" +rabbitizer = "1.9.3" ``` See this crate at . diff --git a/include/common/RabbitizerVersion.h b/include/common/RabbitizerVersion.h index 859e2125..9007187d 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 9 -#define RAB_VERSION_PATCH 2 +#define RAB_VERSION_PATCH 3 #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 23fc24ee..05c9a7ba 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.9.2" +version = "1.9.3" description = "MIPS instruction decoder" # license = "MIT" readme = "README.md" From 7b35aa7a8c09226a78ec587edc9915d54fc31cd8 Mon Sep 17 00:00:00 2001 From: angie Date: Sun, 17 Mar 2024 11:19:32 -0300 Subject: [PATCH 6/6] typo --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c8da32cf..732e7b86 100644 --- a/Makefile +++ b/Makefile @@ -124,7 +124,7 @@ tidy: tests: $(TESTS_ELFS) -.PHONY: all static dynamic tables distclean clean distclean format tidy tests +.PHONY: all static dynamic tables cleantables clean distclean format tidy tests .DEFAULT_GOAL := all .SECONDARY: