mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Fixed const stride issues
This commit is contained in:
parent
e60bbdf64f
commit
8c700e6deb
5 changed files with 34 additions and 3 deletions
|
@ -1880,8 +1880,14 @@ void BeCOFFObject::WriteConst(BeCOFFSection& sect, BeConstant* constVal)
|
|||
}
|
||||
else if (constStruct->mType->mTypeCode == BeTypeCode_SizedArray)
|
||||
{
|
||||
BeSizedArrayType* arrayType = (BeSizedArrayType*)constStruct->mType;
|
||||
for (auto& memberVal : constStruct->mMemberValues)
|
||||
{
|
||||
WriteConst(sect, memberVal);
|
||||
int padding = arrayType->mElementType->GetStride() - arrayType->mElementType->mSize;
|
||||
if (padding > 0)
|
||||
sect.mData.WriteZeros(padding);
|
||||
}
|
||||
}
|
||||
else
|
||||
BF_FATAL("Invalid StructConst type");
|
||||
|
|
|
@ -899,8 +899,10 @@ void BeIRCodeGen::Read(BeValue*& beValue)
|
|||
}
|
||||
else if (constType == BfConstType_Undef)
|
||||
{
|
||||
CMD_PARAM(BeType*, type);
|
||||
beValue = mBeModule->CreateUndefValue(type);
|
||||
CMD_PARAM(BeType*, type);
|
||||
auto constUndef = mBeModule->mOwnedValues.Alloc<BeUndefConstant>();
|
||||
constUndef->mType = type;
|
||||
beValue = constUndef;
|
||||
return;
|
||||
}
|
||||
else if (constType == BfConstType_TypeOf)
|
||||
|
|
|
@ -2949,7 +2949,7 @@ void BeMCContext::CreateStore(BeMCInstKind instKind, const BeMCOperand& val, con
|
|||
//AllocInst(instKind, destOperand, elementVal);
|
||||
CreateStore(instKind, elementVal, destOperand);
|
||||
|
||||
offset += elemType->mSize;
|
||||
offset += elemType->GetStride();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1348,6 +1348,16 @@ void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, boo
|
|||
return;
|
||||
}
|
||||
|
||||
if (auto constant = BeValueDynCast<BeUndefConstant>(value))
|
||||
{
|
||||
if (showType)
|
||||
{
|
||||
BeModule::ToString(str, constant->mType);
|
||||
str += " ";
|
||||
}
|
||||
str += "undef";
|
||||
}
|
||||
|
||||
if (auto constant = BeValueDynCast<BeCastConstant>(value))
|
||||
{
|
||||
ToString(str, constant->mType);
|
||||
|
|
|
@ -403,12 +403,25 @@ public:
|
|||
virtual void HashContent(BeHashContext& hashCtx) override
|
||||
{
|
||||
hashCtx.Mixin(TypeId);
|
||||
hashCtx.Mixin(mType);
|
||||
hashCtx.Mixin(mMemberValues.size());
|
||||
for (auto member : mMemberValues)
|
||||
member->HashReference(hashCtx);
|
||||
}
|
||||
};
|
||||
|
||||
class BeUndefConstant : public BeConstant
|
||||
{
|
||||
public:
|
||||
BE_VALUE_TYPE(BeUndefConstant, BeConstant);
|
||||
|
||||
virtual void HashContent(BeHashContext& hashCtx) override
|
||||
{
|
||||
hashCtx.Mixin(mType);
|
||||
hashCtx.Mixin(TypeId);
|
||||
}
|
||||
};
|
||||
|
||||
class BeStringConstant : public BeConstant
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue