Skip to content

Commit

Permalink
RemoveRegNumFromMask() and RemoveRegNum() and consume them
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalspathak committed May 29, 2024
1 parent ed203f3 commit fd18c7f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 13 deletions.
17 changes: 8 additions & 9 deletions src/coreclr/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ void LinearScan::updateNextFixedRef(RegRecord* regRecord, RefPosition* nextRefPo

if (nextLocation == MaxLocation)
{
fixedRegs &= ~genRegMask(regRecord->regNum);
fixedRegs.RemoveRegNumFromMask(regRecord->regNum);
}
else
{
Expand Down Expand Up @@ -4655,7 +4655,7 @@ void LinearScan::processBlockStartLocations(BasicBlock* currentBlock)
RegRecord* anotherHalfRegRec = findAnotherHalfRegRec(targetRegRecord);

// Use TYP_FLOAT to get the regmask of just the half reg.
liveRegs &= ~getRegMask(anotherHalfRegRec->regNum, TYP_FLOAT);
liveRegs.RemoveRegNum(anotherHalfRegRec->regNum, TYP_FLOAT);
}

#endif // TARGET_ARM
Expand Down Expand Up @@ -9814,7 +9814,7 @@ void LinearScan::resolveEdge(BasicBlock* fromBlock,
regNumber upperHalfReg = REG_NEXT(fromReg);
if ((otherInterval->registerType == TYP_DOUBLE) && (location[upperHalfReg] != REG_NA))
{
targetRegsReady &= ~fromRegMask;
targetRegsReady.RemoveRegNumFromMask(fromReg);
}
}
}
Expand Down Expand Up @@ -9859,7 +9859,7 @@ void LinearScan::resolveEdge(BasicBlock* fromBlock,
regNumber fromReg = (regNumber)location[sourceReg];
if (targetReg == fromReg)
{
targetRegsToDo &= ~targetRegMask;
targetRegsToDo.RemoveRegNumFromMask(targetReg);
}
else
{
Expand Down Expand Up @@ -9902,8 +9902,7 @@ void LinearScan::resolveEdge(BasicBlock* fromBlock,
// Otherwise, we'll spill it to the stack and reload it later.
if (useSwap)
{
regMaskTP fromRegMask = genRegMask(fromReg);
targetRegsToDo &= ~fromRegMask;
targetRegsToDo.RemoveRegNumFromMask(fromReg);
}
}
else
Expand Down Expand Up @@ -9950,7 +9949,7 @@ void LinearScan::resolveEdge(BasicBlock* fromBlock,
regMaskTP otherTargetRegMask = genRegMask(otherTargetReg);
targetRegsFromStack |= otherTargetRegMask;
stackToRegIntervals[otherTargetReg] = otherInterval;
targetRegsToDo &= ~otherTargetRegMask;
targetRegsToDo.RemoveRegNumFromMask(otherTargetReg);

// Now, move the interval that is going to targetReg.
addResolution(block, insertionPoint, sourceIntervals[sourceReg], targetReg,
Expand All @@ -9976,13 +9975,13 @@ void LinearScan::resolveEdge(BasicBlock* fromBlock,
regNumber upperHalfReg = REG_NEXT(fromReg);
if ((otherInterval->registerType == TYP_DOUBLE) && (location[upperHalfReg] != REG_NA))
{
targetRegsReady &= ~fromRegMask;
targetRegsReady.RemoveRegNumFromMask(fromReg);
}
}
#endif // TARGET_ARM
}
}
targetRegsToDo &= ~targetRegMask;
targetRegsToDo.RemoveRegNumFromMask(targetReg);
}
else
{
Expand Down
7 changes: 3 additions & 4 deletions src/coreclr/jit/lsra.h
Original file line number Diff line number Diff line change
Expand Up @@ -1824,8 +1824,7 @@ class LinearScan : public LinearScanInterface
}
void setRegInUse(regNumber reg, var_types regType)
{
regMaskTP regMask = getRegMask(reg, regType);
setRegsInUse(regMask);
m_AvailableRegs.RemoveRegNum(reg, regType);
}
void makeRegsAvailable(regMaskTP regMask)
{
Expand Down Expand Up @@ -1853,7 +1852,7 @@ class LinearScan : public LinearScanInterface
regMaskTP m_RegistersWithConstants;
void clearConstantReg(regNumber reg, var_types regType)
{
m_RegistersWithConstants &= ~getRegMask(reg, regType);
m_RegistersWithConstants.RemoveRegNum(reg, regType);
}
void setConstantReg(regNumber reg, var_types regType)
{
Expand Down Expand Up @@ -1913,7 +1912,7 @@ class LinearScan : public LinearScanInterface
}
void clearRegBusyUntilKill(regNumber reg)
{
regsBusyUntilKill &= ~genRegMask(reg);
regsBusyUntilKill.RemoveRegNumFromMask(reg);
}

bool isRegInUse(regNumber reg, var_types regType)
Expand Down
25 changes: 25 additions & 0 deletions src/coreclr/jit/regMaskTPOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ void regMaskTP::AddRegNumInMask(regNumber reg, var_types type)
{
low |= genSingleTypeRegMask(reg, type);
}

// ----------------------------------------------------------
// RemoveRegNumFromMask: Removes `reg` from the mask. It is same as RemoveRegNumFromMask(reg) except
// that it takes `type` as an argument and adds `reg` to the mask for that type.
//
void regMaskTP::RemoveRegNumFromMask(regNumber reg, var_types type)
{
low &= ~genSingleTypeRegMask(reg, type);
}
#endif

// This is similar to AddRegNumInMask(reg, regType) for all platforms
Expand Down Expand Up @@ -89,6 +98,22 @@ void regMaskTP::RemoveRegNumFromMask(regNumber reg)
#endif
}

//------------------------------------------------------------------------
// RemoveRegNum: his is similar to RemoveRegNumFromMask(reg, regType) for all platforms
// except Arm. For Arm, it calls getRegMask() instead of genRegMask()
// to create a mask that needs to be added.
// Parameters:
// reg - Register to remove
//
void regMaskTP::RemoveRegNum(regNumber reg, var_types type)
{
#ifdef TARGET_ARM
low &= ~getRegMask(reg, type);
#else
RemoveRegNumFromMask(reg);
#endif
}

//------------------------------------------------------------------------
// IsRegNumInMask: Checks if `reg` is in the mask
//
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,11 @@ struct regMaskTP
void AddRegNumInMask(regNumber reg);
#ifdef TARGET_ARM
void AddRegNumInMask(regNumber reg, var_types type);
void RemoveRegNumFromMask(regNumber reg, var_types type);
#endif
void AddRegNum(regNumber reg, var_types type);
void RemoveRegNumFromMask(regNumber reg);
void RemoveRegNum(regNumber reg, var_types type);
bool IsRegNumInMask(regNumber reg);

regMaskTP(regMaskSmall lowMask, RegSet32 highMask)
Expand Down

0 comments on commit fd18c7f

Please sign in to comment.