| 8755 | static int gLegalizeIdx = 0; |
| 8756 | |
| 8757 | void BeMCContext::DoActualization() |
| 8758 | { |
| 8759 | while (true) |
| 8760 | { |
| 8761 | bool hasMoreWork = false; |
| 8762 | |
| 8763 | for (auto mcBlock : mBlocks) |
| 8764 | { |
| 8765 | mActiveBlock = mcBlock; |
| 8766 | for (int instIdx = 0; instIdx < (int)mcBlock->mInstructions.size(); instIdx++) |
| 8767 | { |
| 8768 | auto inst = mcBlock->mInstructions[instIdx]; |
| 8769 | SetCurrentInst(inst); |
| 8770 | |
| 8771 | bool forceMove = false; |
| 8772 | |
| 8773 | if (inst->mKind == BeMCInstKind_DbgDecl) |
| 8774 | { |
| 8775 | auto vregInfo = GetVRegInfo(inst->mArg0); |
| 8776 | if (vregInfo->mWantsExprActualize) |
| 8777 | { |
| 8778 | if (inst->mArg0.mKind == BeMCOperandKind_VReg) |
| 8779 | { |
| 8780 | if (vregInfo->mRelTo.IsSymbol()) |
| 8781 | { |
| 8782 | forceMove = true; |
| 8783 | } |
| 8784 | else if (vregInfo->mDbgVariable->mIsValue) |
| 8785 | { |
| 8786 | vregInfo->mDbgVariable->mIsValue = false; |
| 8787 | inst->mArg0.mKind = BeMCOperandKind_VRegAddr; |
| 8788 | } |
| 8789 | else |
| 8790 | { |
| 8791 | inst->mArg0.mKind = BeMCOperandKind_VRegAddr; |
| 8792 | vregInfo->mDbgVariable->mType = mModule->mDbgModule->CreateReferenceType(BeValueDynCast<BeDbgType>(vregInfo->mDbgVariable->mType)); |
| 8793 | } |
| 8794 | } |
| 8795 | vregInfo->mWantsExprActualize = false; |
| 8796 | } |
| 8797 | } |
| 8798 | |
| 8799 | if ((inst->IsDef()) || (forceMove)) |
| 8800 | { |
| 8801 | int vregIdx = inst->mArg0.mVRegIdx; |
| 8802 | auto vregInfo = GetVRegInfo(inst->mArg0); |
| 8803 | |
| 8804 | if (vregInfo->mWantsExprOffsetActualize) |
| 8805 | { |
| 8806 | vregInfo->mWantsExprOffsetActualize = false; |
| 8807 | |
| 8808 | auto offsetType = GetType(vregInfo->mRelOffset); |
| 8809 | |
| 8810 | auto scratchReg = AllocVirtualReg(offsetType, 2, false); |
| 8811 | CreateDefineVReg(scratchReg, instIdx++); |
| 8812 | |
| 8813 | AllocInst(BeMCInstKind_Mov, scratchReg, vregInfo->mRelOffset, instIdx++); |
| 8814 | AllocInst(BeMCInstKind_IMul, scratchReg, BeMCOperand::FromImmediate(vregInfo->mRelOffsetScale), instIdx++); |
nothing calls this directly
no test coverage detected