mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Fixed immediate cmp reorder, offsetted immediate load
This commit is contained in:
parent
40d6195db7
commit
5bf50d658c
2 changed files with 22 additions and 1 deletions
|
@ -2878,6 +2878,14 @@ BeMCOperand BeMCContext::CreateLoad(const BeMCOperand& mcTarget)
|
||||||
return CreateLoad(fakePtr);
|
return CreateLoad(fakePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (HasImmediateTarget(mcTarget))
|
||||||
|
{
|
||||||
|
BeMCOperand scratchReg = AllocVirtualReg(GetType(mcTarget), 2);
|
||||||
|
CreateDefineVReg(scratchReg);
|
||||||
|
AllocInst(BeMCInstKind_Mov, scratchReg, mcTarget);
|
||||||
|
return CreateLoad(scratchReg);
|
||||||
|
}
|
||||||
|
|
||||||
BeMCOperand result;
|
BeMCOperand result;
|
||||||
|
|
||||||
auto loadedTarget = BeMCOperand::ToLoad(mcTarget);
|
auto loadedTarget = BeMCOperand::ToLoad(mcTarget);
|
||||||
|
@ -6026,6 +6034,18 @@ void BeMCContext::GetRMParams(const BeMCOperand& operand, BeRMParamsInfo& rmInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BeMCContext::HasImmediateTarget(const BeMCOperand& operand)
|
||||||
|
{
|
||||||
|
if (operand.IsImmediate())
|
||||||
|
return true;
|
||||||
|
auto vregInfo = GetVRegInfo(operand);
|
||||||
|
if (vregInfo == NULL)
|
||||||
|
return false;
|
||||||
|
if (vregInfo->mRelTo)
|
||||||
|
return HasImmediateTarget(vregInfo->mRelTo);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void BeMCContext::DisableRegister(const BeMCOperand& operand, X64CPURegister reg)
|
void BeMCContext::DisableRegister(const BeMCOperand& operand, X64CPURegister reg)
|
||||||
{
|
{
|
||||||
auto vregInfo = GetVRegInfo(operand);
|
auto vregInfo = GetVRegInfo(operand);
|
||||||
|
@ -10436,7 +10456,7 @@ bool BeMCContext::DoLegalization()
|
||||||
bool needSwap = false;
|
bool needSwap = false;
|
||||||
|
|
||||||
// Cmp <imm>, <r/m> is not legal, so we need to swap LHS/RHS, which means also modifying the instruction that uses the result of the cmp
|
// Cmp <imm>, <r/m> is not legal, so we need to swap LHS/RHS, which means also modifying the instruction that uses the result of the cmp
|
||||||
if (inst->mArg0.IsImmediate())
|
if (arg0.IsImmediate())
|
||||||
needSwap = true;
|
needSwap = true;
|
||||||
|
|
||||||
if (arg0Type->IsFloat())
|
if (arg0Type->IsFloat())
|
||||||
|
|
|
@ -1446,6 +1446,7 @@ public:
|
||||||
int GetRegSize(int regNum);
|
int GetRegSize(int regNum);
|
||||||
void ValidateRMResult(const BeMCOperand& operand, BeRMParamsInfo& rmInfo, bool doValidate = true);
|
void ValidateRMResult(const BeMCOperand& operand, BeRMParamsInfo& rmInfo, bool doValidate = true);
|
||||||
void GetRMParams(const BeMCOperand& operand, BeRMParamsInfo& rmInfo, bool doValidate = true);
|
void GetRMParams(const BeMCOperand& operand, BeRMParamsInfo& rmInfo, bool doValidate = true);
|
||||||
|
bool HasImmediateTarget(const BeMCOperand& operand);
|
||||||
void DisableRegister(const BeMCOperand& operand, X64CPURegister reg);
|
void DisableRegister(const BeMCOperand& operand, X64CPURegister reg);
|
||||||
void MarkInvalidRMRegs(const BeMCOperand& operand);
|
void MarkInvalidRMRegs(const BeMCOperand& operand);
|
||||||
void GetUsedRegs(const BeMCOperand& operand, X64CPURegister& regA, X64CPURegister& regB); // Expands regs
|
void GetUsedRegs(const BeMCOperand& operand, X64CPURegister& regA, X64CPURegister& regB); // Expands regs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue