MCPcopy Create free account
hub / github.com/beefytech/Beef / FixOperand

Method FixOperand

IDEHelper/Backend/BeMCContext.cpp:5459–5524  ·  view source on GitHub ↗

Depth -1 is reserved explicitly for reg finalization, so we leave the vector type for emission

Source from the content-addressed store, hash-verified

5457
5458// Depth -1 is reserved explicitly for reg finalization, so we leave the vector type for emission
5459void BeMCContext::FixOperand(BeMCOperand& operand, int depth)
5460{
5461 // We don't want to check for VRegLoad, that would erase the dereference
5462 if ((operand.mKind != BeMCOperandKind_VReg) && (operand.mKind != BeMCOperandKind_VRegAddr))
5463 return;
5464
5465 auto vregInfo = mVRegInfo[operand.mVRegIdx];
5466 if (vregInfo->mReg != X64Reg_None)
5467 {
5468 // For vectors we need the explicit type info
5469 if ((depth != -1) || (!vregInfo->mType->IsVector()))
5470 {
5471 operand.mKind = BeMCOperandKind_NativeReg;
5472 operand.mReg = vregInfo->mReg;
5473 return;
5474 }
5475 }
5476
5477 if ((vregInfo->mIsRetVal) && (mCompositeRetVRegIdx != -1) && (mCompositeRetVRegIdx != operand.mVRegIdx))
5478 {
5479 BF_ASSERT(mCompositeRetVRegIdx != -1);
5480 BeMCOperand origOperand = operand;
5481 operand = BeMCOperand::FromVReg(mCompositeRetVRegIdx);
5482 if ((origOperand.mKind == BeMCOperandKind_VReg) && (vregInfo->mType->IsNonVectorComposite()))
5483 operand.mKind = BeMCOperandKind_VRegLoad;
5484 FixOperand(operand, depth + 1);
5485
5486 //auto retVRegInfo = mVRegInfo[mCompositeRetVRegIdx];
5487 //operand = BeMCOperand::FromReg(retVRegInfo->mReg);
5488 }
5489
5490 if (vregInfo->IsDirectRelToAny())
5491 {
5492 auto checkOperand = vregInfo->mRelTo;
5493 if (checkOperand.IsVReg())
5494 FixOperand(checkOperand, depth + 1);
5495
5496 if (checkOperand.IsNativeReg())
5497 {
5498 auto resizedReg = ResizeRegister(checkOperand.mReg, vregInfo->mType);
5499 if (resizedReg != X64Reg_None)
5500 operand = BeMCOperand::FromReg(resizedReg);
5501 }
5502 else if (checkOperand.mKind == BeMCOperandKind_Symbol)
5503 {
5504 auto symbol = mCOFFObject->mSymbols[checkOperand.mSymbolIdx];
5505 if (AreTypesEquivalent(vregInfo->mType, symbol->mType))
5506 {
5507 if (checkOperand.mKind == BeMCOperandKind_VRegAddr)
5508 {
5509 operand = OperandToAddr(checkOperand);
5510 }
5511 else
5512 operand = checkOperand;
5513 }
5514 }
5515 else if (checkOperand.mKind == BeMCOperandKind_SymbolAddr)
5516 {

Callers

nothing calls this directly

Calls 6

IsVectorMethod · 0.80
IsNonVectorCompositeMethod · 0.80
IsDirectRelToAnyMethod · 0.80
IsVRegMethod · 0.80
IsNativeRegMethod · 0.80
IsImmediateMethod · 0.45

Tested by

no test coverage detected