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

Fixes to global indexing

This commit is contained in:
Brian Fiete 2020-05-22 06:39:12 -07:00
parent 24f931df51
commit adbae6f1d4
3 changed files with 7 additions and 7 deletions

View file

@ -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";

View file

@ -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);

View file

@ -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);