mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Const sized array lookup fix
This commit is contained in:
parent
c43212c38a
commit
8c2d65ca78
1 changed files with 20 additions and 6 deletions
|
@ -14992,11 +14992,25 @@ void BeMCContext::Generate(BeFunction* function)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto aggType = GetType(mcAgg);
|
auto aggType = GetType(mcAgg);
|
||||||
BF_ASSERT(aggType->IsStruct());
|
int byteOffset = 0;
|
||||||
BeStructType* structType = (BeStructType*)aggType;
|
BeType* memberType = NULL;
|
||||||
auto& structMember = structType->mMembers[castedInst->mIdx];
|
|
||||||
|
if (aggType->IsSizedArray())
|
||||||
|
{
|
||||||
|
auto sizedArray = (BeSizedArrayType*)aggType;
|
||||||
|
memberType = sizedArray->mElementType;
|
||||||
|
byteOffset = BF_ALIGN(memberType->mSize, memberType->mAlign) * castedInst->mIdx;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BF_ASSERT(aggType->IsStruct());
|
||||||
|
BeStructType* structType = (BeStructType*)aggType;
|
||||||
|
auto& structMember = structType->mMembers[castedInst->mIdx];
|
||||||
|
byteOffset = structMember.mByteOffset;
|
||||||
|
memberType = structMember.mType;
|
||||||
|
}
|
||||||
|
|
||||||
if (mcAgg.mKind == BeMCOperandKind_VReg)
|
if (mcAgg.mKind == BeMCOperandKind_VReg)
|
||||||
mcAgg.mKind = BeMCOperandKind_VRegAddr;
|
mcAgg.mKind = BeMCOperandKind_VRegAddr;
|
||||||
|
@ -15004,8 +15018,8 @@ void BeMCContext::Generate(BeFunction* function)
|
||||||
mcAgg.mKind = BeMCOperandKind_VReg;
|
mcAgg.mKind = BeMCOperandKind_VReg;
|
||||||
else
|
else
|
||||||
NotImpl();
|
NotImpl();
|
||||||
auto memberPtrType = mModule->mContext->GetPointerTo(structMember.mType);
|
auto memberPtrType = mModule->mContext->GetPointerTo(memberType);
|
||||||
result = AllocRelativeVirtualReg(memberPtrType, mcAgg, BeMCOperand::FromImmediate(structMember.mByteOffset), 1);
|
result = AllocRelativeVirtualReg(memberPtrType, mcAgg, BeMCOperand::FromImmediate(byteOffset), 1);
|
||||||
result.mKind = BeMCOperandKind_VRegLoad;
|
result.mKind = BeMCOperandKind_VRegLoad;
|
||||||
CreateDefineVReg(result);
|
CreateDefineVReg(result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue