mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Fix to sized array initialization
This commit is contained in:
parent
4b965a440d
commit
24f931df51
3 changed files with 32 additions and 5 deletions
|
@ -3622,7 +3622,7 @@ BeMCOperand BeMCContext::AllocVirtualReg(BeType* type, int refCount, bool mustBe
|
||||||
|
|
||||||
if (mDebugging)
|
if (mDebugging)
|
||||||
{
|
{
|
||||||
if (mcOperand.mVRegIdx == 15)
|
if (mcOperand.mVRegIdx == 4)
|
||||||
{
|
{
|
||||||
NOP;
|
NOP;
|
||||||
}
|
}
|
||||||
|
@ -3840,6 +3840,16 @@ bool BeMCContext::HasSymbolAddr(const BeMCOperand& operand)
|
||||||
|
|
||||||
BeMCOperand BeMCContext::ReplaceWithNewVReg(BeMCOperand& operand, int& instIdx, bool isInput, bool mustBeReg)
|
BeMCOperand BeMCContext::ReplaceWithNewVReg(BeMCOperand& operand, int& instIdx, bool isInput, bool mustBeReg)
|
||||||
{
|
{
|
||||||
|
if ((isInput) && (operand.mKind == BeMCOperandKind_VRegLoad))
|
||||||
|
{
|
||||||
|
BeMCOperand addrOperand = BeMCOperand::ToAddr(operand);
|
||||||
|
BeMCOperand scratchReg = AllocVirtualReg(GetType(addrOperand), 2, mustBeReg);
|
||||||
|
CreateDefineVReg(scratchReg, instIdx++);
|
||||||
|
AllocInst(BeMCInstKind_Mov, scratchReg, addrOperand, instIdx++);
|
||||||
|
operand = BeMCOperand::ToLoad(scratchReg);
|
||||||
|
return scratchReg;
|
||||||
|
}
|
||||||
|
|
||||||
BeMCOperand scratchReg = AllocVirtualReg(GetType(operand), 2, mustBeReg);
|
BeMCOperand scratchReg = AllocVirtualReg(GetType(operand), 2, mustBeReg);
|
||||||
CreateDefineVReg(scratchReg, instIdx++);
|
CreateDefineVReg(scratchReg, instIdx++);
|
||||||
if (isInput)
|
if (isInput)
|
||||||
|
|
|
@ -9,10 +9,6 @@ StartupProject = "Tests"
|
||||||
BfOptimizationLevel = "O0"
|
BfOptimizationLevel = "O0"
|
||||||
IntermediateType = "ObjectAndIRCode"
|
IntermediateType = "ObjectAndIRCode"
|
||||||
|
|
||||||
[Configs.Debug.Linux64]
|
|
||||||
Toolset = "GNU"
|
|
||||||
EnableRealtimeLeakCheck = false
|
|
||||||
|
|
||||||
[Configs.Test.Win64]
|
[Configs.Test.Win64]
|
||||||
IntermediateType = "ObjectAndIRCode"
|
IntermediateType = "ObjectAndIRCode"
|
||||||
COptimizationLevel = "O2"
|
COptimizationLevel = "O2"
|
||||||
|
|
|
@ -4,6 +4,8 @@ namespace Tests
|
||||||
{
|
{
|
||||||
class SizedArrays
|
class SizedArrays
|
||||||
{
|
{
|
||||||
|
public static int[8] iArr = .(123, 234, 345, );
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
static void TestBasics()
|
static void TestBasics()
|
||||||
{
|
{
|
||||||
|
@ -23,5 +25,24 @@ namespace Tests
|
||||||
Test.Assert(val0 != val2);
|
Test.Assert(val0 != val2);
|
||||||
Test.Assert(val2[1] == val1);
|
Test.Assert(val2[1] == val1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
static void TestStatic()
|
||||||
|
{
|
||||||
|
Test.Assert(iArr[0] == 123);
|
||||||
|
Test.Assert(iArr[1] == 234);
|
||||||
|
Test.Assert(iArr[2] == 345);
|
||||||
|
Test.Assert(iArr[3] == 0);
|
||||||
|
|
||||||
|
iArr[0] += 1000;
|
||||||
|
iArr[2] += 2000;
|
||||||
|
iArr[3] += 3000;
|
||||||
|
iArr[3] += 4000;
|
||||||
|
|
||||||
|
Test.Assert(iArr[0] == 1123);
|
||||||
|
Test.Assert(iArr[1] == 2234);
|
||||||
|
Test.Assert(iArr[2] == 3345);
|
||||||
|
Test.Assert(iArr[3] == 4000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue