mirror of
https://github.com/Decompollaborate/rabbitizer.git
synced 2024-12-29 09:22:02 +00:00
Remove getImmediate and getInstrIndex
This commit is contained in:
parent
91f30645e8
commit
34f2e2e6a5
@ -170,13 +170,9 @@ void RabbitizerInstruction_processUniqueId(RabbitizerInstruction *self);
|
||||
NODISCARD NON_NULL(1) PURE
|
||||
uint32_t RabbitizerInstruction_getRaw(const RabbitizerInstruction *self);
|
||||
|
||||
NODISCARD NON_NULL(1) PURE
|
||||
uint32_t RabbitizerInstruction_getImmediate(const RabbitizerInstruction *self);
|
||||
NODISCARD NON_NULL(1) PURE
|
||||
int32_t RabbitizerInstruction_getProcessedImmediate(const RabbitizerInstruction *self);
|
||||
NODISCARD NON_NULL(1) PURE
|
||||
uint32_t RabbitizerInstruction_getInstrIndex(const RabbitizerInstruction *self);
|
||||
NODISCARD NON_NULL(1) PURE
|
||||
uint32_t RabbitizerInstruction_getInstrIndexAsVram(const RabbitizerInstruction *self);
|
||||
|
||||
NODISCARD NON_NULL(1) PURE
|
||||
|
@ -44,6 +44,7 @@ class Instruction:
|
||||
def __init__(self, word: int, vram: int=0, category: Enum=InstrCategory.CPU) -> None: ...
|
||||
|
||||
def getRaw(self) -> int: ...
|
||||
#! deprecated
|
||||
def getImmediate(self) -> int: ...
|
||||
def getProcessedImmediate(self) -> int: ...
|
||||
def getInstrIndexAsVram(self) -> int: ...
|
||||
|
@ -68,7 +68,7 @@ static PyMemberDef rabbitizer_type_Instruction_members[] = {
|
||||
|
||||
|
||||
#define DEF_MEMBER_GET_UINT(name) \
|
||||
static PyObject *rabbitizer_type_Instruction_member_get_##name(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) { \
|
||||
static PyObject *rabbitizer_type_Instruction_member_get_##name(PyRabbitizerInstruction *self, UNUSED PyObject *closure) { \
|
||||
return PyLong_FromUnsignedLong(RAB_INSTR_GET_##name(&self->instr)); \
|
||||
}
|
||||
|
||||
@ -109,7 +109,7 @@ DEF_MEMBER_GET_REGGPR(rd)
|
||||
|
||||
DEF_MEMBER_GET_UINT(sa)
|
||||
|
||||
static PyObject *rabbitizer_type_Instruction_member_get_uniqueId(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) {
|
||||
static PyObject *rabbitizer_type_Instruction_member_get_uniqueId(PyRabbitizerInstruction *self, UNUSED PyObject *closure) {
|
||||
PyObject *enumInstance = rabbitizer_enum_InstrId_enumvalues[self->instr.uniqueId].instance;
|
||||
|
||||
if (enumInstance == NULL) {
|
||||
@ -138,17 +138,19 @@ static PyGetSetDef rabbitizer_type_Instruction_getsetters[] = {
|
||||
|
||||
|
||||
#define DEF_METHOD_GET_UINT(name) \
|
||||
static PyObject *rabbitizer_type_Instruction_##name(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) { \
|
||||
static PyObject *rabbitizer_type_Instruction_##name(PyRabbitizerInstruction *self, UNUSED PyObject *closure) { \
|
||||
return PyLong_FromUnsignedLong(RabbitizerInstruction_##name(&self->instr)); \
|
||||
}
|
||||
|
||||
#define DEF_METHOD_GET_INT(name) \
|
||||
static PyObject *rabbitizer_type_Instruction_##name(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) { \
|
||||
static PyObject *rabbitizer_type_Instruction_##name(PyRabbitizerInstruction *self, UNUSED PyObject *closure) { \
|
||||
return PyLong_FromLong(RabbitizerInstruction_##name(&self->instr)); \
|
||||
}
|
||||
|
||||
DEF_METHOD_GET_UINT(getRaw)
|
||||
DEF_METHOD_GET_UINT(getImmediate)
|
||||
static PyObject *rabbitizer_type_Instruction_getImmediate(PyRabbitizerInstruction *self, UNUSED PyObject *closure) {
|
||||
return PyLong_FromUnsignedLong(RAB_INSTR_GET_immediate(&self->instr));
|
||||
}
|
||||
DEF_METHOD_GET_INT(getProcessedImmediate)
|
||||
DEF_METHOD_GET_UINT(getInstrIndexAsVram)
|
||||
DEF_METHOD_GET_INT(getBranchOffset)
|
||||
@ -168,14 +170,14 @@ static PyObject *rabbitizer_type_Instruction_getGenericBranchOffset(PyRabbitizer
|
||||
return PyLong_FromLong(RabbitizerInstruction_getGenericBranchOffset(&self->instr, currentVram));
|
||||
}
|
||||
|
||||
static PyObject *rabbitizer_type_Instruction_blankOut(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) {
|
||||
static PyObject *rabbitizer_type_Instruction_blankOut(PyRabbitizerInstruction *self, UNUSED PyObject *closure) {
|
||||
RabbitizerInstruction_blankOut(&self->instr);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
||||
#define DEF_METHOD_BOOL(name) \
|
||||
static PyObject *rabbitizer_type_Instruction_##name(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) { \
|
||||
static PyObject *rabbitizer_type_Instruction_##name(PyRabbitizerInstruction *self, UNUSED PyObject *closure) { \
|
||||
if (RabbitizerInstruction_##name(&self->instr)) { \
|
||||
Py_RETURN_TRUE; \
|
||||
} \
|
||||
@ -190,7 +192,7 @@ DEF_METHOD_BOOL(isJrRa)
|
||||
DEF_METHOD_BOOL(isJrNotRa)
|
||||
DEF_METHOD_BOOL(hasDelaySlot)
|
||||
|
||||
static PyObject *rabbitizer_type_Instruction_mapInstrToType(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) {
|
||||
static PyObject *rabbitizer_type_Instruction_mapInstrToType(PyRabbitizerInstruction *self, UNUSED PyObject *closure) {
|
||||
const char *type = RabbitizerInstruction_mapInstrToType(&self->instr);
|
||||
|
||||
if (type != NULL) {
|
||||
@ -292,7 +294,7 @@ static PyObject *rabbitizer_type_Instruction_hasOperandAlias(PyRabbitizerInstruc
|
||||
DEF_METHOD_BOOL(isValid)
|
||||
|
||||
#define DEF_DESCRIPTOR_METHOD_BOOL(name) \
|
||||
static PyObject *rabbitizer_type_Instruction_##name(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) { \
|
||||
static PyObject *rabbitizer_type_Instruction_##name(PyRabbitizerInstruction *self, UNUSED PyObject *closure) { \
|
||||
if (RabbitizerInstrDescriptor_##name(self->instr.descriptor)) { \
|
||||
Py_RETURN_TRUE; \
|
||||
} \
|
||||
|
@ -259,7 +259,7 @@ void RabbitizerRegistersTracker_processLui(RabbitizerRegistersTracker *self, con
|
||||
|
||||
state = &self->registers[RAB_INSTR_GET_rt(instr)];
|
||||
RabbitizerTrackedRegisterState_clear(state);
|
||||
RabbitizerTrackedRegisterState_setHi(state, RabbitizerInstruction_getImmediate(instr), instrOffset);
|
||||
RabbitizerTrackedRegisterState_setHi(state, RabbitizerInstruction_getProcessedImmediate(instr), instrOffset);
|
||||
|
||||
if (prevInstr != NULL) {
|
||||
// If the previous instructions is a branch likely, then nulify
|
||||
@ -276,7 +276,7 @@ void RabbitizerRegistersTracker_processGpLoad(RabbitizerRegistersTracker *self,
|
||||
state = &self->registers[RAB_INSTR_GET_rt(instr)];
|
||||
|
||||
RabbitizerTrackedRegisterState_clear(state);
|
||||
RabbitizerTrackedRegisterState_setGpLoad(state, RabbitizerInstruction_getImmediate(instr), instrOffset);
|
||||
RabbitizerTrackedRegisterState_setGpLoad(state, RabbitizerInstruction_getProcessedImmediate(instr), instrOffset);
|
||||
}
|
||||
|
||||
bool RabbitizerRegistersTracker_getLuiOffsetForConstant(const RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int *dstOffset) {
|
||||
|
@ -32,9 +32,6 @@ uint32_t RabbitizerInstruction_getRaw(const RabbitizerInstruction *self) {
|
||||
return self->word;
|
||||
}
|
||||
|
||||
uint32_t RabbitizerInstruction_getImmediate(const RabbitizerInstruction *self) {
|
||||
return RAB_INSTR_GET_immediate(self);
|
||||
}
|
||||
int32_t RabbitizerInstruction_getProcessedImmediate(const RabbitizerInstruction *self) {
|
||||
if (RabbitizerInstrDescriptor_isUnsigned(self->descriptor)) {
|
||||
return RAB_INSTR_GET_immediate(self);
|
||||
@ -42,12 +39,8 @@ int32_t RabbitizerInstruction_getProcessedImmediate(const RabbitizerInstruction
|
||||
return RabbitizerUtils_From2Complement(RAB_INSTR_GET_immediate(self), 16);
|
||||
}
|
||||
|
||||
uint32_t RabbitizerInstruction_getInstrIndex(const RabbitizerInstruction *self) {
|
||||
return RAB_INSTR_GET_instr_index(self);
|
||||
}
|
||||
|
||||
uint32_t RabbitizerInstruction_getInstrIndexAsVram(const RabbitizerInstruction *self) {
|
||||
uint32_t vram = RabbitizerInstruction_getInstrIndex(self) << 2;
|
||||
uint32_t vram = RAB_INSTR_GET_instr_index(self) << 2;
|
||||
|
||||
if (self->vram == 0) {
|
||||
vram |= 0x80000000;
|
||||
@ -59,7 +52,7 @@ uint32_t RabbitizerInstruction_getInstrIndexAsVram(const RabbitizerInstruction *
|
||||
}
|
||||
|
||||
int32_t RabbitizerInstruction_getBranchOffset(const RabbitizerInstruction *self) {
|
||||
int32_t diff = RabbitizerUtils_From2Complement(RabbitizerInstruction_getImmediate(self), 16);
|
||||
int32_t diff = RabbitizerUtils_From2Complement(RAB_INSTR_GET_immediate(self), 16);
|
||||
|
||||
return diff * 4 + 4;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user