1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Fixed splat MakeCallableTarget

This commit is contained in:
Brian Fiete 2020-09-17 05:46:38 -07:00
parent 1be4c24e45
commit 378d514d0a

View file

@ -13042,28 +13042,29 @@ BfTypedValue BfExprEvaluator::MakeCallableTarget(BfAstNode* targetSrc, BfTypedVa
auto primStructType = mModule->GetWrappedStructType(target.mType); auto primStructType = mModule->GetWrappedStructType(target.mType);
if (primStructType != NULL) if (primStructType != NULL)
{ {
mModule->PopulateType(primStructType); mModule->PopulateType(primStructType);
target.mType = primStructType;
if (primStructType->IsTypedPrimitive()) if (primStructType->IsTypedPrimitive())
{ {
// Type is already the same // Type is already the same
target.mType = primStructType;
} }
else if (target.IsAddr()) else if (target.IsAddr())
{ {
auto ptrType = mModule->CreatePointerType(primStructType); auto ptrType = mModule->CreatePointerType(primStructType);
target = BfTypedValue(mModule->mBfIRBuilder->CreateBitCast(target.mValue, mModule->mBfIRBuilder->MapType(ptrType)), primStructType, true); target = BfTypedValue(mModule->mBfIRBuilder->CreateBitCast(target.mValue, mModule->mBfIRBuilder->MapType(ptrType)), primStructType, true);
} }
else if (primStructType->IsSplattable()) else if ((primStructType->IsSplattable()) && (target.IsSplat()))
{ {
BF_ASSERT(target.IsSplat() || target.mValue.IsFake()); target.mType = primStructType;
if (target.IsSplat()) target.mKind = BfTypedValueKind_SplatHead;
target.mKind = BfTypedValueKind_SplatHead; }
else else
{ {
if (!target.mValue.IsFake()) auto allocPtr = mModule->CreateAlloca(primStructType);
mModule->FailInternal("MakeCallableTarget splat fail", targetSrc); auto srcPtrType = mModule->mBfIRBuilder->CreateBitCast(allocPtr, mModule->mBfIRBuilder->GetPointerTo(mModule->mBfIRBuilder->MapType(target.mType)));
} mModule->mBfIRBuilder->CreateStore(target.mValue, srcPtrType);
target = BfTypedValue(allocPtr, primStructType, true);
} }
} }