mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed crepr union size
This commit is contained in:
parent
682798fe7e
commit
868700b0dd
5 changed files with 15 additions and 35 deletions
|
@ -19286,8 +19286,6 @@ void BfExprEvaluator::InitializedSizedArray(BfSizedArrayType* arrayType, BfToken
|
|||
elementValue = mModule->GetDefaultTypedValue(checkArrayType->mElementType);
|
||||
|
||||
// For now, we can't properly create const-valued non-size-aligned composites
|
||||
// if (checkArrayType->mElementType->NeedsExplicitAlignment())
|
||||
// isAllConst = false;
|
||||
if (!elementValue.mValue.IsConst())
|
||||
isAllConst = false;
|
||||
if (elementValue.IsAddr())
|
||||
|
|
|
@ -3690,14 +3690,6 @@ void BfIRBuilder::CreateTypeDefinition_Data(BfModule* populateModule, BfTypeInst
|
|||
|
||||
BfIRType resolvedFieldIRType = MapType(resolvedFieldType);
|
||||
|
||||
//bool needsExplicitAlignment = !isCRepr || resolvedFieldType->NeedsExplicitAlignment();
|
||||
bool needsExplicitAlignment = true;
|
||||
if (!needsExplicitAlignment)
|
||||
{
|
||||
int alignSize = resolvedFieldType->mAlign;
|
||||
dataPos = (dataPos + (alignSize - 1)) & ~(alignSize - 1);
|
||||
}
|
||||
|
||||
if (fieldInstance->mDataOffset > dataPos)
|
||||
{
|
||||
int fillSize = fieldInstance->mDataOffset - dataPos;
|
||||
|
@ -3710,8 +3702,9 @@ void BfIRBuilder::CreateTypeDefinition_Data(BfModule* populateModule, BfTypeInst
|
|||
|
||||
BF_ASSERT((int)irFieldTypes.size() == fieldInstance->mDataIdx);
|
||||
irFieldTypes.push_back(resolvedFieldIRType);
|
||||
}
|
||||
|
||||
if ((isCRepr) && (needsExplicitAlignment) && (fieldIdx == (int)orderedFields.size() - 1))
|
||||
if (isCRepr)
|
||||
{
|
||||
// Add explicit padding at end to enforce the "aligned size"
|
||||
int endPad = typeInstance->mInstSize - dataPos;
|
||||
|
@ -3723,7 +3716,6 @@ void BfIRBuilder::CreateTypeDefinition_Data(BfModule* populateModule, BfTypeInst
|
|||
dataPos += endPad;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeInstance->mIsUnion)
|
||||
{
|
||||
|
|
|
@ -4859,8 +4859,6 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
}
|
||||
}
|
||||
|
||||
//bool needsExplicitAlignment = !isCRepr || ((typeInstance->mBaseType != NULL) && (!typeInstance->mBaseType->mIsCRepr));
|
||||
|
||||
bool needsExplicitAlignment = true;
|
||||
|
||||
for (int fieldIdx = 0; fieldIdx < (int)dataFieldVec.size(); fieldIdx++)
|
||||
|
@ -4873,8 +4871,6 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
|||
int alignSize = fieldInstance->GetAlign(packing);
|
||||
fieldInstance->mDataSize = dataSize;
|
||||
|
||||
//bool needsExplicitAlignment = !isCRepr || resolvedFieldType->NeedsExplicitAlignment();
|
||||
|
||||
int nextDataPos = dataPos;
|
||||
nextDataPos = (dataPos + (alignSize - 1)) & ~(alignSize - 1);
|
||||
int padding = nextDataPos - dataPos;
|
||||
|
|
|
@ -508,7 +508,6 @@ public:
|
|||
|
||||
int GetStride() { return BF_ALIGN(mSize, mAlign); }
|
||||
bool IsSizeAligned() { return (mSize == 0) || (mSize % mAlign == 0); }
|
||||
virtual bool NeedsExplicitAlignment() { return !IsSizeAligned(); }
|
||||
virtual bool IsInstanceOf(BfTypeDef* typeDef) { return false; }
|
||||
|
||||
virtual bool HasBeenReferenced() { return mDefineState != BfTypeDefineState_Undefined; }
|
||||
|
@ -2030,7 +2029,6 @@ public:
|
|||
int GetEndingInstanceAlignment() { if (mInstSize % mInstAlign == 0) return mInstAlign; return mInstSize % mInstAlign; }
|
||||
virtual bool HasTypeFailed() override { return mTypeFailed; }
|
||||
virtual bool IsReified() override { return mIsReified; }
|
||||
virtual bool NeedsExplicitAlignment() override { return !IsSizeAligned() || (mPacking != 0); }
|
||||
virtual bool IsDataIncomplete() override { return ((mTypeIncomplete) || (mBaseTypeMayBeIncomplete)) && (!mNeedsMethodProcessing); }
|
||||
virtual bool IsFinishingType() override { return mIsFinishingType; }
|
||||
virtual bool IsIncomplete() override { return (mTypeIncomplete) || (mBaseTypeMayBeIncomplete); }
|
||||
|
@ -2453,8 +2451,6 @@ public:
|
|||
mWantsGCMarking = false;
|
||||
}
|
||||
|
||||
virtual bool NeedsExplicitAlignment() override { return mElementType->NeedsExplicitAlignment(); }
|
||||
|
||||
virtual bool IsSizedArray() override { return true; }
|
||||
virtual bool IsUndefSizedArray() override { return mElementCount == -1; }
|
||||
|
||||
|
@ -2485,8 +2481,6 @@ public:
|
|||
BfType* mElementCountSource;
|
||||
|
||||
public:
|
||||
virtual bool NeedsExplicitAlignment() override { return mElementType->NeedsExplicitAlignment(); }
|
||||
|
||||
virtual bool IsUnknownSizedArrayType() override { return true; }
|
||||
|
||||
virtual bool IsWrappableType() override { return true; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue