Skip to content

Commit

Permalink
REVERT: temporary add #ifdef TARGET_ARM64 for accessing regMaskTP met…
Browse files Browse the repository at this point in the history
…hods
  • Loading branch information
kunalspathak committed May 20, 2024
1 parent 06bd9e2 commit 325bc6e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/coreclr/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,11 @@ void LinearScan::updateNextFixedRef(RegRecord* regRecord, RefPosition* nextRefPo
SingleTypeRegSet LinearScan::getMatchingConstants(SingleTypeRegSet mask, Interval* currentInterval, RefPosition* refPosition)
{
assert(currentInterval->isConstant && RefTypeIsDef(refPosition->refType));
#ifdef TARGET_ARM64
SingleTypeRegSet candidates = (mask & m_RegistersWithConstants).GetRegSetForType(currentInterval->registerType);
#else
SingleTypeRegSet candidates = (mask & m_RegistersWithConstants);
#endif
SingleTypeRegSet result = RBM_NONE;
while (candidates != RBM_NONE)
{
Expand Down Expand Up @@ -495,7 +499,12 @@ SingleTypeRegSet LinearScan::getConstrainedRegMask(RefPosition* refPosition,

if ((refPosition != nullptr) && !refPosition->RegOptional())
{
SingleTypeRegSet busyRegs = (regsBusyUntilKill | regsInUseThisLocation).GetRegSetForType(TYP_VOID); //TODO: Pass the right type
#ifdef TARGET_ARM64
// TODO-lsra: Pass the right type
SingleTypeRegSet busyRegs = (regsBusyUntilKill | regsInUseThisLocation).GetRegSetForType(TYP_VOID);
#else
SingleTypeRegSet busyRegs = (regsBusyUntilKill | regsInUseThisLocation);
#endif
if ((newMask & ~busyRegs) == RBM_NONE)
{
// Constrained mask does not have at least one free register to allocate.
Expand Down Expand Up @@ -13481,8 +13490,14 @@ SingleTypeRegSet LinearScan::RegisterSelection::select(Interval*
if (currentInterval->isWriteThru)
{
// We'll only prefer a callee-save register if it's already been used.
#ifdef TARGET_ARM64
SingleTypeRegSet unusedCalleeSaves =
calleeSaveCandidates & ~(linearScan->compiler->codeGen->regSet.rsGetModifiedRegsMask()).GetRegSetForType(regType);
#else
SingleTypeRegSet unusedCalleeSaves =
calleeSaveCandidates &
~(linearScan->compiler->codeGen->regSet.rsGetModifiedRegsMask());
#endif
callerCalleePrefs = calleeSaveCandidates & ~unusedCalleeSaves;
preferences &= ~unusedCalleeSaves;
}
Expand Down Expand Up @@ -13531,7 +13546,11 @@ SingleTypeRegSet LinearScan::RegisterSelection::select(Interval*
// TODO-CQ: We assign same registerAssignment to UPPER_RESTORE and the next USE.
// When we allocate for USE, we see that the register is busy at current location
// and we end up with that candidate is no longer available.
#ifdef TARGET_ARM64
SingleTypeRegSet busyRegs = (linearScan->regsBusyUntilKill | linearScan->regsInUseThisLocation).GetRegSetForType(regType);
#else
SingleTypeRegSet busyRegs = (linearScan->regsBusyUntilKill | linearScan->regsInUseThisLocation);
#endif
candidates &= ~busyRegs;

#ifdef TARGET_ARM
Expand All @@ -13553,7 +13572,11 @@ SingleTypeRegSet LinearScan::RegisterSelection::select(Interval*
// Also eliminate as busy any register with a conflicting fixed reference at this or
// the next location.
// Note that this will eliminate the fixedReg, if any, but we'll add it back below.
#ifdef TARGET_ARM64
SingleTypeRegSet checkConflictMask = candidates & linearScan->fixedRegs.GetRegSetForType(regType);
#else
SingleTypeRegSet checkConflictMask = candidates & linearScan->fixedRegs;
#endif
while (checkConflictMask != RBM_NONE)
{
regNumber checkConflictReg = genFirstRegNumFromMask(checkConflictMask);
Expand Down Expand Up @@ -13853,7 +13876,11 @@ SingleTypeRegSet LinearScan::RegisterSelection::selectMinimal(
// TODO-CQ: We assign same registerAssignment to UPPER_RESTORE and the next USE.
// When we allocate for USE, we see that the register is busy at current location
// and we end up with that candidate is no longer available.
#ifdef TARGET_ARM64
SingleTypeRegSet busyRegs = (linearScan->regsBusyUntilKill | linearScan->regsInUseThisLocation).GetRegSetForType(regType);
#else
SingleTypeRegSet busyRegs = (linearScan->regsBusyUntilKill | linearScan->regsInUseThisLocation);
#endif // TARGET_ARM64
candidates &= ~busyRegs;

#ifdef TARGET_ARM
Expand All @@ -13871,7 +13898,11 @@ SingleTypeRegSet LinearScan::RegisterSelection::selectMinimal(
// Also eliminate as busy any register with a conflicting fixed reference at this or
// the next location.
// Note that this will eliminate the fixedReg, if any, but we'll add it back below.
#ifdef TARGET_ARM64
SingleTypeRegSet checkConflictMask = candidates & linearScan->fixedRegs.GetRegSetForType(regType);
#else
SingleTypeRegSet checkConflictMask = candidates & linearScan->fixedRegs;
#endif
while (checkConflictMask != RBM_NONE)
{
regNumber checkConflictReg = genFirstRegNumFromMask(checkConflictMask);
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/jit/lsra.h
Original file line number Diff line number Diff line change
Expand Up @@ -1251,7 +1251,11 @@ class LinearScan : public LinearScanInterface
result &= (m_AvailableRegs >> 1);
}
#endif // TARGET_ARM
#ifdef TARGET_ARM64
return result.GetRegSetForType(regType);
#else
return result;
#endif
}

#ifdef DEBUG
Expand Down
18 changes: 18 additions & 0 deletions src/coreclr/jit/lsrabuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -708,11 +708,15 @@ void LinearScan::addKillForRegs(regMaskTP mask, LsraLocation currentLoc)
// modified until codegen, which is too late.
compiler->codeGen->regSet.rsSetRegsModified(mask DEBUGARG(true));

#ifdef TARGET_ARM64
RefPosition* pos = newRefPosition((Interval*)nullptr, currentLoc, RefTypeKill, nullptr, mask.getLow());
*killTail = pos;
killTail = &pos->nextRefPosition;

pos = newRefPosition((Interval*)nullptr, currentLoc, RefTypeKill, nullptr, mask.getHigh());
#else
RefPosition* pos = newRefPosition((Interval*)nullptr, currentLoc, RefTypeKill, nullptr, mask);
#endif

*killTail = pos;
killTail = &pos->nextRefPosition;
Expand Down Expand Up @@ -1152,7 +1156,11 @@ bool LinearScan::buildKillPositionsForNode(GenTree* tree, LsraLocation currentLo
}
Interval* interval = getIntervalForLocalVar(varIndex);
const bool isCallKill = ((killMask == RBM_INT_CALLEE_TRASH) || (killMask == RBM_CALLEE_TRASH));
#ifdef TARGET_ARM64
SingleTypeRegSet regsKillMask = killMask.GetRegSetForType(interval->registerType);
#else
SingleTypeRegSet regsKillMask = killMask;
#endif

if (isCallKill)
{
Expand Down Expand Up @@ -3165,8 +3173,14 @@ void LinearScan::BuildCallDefs(GenTree* tree, int dstCount, regMaskTP dstCandida
// For all other cases of multi-reg definitions, the registers must be in sequential order.
regNumber thisReg = tree->AsCall()->GetReturnTypeDesc()->GetABIReturnReg(i, tree->AsCall()->GetUnmanagedCallConv());

#ifdef TARGET_ARM64
assert(dstCandidates.IsRegNumInMask(thisReg));
dstCandidates.RemoveRegNumFromMask(thisReg);
#else
assert((dstCandidates & genRegMask(thisReg)) != RBM_NONE);
dstCandidates &= ~genRegMask(thisReg);
#endif // TARGET_ARM64


BuildDef(tree, genRegMask(thisReg), i);
}
Expand Down Expand Up @@ -3368,7 +3382,11 @@ void LinearScan::UpdatePreferencesOfDyingLocal(Interval* interval)
}
#endif

#ifdef TARGET_ARM64
SingleTypeRegSet unprefSet = unpref.GetRegSetForType(interval->registerType);
#else
SingleTypeRegSet unprefSet = unpref;
#endif
interval->registerAversion |= unprefSet;
SingleTypeRegSet newPreferences = allRegs(interval->registerType) & ~unprefSet;
interval->updateRegisterPreferences(newPreferences);
Expand Down

0 comments on commit 325bc6e

Please sign in to comment.