reads/modifies HI/LO

This commit is contained in:
angie 2022-10-14 14:58:14 -03:00
parent 71d241150f
commit 5d0f9ad8f6
7 changed files with 101 additions and 16 deletions

View File

@ -223,6 +223,11 @@ namespace rabbitizer {
bool modifiesRt() const;
bool modifiesRd() const;
bool readsHI() const;
bool readsLO() const;
bool modifiesHI() const;
bool modifiesLO() const;
bool notEmitedByCompilers() const;
bool canBeHi() const;

View File

@ -846,6 +846,19 @@ bool InstructionBase::modifiesRd() const {
return RabbitizerInstrDescriptor_modifiesRd(this->instr.descriptor);
}
bool InstructionBase::readsHI() const {
return RabbitizerInstrDescriptor_readsHI(this->instr.descriptor);
}
bool InstructionBase::readsLO() const {
return RabbitizerInstrDescriptor_readsLO(this->instr.descriptor);
}
bool InstructionBase::modifiesHI() const {
return RabbitizerInstrDescriptor_modifiesHI(this->instr.descriptor);
}
bool InstructionBase::modifiesLO() const {
return RabbitizerInstrDescriptor_modifiesLO(this->instr.descriptor);
}
bool InstructionBase::notEmitedByCompilers() const {
return RabbitizerInstrDescriptor_notEmitedByCompilers(this->instr.descriptor);
}

View File

@ -76,6 +76,11 @@ typedef struct RabbitizerInstrDescriptor {
*/
bool modifiesRd;
bool readsHI;
bool readsLO;
bool modifiesHI;
bool modifiesLO;
/**
* This instruction is not emited by a C compiler
*/
@ -163,6 +168,15 @@ bool RabbitizerInstrDescriptor_modifiesRt(const RabbitizerInstrDescriptor *self)
NODISCARD NON_NULL(1) PURE
bool RabbitizerInstrDescriptor_modifiesRd(const RabbitizerInstrDescriptor *self);
NODISCARD NON_NULL(1) PURE
bool RabbitizerInstrDescriptor_readsHI(const RabbitizerInstrDescriptor *self);
NODISCARD NON_NULL(1) PURE
bool RabbitizerInstrDescriptor_readsLO(const RabbitizerInstrDescriptor *self);
NODISCARD NON_NULL(1) PURE
bool RabbitizerInstrDescriptor_modifiesHI(const RabbitizerInstrDescriptor *self);
NODISCARD NON_NULL(1) PURE
bool RabbitizerInstrDescriptor_modifiesLO(const RabbitizerInstrDescriptor *self);
NODISCARD NON_NULL(1) PURE
bool RabbitizerInstrDescriptor_notEmitedByCompilers(const RabbitizerInstrDescriptor *self);

View File

@ -99,12 +99,14 @@ RABBITIZER_DEF_INSTR_ID(
RABBITIZER_DEF_INSTR_ID(
cpu, 0x11, mthi,
.operands={RAB_OPERAND_cpu_rs},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesHI=true
) // Move To HI register
RABBITIZER_DEF_INSTR_ID(
cpu, 0x13, mtlo,
.operands={RAB_OPERAND_cpu_rs},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesLO=true
) // Move To LO register
RABBITIZER_DEF_INSTR_ID(
cpu, 0x08, jr,
@ -136,13 +138,15 @@ RABBITIZER_DEF_INSTR_ID(
cpu, 0x10, mfhi,
.operands={RAB_OPERAND_cpu_rd},
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesRd=true
.modifiesRd=true,
.readsHI=true
) // Move From HI register
RABBITIZER_DEF_INSTR_ID(
cpu, 0x12, mflo,
.operands={RAB_OPERAND_cpu_rd},
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesRd=true
.modifiesRd=true,
.readsLO=true
) // Move From LO register
// OP rd, rs, rt
@ -161,48 +165,64 @@ RABBITIZER_DEF_INSTR_ID(
RABBITIZER_DEF_INSTR_ID(
cpu, 0x1A, div,
.operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesHI=true,
.modifiesLO=true
) // DIVide word
RABBITIZER_DEF_INSTR_ID(
cpu, 0x1B, divu,
.operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesHI=true,
.modifiesLO=true
) // DIVide Unsigned word
RABBITIZER_DEF_INSTR_ID_ALTNAME(
cpu, -0x1A, sn64_div, div,
.operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesHI=true,
.modifiesLO=true
) // DIVide word
RABBITIZER_DEF_INSTR_ID_ALTNAME(
cpu, -0x1B, sn64_divu, divu,
.operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesHI=true,
.modifiesLO=true
) // DIVide Unsigned word
RABBITIZER_DEF_INSTR_ID(
cpu, 0x1E, ddiv,
.operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesHI=true,
.modifiesLO=true
) // Doubleword DIVide
RABBITIZER_DEF_INSTR_ID(
cpu, 0x1F, ddivu,
.operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesHI=true,
.modifiesLO=true
) // Doubleword DIVide Unsigned
/*
RABBITIZER_DEF_INSTR_ID(
cpu, , ddiv,
.operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesHI=true,
.modifiesLO=true
)
*/
/*
RABBITIZER_DEF_INSTR_ID(
cpu, , ddivu,
.operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesHI=true,
.modifiesLO=true
)
*/
@ -316,22 +336,30 @@ RABBITIZER_DEF_INSTR_ID(
RABBITIZER_DEF_INSTR_ID(
cpu, 0x18, mult,
.operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesHI=true,
.modifiesLO=true
) // MULTtiply word
RABBITIZER_DEF_INSTR_ID(
cpu, 0x19, multu,
.operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesHI=true,
.modifiesLO=true
) // MULTtiply Unsigned word
RABBITIZER_DEF_INSTR_ID(
cpu, 0x1C, dmult,
.operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesHI=true,
.modifiesLO=true
) // Doubleword MULTiply
RABBITIZER_DEF_INSTR_ID(
cpu, 0x1D, dmultu,
.operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt},
.instrType=RABBITIZER_INSTR_TYPE_R
.instrType=RABBITIZER_INSTR_TYPE_R,
.modifiesHI=true,
.modifiesLO=true
) // Doubleword MULTiply Unsigned
RABBITIZER_DEF_INSTR_ID(

View File

@ -94,6 +94,10 @@ class Instruction:
def isUnsigned(self) -> bool: ...
def modifiesRt(self) -> bool: ...
def modifiesRd(self) -> bool: ...
def readsHI(self) -> bool: ...
def readsLO(self) -> bool: ...
def modifiesHI(self) -> bool: ...
def modifiesLO(self) -> bool: ...
def notEmitedByCompilers(self) -> bool: ...
def canBeHi(self) -> bool: ...
def canBeLo(self) -> bool: ...

View File

@ -353,6 +353,10 @@ DEF_DESCRIPTOR_METHOD_BOOL(isDouble)
DEF_DESCRIPTOR_METHOD_BOOL(isUnsigned)
DEF_DESCRIPTOR_METHOD_BOOL(modifiesRt)
DEF_DESCRIPTOR_METHOD_BOOL(modifiesRd)
DEF_DESCRIPTOR_METHOD_BOOL(readsHI)
DEF_DESCRIPTOR_METHOD_BOOL(readsLO)
DEF_DESCRIPTOR_METHOD_BOOL(modifiesHI)
DEF_DESCRIPTOR_METHOD_BOOL(modifiesLO)
DEF_DESCRIPTOR_METHOD_BOOL(notEmitedByCompilers)
DEF_DESCRIPTOR_METHOD_BOOL(canBeHi)
DEF_DESCRIPTOR_METHOD_BOOL(canBeLo)
@ -474,6 +478,10 @@ static PyMethodDef rabbitizer_type_Instruction_methods[] = {
METHOD_NO_ARGS(isUnsigned, ""),
METHOD_NO_ARGS(modifiesRt, ""),
METHOD_NO_ARGS(modifiesRd, ""),
METHOD_NO_ARGS(readsHI, ""),
METHOD_NO_ARGS(readsLO, ""),
METHOD_NO_ARGS(modifiesHI, ""),
METHOD_NO_ARGS(modifiesLO, ""),
METHOD_NO_ARGS(notEmitedByCompilers, ""),
METHOD_NO_ARGS(canBeHi, ""),
METHOD_NO_ARGS(canBeLo, ""),

View File

@ -72,6 +72,19 @@ bool RabbitizerInstrDescriptor_modifiesRd(const RabbitizerInstrDescriptor *self)
return self->modifiesRd;
}
bool RabbitizerInstrDescriptor_readsHI(const RabbitizerInstrDescriptor *self) {
return self->readsHI;
}
bool RabbitizerInstrDescriptor_readsLO(const RabbitizerInstrDescriptor *self) {
return self->readsLO;
}
bool RabbitizerInstrDescriptor_modifiesHI(const RabbitizerInstrDescriptor *self) {
return self->modifiesHI;
}
bool RabbitizerInstrDescriptor_modifiesLO(const RabbitizerInstrDescriptor *self) {
return self->modifiesLO;
}
bool RabbitizerInstrDescriptor_notEmitedByCompilers(const RabbitizerInstrDescriptor *self) {
return self->notEmitedByCompilers;
}