1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Fixed ExtractValue for splat unions

This commit is contained in:
Brian Fiete 2022-09-10 10:25:45 -07:00
parent 47732ae09c
commit cafbcd30dc
3 changed files with 23 additions and 11 deletions

View file

@ -13213,9 +13213,9 @@ BfTypedValue BfModule::ExtractValue(BfTypedValue typedValue, BfFieldInstance* fi
{
if (typedValue.IsSplat())
{
BfTypedValue innerVal = typedValue;
innerVal.mType = fieldType;
return innerVal;
bool isAddr = false;
BfIRValue irVal = ExtractSplatValue(typedValue, 0, fieldType, &isAddr);
return BfTypedValue(irVal, fieldType, isAddr ? BfTypedValueKind_Addr : BfTypedValueKind_SplatHead);
}
}
}
@ -13240,9 +13240,9 @@ BfTypedValue BfModule::ExtractValue(BfTypedValue typedValue, BfFieldInstance* fi
if (typedValue.IsSplat())
{
BfTypedValue innerVal = typedValue;
innerVal.mType = fieldType;
return innerVal;
bool isAddr = false;
BfIRValue irVal = ExtractSplatValue(typedValue, 0, fieldType, &isAddr);
return BfTypedValue(irVal, fieldType, isAddr ? BfTypedValueKind_Addr : BfTypedValueKind_SplatHead);
}
}
}
@ -15499,11 +15499,6 @@ void BfModule::DoLocalVariableDebugInfo(BfLocalVariable* localVarDef, bool doAli
BfLocalVariable* BfModule::AddLocalVariableDef(BfLocalVariable* localVarDef, bool addDebugInfo, bool doAliasValue, BfIRValue declareBefore, BfIRInitType initType)
{
if (localVarDef->mName == "newSuccIndex")
{
NOP;
}
if ((localVarDef->mValue) && (!localVarDef->mAddr) && (IsTargetingBeefBackend()) && (!localVarDef->mResolvedType->IsValuelessType()))
{
if ((!localVarDef->mValue.IsConst()) &&

View file

@ -420,6 +420,7 @@ namespace Tests
{
if (!MoveNext())
return .Err;
#unwarn
return &CurrentRef;
}
}

View file

@ -35,6 +35,18 @@ namespace Tests
public int16 mInt16;
}
[Union]
public struct UnionE
{
public uint32 values;
public int r
{
get { return uint8((this.values & 0xFF000000) >> 24); }
set mut { this.values = (this.values & 0x00FFFFFF) | ((uint32(value) & 0x000000FF) << 24); }
}
}
[Test]
static void TestBasics()
{
@ -54,6 +66,10 @@ namespace Tests
Test.Assert(sizeof(UnionD) == 6);
Test.Assert(alignof(UnionD) == 4);
Test.Assert(((int16*)&ud)[2] == 234);
UnionE ue = .();
ue.r = 123;
Test.Assert(ue.r == 123);
}
}
}