mirror of
https://github.com/Decompollaborate/rabbitizer.git
synced 2025-03-14 13:21:28 +00:00
introduce macros for reading the bits from the instruction word
This commit is contained in:
parent
8ec7d72b79
commit
d0b39c6f8c
@ -41,8 +41,28 @@ typedef struct RabbitizerInstruction {
|
||||
RabbitizerInstrCategory category;
|
||||
} RabbitizerInstruction;
|
||||
|
||||
#define RAB_INSTR_GET_IMMEDIATE(self) (((self)->rd << 11) | ((self)->sa << 6) | ((self)->function))
|
||||
#define RAB_INSTR_GET_opcode(self) ((self)->opcode)
|
||||
#define RAB_INSTR_GET_rs(self) ((self)->rs)
|
||||
#define RAB_INSTR_GET_rt(self) ((self)->rt)
|
||||
#define RAB_INSTR_GET_rd(self) ((self)->rd)
|
||||
#define RAB_INSTR_GET_sa(self) ((self)->sa)
|
||||
#define RAB_INSTR_GET_function(self) ((self)->function)
|
||||
|
||||
#define RAB_INSTR_GET_instr_index(self) (((self)->rs << 21) | ((self)->rt << 16) | ((self)->rd << 11) | ((self)->sa << 6) | ((self)->function))
|
||||
#define RAB_INSTR_GET_immediate(self) (((self)->rd << 11) | ((self)->sa << 6) | ((self)->function))
|
||||
|
||||
#define RAB_INSTR_GET_fs(self) ((self)->rd)
|
||||
#define RAB_INSTR_GET_ft(self) ((self)->rt)
|
||||
#define RAB_INSTR_GET_fd(self) ((self)->sa)
|
||||
|
||||
#define RAB_INSTR_GET_op(self) ((self)->rt)
|
||||
#define RAB_INSTR_GET_fmt(self) ((self)->rs)
|
||||
#define RAB_INSTR_GET_fc(self) (((self)->function >> 4) & 0x3)
|
||||
#define RAB_INSTR_GET_cond(self) ((self)->function & 0xF)
|
||||
|
||||
#define RAB_INSTR_GET_cop0d(self) ((self)->rd)
|
||||
|
||||
#define RAB_INSTR_GET_cop2t(self) ((self)->rt)
|
||||
|
||||
void RabbitizerInstruction_init(RabbitizerInstruction *self, uint32_t word);
|
||||
void RabbitizerInstruction_destroy(RabbitizerInstruction* self);
|
||||
|
@ -14,7 +14,9 @@
|
||||
|
||||
#define RAB_INSTR_RSP_GET_ELEMENT_HIGH(self) ((((self)->rs)) & 0xF)
|
||||
#define RAB_INSTR_RSP_GET_ELEMENT_LOW(self) ((((self)->sa) >> 1) & 0xF)
|
||||
#define RAB_INSTR_RSP_GET_OFFSET_VECTOR_RAW(self) (RAB_INSTR_GET_IMMEDIATE(self) & 0x7F)
|
||||
#define RAB_INSTR_RSP_GET_OFFSET_VECTOR_RAW(self) (RAB_INSTR_GET_immediate(self) & 0x7F)
|
||||
|
||||
#define RAB_INSTR_RSP_GET_index(self) ((self)->sa >> 1)
|
||||
|
||||
|
||||
void RabbitizerInstructionRsp_init(RabbitizerInstruction *self, uint32_t word);
|
||||
|
@ -35,13 +35,13 @@ void RabbitizerInstruction_destroy(RabbitizerInstruction *self) {
|
||||
/* Register getters */
|
||||
|
||||
uint8_t RabbitizerInstruction_getFs(const RabbitizerInstruction *self) {
|
||||
return self->rd;
|
||||
return RAB_INSTR_GET_fs(self);
|
||||
}
|
||||
uint8_t RabbitizerInstruction_getFt(const RabbitizerInstruction *self) {
|
||||
return self->rt;
|
||||
return RAB_INSTR_GET_ft(self);
|
||||
}
|
||||
uint8_t RabbitizerInstruction_getFd(const RabbitizerInstruction *self) {
|
||||
return self->sa;
|
||||
return RAB_INSTR_GET_fd(self);
|
||||
}
|
||||
|
||||
/* Register getters */
|
||||
@ -50,20 +50,20 @@ uint8_t RabbitizerInstruction_getFd(const RabbitizerInstruction *self) {
|
||||
/* Coprocessor stuffs */
|
||||
|
||||
uint8_t RabbitizerInstruction_getFmt(const RabbitizerInstruction *self) {
|
||||
return self->rs;
|
||||
return RAB_INSTR_GET_fmt(self);
|
||||
}
|
||||
|
||||
uint8_t RabbitizerInstruction_getTf(const RabbitizerInstruction *self) {
|
||||
return self->rt & 0x1;
|
||||
return RAB_INSTR_GET_rt(self) & 0x1;
|
||||
}
|
||||
uint8_t RabbitizerInstruction_getNd(const RabbitizerInstruction *self) {
|
||||
return (self->rt >> 1) & 0x1;
|
||||
return (RAB_INSTR_GET_rt(self) >> 1) & 0x1;
|
||||
}
|
||||
uint8_t RabbitizerInstruction_getFc(const RabbitizerInstruction *self) {
|
||||
return (self->function >> 4) & 0x3;
|
||||
return RAB_INSTR_GET_fc(self);
|
||||
}
|
||||
uint8_t RabbitizerInstruction_getCond(const RabbitizerInstruction *self) {
|
||||
return self->function & 0xF;
|
||||
return RAB_INSTR_GET_cond(self);
|
||||
}
|
||||
|
||||
/* Coprocessor stuffs */
|
||||
@ -76,12 +76,11 @@ uint32_t RabbitizerInstruction_getRaw(const RabbitizerInstruction *self) {
|
||||
}
|
||||
|
||||
uint32_t RabbitizerInstruction_getImmediate(const RabbitizerInstruction *self) {
|
||||
//return (self->rd << 11) | (self->sa << 6) | (self->function);
|
||||
return RAB_INSTR_GET_IMMEDIATE(self);
|
||||
return RAB_INSTR_GET_immediate(self);
|
||||
}
|
||||
|
||||
uint32_t RabbitizerInstruction_getInstrIndex(const RabbitizerInstruction *self) {
|
||||
return (self->rs << 21) | (self->rt << 16) | (self->rd << 11) | (self->sa << 6) | (self->function);
|
||||
return RAB_INSTR_GET_instr_index(self);
|
||||
}
|
||||
|
||||
uint32_t RabbitizerInstruction_getInstrIndexAsVram(const RabbitizerInstruction *self) {
|
||||
|
@ -46,7 +46,7 @@ typedef size_t (*OperandCallback)(const RabbitizerInstruction *self, char *dst,
|
||||
|
||||
size_t RabbitizerOperandType_processRs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
const char *reg = RabbitizerRegister_getNameGpr(self->rs);
|
||||
const char *reg = RabbitizerRegister_getNameGpr(RAB_INSTR_GET_rs(self));
|
||||
|
||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||
return totalSize;
|
||||
@ -54,7 +54,7 @@ size_t RabbitizerOperandType_processRs(const RabbitizerInstruction *self, char *
|
||||
|
||||
size_t RabbitizerOperandType_processRt(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
const char *reg = RabbitizerRegister_getNameGpr(self->rt);
|
||||
const char *reg = RabbitizerRegister_getNameGpr(RAB_INSTR_GET_rt(self));
|
||||
|
||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||
return totalSize;
|
||||
@ -62,7 +62,7 @@ size_t RabbitizerOperandType_processRt(const RabbitizerInstruction *self, char *
|
||||
|
||||
size_t RabbitizerOperandType_processRd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
const char *reg = RabbitizerRegister_getNameGpr(self->rd);
|
||||
const char *reg = RabbitizerRegister_getNameGpr(RAB_INSTR_GET_rd(self));
|
||||
|
||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||
return totalSize;
|
||||
@ -70,7 +70,7 @@ size_t RabbitizerOperandType_processRd(const RabbitizerInstruction *self, char *
|
||||
|
||||
size_t RabbitizerOperandType_processCop0d(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
const char *reg = RabbitizerRegister_getNameCop0(self->rd);
|
||||
const char *reg = RabbitizerRegister_getNameCop0(RAB_INSTR_GET_cop0d(self));
|
||||
|
||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||
return totalSize;
|
||||
@ -110,7 +110,7 @@ size_t RabbitizerOperandType_processCop1Cs(const RabbitizerInstruction *self, ch
|
||||
|
||||
size_t RabbitizerOperandType_processCop2t(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
const char *reg = RabbitizerRegister_getNameCop2(self->rt);
|
||||
const char *reg = RabbitizerRegister_getNameCop2(RAB_INSTR_GET_cop2t(self));
|
||||
|
||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||
return totalSize;
|
||||
@ -119,21 +119,21 @@ size_t RabbitizerOperandType_processCop2t(const RabbitizerInstruction *self, cha
|
||||
size_t RabbitizerOperandType_processSa(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
|
||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", self->sa);
|
||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", RAB_INSTR_GET_sa(self));
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
size_t RabbitizerOperandType_processOp(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
|
||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%02X", self->rt);
|
||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%02X", RAB_INSTR_GET_op(self));
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
size_t RabbitizerOperandType_processCode(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
int code = (self->rs << 5) | (self->rt);
|
||||
int lower = (self->rd << 5) | (self->sa);
|
||||
int code = (RAB_INSTR_GET_rs(self) << 5) | (RAB_INSTR_GET_rt(self));
|
||||
int lower = (RAB_INSTR_GET_rd(self) << 5) | (RAB_INSTR_GET_sa(self));
|
||||
|
||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", code);
|
||||
if (lower) {
|
||||
@ -193,7 +193,7 @@ size_t RabbitizerOperandType_processImmediateBase(const RabbitizerInstruction *s
|
||||
|
||||
size_t RabbitizerOperandTypeRsp_processRs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
const char *reg = RabbitizerRegister_getNameRspGpr(self->rs);
|
||||
const char *reg = RabbitizerRegister_getNameRspGpr(RAB_INSTR_GET_rs(self));
|
||||
|
||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||
return totalSize;
|
||||
@ -201,7 +201,7 @@ size_t RabbitizerOperandTypeRsp_processRs(const RabbitizerInstruction *self, cha
|
||||
|
||||
size_t RabbitizerOperandTypeRsp_processRt(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
const char *reg = RabbitizerRegister_getNameRspGpr(self->rt);
|
||||
const char *reg = RabbitizerRegister_getNameRspGpr(RAB_INSTR_GET_rt(self));
|
||||
|
||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||
return totalSize;
|
||||
@ -209,7 +209,7 @@ size_t RabbitizerOperandTypeRsp_processRt(const RabbitizerInstruction *self, cha
|
||||
|
||||
size_t RabbitizerOperandTypeRsp_processRd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
const char *reg = RabbitizerRegister_getNameRspVector(self->rd);
|
||||
const char *reg = RabbitizerRegister_getNameRspVector(RAB_INSTR_GET_rd(self));
|
||||
|
||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||
return totalSize;
|
||||
@ -217,7 +217,7 @@ size_t RabbitizerOperandTypeRsp_processRd(const RabbitizerInstruction *self, cha
|
||||
|
||||
size_t RabbitizerOperandTypeRsp_processCop0d(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) {
|
||||
size_t totalSize = 0;
|
||||
const char *reg = RabbitizerRegister_getNameRspCop0(self->rd);
|
||||
const char *reg = RabbitizerRegister_getNameRspCop0(RAB_INSTR_GET_cop0d(self));
|
||||
|
||||
RABUTILS_BUFFER_CPY(dst, totalSize, reg);
|
||||
return totalSize;
|
||||
@ -285,7 +285,7 @@ size_t RabbitizerOperandTypeRsp_processVdIndex(const RabbitizerInstruction *self
|
||||
|
||||
RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandTypeRsp_processVd(self, dst, immOverride, immOverrideLength));
|
||||
|
||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", (self->sa >> 1));
|
||||
RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", RAB_INSTR_RSP_GET_index(self));
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
@ -461,22 +461,22 @@ bool RabbitizerInstruction_mustDisasmAsData(const RabbitizerInstruction *self) {
|
||||
|
||||
if (!hasCode) {
|
||||
if (!hasRs) {
|
||||
if (self->rs != 0) {
|
||||
if (RAB_INSTR_GET_rs(self) != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!hasRt) {
|
||||
if (self->rt != 0) {
|
||||
if (RAB_INSTR_GET_rt(self) != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!hasRd) {
|
||||
if (self->rd != 0 && self->uniqueId != RABBITIZER_INSTR_ID_cpu_jalr) {
|
||||
if (RAB_INSTR_GET_rd(self) != 0 && self->uniqueId != RABBITIZER_INSTR_ID_cpu_jalr) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!hasSa) {
|
||||
if (self->sa != 0) {
|
||||
if (RAB_INSTR_GET_sa(self) != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -486,7 +486,6 @@ bool RabbitizerInstruction_mustDisasmAsData(const RabbitizerInstruction *self) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t RabbitizerInstruction_getSizeForBuffer(const RabbitizerInstruction *self, size_t immOverrideLength, int extraLJust) {
|
||||
if (!RabbitizerInstruction_isImplemented(self) || RabbitizerInstruction_mustDisasmAsData(self)) {
|
||||
size_t totalSize = RabbitizerInstruction_getSizeForBufferDataDisasm(self, extraLJust);
|
||||
|
@ -23,10 +23,10 @@ bool RabbitizerInstruction_isLikelyHandwritten(const RabbitizerInstruction *self
|
||||
}
|
||||
|
||||
if (RabbitizerInstrDescriptor_isIType(self->descriptor) && !RabbitizerInstrDescriptor_isFloat(self->descriptor)) {
|
||||
if (self->rs == RABBITIZER_REG_GPR_O32_k0 || self->rs == RABBITIZER_REG_GPR_O32_k1) {
|
||||
if (RAB_INSTR_GET_rs(self) == RABBITIZER_REG_GPR_O32_k0 || RAB_INSTR_GET_rs(self) == RABBITIZER_REG_GPR_O32_k1) {
|
||||
return true;
|
||||
}
|
||||
if (self->rt == RABBITIZER_REG_GPR_O32_k0 || self->rt == RABBITIZER_REG_GPR_O32_k1) {
|
||||
if (RAB_INSTR_GET_rt(self) == RABBITIZER_REG_GPR_O32_k0 || RAB_INSTR_GET_rt(self) == RABBITIZER_REG_GPR_O32_k1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -39,19 +39,19 @@ bool RabbitizerInstruction_isLikelyHandwritten(const RabbitizerInstruction *self
|
||||
}
|
||||
|
||||
bool RabbitizerInstruction_isNop(const RabbitizerInstruction *self) {
|
||||
return self->opcode == 0 &&
|
||||
self->rs == 0 &&
|
||||
self->rt == 0 &&
|
||||
self->rd == 0 &&
|
||||
self->sa == 0 &&
|
||||
self->function == 0;
|
||||
return RAB_INSTR_GET_opcode(self) == 0 &&
|
||||
RAB_INSTR_GET_rs(self) == 0 &&
|
||||
RAB_INSTR_GET_rt(self) == 0 &&
|
||||
RAB_INSTR_GET_rd(self) == 0 &&
|
||||
RAB_INSTR_GET_sa(self) == 0 &&
|
||||
RAB_INSTR_GET_function(self) == 0;
|
||||
}
|
||||
|
||||
bool RabbitizerInstruction_isUnconditionalBranch(const RabbitizerInstruction *self) {
|
||||
if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_b) {
|
||||
return true;
|
||||
}
|
||||
if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_beq && self->rt == 0 && self->rs == 0) {
|
||||
if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_beq && RAB_INSTR_GET_rt(self) == 0 && RAB_INSTR_GET_rs(self) == 0) {
|
||||
return true;
|
||||
}
|
||||
if (RabbitizerConfig_Cfg.toolchainTweaks.treatJAsUnconditionalBranch && self->uniqueId == RABBITIZER_INSTR_ID_cpu_j) {
|
||||
@ -63,7 +63,7 @@ bool RabbitizerInstruction_isUnconditionalBranch(const RabbitizerInstruction *se
|
||||
bool RabbitizerInstruction_isJrRa(const RabbitizerInstruction *self) {
|
||||
if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_jr) {
|
||||
// TODO: abi stuffs
|
||||
return self->rs == RABBITIZER_REG_GPR_O32_ra;
|
||||
return RAB_INSTR_GET_rs(self) == RABBITIZER_REG_GPR_O32_ra;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -71,7 +71,7 @@ bool RabbitizerInstruction_isJrRa(const RabbitizerInstruction *self) {
|
||||
bool RabbitizerInstruction_isJrNotRa(const RabbitizerInstruction *self) {
|
||||
if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_jr) {
|
||||
// TODO: abi stuffs
|
||||
return self->rs != RABBITIZER_REG_GPR_O32_ra;
|
||||
return RAB_INSTR_GET_rs(self) != RABBITIZER_REG_GPR_O32_ra;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
void RabbitizerInstruction_processUniqueId_Normal(RabbitizerInstruction *self) {
|
||||
switch (self->opcode) {
|
||||
switch (RAB_INSTR_GET_opcode(self)) {
|
||||
// 0b000000: "SPECIAL",
|
||||
// 0b000001: "REGIMM",
|
||||
case 0b000010:
|
||||
@ -191,8 +191,8 @@ void RabbitizerInstruction_processUniqueId_Normal(RabbitizerInstruction *self) {
|
||||
if (RabbitizerConfig_Cfg.pseudos.enablePseudos) {
|
||||
switch (self->uniqueId) {
|
||||
case RABBITIZER_INSTR_ID_cpu_beq:
|
||||
if (self->rt == 0) {
|
||||
if (self->rs == 0) {
|
||||
if (RAB_INSTR_GET_rt(self) == 0) {
|
||||
if (RAB_INSTR_GET_rs(self) == 0) {
|
||||
if (RabbitizerConfig_Cfg.pseudos.pseudoB) {
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_cpu_b;
|
||||
}
|
||||
@ -205,7 +205,7 @@ void RabbitizerInstruction_processUniqueId_Normal(RabbitizerInstruction *self) {
|
||||
break;
|
||||
|
||||
case RABBITIZER_INSTR_ID_cpu_bne:
|
||||
if (self->rt == 0) {
|
||||
if (RAB_INSTR_GET_rt(self) == 0) {
|
||||
if (RabbitizerConfig_Cfg.pseudos.pseudoBnez) {
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_cpu_bnez;
|
||||
}
|
||||
@ -222,7 +222,7 @@ void RabbitizerInstruction_processUniqueId_Normal(RabbitizerInstruction *self) {
|
||||
|
||||
|
||||
void RabbitizerInstruction_processUniqueId_Special(RabbitizerInstruction *self) {
|
||||
switch (self->function) {
|
||||
switch (RAB_INSTR_GET_function(self)) {
|
||||
case 0b000000:
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_cpu_sll;
|
||||
break;
|
||||
@ -414,7 +414,7 @@ void RabbitizerInstruction_processUniqueId_Special(RabbitizerInstruction *self)
|
||||
} else if (RabbitizerConfig_Cfg.pseudos.enablePseudos) {
|
||||
switch (self->uniqueId) {
|
||||
case RABBITIZER_INSTR_ID_cpu_or:
|
||||
if (self->rt == 0) {
|
||||
if (RAB_INSTR_GET_rt(self) == 0) {
|
||||
if (RabbitizerConfig_Cfg.pseudos.pseudoMove) {
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_cpu_move;
|
||||
}
|
||||
@ -422,7 +422,7 @@ void RabbitizerInstruction_processUniqueId_Special(RabbitizerInstruction *self)
|
||||
break;
|
||||
|
||||
case RABBITIZER_INSTR_ID_cpu_nor:
|
||||
if (self->rt == 0) {
|
||||
if (RAB_INSTR_GET_rt(self) == 0) {
|
||||
if (RabbitizerConfig_Cfg.pseudos.pseudoNot) {
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_cpu_not;
|
||||
}
|
||||
@ -430,7 +430,7 @@ void RabbitizerInstruction_processUniqueId_Special(RabbitizerInstruction *self)
|
||||
break;
|
||||
|
||||
case RABBITIZER_INSTR_ID_cpu_subu:
|
||||
if (self->rs == 0) {
|
||||
if (RAB_INSTR_GET_rs(self) == 0) {
|
||||
if (RabbitizerConfig_Cfg.pseudos.pseudoNegu) {
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_cpu_negu;
|
||||
}
|
||||
@ -447,11 +447,11 @@ void RabbitizerInstruction_processUniqueId_Special(RabbitizerInstruction *self)
|
||||
switch (self->uniqueId) {
|
||||
case RABBITIZER_INSTR_ID_cpu_jalr:
|
||||
if (RabbitizerConfig_Cfg.regNames.gprAbiNames == RABBITIZER_ABI_NUMERIC || RabbitizerConfig_Cfg.regNames.gprAbiNames == RABBITIZER_ABI_O32) {
|
||||
if (self->rd != RABBITIZER_REG_GPR_O32_ra) {
|
||||
if (RAB_INSTR_GET_rd(self) != RABBITIZER_REG_GPR_O32_ra) {
|
||||
self->descriptor = &RabbitizerInstrDescriptor_Descriptors[RABBITIZER_INSTR_ID_cpu_jalr_rd];
|
||||
}
|
||||
} else {
|
||||
if (self->rd != RABBITIZER_REG_GPR_N32_ra) {
|
||||
if (RAB_INSTR_GET_rd(self) != RABBITIZER_REG_GPR_N32_ra) {
|
||||
self->descriptor = &RabbitizerInstrDescriptor_Descriptors[RABBITIZER_INSTR_ID_cpu_jalr_rd];
|
||||
}
|
||||
}
|
||||
@ -476,7 +476,7 @@ void RabbitizerInstruction_processUniqueId_Special(RabbitizerInstruction *self)
|
||||
|
||||
|
||||
void RabbitizerInstruction_processUniqueId_Regimm(RabbitizerInstruction *self) {
|
||||
switch (self->rt) {
|
||||
switch (RAB_INSTR_GET_rt(self)) {
|
||||
case 0b00000:
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_cpu_bltz;
|
||||
break;
|
||||
@ -574,7 +574,7 @@ void RabbitizerInstruction_processUniqueId_Coprocessor0(RabbitizerInstruction *s
|
||||
break;
|
||||
|
||||
default:
|
||||
switch (self->function) {
|
||||
switch (RAB_INSTR_GET_function(self)) {
|
||||
case 0b000001:
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_cpu_tlbr;
|
||||
break;
|
||||
@ -647,7 +647,7 @@ void RabbitizerInstruction_processUniqueId_Coprocessor1(RabbitizerInstruction *s
|
||||
|
||||
default:
|
||||
fmt = fmt & 0x07;
|
||||
switch (self->function) {
|
||||
switch (RAB_INSTR_GET_function(self)) {
|
||||
case 0b000000:
|
||||
if (fmt == 0) {
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_cpu_add_s;
|
||||
@ -886,7 +886,7 @@ void RabbitizerInstruction_processUniqueId_Coprocessor1(RabbitizerInstruction *s
|
||||
|
||||
} else if (fc == 0b10) {
|
||||
// Convert codes
|
||||
switch (self->function & 0x07) {
|
||||
switch (RAB_INSTR_GET_function(self) & 0x07) {
|
||||
case 0b000:
|
||||
if (fmt == 0b001) {
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_cpu_cvt_s_d;
|
||||
@ -938,7 +938,7 @@ void RabbitizerInstruction_processUniqueId_Coprocessor2(RabbitizerInstruction *s
|
||||
|
||||
|
||||
void RabbitizerInstruction_processUniqueId(RabbitizerInstruction *self) {
|
||||
switch (self->opcode) {
|
||||
switch (RAB_INSTR_GET_opcode(self)) {
|
||||
default:
|
||||
RabbitizerInstruction_processUniqueId_Normal(self);
|
||||
break;
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
void RabbitizerInstructionRsp_processUniqueId_Normal(RabbitizerInstruction *self) {
|
||||
switch (self->opcode) {
|
||||
switch (RAB_INSTR_GET_opcode(self)) {
|
||||
case 0b000010:
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_rsp_j;
|
||||
break;
|
||||
@ -98,7 +98,7 @@ void RabbitizerInstructionRsp_processUniqueId_Normal(RabbitizerInstruction *self
|
||||
|
||||
// new rsp stuff
|
||||
case 0b111010:
|
||||
switch (self->rd) {
|
||||
switch (RAB_INSTR_GET_rd(self)) {
|
||||
case 0b00000:
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_rsp_sbv;
|
||||
break;
|
||||
@ -144,7 +144,7 @@ void RabbitizerInstructionRsp_processUniqueId_Normal(RabbitizerInstruction *self
|
||||
break;
|
||||
|
||||
case 0b110010:
|
||||
switch (self->rd) {
|
||||
switch (RAB_INSTR_GET_rd(self)) {
|
||||
case 0b00000:
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_rsp_lbv;
|
||||
break;
|
||||
@ -187,9 +187,9 @@ void RabbitizerInstructionRsp_processUniqueId_Normal(RabbitizerInstruction *self
|
||||
}
|
||||
|
||||
if (RabbitizerConfig_Cfg.pseudos.enablePseudos) {
|
||||
if (self->rt == 0) {
|
||||
if (RAB_INSTR_GET_rt(self) == 0) {
|
||||
if (self->uniqueId == RABBITIZER_INSTR_ID_rsp_beq) {
|
||||
if (self->rs == 0) {
|
||||
if (RAB_INSTR_GET_rs(self) == 0) {
|
||||
if (RabbitizerConfig_Cfg.pseudos.pseudoB) {
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_rsp_b;
|
||||
}
|
||||
@ -211,7 +211,7 @@ void RabbitizerInstructionRsp_processUniqueId_Normal(RabbitizerInstruction *self
|
||||
|
||||
|
||||
void RabbitizerInstructionRsp_processUniqueId_Special(RabbitizerInstruction *self) {
|
||||
switch (self->function) {
|
||||
switch (RAB_INSTR_GET_function(self)) {
|
||||
case 0b000000:
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_rsp_sll;
|
||||
break;
|
||||
@ -288,7 +288,7 @@ void RabbitizerInstructionRsp_processUniqueId_Special(RabbitizerInstruction *sel
|
||||
// NOP is special enough
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_rsp_nop;
|
||||
} else if (RabbitizerConfig_Cfg.pseudos.enablePseudos) {
|
||||
if (self->rt == 0) {
|
||||
if (RAB_INSTR_GET_rt(self) == 0) {
|
||||
if (self->uniqueId == RABBITIZER_INSTR_ID_rsp_or) {
|
||||
if (RabbitizerConfig_Cfg.pseudos.pseudoMove) {
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_rsp_move;
|
||||
@ -299,7 +299,7 @@ void RabbitizerInstructionRsp_processUniqueId_Special(RabbitizerInstruction *sel
|
||||
}
|
||||
}
|
||||
} else if (self->uniqueId == RABBITIZER_INSTR_ID_rsp_subu) {
|
||||
if (self->rs == 0) {
|
||||
if (RAB_INSTR_GET_rs(self) == 0) {
|
||||
if (RabbitizerConfig_Cfg.pseudos.pseudoNegu) {
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_rsp_negu;
|
||||
}
|
||||
@ -311,7 +311,7 @@ void RabbitizerInstructionRsp_processUniqueId_Special(RabbitizerInstruction *sel
|
||||
|
||||
if (self->uniqueId == RABBITIZER_INSTR_ID_rsp_jalr) {
|
||||
// $ra
|
||||
if (self->rd != 31) {
|
||||
if (RAB_INSTR_GET_rd(self) != 31) {
|
||||
self->descriptor = &RabbitizerInstrDescriptor_Descriptors[RABBITIZER_INSTR_ID_rsp_jalr_rd];
|
||||
}
|
||||
}
|
||||
@ -319,7 +319,7 @@ void RabbitizerInstructionRsp_processUniqueId_Special(RabbitizerInstruction *sel
|
||||
|
||||
|
||||
void RabbitizerInstructionRsp_processUniqueId_Regimm(RabbitizerInstruction *self) {
|
||||
switch (self->rt) {
|
||||
switch (RAB_INSTR_GET_rt(self)) {
|
||||
case 0b00000:
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_rsp_bltz;
|
||||
break;
|
||||
@ -363,7 +363,7 @@ void RabbitizerInstructionRsp_processUniqueId_Coprocessor0(RabbitizerInstruction
|
||||
|
||||
|
||||
void RabbitizerInstructionRsp_processUniqueId_Coprocessor2(RabbitizerInstruction *self) {
|
||||
if (((self->rs >> 4) & 0x1) == 0) {
|
||||
if (((RAB_INSTR_GET_rs(self) >> 4) & 0x1) == 0) {
|
||||
switch (RAB_INSTR_RSP_GET_ELEMENT_HIGH(self)) {
|
||||
case 0b00000:
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_rsp_mfc2;
|
||||
@ -386,7 +386,7 @@ void RabbitizerInstructionRsp_processUniqueId_Coprocessor2(RabbitizerInstruction
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (self->function) {
|
||||
switch (RAB_INSTR_GET_function(self)) {
|
||||
case 0x00:
|
||||
self->uniqueId = RABBITIZER_INSTR_ID_rsp_vmulf;
|
||||
break;
|
||||
@ -533,7 +533,7 @@ void RabbitizerInstructionRsp_processUniqueId_Coprocessor2(RabbitizerInstruction
|
||||
|
||||
|
||||
void RabbitizerInstructionRsp_processUniqueId(RabbitizerInstruction *self) {
|
||||
switch (self->opcode) {
|
||||
switch (RAB_INSTR_GET_opcode(self)) {
|
||||
default:
|
||||
RabbitizerInstructionRsp_processUniqueId_Normal(self);
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user