1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

More SIMD work

This commit is contained in:
Brian Fiete 2020-08-25 07:33:55 -07:00
parent b57cbe2d69
commit ca4b383339
19 changed files with 695 additions and 76 deletions

View file

@ -4943,7 +4943,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfMethodInstance* methodInstance, BfIRV
mModule->mBfIRBuilder->Call_AddAttribute(callInst, argIdx + 1, BfIRAttribute_NoCapture);
addDeref = paramType->mSize;
}
else if (methodInstance->WantsIRStructsByVal())
else if (methodInstance->WantsStructsAttribByVal())
{
mModule->mBfIRBuilder->Call_AddAttribute(callInst, argIdx + 1, BfIRAttribute_ByVal, mModule->mSystem->mPtrSize);
}
@ -5210,7 +5210,7 @@ void BfExprEvaluator::SplatArgs(BfTypedValue value, SizedArrayImpl<BfIRValue>& i
checkTypeLambda(value);
}
void BfExprEvaluator::PushArg(BfTypedValue argVal, SizedArrayImpl<BfIRValue>& irArgs, bool disableSplat, bool disableLowering)
void BfExprEvaluator::PushArg(BfTypedValue argVal, SizedArrayImpl<BfIRValue>& irArgs, bool disableSplat, bool disableLowering, bool isIntrinsic)
{
MakeBaseConcrete(argVal);
@ -5231,12 +5231,17 @@ void BfExprEvaluator::PushArg(BfTypedValue argVal, SizedArrayImpl<BfIRValue>& ir
SplatArgs(argVal, irArgs);
}
else
{
{
if (argVal.mType->IsComposite())
{
argVal = mModule->MakeAddressable(argVal);
if (isIntrinsic)
{
// We can handle composites either by value or not
}
else
argVal = mModule->MakeAddressable(argVal);
if (!disableLowering)
if ((!disableLowering) && (!isIntrinsic))
{
BfTypeCode loweredTypeCode = BfTypeCode_None;
BfTypeCode loweredTypeCode2 = BfTypeCode_None;
@ -5922,10 +5927,17 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
}
else if ((wantType->IsComposite()) && (!expandedParamsArray))
{
// We need to make a temp and get the addr of that
if ((!wantsSplat) && (!argValue.IsValuelessType()) && (!argValue.IsAddr()))
{
argValue = mModule->MakeAddressable(argValue);
if (methodInstance->mIsIntrinsic)
{
// Intrinsics can handle structs either by value or address
}
else
{
// We need to make a temp and get the addr of that
if ((!wantsSplat) && (!argValue.IsValuelessType()) && (!argValue.IsAddr()))
{
argValue = mModule->MakeAddressable(argValue);
}
}
}
else if (!wantType->IsRef())
@ -5982,7 +5994,7 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
else if (wantsSplat)
SplatArgs(argValue, irArgs);
else
PushArg(argValue, irArgs, true, false);
PushArg(argValue, irArgs, true, false, methodInstance->mIsIntrinsic);
}
paramIdx++;
}

View file

@ -382,7 +382,7 @@ public:
BfTypedValue CreateCall(BfMethodMatcher* methodMatcher, BfTypedValue target);
void MakeBaseConcrete(BfTypedValue& typedValue);
void SplatArgs(BfTypedValue value, SizedArrayImpl<BfIRValue>& irArgs);
void PushArg(BfTypedValue argVal, SizedArrayImpl<BfIRValue>& irArgs, bool disableSplat = false, bool disableLowering = false);
void PushArg(BfTypedValue argVal, SizedArrayImpl<BfIRValue>& irArgs, bool disableSplat = false, bool disableLowering = false, bool isIntrinsic = false);
void PushThis(BfAstNode* targetSrc, BfTypedValue callTarget, BfMethodInstance* methodInstance, SizedArrayImpl<BfIRValue>& irArgs, bool skipMutCheck = false);
BfTypedValue MatchConstructor(BfAstNode* targetSrc, BfMethodBoundExpression* methodBoundExpr, BfTypedValue target, BfTypeInstance* targetType,
BfResolvedArgs& argValues, bool callCtorBodyOnly, bool allowAppendAlloc, BfTypedValue* appendIndexValue = NULL);

View file

@ -2288,19 +2288,6 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDbgDefine)
irType = CreateStructType(name);
StructSetBody(irType, members, false);
}
else if (underlyingArraySize != -1)
{
if (underlyingArrayIsVector)
{
if (underlyingArrayType == mModule->GetPrimitiveType(BfTypeCode_Boolean))
underlyingArrayType = mModule->GetPrimitiveType(BfTypeCode_UInt8);
irType = GetVectorType(MapType(underlyingArrayType), underlyingArraySize);
}
else
irType = GetSizedArrayType(MapType(underlyingArrayType), underlyingArraySize);
if (wantDIData)
diType = DbgCreateArrayType((int64)type->mSize * 8, type->mAlign * 8, DbgGetType(underlyingArrayType), underlyingArraySize);
}
else if (type->IsSizedArray())
{
BfSizedArrayType* arrayType = (BfSizedArrayType*)type;
@ -2400,7 +2387,7 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDbgDefine)
BfIRMDNode diForwardDecl;
if (wantDIData)
{
{
BfFileInstance* bfFileInstance;
// Why did we bother setting the actual type declaration location?
@ -2475,7 +2462,19 @@ void BfIRBuilder::CreateTypeDeclaration(BfType* type, bool forceDbgDefine)
DbgSetType(type, diType);
}
if (type->IsTypedPrimitive())
if (underlyingArraySize != -1)
{
if (underlyingArrayIsVector)
{
if (underlyingArrayType == mModule->GetPrimitiveType(BfTypeCode_Boolean))
underlyingArrayType = mModule->GetPrimitiveType(BfTypeCode_UInt8);
irType = GetVectorType(MapType(underlyingArrayType), underlyingArraySize);
}
else
irType = GetSizedArrayType(MapType(underlyingArrayType), underlyingArraySize);
SetType(type, irType);
}
else if (type->IsTypedPrimitive())
{
mModule->PopulateType(type);
auto underlyingType = type->GetUnderlyingType();
@ -2565,8 +2564,8 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type)
isPacked = typeInstance->mIsPacked;
isUnion = typeInstance->mIsUnion;
typeInstance->GetUnderlyingArray(underlyingArrayType, underlyingArraySize, underlyingArrayIsVector);
if (underlyingArrayType != NULL)
return; // Done
// if (underlyingArrayType != NULL)
// return; // Done
}
String typeName = GetDebugTypeName(typeInstance, false);
@ -2584,7 +2583,7 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type)
int flags = llvm::DINode::FlagPublic;
auto fieldType = typeInstance->GetUnionInnerType();
auto resolvedFieldDIType = DbgGetType(fieldType);
String fieldName = "__bfunion";
String fieldName = "$bfunion";
auto memberType = DbgCreateMemberType(diForwardDecl, fieldName, fileDIScope, lineNum,
fieldType->mSize * 8, fieldType->mAlign * 8, 0,
flags, resolvedFieldDIType);

