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

Method CreateStore

IDEHelper/Backend/BeMCContext.cpp:2951–3030  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2949}
2950
2951void BeMCContext::CreateStore(BeMCInstKind instKind, const BeMCOperand& val, const BeMCOperand& ptr)
2952{
2953 BeMCOperand mcVal = val;
2954 BeMCOperand mcPtr = ptr;
2955
2956 if (mcVal.mKind == BeMCOperandKind_ConstAgg)
2957 {
2958 if (auto aggConst = BeValueDynCast<BeStructConstant>(mcVal.mConstant))
2959 {
2960 if (NeedsDecompose(mcVal.mConstant))
2961 {
2962 int offset = 0;
2963
2964 auto aggType = aggConst->GetType();
2965
2966 for (int memberIdx = 0; memberIdx < (int)aggConst->mMemberValues.size(); memberIdx++)
2967 {
2968 auto val = aggConst->mMemberValues[memberIdx];
2969 BeType* elemType = NULL;
2970 if (aggType->IsSizedArray())
2971 elemType = ((BeSizedArrayType*)aggType)->mElementType;
2972 else
2973 {
2974 auto& memberInfo = ((BeStructType*)aggType)->mMembers[memberIdx];
2975 offset = memberInfo.mByteOffset;
2976 elemType = memberInfo.mType;
2977 }
2978 if (elemType->mSize == 0)
2979 continue;
2980
2981 auto destOperand = AllocVirtualReg(mModule->mContext->GetPointerTo(elemType));
2982 auto vregInfo = GetVRegInfo(destOperand);
2983 vregInfo->mDefOnFirstUse = true;
2984 vregInfo->mRelTo = mcPtr;
2985 vregInfo->mIsExpr = true;
2986
2987 vregInfo->mRelOffset = BeMCOperand::FromImmediate(offset);
2988
2989 //destOperand.mKind = BeMCOperandKind_VRegLoad;
2990
2991 auto elementVal = GetOperand(val);
2992 //AllocInst(instKind, destOperand, elementVal);
2993 CreateStore(instKind, elementVal, destOperand);
2994
2995 offset += elemType->GetStride();
2996 }
2997 return;
2998 }
2999 }
3000 }
3001
3002 // Addr mov infers something like a "int* intPtr = &intVal"
3003 if (mcVal.mKind == BeMCOperandKind_VRegAddr)
3004 {
3005 auto vregInfo = GetVRegInfo(mcVal);
3006 vregInfo->mForceMem = true;
3007 CheckForce(vregInfo);
3008 }

Callers

nothing calls this directly

Calls 6

NeedsDecomposeFunction · 0.85
GetTypeMethod · 0.45
sizeMethod · 0.45
IsSizedArrayMethod · 0.45
GetPointerToMethod · 0.45
GetStrideMethod · 0.45

Tested by

no test coverage detected