mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +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)
|
else if (constStruct->mType->mTypeCode == BeTypeCode_SizedArray)
|
||||||
{
|
{
|
||||||
|
BeSizedArrayType* arrayType = (BeSizedArrayType*)constStruct->mType;
|
||||||
for (auto& memberVal : constStruct->mMemberValues)
|
for (auto& memberVal : constStruct->mMemberValues)
|
||||||
|
{
|
||||||
WriteConst(sect, memberVal);
|
WriteConst(sect, memberVal);
|
||||||
|
int padding = arrayType->mElementType->GetStride() - arrayType->mElementType->mSize;
|
||||||
|
if (padding > 0)
|
||||||
|
sect.mData.WriteZeros(padding);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
BF_FATAL("Invalid StructConst type");
|
BF_FATAL("Invalid StructConst type");
|
||||||
|
|
|
@ -899,8 +899,10 @@ void BeIRCodeGen::Read(BeValue*& beValue)
|
||||||
}
|
}
|
||||||
else if (constType == BfConstType_Undef)
|
else if (constType == BfConstType_Undef)
|
||||||
{
|
{
|
||||||
CMD_PARAM(BeType*, type);
|
CMD_PARAM(BeType*, type);
|
||||||
beValue = mBeModule->CreateUndefValue(type);
|
auto constUndef = mBeModule->mOwnedValues.Alloc<BeUndefConstant>();
|
||||||
|
constUndef->mType = type;
|
||||||
|
beValue = constUndef;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (constType == BfConstType_TypeOf)
|
else if (constType == BfConstType_TypeOf)
|
||||||
|
|
|
@ -2949,7 +2949,7 @@ void BeMCContext::CreateStore(BeMCInstKind instKind, const BeMCOperand& val, con
|
||||||
//AllocInst(instKind, destOperand, elementVal);
|
//AllocInst(instKind, destOperand, elementVal);
|
||||||
CreateStore(instKind, elementVal, destOperand);
|
CreateStore(instKind, elementVal, destOperand);
|
||||||
|
|
||||||
offset += elemType->mSize;
|
offset += elemType->GetStride();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1348,6 +1348,16 @@ void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, boo
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto constant = BeValueDynCast<BeUndefConstant>(value))
|
||||||
|
{
|
||||||
|
if (showType)
|
||||||
|
{
|
||||||
|
BeModule::ToString(str, constant->mType);
|
||||||
|
str += " ";
|
||||||
|
}
|
||||||
|
str += "undef";
|
||||||
|
}
|
||||||
|
|
||||||
if (auto constant = BeValueDynCast<BeCastConstant>(value))
|
if (auto constant = BeValueDynCast<BeCastConstant>(value))
|
||||||
{
|
{
|
||||||
ToString(str, constant->mType);
|
ToString(str, constant->mType);
|
||||||
|
|
|
@ -403,12 +403,25 @@ public:
|
||||||
virtual void HashContent(BeHashContext& hashCtx) override
|
virtual void HashContent(BeHashContext& hashCtx) override
|
||||||
{
|
{
|
||||||
hashCtx.Mixin(TypeId);
|
hashCtx.Mixin(TypeId);
|
||||||
|
hashCtx.Mixin(mType);
|
||||||
hashCtx.Mixin(mMemberValues.size());
|
hashCtx.Mixin(mMemberValues.size());
|
||||||
for (auto member : mMemberValues)
|
for (auto member : mMemberValues)
|
||||||
member->HashReference(hashCtx);
|
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
|
class BeStringConstant : public BeConstant
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue