isJumpWithAddress

This commit is contained in:
angie 2022-10-13 14:32:36 -03:00
parent b5f4df9c1a
commit faaf017aef
8 changed files with 21 additions and 1 deletions

View File

@ -206,6 +206,7 @@ namespace rabbitizer {
bool isBranch() const;
bool isBranchLikely() const;
bool isJump() const;
bool isJumpWithAddress() const;
bool isTrap() const;
bool isFloat() const;

View File

@ -797,6 +797,9 @@ bool InstructionBase::isBranchLikely() const {
bool InstructionBase::isJump() const {
return RabbitizerInstrDescriptor_isJump(this->instr.descriptor);
}
bool InstructionBase::isJumpWithAddress() const {
return RabbitizerInstrDescriptor_isJumpWithAddress(this->instr.descriptor);
}
bool InstructionBase::isTrap() const {
return RabbitizerInstrDescriptor_isTrap(this->instr.descriptor);
}

View File

@ -50,6 +50,10 @@ typedef struct RabbitizerInstrDescriptor {
* The instruction can jump inside or outside its current function
*/
bool isJump;
/**
* The target address of this jump is encoded in the instruction (MIPS: J and JAL)
*/
bool isJumpWithAddress;
/**
* Triggers a trap on the processor
*/
@ -149,6 +153,8 @@ bool RabbitizerInstrDescriptor_isBranchLikely(const RabbitizerInstrDescriptor *s
NODISCARD NON_NULL(1) PURE
bool RabbitizerInstrDescriptor_isJump(const RabbitizerInstrDescriptor *self);
NODISCARD NON_NULL(1) PURE
bool RabbitizerInstrDescriptor_isJumpWithAddress(const RabbitizerInstrDescriptor *self);
NODISCARD NON_NULL(1) PURE
bool RabbitizerInstrDescriptor_isTrap(const RabbitizerInstrDescriptor *self);
NODISCARD NON_NULL(1) PURE

View File

@ -7,6 +7,7 @@ RABBITIZER_DEF_INSTR_ID(
.operands={RAB_OPERAND_cpu_label},
.instrType=RABBITIZER_INSTR_TYPE_J,
.isJump=true,
.isJumpWithAddress=true,
.architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I
) // Jump
RABBITIZER_DEF_INSTR_ID(
@ -14,6 +15,7 @@ RABBITIZER_DEF_INSTR_ID(
.operands={RAB_OPERAND_cpu_label},
.instrType=RABBITIZER_INSTR_TYPE_J,
.isJump=true,
.isJumpWithAddress=true,
.doesLink=true,
.architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I
) // Jump And Link

View File

@ -6,13 +6,15 @@ RABBITIZER_DEF_INSTR_ID(
rsp, 0x02, j,
.operands={RAB_OPERAND_cpu_label},
.instrType=RABBITIZER_INSTR_TYPE_J,
.isJump=true
.isJump=true,
.isJumpWithAddress=true
) // Jump
RABBITIZER_DEF_INSTR_ID(
rsp, 0x03, jal,
.operands={RAB_OPERAND_cpu_label},
.instrType=RABBITIZER_INSTR_TYPE_J,
.isJump=true,
.isJumpWithAddress=true,
.doesLink=true
) // Jump And Link

View File

@ -75,6 +75,7 @@ class Instruction:
def isBranch(self) -> bool: ...
def isBranchLikely(self) -> bool: ...
def isJump(self) -> bool: ...
def isJumpWithAddress(self) -> bool: ...
def isTrap(self) -> bool: ...
def isFloat(self) -> bool: ...
def isDouble(self) -> bool: ...

View File

@ -245,6 +245,7 @@ DEF_DESCRIPTOR_METHOD_BOOL(isRegimmType)
DEF_DESCRIPTOR_METHOD_BOOL(isBranch)
DEF_DESCRIPTOR_METHOD_BOOL(isBranchLikely)
DEF_DESCRIPTOR_METHOD_BOOL(isJump)
DEF_DESCRIPTOR_METHOD_BOOL(isJumpWithAddress)
DEF_DESCRIPTOR_METHOD_BOOL(isTrap)
DEF_DESCRIPTOR_METHOD_BOOL(isFloat)
DEF_DESCRIPTOR_METHOD_BOOL(isDouble)
@ -351,6 +352,7 @@ static PyMethodDef rabbitizer_type_Instruction_methods[] = {
METHOD_NO_ARGS(isBranch, ""),
METHOD_NO_ARGS(isBranchLikely, ""),
METHOD_NO_ARGS(isJump, ""),
METHOD_NO_ARGS(isJumpWithAddress, ""),
METHOD_NO_ARGS(isTrap, ""),
METHOD_NO_ARGS(isFloat, ""),
METHOD_NO_ARGS(isDouble, ""),

View File

@ -47,6 +47,9 @@ bool RabbitizerInstrDescriptor_isBranchLikely(const RabbitizerInstrDescriptor *s
bool RabbitizerInstrDescriptor_isJump(const RabbitizerInstrDescriptor *self) {
return self->isJump;
}
bool RabbitizerInstrDescriptor_isJumpWithAddress(const RabbitizerInstrDescriptor *self) {
return self->isJumpWithAddress;
}
bool RabbitizerInstrDescriptor_isTrap(const RabbitizerInstrDescriptor *self) {
return self->isTrap;
}