1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Improved setting mForceMem

This commit is contained in:
Brian Fiete 2022-05-13 14:07:40 -07:00
parent bf5d4fd340
commit 5bd8aac41b
2 changed files with 16 additions and 9 deletions

View file

@ -2155,7 +2155,7 @@ String BeMCContext::ToString(const BeMCOperand& operand)
return "???"; return "???";
} }
BeMCOperand BeMCContext::GetOperand(BeValue* value, bool allowMetaResult, bool allowFail) BeMCOperand BeMCContext::GetOperand(BeValue* value, bool allowMetaResult, bool allowFail, bool skipForceVRegAddr)
{ {
if (value == NULL) if (value == NULL)
return BeMCOperand(); return BeMCOperand();
@ -2572,6 +2572,13 @@ BeMCOperand BeMCContext::GetOperand(BeValue* value, bool allowMetaResult, bool a
AllocInst(BeMCInstKind_Xor, operand, xorVal); AllocInst(BeMCInstKind_Xor, operand, xorVal);
} }
if ((operand.mKind == BeMCOperandKind_VRegAddr) && (!skipForceVRegAddr))
{
auto vregInfo = GetVRegInfo(operand);
if (!vregInfo->mForceMem)
vregInfo->mForceMem = true;
}
return operand; return operand;
} }
@ -16959,7 +16966,7 @@ void BeMCContext::Generate(BeFunction* function)
case BeLifetimeStartInst::TypeId: case BeLifetimeStartInst::TypeId:
{ {
auto castedInst = (BeLifetimeEndInst*)inst; auto castedInst = (BeLifetimeEndInst*)inst;
auto mcPtr = GetOperand(castedInst->mPtr, false, true); auto mcPtr = GetOperand(castedInst->mPtr, false, true, true);
if (mcPtr) if (mcPtr)
{ {
auto vregInfo = GetVRegInfo(mcPtr); auto vregInfo = GetVRegInfo(mcPtr);
@ -16976,7 +16983,7 @@ void BeMCContext::Generate(BeFunction* function)
case BeLifetimeExtendInst::TypeId: case BeLifetimeExtendInst::TypeId:
{ {
auto castedInst = (BeLifetimeEndInst*)inst; auto castedInst = (BeLifetimeEndInst*)inst;
auto mcPtr = GetOperand(castedInst->mPtr, false, true); auto mcPtr = GetOperand(castedInst->mPtr, false, true, true);
if (mcPtr) if (mcPtr)
AllocInst(BeMCInstKind_LifetimeExtend, mcPtr); AllocInst(BeMCInstKind_LifetimeExtend, mcPtr);
} }
@ -16984,7 +16991,7 @@ void BeMCContext::Generate(BeFunction* function)
case BeLifetimeEndInst::TypeId: case BeLifetimeEndInst::TypeId:
{ {
auto castedInst = (BeLifetimeEndInst*)inst; auto castedInst = (BeLifetimeEndInst*)inst;
auto mcPtr = GetOperand(castedInst->mPtr, false, true); auto mcPtr = GetOperand(castedInst->mPtr, false, true, true);
if (mcPtr.IsVRegAny()) if (mcPtr.IsVRegAny())
{ {
AllocInst(BeMCInstKind_LifetimeEnd, mcPtr); AllocInst(BeMCInstKind_LifetimeEnd, mcPtr);
@ -17031,7 +17038,7 @@ void BeMCContext::Generate(BeFunction* function)
case BeLoadInst::TypeId: case BeLoadInst::TypeId:
{ {
auto castedInst = (BeLoadInst*)inst; auto castedInst = (BeLoadInst*)inst;
auto mcTarget = GetOperand(castedInst->mTarget); auto mcTarget = GetOperand(castedInst->mTarget, false, false, true);
result = CreateLoad(mcTarget); result = CreateLoad(mcTarget);
} }
break; break;
@ -17039,7 +17046,7 @@ void BeMCContext::Generate(BeFunction* function)
{ {
auto castedInst = (BeStoreInst*)inst; auto castedInst = (BeStoreInst*)inst;
auto mcVal = GetOperand(castedInst->mVal); auto mcVal = GetOperand(castedInst->mVal);
auto mcPtr = GetOperand(castedInst->mPtr); auto mcPtr = GetOperand(castedInst->mPtr, false, false, true);
bool handled = false; bool handled = false;
@ -17049,7 +17056,7 @@ void BeMCContext::Generate(BeFunction* function)
case BeSetCanMergeInst::TypeId: case BeSetCanMergeInst::TypeId:
{ {
auto castedInst = (BeSetCanMergeInst*)inst; auto castedInst = (BeSetCanMergeInst*)inst;
auto mcVal = GetOperand(castedInst->mVal); auto mcVal = GetOperand(castedInst->mVal, false, false, true);
auto vregInfo = GetVRegInfo(mcVal); auto vregInfo = GetVRegInfo(mcVal);
vregInfo->mForceMerge = true; vregInfo->mForceMerge = true;
} }
@ -18002,7 +18009,7 @@ void BeMCContext::Generate(BeFunction* function)
{ {
auto castedInst = (BeDbgDeclareInst*)inst; auto castedInst = (BeDbgDeclareInst*)inst;
auto dbgVar = castedInst->mDbgVar; auto dbgVar = castedInst->mDbgVar;
auto mcValue = GetOperand(castedInst->mValue); auto mcValue = GetOperand(castedInst->mValue, false, false, true);
auto mcVReg = mcValue; auto mcVReg = mcValue;
auto vregInfo = GetVRegInfo(mcVReg); auto vregInfo = GetVRegInfo(mcVReg);

View file

@ -1362,7 +1362,7 @@ public:
String ToString(bool showVRegFlags = true, bool showVRegDetails = false); String ToString(bool showVRegFlags = true, bool showVRegDetails = false);
void Print(bool showVRegFlags, bool showVRegDetails); void Print(bool showVRegFlags, bool showVRegDetails);
void Print(); void Print();
BeMCOperand GetOperand(BeValue* value, bool allowMetaResult = false, bool allowFail = false); // Meta results are PHIs or CmpResults BeMCOperand GetOperand(BeValue* value, bool allowMetaResult = false, bool allowFail = false, bool skipForceVRegAddr = false); // Meta results are PHIs or CmpResults
BeMCOperand CreateNot(const BeMCOperand& operand); BeMCOperand CreateNot(const BeMCOperand& operand);
BeMCOperand TryToVector(BeValue* value); BeMCOperand TryToVector(BeValue* value);
BeType* GetType(const BeMCOperand& operand); BeType* GetType(const BeMCOperand& operand);