From adbae6f1d4bddfd802974728f57a41682f319ee3 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 22 May 2020 06:39:12 -0700 Subject: [PATCH] Fixes to global indexing --- IDEHelper/Backend/BeMCContext.cpp | 8 ++++---- IDEHelper/Backend/BeMCContext.h | 2 +- IDEHelper/Tests/src/SizedArrays.bf | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/IDEHelper/Backend/BeMCContext.cpp b/IDEHelper/Backend/BeMCContext.cpp index 4e1c6718..f71de2f5 100644 --- a/IDEHelper/Backend/BeMCContext.cpp +++ b/IDEHelper/Backend/BeMCContext.cpp @@ -3838,9 +3838,9 @@ bool BeMCContext::HasSymbolAddr(const BeMCOperand& operand) return false; } -BeMCOperand BeMCContext::ReplaceWithNewVReg(BeMCOperand& operand, int& instIdx, bool isInput, bool mustBeReg) +BeMCOperand BeMCContext::ReplaceWithNewVReg(BeMCOperand& operand, int& instIdx, bool isInput, bool mustBeReg, bool preserveDeref) { - if ((isInput) && (operand.mKind == BeMCOperandKind_VRegLoad)) + if ((isInput) && (operand.mKind == BeMCOperandKind_VRegLoad) && (preserveDeref)) { BeMCOperand addrOperand = BeMCOperand::ToAddr(operand); BeMCOperand scratchReg = AllocVirtualReg(GetType(addrOperand), 2, mustBeReg); @@ -8356,7 +8356,7 @@ bool BeMCContext::DoLegalization() { if ((HasSymbolAddr(inst->mArg0)) && (inst->mKind != BeMCInstKind_Call)) { - ReplaceWithNewVReg(inst->mArg0, instIdx, true, false); + ReplaceWithNewVReg(inst->mArg0, instIdx, true, false, true); isFinalRun = false; // if (debugging) // OutputDebugStrF(" SymbolAddr0\n"); @@ -14769,7 +14769,7 @@ void BeMCContext::Generate(BeFunction* function) mDbgPreferredRegs[32] = X64Reg_R8;*/ //mDbgPreferredRegs[8] = X64Reg_RAX; - //mDebugging = function->mName == "?Hey@Blurg@bf@@SAXXZ"; + //mDebugging = function->mName == "?DrawBox@Graphics@gfx@Beefy@bf@@QEAAXPEAVImage@234@MMMM@Z"; //"?ColorizeCodeString@IDEUtils@IDE@bf@@SAXPEAVString@System@3@W4CodeKind@123@@Z"; //"?Main@Program@bf@@CAHPEAV?$Array1@PEAVString@System@bf@@@System@2@@Z"; diff --git a/IDEHelper/Backend/BeMCContext.h b/IDEHelper/Backend/BeMCContext.h index 64da7405..a605aca8 100644 --- a/IDEHelper/Backend/BeMCContext.h +++ b/IDEHelper/Backend/BeMCContext.h @@ -1317,7 +1317,7 @@ public: BeMCOperand AllocRelativeVirtualReg(BeType* type, const BeMCOperand& relTo, const BeMCOperand& relOffset, int relScale); BeMCVRegInfo* GetVRegInfo(const BeMCOperand& operand); bool HasSymbolAddr(const BeMCOperand& operand); - BeMCOperand ReplaceWithNewVReg(BeMCOperand& operand, int& instIdx, bool isInput, bool mustBeReg = true); + BeMCOperand ReplaceWithNewVReg(BeMCOperand& operand, int& instIdx, bool isInput, bool mustBeReg = true, bool preserveDeref = false); BeMCOperand RemapOperand(BeMCOperand& operand, BeMCRemapper& regRemaps); bool IsLive(BeVTrackingList* liveRegs, int vregIdx, BeMCRemapper& regRemaps); void AddRegRemap(int from, int to, BeMCRemapper& regRemaps, bool allowRemapToDbgVar = false); diff --git a/IDEHelper/Tests/src/SizedArrays.bf b/IDEHelper/Tests/src/SizedArrays.bf index f03915ad..b6a69e05 100644 --- a/IDEHelper/Tests/src/SizedArrays.bf +++ b/IDEHelper/Tests/src/SizedArrays.bf @@ -35,8 +35,8 @@ namespace Tests Test.Assert(iArr[3] == 0); iArr[0] += 1000; - iArr[2] += 2000; - iArr[3] += 3000; + iArr[1] += 2000; + iArr[2] += 3000; iArr[3] += 4000; Test.Assert(iArr[0] == 1123);