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

Added RefType, changed how CRepr types are represented

This commit is contained in:
Brian Fiete 2020-07-02 11:05:17 -07:00
parent 716f7b3638
commit 0c946de3ca
13 changed files with 311 additions and 40 deletions

View file

@ -655,6 +655,33 @@ BfIRValue BfIRConstHolder::CreateConstArray(BfIRType type, const BfSizedArray<Bf
return irValue;
}
BfIRValue BfIRConstHolder::CreateConstArrayZero(BfIRType type, int count)
{
BfConstantArrayZero* constant = mTempAlloc.Alloc<BfConstantArrayZero>();
constant->mConstType = BfConstType_ArrayZero;
constant->mType = type = type;
constant->mCount = count;
auto irValue = BfIRValue(BfIRValueFlags_Const, mTempAlloc.GetChunkedId(constant));
#ifdef CHECK_CONSTHOLDER
irValue.mHolder = this;
#endif
return irValue;
}
BfIRValue BfIRConstHolder::CreateConstArrayZero(int count)
{
BfConstant* constant = mTempAlloc.Alloc<BfConstant>();
constant->mConstType = BfConstType_ArrayZero8;
constant->mInt64 = count;
auto irValue = BfIRValue(BfIRValueFlags_Const, mTempAlloc.GetChunkedId(constant));
#ifdef CHECK_CONSTHOLDER
irValue.mHolder = this;
#endif
return irValue;
}
BfIRValue BfIRConstHolder::CreateTypeOf(BfType* type)
{
BfTypeOf_Const* typeOf = mTempAlloc.Alloc<BfTypeOf_Const>();
@ -1779,6 +1806,11 @@ void BfIRBuilder::Write(const BfIRValue& irValue)
Write(arrayConst->mValues);
}
break;
case (int)BfConstType_ArrayZero8:
{
Write(constant->mInt64);
}
break;
default:
{
BF_FATAL("Unhandled");
@ -3026,7 +3058,8 @@ void BfIRBuilder::CreateTypeDefinition(BfType* type, bool forceDbgDefine)
BfIRType resolvedFieldIRType = MapType(resolvedFieldType);
bool needsExplicitAlignment = !isCRepr || resolvedFieldType->NeedsExplicitAlignment();
//bool needsExplicitAlignment = !isCRepr || resolvedFieldType->NeedsExplicitAlignment();
bool needsExplicitAlignment = true;
if (!needsExplicitAlignment)
{
int alignSize = resolvedFieldType->mAlign;
@ -3075,7 +3108,7 @@ void BfIRBuilder::CreateTypeDefinition(BfType* type, bool forceDbgDefine)
}
if (!typeInstance->IsTypedPrimitive())
StructSetBody(MapTypeInst(typeInstance), irFieldTypes, isPacked || !isCRepr);
StructSetBody(MapTypeInst(typeInstance), irFieldTypes, /*isPacked || !isCRepr*/true);
if (typeInstance->IsNullable())
{