View file

@ -406,6 +406,7 @@ enum BfIRConfigConst : uint8
enum BfIRIntrinsic : uint8
{
BfIRIntrinsic__PLATFORM,
BfIRIntrinsic_Abs,
BfIRIntrinsic_Add,
BfIRIntrinsic_And,
@ -435,6 +436,7 @@ enum BfIRIntrinsic : uint8
BfIRIntrinsic_Free,
BfIRIntrinsic_Gt,
BfIRIntrinsic_GtE,
BfIRIntrinsic_Index,
BfIRIntrinsic_Log,
BfIRIntrinsic_Log10,
BfIRIntrinsic_Log2,

View file

@ -133,6 +133,7 @@ struct BuiltinEntry
static const BuiltinEntry gIntrinEntries[] =
{
{":PLATFORM"},
{"abs"},
{"add"},
{"and"},
@ -161,7 +162,8 @@ static const BuiltinEntry gIntrinEntries[] =
{"floor"},
{"free"},
{"gt"},
{"gte"},
{"gte"},
("index"),
{"log"},
{"log10"},
{"log2"},
@ -1094,6 +1096,71 @@ llvm::Value* BfIRCodeGen::TryToVector(llvm::Value* value)
return NULL;
}
llvm::Value* BfIRCodeGen::TryToVector(llvm::Value* value, llvm::Type* elemType)
{
auto valueType = value->getType();
if (auto vecType = llvm::dyn_cast<llvm::VectorType>(valueType))
{
if (vecType->getVectorElementType() == elemType)
return value;
//TODO: We need an alloca....
FatalError("Failed to get vector");
return value;
}
if (auto ptrType = llvm::dyn_cast<llvm::PointerType>(valueType))
{
auto ptrElemType = ptrType->getElementType();
if (auto arrType = llvm::dyn_cast<llvm::ArrayType>(ptrElemType))
{
auto vecType = llvm::VectorType::get(arrType->getArrayElementType(), (uint)arrType->getArrayNumElements());
auto vecPtrType = vecType->getPointerTo();
auto ptrVal0 = mIRBuilder->CreateBitCast(value, vecPtrType);
return mIRBuilder->CreateAlignedLoad(ptrVal0, 1);
}
if (auto vecType = llvm::dyn_cast<llvm::VectorType>(ptrElemType))
{
if (vecType->getVectorElementType() == elemType)
return mIRBuilder->CreateAlignedLoad(value, 1);
auto dataLayout = llvm::DataLayout(mLLVMModule);
int wantNumElements = (int)vecType->getVectorNumElements() * (int)dataLayout.getTypeSizeInBits(vecType->getVectorElementType()) / (int)dataLayout.getTypeSizeInBits(elemType);
auto newVecType = llvm::VectorType::get(elemType, wantNumElements);
auto vecPtrType = newVecType->getPointerTo();
auto ptrVal0 = mIRBuilder->CreateBitCast(value, vecPtrType);
return mIRBuilder->CreateAlignedLoad(ptrVal0, 1);
}
}
return NULL;
}
llvm::Type* BfIRCodeGen::GetElemType(llvm::Value* value)
{
auto valueType = value->getType();
if (auto vecType = llvm::dyn_cast<llvm::VectorType>(valueType))
return vecType->getVectorElementType();;
if (auto ptrType = llvm::dyn_cast<llvm::PointerType>(valueType))
{
auto ptrElemType = ptrType->getElementType();
if (auto arrType = llvm::dyn_cast<llvm::ArrayType>(ptrElemType))
return arrType->getArrayElementType();
if (auto vecType = llvm::dyn_cast<llvm::VectorType>(ptrElemType))
return vecType->getVectorElementType();
}
return NULL;
}
bool BfIRCodeGen::TryMemCpy(llvm::Value* ptr, llvm::Value* val)
{
auto valType = val->getType();
@ -1160,23 +1227,31 @@ bool BfIRCodeGen::TryVectorCpy(llvm::Value* ptr, llvm::Value* val)
if (ptr->getType()->getPointerElementType() == val->getType())
return false;
auto valType = val->getType();
auto vecType = llvm::dyn_cast<llvm::VectorType>(valType);
if (vecType == NULL)
if (!llvm::isa<llvm::VectorType>(val->getType()))
{
return false;
for (int i = 0; i < (int)vecType->getVectorNumElements(); i++)
{
auto extract = mIRBuilder->CreateExtractElement(val, i);
llvm::Value* gepArgs[] = {
llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), 0),
llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), i) };
auto gep = mIRBuilder->CreateInBoundsGEP(ptr, llvm::makeArrayRef(gepArgs));
mIRBuilder->CreateStore(extract, gep);
}
auto usePtr = mIRBuilder->CreateBitCast(ptr, val->getType()->getPointerTo());
mIRBuilder->CreateAlignedStore(val, usePtr, 1);
// auto valType = val->getType();
// auto vecType = llvm::dyn_cast<llvm::VectorType>(valType);
// if (vecType == NULL)
// return false;
//
// for (int i = 0; i < (int)vecType->getVectorNumElements(); i++)
// {
// auto extract = mIRBuilder->CreateExtractElement(val, i);
//
// llvm::Value* gepArgs[] = {
// llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), 0),
// llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), i) };
// auto gep = mIRBuilder->CreateInBoundsGEP(ptr, llvm::makeArrayRef(gepArgs));
//
// mIRBuilder->CreateStore(extract, gep);
// }
return true;
}
@ -2215,6 +2290,7 @@ void BfIRCodeGen::HandleNextCmd()
static _Intrinsics intrinsics[] =
{
{ (llvm::Intrinsic::ID)-1, -1}, // PLATFORM,
{ llvm::Intrinsic::fabs, 0, -1},
{ (llvm::Intrinsic::ID)-2, -1}, // add,
{ (llvm::Intrinsic::ID)-2, -1}, // and,
@ -2243,7 +2319,8 @@ void BfIRCodeGen::HandleNextCmd()
{ llvm::Intrinsic::floor, 0, -1},
{ (llvm::Intrinsic::ID)-2, -1}, // free
{ (llvm::Intrinsic::ID)-2, -1}, // gt
{ (llvm::Intrinsic::ID)-2, -1}, // gte
{ (llvm::Intrinsic::ID)-2, -1}, // gte
{ (llvm::Intrinsic::ID)-2, -1}, // index
{ llvm::Intrinsic::log, 0, -1},
{ llvm::Intrinsic::log10, 0, -1},
{ llvm::Intrinsic::log2, 0, -1},
@ -2269,21 +2346,6 @@ void BfIRCodeGen::HandleNextCmd()
};
BF_STATIC_ASSERT(BF_ARRAY_COUNT(intrinsics) == BfIRIntrinsic_COUNT);
bool isFakeIntrinsic = (int)intrinsics[intrinId].mID == -2;
if (isFakeIntrinsic)
{
auto intrinsicData = mAlloc.Alloc<BfIRIntrinsicData>();
intrinsicData->mName = intrinName;
intrinsicData->mIntrinsic = (BfIRIntrinsic)intrinId;
intrinsicData->mReturnType = returnType;
BfIRCodeGenEntry entry;
entry.mKind = BfIRCodeGenEntryKind_IntrinsicData;
entry.mIntrinsicData = intrinsicData;
mResults.TryAdd(curId, entry);
break;
}
CmdParamVec<llvm::Type*> useParams;
if (intrinsics[intrinId].mArg0 != -1)
{
@ -2298,11 +2360,55 @@ void BfIRCodeGen::HandleNextCmd()
}
}
BF_ASSERT(intrinsics[intrinId].mID != (llvm::Intrinsic::ID) - 1);
func = llvm::Intrinsic::getDeclaration(mLLVMModule, intrinsics[intrinId].mID, useParams);
bool isFakeIntrinsic = (int)intrinsics[intrinId].mID == -2;
if (isFakeIntrinsic)
{
auto intrinsicData = mAlloc.Alloc<BfIRIntrinsicData>();
intrinsicData->mName = intrinName;
intrinsicData->mIntrinsic = (BfIRIntrinsic)intrinId;
intrinsicData->mReturnType = returnType;
BfIRCodeGenEntry entry;
entry.mKind = BfIRCodeGenEntryKind_IntrinsicData;
entry.mIntrinsicData = intrinsicData;
mResults.TryAdd(curId, entry);
break;
}
if (intrinId == BfIRIntrinsic__PLATFORM)
{
int colonPos = (int)intrinName.IndexOf(':');
String platName = intrinName.Substring(0, colonPos);
String platIntrinName = intrinName.Substring(colonPos + 1);
if (platName.IsEmpty())
{
auto intrinsicData = mAlloc.Alloc<BfIRIntrinsicData>();
intrinsicData->mName = platIntrinName;
intrinsicData->mIntrinsic = BfIRIntrinsic__PLATFORM;
intrinsicData->mReturnType = returnType;
BfIRCodeGenEntry entry;
entry.mKind = BfIRCodeGenEntryKind_IntrinsicData;
entry.mIntrinsicData = intrinsicData;
mResults.TryAdd(curId, entry);
break;
}
llvm::Intrinsic::ID intrin = llvm::Intrinsic::getIntrinsicForGCCBuiltin(platName.c_str(), platIntrinName.c_str());
if ((int)intrin <= 0)
FatalError(StrFormat("Unable to find intrinsic '%s'", intrinName.c_str()));
else
func = llvm::Intrinsic::getDeclaration(mLLVMModule, intrinsics[intrinId].mID, useParams);
}
else
{
BF_ASSERT(intrinsics[intrinId].mID != (llvm::Intrinsic::ID)-1);
func = llvm::Intrinsic::getDeclaration(mLLVMModule, intrinsics[intrinId].mID, useParams);
}
mIntrinsicReverseMap[func] = intrinId;
SetResult(curId, func);
SetResult(curId, func);
}
break;
case BfIRCmd_CreateFunctionType:
@ -2414,6 +2520,23 @@ void BfIRCodeGen::HandleNextCmd()
switch (intrinsicData->mIntrinsic)
{
case BfIRIntrinsic__PLATFORM:
{
if (intrinsicData->mName == "add_ps")
{
auto val0 = TryToVector(args[0], llvm::Type::getFloatTy(*mLLVMContext));
auto val1 = TryToVector(args[0], llvm::Type::getFloatTy(*mLLVMContext));
//SetResult(curId, TryToVector(mIRBuilder->CreateFAdd(val0, val1), GetElemType(args[0])));
SetResult(curId, mIRBuilder->CreateFAdd(val0, val1));
}
else
{
FatalError(StrFormat("Unable to find intrinsic '%s'", intrinsicData->mName.c_str()));
}
}
break;
case BfIRIntrinsic_Add:
case BfIRIntrinsic_And:
case BfIRIntrinsic_Div:
@ -2453,7 +2576,11 @@ void BfIRCodeGen::HandleNextCmd()
{
auto ptrVal1 = mIRBuilder->CreateBitCast(args[1], vecType->getPointerTo());
val1 = mIRBuilder->CreateAlignedLoad(ptrVal1, 1);
}
}
else if (args[1]->getType()->isVectorTy())
{
val1 = args[1];
}
else
{
val1 = mIRBuilder->CreateInsertElement(llvm::UndefValue::get(vecType), args[1], (uint64)0);
@ -2644,6 +2771,19 @@ void BfIRCodeGen::HandleNextCmd()
}
}
break;
case BfIRIntrinsic_Index:
{
llvm::Value* gepArgs[] = {
llvm::ConstantInt::get(llvm::Type::getInt32Ty(*mLLVMContext), 0),
args[1] };
auto gep = mIRBuilder->CreateInBoundsGEP(args[0], llvm::makeArrayRef(gepArgs));
if (args.size() >= 3)
mIRBuilder->CreateStore(args[2], gep);
else
SetResult(curId, mIRBuilder->CreateLoad(gep));
}
break;
case BfIRIntrinsic_AtomicCmpStore:
case BfIRIntrinsic_AtomicCmpStore_Weak:
case BfIRIntrinsic_AtomicCmpXChg:
@ -3016,6 +3156,11 @@ void BfIRCodeGen::HandleNextCmd()
int intrinId = -1;
if (mIntrinsicReverseMap.TryGetValue(funcPtr, &intrinId))
{
if (intrinId == BfIRIntrinsic__PLATFORM)
{
NOP;
}
if (intrinId == BfIRIntrinsic_MemSet)
{
int align = 1;
@ -4876,6 +5021,9 @@ int BfIRCodeGen::GetIntrinsicId(const StringImpl& name)
if (name.StartsWith("shuffle"))
return BfIRIntrinsic_Shuffle;
if (name.Contains(':'))
return BfIRIntrinsic__PLATFORM;
return -1;
}

View file

@ -21,7 +21,7 @@ class BfIRIntrinsicData
public:
String mName;
BfIRIntrinsic mIntrinsic;
llvm::Type* mReturnType;
llvm::Type* mReturnType;
};
struct BfIRCodeGenEntry
@ -100,6 +100,8 @@ public:
void CreateMemSet(llvm::Value* addr, llvm::Value* val, llvm::Value* size, int alignment, bool isVolatile = false);
void AddNop();
llvm::Value* TryToVector(llvm::Value* value);
llvm::Value* TryToVector(llvm::Value* value, llvm::Type* elemType);
llvm::Type* GetElemType(llvm::Value* value);
bool TryMemCpy(llvm::Value* ptr, llvm::Value* val);
bool TryVectorCpy(llvm::Value* ptr, llvm::Value* val);

