mirror of
https://github.com/Decompollaborate/rabbitizer.git
synced 2025-01-03 23:36:57 +00:00
Prioritize moving when one register has value and the other doesn't
This commit is contained in:
parent
917a24808f
commit
7cd1f136a0
@ -28,6 +28,7 @@ void RabbitizerRegistersTracker_destroy(RabbitizerRegistersTracker *self) {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: simplify logic
|
||||
bool RabbitizerRegistersTracker_moveRegisters(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr) {
|
||||
RabbitizerTrackedRegisterState *dstState;
|
||||
RabbitizerTrackedRegisterState *srcState;
|
||||
@ -50,8 +51,11 @@ bool RabbitizerRegistersTracker_moveRegisters(RabbitizerRegistersTracker *self,
|
||||
} else if (rs == 0) {
|
||||
reg = rt;
|
||||
} else {
|
||||
// Check stuff like `addu $3, $3, $2`
|
||||
if (rd == rs) {
|
||||
if (RabbitizerTrackedRegisterState_hasAnyValue(&self->registers[rs]) && !RabbitizerTrackedRegisterState_hasAnyValue(&self->registers[rt])) {
|
||||
reg = rs;
|
||||
} else if (RabbitizerTrackedRegisterState_hasAnyValue(&self->registers[rt]) && !RabbitizerTrackedRegisterState_hasAnyValue(&self->registers[rs])) {
|
||||
reg = rt;
|
||||
} else if (rd == rs) { // Check stuff like `addu $3, $3, $2`
|
||||
reg = rt;
|
||||
if (self->registers[rs].hasLuiValue || self->registers[rs].hasGpGot) {
|
||||
reg = rs;
|
||||
@ -75,7 +79,7 @@ bool RabbitizerRegistersTracker_moveRegisters(RabbitizerRegistersTracker *self,
|
||||
srcState = &self->registers[reg];
|
||||
dstState = &self->registers[rd];
|
||||
|
||||
if (srcState->hasLoValue || srcState->hasLuiValue || srcState->hasGpGot) {
|
||||
if (RabbitizerTrackedRegisterState_hasAnyValue(srcState)) {
|
||||
RabbitizerTrackedRegisterState_copyState(dstState, srcState);
|
||||
return true;
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ void RabbitizerTrackedRegisterState_dereferenceState(RabbitizerTrackedRegisterSt
|
||||
}
|
||||
|
||||
bool RabbitizerTrackedRegisterState_hasAnyValue(const RabbitizerTrackedRegisterState *self) {
|
||||
return self->hasLuiValue || self->hasLoValue;
|
||||
return self->hasLuiValue || self->hasLoValue || self->hasGpGot;
|
||||
}
|
||||
|
||||
bool RabbitizerTrackedRegisterState_wasSetInCurrentOffset(const RabbitizerTrackedRegisterState *self, int offset) {
|
||||
|
Loading…
Reference in New Issue
Block a user