This commit is contained in:
Angie 2024-03-10 16:56:29 -03:00
parent 078574d715
commit c4360efe43
15 changed files with 40 additions and 2 deletions

View File

@ -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

View File

@ -21,6 +21,7 @@ enum class OperandType {
cpu_cop2t,
cpu_cop2cd,
cpu_op,
cpu_hint,
cpu_code,
cpu_code_lower,
cpu_copraw,

View File

@ -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 },

View File

@ -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,

View File

@ -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);

View File

@ -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,

View File

@ -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))

View File

@ -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

View File

@ -21,6 +21,7 @@ pub enum OperandType {
cpu_cop2t,
cpu_cop2cd,
cpu_op,
cpu_hint,
cpu_code,
cpu_code_lower,
cpu_copraw,

View File

@ -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:

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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)