View file

@ -10572,7 +10572,7 @@ void BfModule::FinishAttributeState(BfAttributeState* attributeState)
Warn(0, "Unused attributes", attributeState->mSrc);
}
void BfModule::ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bool& isCRepr, bool& isOrdered, BfType*& underlyingArrayType, int& underlyingArraySize)
void BfModule::ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bool& isCRepr, bool& isOrdered, int& alignOverride, BfType*& underlyingArrayType, int& underlyingArraySize)
{
if (mCurTypeInstance->mCustomAttributes != NULL)
{
@ -10615,6 +10615,14 @@ void BfModule::ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bo
}
}
}
else if (typeName == "System.AlignAttribute")
{
if (customAttribute.mCtorArgs.size() >= 1)
{
auto alignConstant = mCurTypeInstance->mConstHolder->GetConstant(customAttribute.mCtorArgs[0]);
alignOverride = alignConstant->mInt32;
}
}
else if (typeName == "System.UnderlyingArrayAttribute")
{
if (customAttribute.mCtorArgs.size() >= 2)
@ -14856,7 +14864,7 @@ void BfModule::SetupIRMethod(BfMethodInstance* methodInstance, BfIRFunction func
PopulateType(resolvedTypeRef, BfPopulateType_Data);
addDeref = resolvedTypeRef->mSize;
}
else if (methodInstance->WantsIRStructsByVal())
else if (methodInstance->WantsStructsAttribByVal())
{
mBfIRBuilder->PopulateType(resolvedTypeRef);
mBfIRBuilder->Func_AddAttribute(func, argIdx + 1, BfIRAttribute_ByVal, mSystem->mPtrSize);

View file

@ -1467,7 +1467,7 @@ public:
void GetCustomAttributes(BfCustomAttributes* customAttributes, BfAttributeDirective* attributesDirective, BfAttributeTargets attrType, bool allowNonConstArgs = false, BfCaptureInfo* captureInfo = NULL);
BfCustomAttributes* GetCustomAttributes(BfAttributeDirective* attributesDirective, BfAttributeTargets attrType, bool allowNonConstArgs = false, BfCaptureInfo* captureInfo = NULL);
void FinishAttributeState(BfAttributeState* attributeState);
void ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bool& isCRepr, bool& isOrdered, BfType*& underlyingArrayType, int& underlyingArraySize);
void ProcessTypeInstCustomAttributes(bool& isPacked, bool& isUnion, bool& isCRepr, bool& isOrdered, int& alignOverride, BfType*& underlyingArrayType, int& underlyingArraySize);
void ProcessCustomAttributeData();
bool TryGetConstString(BfIRConstHolder* constHolder, BfIRValue irValue, StringImpl& str);
BfVariant TypedValueToVariant(BfAstNode* refNode, const BfTypedValue& value, bool allowUndef = false);

View file

@ -2594,9 +2594,10 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
bool isUnion = false;
bool isCRepr = false;
bool isOrdered = false;
int alignOverride = 0;
BfType* underlyingArrayType = NULL;
int underlyingArraySize = -1;
ProcessTypeInstCustomAttributes(isPacked, isUnion, isCRepr, isOrdered, underlyingArrayType, underlyingArraySize);
ProcessTypeInstCustomAttributes(isPacked, isUnion, isCRepr, isOrdered, alignOverride, underlyingArrayType, underlyingArraySize);
if (underlyingArraySize > 0)
{
typeInstance->mHasUnderlyingArray = true;
@ -3289,7 +3290,9 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
CheckMemberNames(typeInstance);
if (isPacked)
if (alignOverride > 0)
typeInstance->mInstAlign = alignOverride;
else if (isPacked)
typeInstance->mInstAlign = 1;
else
typeInstance->mInstAlign = std::max(1, typeInstance->mInstAlign);

View file

@ -696,7 +696,7 @@ bool BfMethodInstance::GetLoweredReturnType(BfTypeCode* loweredTypeCode, BfTypeC
return mReturnType->GetLoweredType(mMethodDef->mIsStatic ? BfTypeUsage_Return_Static : BfTypeUsage_Return_NonStatic, loweredTypeCode, loweredTypeCode2);
}
bool BfMethodInstance::WantsIRStructsByVal()
bool BfMethodInstance::WantsStructsAttribByVal()
{
auto owner = GetOwner();
if ((owner->mModule->mCompiler->mOptions.mPlatformType == BfPlatformType_Windows) &&

View file

@ -872,8 +872,8 @@ public:
bool HasParamsArray();
int GetStructRetIdx();
bool HasSelf();
bool GetLoweredReturnType(BfTypeCode* loweredTypeCode = NULL, BfTypeCode* loweredTypeCode2 = NULL);
bool WantsIRStructsByVal();
bool GetLoweredReturnType(BfTypeCode* loweredTypeCode = NULL, BfTypeCode* loweredTypeCode2 = NULL);
bool WantsStructsAttribByVal();
bool IsAutocompleteMethod() { /*return mIdHash == -1;*/ return mIsAutocompleteMethod; }
bool IsSkipCall(bool bypassVirtual = false);
bool IsVarArgs();
@ -1003,7 +1003,7 @@ public:
virtual bool IsUnspecializedTypeVariation() override { return mElementType->IsUnspecializedType(); }
virtual bool IsReified() override { return mElementType->IsReified(); }
virtual bool IsDependentOnUnderlyingType() override { return true; }
virtual bool IsAllocType() { return mModifiedKind == BfToken_AllocType; }
virtual bool IsAllocType() override { return mModifiedKind == BfToken_AllocType; }
virtual BfType* GetUnderlyingType() override { return mElementType; }
};