mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 14:24:10 +02:00
Fixed BeInstEnumerator.Remove
This commit is contained in:
parent
cf6d8a3a99
commit
89aeb7924c
2 changed files with 49 additions and 29 deletions
|
@ -1873,6 +1873,31 @@ int BeMCBlock::FindLabelInstIdx(int labelIdx)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void BeInstEnumerator::Next()
|
||||||
|
{
|
||||||
|
if (mRemoveCurrent)
|
||||||
|
{
|
||||||
|
if ((mWriteIdx > 0) && (mReadIdx < mBlock->mInstructions.size() - 1))
|
||||||
|
mContext->MergeInstFlags(mBlock->mInstructions[mWriteIdx - 1], mBlock->mInstructions[mReadIdx], mBlock->mInstructions[mReadIdx + 1]);
|
||||||
|
|
||||||
|
mBlock->mInstructions[mReadIdx] = NULL;
|
||||||
|
mRemoveCurrent = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mWriteIdx != mReadIdx)
|
||||||
|
{
|
||||||
|
mBlock->mInstructions[mWriteIdx] = mBlock->mInstructions[mReadIdx];
|
||||||
|
mBlock->mInstructions[mReadIdx] = NULL;
|
||||||
|
}
|
||||||
|
mWriteIdx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
mReadIdx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
BeMCContext::BeMCContext(BeCOFFObject* coffObject) : mOut(coffObject->mTextSect.mData), mLivenessContext(this), mVRegInitializedContext(this), mColorizer(this)
|
BeMCContext::BeMCContext(BeCOFFObject* coffObject) : mOut(coffObject->mTextSect.mData), mLivenessContext(this), mVRegInitializedContext(this), mColorizer(this)
|
||||||
{
|
{
|
||||||
mLivenessContext.mTrackKindCount = 1;
|
mLivenessContext.mTrackKindCount = 1;
|
||||||
|
@ -2636,7 +2661,16 @@ BeMCInst* BeMCContext::AllocInst(BeMCInstKind instKind, const BeMCOperand& arg0,
|
||||||
return mcInst;
|
return mcInst;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BeMCContext::RemoveInst(BeMCBlock* block, int instIdx, bool needChangesMerged)
|
void BeMCContext::MergeInstFlags(BeMCInst* prevInst, BeMCInst* inst, BeMCInst* nextInst)
|
||||||
|
{
|
||||||
|
if (prevInst->mVRegsInitialized == inst->mVRegsInitialized)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ((inst->mVRegsInitialized != NULL) && (nextInst->mVRegsInitialized != NULL))
|
||||||
|
nextInst->mVRegsInitialized = mVRegInitializedContext.MergeChanges(nextInst->mVRegsInitialized, inst->mVRegsInitialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BeMCContext::RemoveInst(BeMCBlock* block, int instIdx, bool needChangesMerged, bool removeFromList)
|
||||||
{
|
{
|
||||||
// If neither the instruction before or after this one shares the vregsInitialized flags, then we need to
|
// If neither the instruction before or after this one shares the vregsInitialized flags, then we need to
|
||||||
// merge down our Changes to the next instruction
|
// merge down our Changes to the next instruction
|
||||||
|
@ -2660,7 +2694,8 @@ void BeMCContext::RemoveInst(BeMCBlock* block, int instIdx, bool needChangesMerg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
block->mInstructions.RemoveAt(instIdx);
|
if (removeFromList)
|
||||||
|
block->mInstructions.RemoveAt(instIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11128,7 +11163,7 @@ void BeMCContext::DoRegFinalization()
|
||||||
mActiveBlock = mcBlock;
|
mActiveBlock = mcBlock;
|
||||||
|
|
||||||
//for (int instIdx = 0; instIdx < (int)mcBlock->mInstructions.size(); instIdx++)
|
//for (int instIdx = 0; instIdx < (int)mcBlock->mInstructions.size(); instIdx++)
|
||||||
for (auto instEnum = BeInstEnumerator(mcBlock); instEnum.HasMore(); instEnum.Next())
|
for (auto instEnum = BeInstEnumerator(this, mcBlock); instEnum.HasMore(); instEnum.Next())
|
||||||
{
|
{
|
||||||
auto inst = instEnum.Get();
|
auto inst = instEnum.Get();
|
||||||
SetCurrentInst(inst);
|
SetCurrentInst(inst);
|
||||||
|
@ -11136,9 +11171,7 @@ void BeMCContext::DoRegFinalization()
|
||||||
{
|
{
|
||||||
auto vregInfo = GetVRegInfo(inst->mArg0);
|
auto vregInfo = GetVRegInfo(inst->mArg0);
|
||||||
if (vregInfo->mDbgVariable != NULL)
|
if (vregInfo->mDbgVariable != NULL)
|
||||||
vregInfo->mAwaitingDbgStart = true;
|
vregInfo->mAwaitingDbgStart = true;
|
||||||
//RemoveInst(mcBlock, instIdx);
|
|
||||||
//instIdx--;
|
|
||||||
instEnum.RemoveCurrent();
|
instEnum.RemoveCurrent();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -15438,7 +15471,7 @@ void BeMCContext::Generate(BeFunction* function)
|
||||||
mDbgPreferredRegs[32] = X64Reg_R8;*/
|
mDbgPreferredRegs[32] = X64Reg_R8;*/
|
||||||
|
|
||||||
//mDbgPreferredRegs[8] = X64Reg_RAX;
|
//mDbgPreferredRegs[8] = X64Reg_RAX;
|
||||||
//mDebugging = (function->mName == "?__BfStaticCtor@roboto_font@Drawing@ClassicUO_assistant@bf@@SAXXZ");
|
//mDebugging = (function->mName == "?FindSourceViewPanel@IDEApp@IDE@bf@@QEAAPEAVSourceViewPanel@ui@23@PEAVString@System@3@@Z");
|
||||||
// || (function->mName == "?__BfStaticCtor@roboto_font@Drawing@ClassicUO_assistant@bf@@SAXXZ")
|
// || (function->mName == "?__BfStaticCtor@roboto_font@Drawing@ClassicUO_assistant@bf@@SAXXZ")
|
||||||
// || (function->mName == "?Hey@Blurg@bf@@SAXXZ")
|
// || (function->mName == "?Hey@Blurg@bf@@SAXXZ")
|
||||||
// ;
|
// ;
|
||||||
|
|
|
@ -695,17 +695,21 @@ public:
|
||||||
int FindLabelInstIdx(int labelIdx);
|
int FindLabelInstIdx(int labelIdx);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class BeMCContext;
|
||||||
|
|
||||||
class BeInstEnumerator
|
class BeInstEnumerator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
BeMCContext* mContext;
|
||||||
BeMCBlock* mBlock;
|
BeMCBlock* mBlock;
|
||||||
int mReadIdx;
|
int mReadIdx;
|
||||||
int mWriteIdx;
|
int mWriteIdx;
|
||||||
bool mRemoveCurrent;
|
bool mRemoveCurrent;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BeInstEnumerator(BeMCBlock* block)
|
BeInstEnumerator(BeMCContext* context, BeMCBlock* block)
|
||||||
{
|
{
|
||||||
|
mContext = context;
|
||||||
mBlock = block;
|
mBlock = block;
|
||||||
mReadIdx = 0;
|
mReadIdx = 0;
|
||||||
mWriteIdx = 0;
|
mWriteIdx = 0;
|
||||||
|
@ -720,26 +724,8 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Next()
|
void Next();
|
||||||
{
|
|
||||||
if (mRemoveCurrent)
|
|
||||||
{
|
|
||||||
mBlock->mInstructions[mReadIdx] = NULL;
|
|
||||||
mRemoveCurrent = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (mWriteIdx != mReadIdx)
|
|
||||||
{
|
|
||||||
mBlock->mInstructions[mWriteIdx] = mBlock->mInstructions[mReadIdx];
|
|
||||||
mBlock->mInstructions[mReadIdx] = NULL;
|
|
||||||
}
|
|
||||||
mWriteIdx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
mReadIdx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HasMore()
|
bool HasMore()
|
||||||
{
|
{
|
||||||
return mReadIdx < mBlock->mInstructions.mSize;
|
return mReadIdx < mBlock->mInstructions.mSize;
|
||||||
|
@ -1356,7 +1342,8 @@ public:
|
||||||
BeMCInst* AllocInst(BeMCInstKind instKind, int insertIdx = -1);
|
BeMCInst* AllocInst(BeMCInstKind instKind, int insertIdx = -1);
|
||||||
BeMCInst* AllocInst(BeMCInstKind instKind, const BeMCOperand& arg0, int insertIdx = -1);
|
BeMCInst* AllocInst(BeMCInstKind instKind, const BeMCOperand& arg0, int insertIdx = -1);
|
||||||
BeMCInst* AllocInst(BeMCInstKind instKind, const BeMCOperand& arg0, const BeMCOperand& arg1, int insertIdx = -1);
|
BeMCInst* AllocInst(BeMCInstKind instKind, const BeMCOperand& arg0, const BeMCOperand& arg1, int insertIdx = -1);
|
||||||
void RemoveInst(BeMCBlock* block, int instIdx, bool needChangesMerged = true);
|
void MergeInstFlags(BeMCInst* prevInst, BeMCInst* inst, BeMCInst* nextInst);
|
||||||
|
void RemoveInst(BeMCBlock* block, int instIdx, bool needChangesMerged = true, bool removeFromList = true);
|
||||||
BeMCOperand AllocBinaryOp(BeMCInstKind instKind, const BeMCOperand & lhs, const BeMCOperand & rhs, BeMCBinIdentityKind identityKind);
|
BeMCOperand AllocBinaryOp(BeMCInstKind instKind, const BeMCOperand & lhs, const BeMCOperand & rhs, BeMCBinIdentityKind identityKind);
|
||||||
BeMCOperand GetCallArgVReg(int argIdx, BeTypeCode typeCode);
|
BeMCOperand GetCallArgVReg(int argIdx, BeTypeCode typeCode);
|
||||||
BeMCOperand CreateCall(const BeMCOperand& func, const SizedArrayImpl<BeMCOperand>& args, BeType* retType = NULL, BfIRCallingConv callingConv = BfIRCallingConv_CDecl, bool structRet = false, bool noReturn = false, bool isVarArg = false);
|
BeMCOperand CreateCall(const BeMCOperand& func, const SizedArrayImpl<BeMCOperand>& args, BeType* retType = NULL, BfIRCallingConv callingConv = BfIRCallingConv_CDecl, bool structRet = false, bool noReturn = false, bool isVarArg = false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue