getBranchVramGeneric should return an unsigned value (#49)

* getBranchVramGeneric should return an unsigned value

* Add test

* Revert "Add test"

This reverts commit 55e7bc12bf.
This commit is contained in:
descawed 2023-12-25 12:58:47 -05:00 committed by GitHub
parent 7d0de275c5
commit b92e43ef51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 9 additions and 9 deletions

View File

@ -176,7 +176,7 @@ namespace rabbitizer {
//! @deprecated //! @deprecated
int32_t getGenericBranchOffset(uint32_t currentVram) const; int32_t getGenericBranchOffset(uint32_t currentVram) const;
int32_t getBranchOffsetGeneric() const; int32_t getBranchOffsetGeneric() const;
int32_t getBranchVramGeneric() const; uint32_t getBranchVramGeneric() const;
int8_t getDestinationGpr() const; int8_t getDestinationGpr() const;
bool outputsToGprZero() const; bool outputsToGprZero() const;

View File

@ -741,7 +741,7 @@ int32_t InstructionBase::getBranchOffsetGeneric() const {
return RabbitizerInstruction_getBranchOffsetGeneric(&this->instr); return RabbitizerInstruction_getBranchOffsetGeneric(&this->instr);
} }
int32_t InstructionBase::getBranchVramGeneric() const { uint32_t InstructionBase::getBranchVramGeneric() const {
#ifdef RAB_SANITY_CHECKS #ifdef RAB_SANITY_CHECKS
if (!hasOperandAlias(OperandType::cpu_branch_target_label) && !hasOperandAlias(OperandType::cpu_label)) { if (!hasOperandAlias(OperandType::cpu_branch_target_label) && !hasOperandAlias(OperandType::cpu_label)) {
// TODO: make a rabbitizer exception class // TODO: make a rabbitizer exception class

View File

@ -378,7 +378,7 @@ following code:
```c ```c
if (RabbitizerInstrDescriptor_isBranch(instr.descriptor)) { if (RabbitizerInstrDescriptor_isBranch(instr.descriptor)) {
int32_t vramTarget = RabbitizerInstruction_getBranchVramGeneric(&instr); uint32_t vramTarget = RabbitizerInstruction_getBranchVramGeneric(&instr);
sprintf(immOverride, ".L%08X", vramTarget); sprintf(immOverride, ".L%08X", vramTarget);
} else if (RabbitizerInstrDescriptor_canBeHi(instr.descriptor)) { } else if (RabbitizerInstrDescriptor_canBeHi(instr.descriptor)) {
@ -472,7 +472,7 @@ int main(int argc, char *argv[]) {
printf("The word %08X corresponds to the instruction (with immediate overriden):\n", word); printf("The word %08X corresponds to the instruction (with immediate overriden):\n", word);
if (RabbitizerInstrDescriptor_isBranch(instr.descriptor)) { if (RabbitizerInstrDescriptor_isBranch(instr.descriptor)) {
int32_t vramTarget = RabbitizerInstruction_getBranchVramGeneric(&instr); uint32_t vramTarget = RabbitizerInstruction_getBranchVramGeneric(&instr);
sprintf(immOverride, ".L%08X", vramTarget); sprintf(immOverride, ".L%08X", vramTarget);
} else if (RabbitizerInstrDescriptor_canBeHi(instr.descriptor)) { } else if (RabbitizerInstrDescriptor_canBeHi(instr.descriptor)) {

View File

@ -217,7 +217,7 @@ int32_t RabbitizerInstruction_getGenericBranchOffset(const RabbitizerInstruction
NODISCARD NON_NULL(1) PURE NODISCARD NON_NULL(1) PURE
int32_t RabbitizerInstruction_getBranchOffsetGeneric(const RabbitizerInstruction *self); int32_t RabbitizerInstruction_getBranchOffsetGeneric(const RabbitizerInstruction *self);
NODISCARD NON_NULL(1) PURE NODISCARD NON_NULL(1) PURE
int32_t RabbitizerInstruction_getBranchVramGeneric(const RabbitizerInstruction *self); uint32_t RabbitizerInstruction_getBranchVramGeneric(const RabbitizerInstruction *self);
NODISCARD NON_NULL(1) PURE NODISCARD NON_NULL(1) PURE
int8_t RabbitizerInstruction_getDestinationGpr(const RabbitizerInstruction *self); int8_t RabbitizerInstruction_getDestinationGpr(const RabbitizerInstruction *self);
NODISCARD NON_NULL(1) PURE NODISCARD NON_NULL(1) PURE

View File

@ -312,7 +312,7 @@ static PyObject *rabbitizer_type_Instruction_getGenericBranchOffset(PyRabbitizer
} }
DEF_METHOD_GET_INT(getBranchOffsetGeneric) DEF_METHOD_GET_INT(getBranchOffsetGeneric)
DEF_METHOD_GET_INT(getBranchVramGeneric) DEF_METHOD_GET_UINT(getBranchVramGeneric)
static PyObject *rabbitizer_type_Instruction_getDestinationGpr(PyRabbitizerInstruction *self, UNUSED PyObject *closure) { static PyObject *rabbitizer_type_Instruction_getDestinationGpr(PyRabbitizerInstruction *self, UNUSED PyObject *closure) {
int8_t reg = RabbitizerInstruction_getDestinationGpr(&self->instr); int8_t reg = RabbitizerInstruction_getDestinationGpr(&self->instr);

View File

@ -69,7 +69,7 @@ extern "C" {
fn RabbitizerInstruction_getBranchOffset(self_: *const Instruction) -> i32; fn RabbitizerInstruction_getBranchOffset(self_: *const Instruction) -> i32;
fn RabbitizerInstruction_getBranchOffsetGeneric(self_: *const Instruction) -> i32; fn RabbitizerInstruction_getBranchOffsetGeneric(self_: *const Instruction) -> i32;
fn RabbitizerInstruction_getBranchVramGeneric(self_: *const Instruction) -> i32; fn RabbitizerInstruction_getBranchVramGeneric(self_: *const Instruction) -> u32;
fn RabbitizerInstruction_getDestinationGpr(self_: *const Instruction) -> i8; fn RabbitizerInstruction_getDestinationGpr(self_: *const Instruction) -> i8;
fn RabbitizerInstruction_outputsToGprZero(self_: *const Instruction) -> bool; fn RabbitizerInstruction_outputsToGprZero(self_: *const Instruction) -> bool;
fn RabbitizerInstruction_blankOut(self_: *mut Instruction); fn RabbitizerInstruction_blankOut(self_: *mut Instruction);
@ -491,7 +491,7 @@ impl Instruction {
unsafe { RabbitizerInstruction_getBranchOffsetGeneric(self) } unsafe { RabbitizerInstruction_getBranchOffsetGeneric(self) }
} }
pub fn branch_vram_generic(&self) -> i32 { pub fn branch_vram_generic(&self) -> u32 {
unsafe { RabbitizerInstruction_getBranchVramGeneric(self) } unsafe { RabbitizerInstruction_getBranchVramGeneric(self) }
} }
pub fn destination_gpr(&self) -> Option<u32> { pub fn destination_gpr(&self) -> Option<u32> {

View File

@ -76,7 +76,7 @@ int32_t RabbitizerInstruction_getBranchOffsetGeneric(const RabbitizerInstruction
return RabbitizerInstruction_getBranchOffset(self); return RabbitizerInstruction_getBranchOffset(self);
} }
int32_t RabbitizerInstruction_getBranchVramGeneric(const RabbitizerInstruction *self) { uint32_t RabbitizerInstruction_getBranchVramGeneric(const RabbitizerInstruction *self) {
if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_cpu_label)) { if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_cpu_label)) {
return RabbitizerInstruction_getInstrIndexAsVram(self); return RabbitizerInstruction_getInstrIndexAsVram(self);
} }