Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle more than 64 registers - Part 4 #102921

Merged
merged 51 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
e895528
Add high field
kunalspathak May 24, 2024
78b34fa
Do not use `const regMaskTP&` as parameter
kunalspathak May 24, 2024
b3218e1
Revert "Do not use `const regMaskTP&` as parameter"
kunalspathak May 24, 2024
ccddf1c
Furture reduce the TP cost
kunalspathak May 24, 2024
53c29d1
jit fornat
kunalspathak May 24, 2024
b4b08fa
Add high to all platforms
kunalspathak May 24, 2024
fed5c2a
use genSingleTypeRegMask()
kunalspathak May 29, 2024
6ffccb3
Make high only to arm64
kunalspathak May 29, 2024
27b8170
Use HAS_MORE_THAN_64_REGISTERS macro
kunalspathak May 29, 2024
4fe1caa
Add regTypeTag in register*.h files
kunalspathak May 29, 2024
a38460a
change the structure of regMaskTP for performance
kunalspathak May 29, 2024
c192d95
AddRegNumInMask/AddRegNum
kunalspathak May 29, 2024
ed203f3
Use AddRegNumInMask() and AddRegNum()
kunalspathak May 29, 2024
fd18c7f
RemoveRegNumFromMask() and RemoveRegNum() and consume them
kunalspathak May 29, 2024
f370cf1
Use IsEmpty() and IsNonEmpty()
kunalspathak May 29, 2024
1d0f492
IsRegNumInMask() and IsRegNumPresent()
kunalspathak May 29, 2024
535c2e1
AddGprRegs()
kunalspathak May 29, 2024
147a88b
AddRegsetForType()
kunalspathak May 29, 2024
d14f56a
RemoveRegsetForType()
kunalspathak May 29, 2024
2d1d2bb
GetRegSetForType() defintion
kunalspathak May 29, 2024
7542417
operators() that operate on regNum
kunalspathak May 29, 2024
5f63e60
misc cleanup
kunalspathak May 29, 2024
e56dc9b
fix some other build failures
kunalspathak May 29, 2024
b2d9b1c
jit format
kunalspathak May 29, 2024
687ed43
Add operator[]
kunalspathak May 30, 2024
3741ac6
Move mapTypeToRegTypeIndex() and mapRegNumtoRegTypeIndex() in compile…
kunalspathak May 30, 2024
8b7084a
Move registerType in Referencable, add getRegisterType()
kunalspathak May 30, 2024
cedb079
Add various variants of genRegNumFromMask() and use them
kunalspathak May 30, 2024
edccae2
Change some more methods to return SingleTypeRegMask
kunalspathak May 31, 2024
c72147f
Initialize regMaskTP in genRegMask()
kunalspathak May 31, 2024
fb0c4ca
bug fix
kunalspathak May 31, 2024
7de39e7
Add assert in genFindLowestBit() and genMaxOneBit() to be only applic…
kunalspathak May 31, 2024
95ca449
genRegNumFromMask() to take SingleTypeRegSet
kunalspathak May 31, 2024
6f07fc3
jit format
kunalspathak May 31, 2024
523e684
Merge remote-tracking branch 'origin/main' into part4
kunalspathak May 31, 2024
00c5c33
Merge remote-tracking branch 'origin/main' into part4
kunalspathak May 31, 2024
42ea15b
fix another assert
kunalspathak May 31, 2024
20bfbb3
Rename getRegMask to getSingleTypeRegMask
kunalspathak Jun 1, 2024
8539238
Move HAS_MORE_THAN_64_REGISTERS related macros
kunalspathak Jun 1, 2024
3bcd7ef
skip unnecessary initialization
kunalspathak Jun 1, 2024
5c1cd6f
fix some places where implicit conversion from `SingleTypeRegSet -> r…
kunalspathak Jun 1, 2024
bc4af58
fix a bug for populating availableRegs
kunalspathak Jun 2, 2024
156c2d6
Simplify the updating of high field
kunalspathak Jun 2, 2024
ac4768b
Revert "Add regTypeTag in register*.h files"
kunalspathak Jun 2, 2024
31e508d
misc cleanup
kunalspathak Jun 2, 2024
67983ec
jit format
kunalspathak Jun 2, 2024
0b67c48
fix the linux build error
kunalspathak Jun 2, 2024
7d3659f
Revert "fix the linux build error"
kunalspathak Jun 2, 2024
92aa687
fix linux error properly
kunalspathak Jun 2, 2024
b44dbe8
fix linux/arm bug
kunalspathak Jun 3, 2024
116b945
review feedback
kunalspathak Jun 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ void CodeGenInterface::genUpdateLife(VARSET_VALARG_TP newLife)
// inline
regMaskTP CodeGenInterface::genGetRegMask(const LclVarDsc* varDsc)
{
regMaskTP regMask = RBM_NONE;
regMaskTP regMask;

assert(varDsc->lvIsInReg());

Expand Down
9 changes: 7 additions & 2 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1015,9 +1015,10 @@ class LclVarDsc

regMaskTP lvRegMask() const
{
regMaskTP regMask = RBM_NONE;
if (GetRegNum() != REG_STK)
{
regMaskTP regMask;

if (varTypeUsesFloatReg(this))
{
regMask = genRegMaskFloat(GetRegNum() ARM_ARG(TypeGet()));
Expand All @@ -1032,8 +1033,12 @@ class LclVarDsc

regMask = genRegMask(GetRegNum());
}
return regMask;
}
else
{
return RBM_NONE;
}
return regMask;
}

//-----------------------------------------------------------------------------
Expand Down
142 changes: 122 additions & 20 deletions src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ inline bool genExactlyOneBit(T value)

inline regMaskTP genFindLowestBit(regMaskTP value)
{
#ifdef HAS_MORE_THAN_64_REGISTERS
// If we ever need to use this method for predicate
// registers, then handle it.
assert(value.getHigh() == RBM_NONE);
#endif
return regMaskTP(genFindLowestBit(value.getLow()));
}

Expand All @@ -111,19 +116,14 @@ inline regMaskTP genFindLowestBit(regMaskTP value)

inline bool genMaxOneBit(regMaskTP value)
{
#ifdef HAS_MORE_THAN_64_REGISTERS
// If we ever need to use this method for predicate
// registers, then handle it.
assert(value.getHigh() == RBM_NONE);
#endif
return genMaxOneBit(value.getLow());
}

/*****************************************************************************
*
* Return true if the given value has exactly one bit set.
*/

inline bool genExactlyOneBit(regMaskTP value)
{
return genExactlyOneBit(value.getLow());
}

/*****************************************************************************
*
* Given a value that has exactly one bit set, return the position of that
Expand Down Expand Up @@ -169,7 +169,7 @@ inline unsigned uhi32(uint64_t value)

inline unsigned genCountBits(regMaskTP mask)
{
return BitOperations::PopCount(mask.getLow());
return PopCount(mask);
}

/*****************************************************************************
Expand Down Expand Up @@ -933,16 +933,115 @@ inline unsigned Compiler::funGetFuncIdx(BasicBlock* block)
// Assumptions:
// The mask contains one and only one register.

inline regNumber genRegNumFromMask(regMaskTP mask)
inline regNumber genRegNumFromMask(const SingleTypeRegSet& mask)
{
assert(mask != RBM_NONE); // Must have one bit set, so can't have a mask of zero

/* Convert the mask to a register number */

regNumber regNum = (regNumber)genLog2(mask);

/* Make sure we got it right */
assert(genSingleTypeRegMask(regNum) == mask);

return regNum;
}

//------------------------------------------------------------------------------
// genRegNumFromMask : Maps a single register mask having gpr/float to a register number.
// If the mask can contain predicate register, use genRegNumFromMask(reg, type)
//
// Arguments:
// mask - the register mask
//
// Return Value:
// The number of the register contained in the mask.
//
// Assumptions:
// The mask contains one and only one register.

inline regNumber genRegNumFromMask(const regMaskTP& mask)
{
#ifdef HAS_MORE_THAN_64_REGISTERS
// This method is only used for gpr/float
assert(mask.getHigh() == RBM_NONE);
#endif

assert(mask.IsNonEmpty()); // Must have one bit set, so can't have a mask of zero

/* Convert the mask to a register number */

regNumber regNum = (regNumber)genLog2(mask.getLow());

/* Make sure we got it right */
assert(genRegMask(regNum) == mask.getLow());
assert(genRegMask(regNum).getLow() == mask.getLow());

return regNum;
}

//------------------------------------------------------------------------------
// genRegNumFromMask : Maps a single register mask to a register number.
//
// Arguments:
// mask - the register mask
// type - The
//
// Return Value:
// The number of the register contained in the mask.
//
// Assumptions:
// The mask contains one and only one register.

inline regNumber genRegNumFromMask(SingleTypeRegSet mask, var_types type)
{
regNumber regNum = genRegNumFromMask(mask);

#ifdef HAS_MORE_THAN_64_REGISTERS
if (varTypeIsMask(type))
{
regNum = (regNumber)(64 + regNum);
}
#endif
return regNum;
}

//------------------------------------------------------------------------------
// genFirstRegNumFromMask : Maps first bit set in the register mask to a register number.
//
// Arguments:
// mask - the register mask
//
// Return Value:
// The number of the first register contained in the mask.
//
// TODO: check if const regMaskTP& matter or should we pass by value
inline regNumber genFirstRegNumFromMask(const regMaskTP& mask)
{
assert(mask.IsNonEmpty()); // Must have one bit set, so can't have a mask of zero

/* Convert the mask to a register number */

regNumber regNum = (regNumber)BitScanForward(mask);

return regNum;
}

//------------------------------------------------------------------------------
// genFirstRegNumFromMask : Maps first bit set in the register mask to a register number.
//
// Arguments:
// mask - the register mask
//
// Return Value:
// The number of the first register contained in the mask.
//
inline regNumber genFirstRegNumFromMask(SingleTypeRegSet mask)
{
assert(mask != RBM_NONE); // Must have one bit set, so can't have a mask of zero

/* Convert the mask to a register number */

regNumber regNum = (regNumber)BitOperations::BitScanForward(mask);

return regNum;
}
Expand All @@ -966,28 +1065,31 @@ inline regNumber genFirstRegNumFromMaskAndToggle(regMaskTP& mask)

regNumber regNum = (regNumber)BitScanForward(mask);

mask ^= genRegMask(regNum);
mask.RemoveRegNumFromMask(regNum);

return regNum;
}

//------------------------------------------------------------------------------
// genFirstRegNumFromMask : Maps first bit set in the register mask to a register number.
//
// genFirstRegNumFromMaskAndToggle : Maps first bit set in the register mask to a
// register number and also toggle the bit in the `mask`.
// Arguments:
// mask - the register mask
//
// Return Value:
// The number of the first register contained in the mask.
// The number of the first register contained in the mask and updates the `mask` to toggle
// the bit.
//

inline regNumber genFirstRegNumFromMask(regMaskTP mask)
inline regNumber genFirstRegNumFromMaskAndToggle(SingleTypeRegSet& mask)
{
assert(mask.IsNonEmpty()); // Must have one bit set, so can't have a mask of zero
assert(mask != RBM_NONE); // Must have one bit set, so can't have a mask of zero

/* Convert the mask to a register number */

regNumber regNum = (regNumber)BitScanForward(mask);
regNumber regNum = (regNumber)BitOperations::BitScanForward(mask);

mask ^= genSingleTypeRegMask(regNum);

return regNum;
}
Expand Down
Loading