mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +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 (mcOperand.mVRegIdx == 15)
|
||||
if (mcOperand.mVRegIdx == 4)
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
@ -3840,6 +3840,16 @@ bool BeMCContext::HasSymbolAddr(const BeMCOperand& operand)
|
|||
|
||||
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);
|
||||
CreateDefineVReg(scratchReg, instIdx++);
|
||||
if (isInput)
|
||||
|
|
|
@ -9,10 +9,6 @@ StartupProject = "Tests"
|
|||
BfOptimizationLevel = "O0"
|
||||
IntermediateType = "ObjectAndIRCode"
|
||||
|
||||
[Configs.Debug.Linux64]
|
||||
Toolset = "GNU"
|
||||
EnableRealtimeLeakCheck = false
|
||||
|
||||
[Configs.Test.Win64]
|
||||
IntermediateType = "ObjectAndIRCode"
|
||||
COptimizationLevel = "O2"
|
||||
|
|
|
@ -4,6 +4,8 @@ namespace Tests
|
|||
{
|
||||
class SizedArrays
|
||||
{
|
||||
public static int[8] iArr = .(123, 234, 345, );
|
||||
|
||||
[Test]
|
||||
static void TestBasics()
|
||||
{
|
||||
|
@ -23,5 +25,24 @@ namespace Tests
|
|||
Test.Assert(val0 != val2);
|
||||
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