| 8526 | } |
| 8527 | |
| 8528 | void BeMCContext::DoFrameObjPass() |
| 8529 | { |
| 8530 | BF_ASSERT(mBlocks.size() == 1); |
| 8531 | |
| 8532 | SetCurrentInst(NULL); |
| 8533 | |
| 8534 | // MS x64 ABI requires a "home address" of 4 intptrs when we call a function, plus whatever |
| 8535 | // we need for calls with more than 4 params. |
| 8536 | // If we're doing UseBP, we have to allocate these at call time |
| 8537 | int homeSize = BF_ALIGN(BF_MAX(mMaxCallParamCount, 4) * 8, 16); |
| 8538 | |
| 8539 | if (mMaxCallParamCount == -1) |
| 8540 | homeSize = 0; |
| 8541 | |
| 8542 | mStackSize = 0; |
| 8543 | |
| 8544 | if (mUseBP) |
| 8545 | mUsedRegs.Add(X64Reg_RBP); |
| 8546 | |
| 8547 | int regStackOffset = 0; |
| 8548 | int xmmRegStackSize = 0; |
| 8549 | for (auto usedReg : mUsedRegs) |
| 8550 | { |
| 8551 | if (!IsVolatileReg(usedReg)) |
| 8552 | { |
| 8553 | BF_ASSERT(usedReg != X64Reg_RSP); |
| 8554 | if (IsXMMReg(usedReg)) |
| 8555 | xmmRegStackSize += 16; |
| 8556 | else |
| 8557 | regStackOffset += 8; |
| 8558 | } |
| 8559 | } |
| 8560 | |
| 8561 | int xmmStackOffset = -1; |
| 8562 | if (xmmRegStackSize > 0) |
| 8563 | { |
| 8564 | int align = 16; |
| 8565 | int alignOffset = regStackOffset + 8; |
| 8566 | int alignedPosition = (mStackSize + alignOffset + (align - 1)) & ~(align - 1); |
| 8567 | mStackSize = alignedPosition - alignOffset; |
| 8568 | mStackSize += xmmRegStackSize; |
| 8569 | xmmStackOffset = -mStackSize - regStackOffset; |
| 8570 | } |
| 8571 | |
| 8572 | for (int vregIdx = 0; vregIdx < (int)mVRegInfo.size(); vregIdx++) |
| 8573 | { |
| 8574 | auto vregInfo = mVRegInfo[vregIdx]; |
| 8575 | |
| 8576 | if (vregInfo->mRelOffset.mKind == BeMCOperandKind_Immediate_HomeSize) |
| 8577 | { |
| 8578 | vregInfo->mRelOffset = BeMCOperand::FromImmediate(homeSize); |
| 8579 | } |
| 8580 | |
| 8581 | if ((vregInfo->mIsRetVal) && (vregIdx != mCompositeRetVRegIdx)) |
| 8582 | continue; |
| 8583 | |
| 8584 | if ((vregInfo->mRefCount > 0) && (!vregInfo->mIsExpr) && (vregInfo->mReg == X64Reg_None) && (vregInfo->mFrameOffset == INT_MIN)) |
| 8585 | { |
nothing calls this directly
no test coverage detected