| 13714 | } |
| 13715 | |
| 13716 | void BfModule::AggregateSplatIntoAddr(BfTypedValue typedValue, BfIRValue addrVal) |
| 13717 | { |
| 13718 | if (!typedValue.IsSplat()) |
| 13719 | return; |
| 13720 | if (typedValue.mType->IsValuelessType()) |
| 13721 | return; |
| 13722 | |
| 13723 | BF_ASSERT(!mIsComptimeModule); |
| 13724 | |
| 13725 | /*static int sCallIdx = 0; |
| 13726 | if (!mCompiler->mIsResolveOnly) |
| 13727 | sCallIdx++; |
| 13728 | int callIdx = sCallIdx;*/ |
| 13729 | |
| 13730 | int elementIdx = 0; |
| 13731 | |
| 13732 | std::function<void(BfType*, BfIRValue)> checkTypeLambda = [&](BfType* checkType, BfIRValue curAddrVal) |
| 13733 | { |
| 13734 | if (checkType->IsStruct()) |
| 13735 | { |
| 13736 | auto checkTypeInstance = checkType->ToTypeInstance(); |
| 13737 | if (checkTypeInstance->mBaseType != NULL) |
| 13738 | { |
| 13739 | mBfIRBuilder->PopulateType(checkTypeInstance->mBaseType); |
| 13740 | auto baseAddrVal = mBfIRBuilder->CreateInBoundsGEP(curAddrVal, 0, 0); |
| 13741 | checkTypeLambda(checkTypeInstance->mBaseType, baseAddrVal); |
| 13742 | } |
| 13743 | |
| 13744 | if (checkTypeInstance->mIsUnion) |
| 13745 | { |
| 13746 | auto unionInnerType = checkTypeInstance->GetUnionInnerType(); |
| 13747 | if (!unionInnerType->IsValuelessType()) |
| 13748 | { |
| 13749 | auto fieldAddrVal = mBfIRBuilder->CreateInBoundsGEP(curAddrVal, 0, 1); |
| 13750 | checkTypeLambda(unionInnerType, fieldAddrVal); |
| 13751 | } |
| 13752 | |
| 13753 | if (checkTypeInstance->IsEnum()) |
| 13754 | { |
| 13755 | auto dscrType = checkTypeInstance->GetDiscriminatorType(); |
| 13756 | auto fieldAddrVal = mBfIRBuilder->CreateInBoundsGEP(curAddrVal, 0, 2); |
| 13757 | checkTypeLambda(dscrType, fieldAddrVal); |
| 13758 | } |
| 13759 | } |
| 13760 | else |
| 13761 | { |
| 13762 | for (int fieldIdx = 0; fieldIdx < (int)checkTypeInstance->mFieldInstances.size(); fieldIdx++) |
| 13763 | { |
| 13764 | auto fieldInstance = (BfFieldInstance*)&checkTypeInstance->mFieldInstances[fieldIdx]; |
| 13765 | if (fieldInstance->mDataIdx >= 0) |
| 13766 | { |
| 13767 | auto fieldAddrVal = mBfIRBuilder->CreateInBoundsGEP(curAddrVal, 0, fieldInstance->mDataIdx); |
| 13768 | checkTypeLambda(fieldInstance->mResolvedType, fieldAddrVal); |
| 13769 | } |
| 13770 | } |
| 13771 | } |
| 13772 | } |
| 13773 | else if (checkType->IsMethodRef()) |
no test coverage detected