Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 0 deletions src/coreclr/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2388,6 +2388,7 @@ void emitter::emitSetFrameRangeArgs(int offsLo, int offsHi)
* small encoding (0 through 3), and vice versa.
*/

#if DEBUG
const emitter::opSize emitter::emitSizeEncode[] = {
emitter::OPSZ1, emitter::OPSZ2, OPSIZE_INVALID, emitter::OPSZ4, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID,
emitter::OPSZ8, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID, OPSIZE_INVALID,
Expand All @@ -2398,6 +2399,7 @@ const emitter::opSize emitter::emitSizeEncode[] = {

const emitAttr emitter::emitSizeDecode[emitter::OPSZ_COUNT] = {EA_1BYTE, EA_2BYTE, EA_4BYTE,
EA_8BYTE, EA_16BYTE, EA_32BYTE};
#endif

/*****************************************************************************
*
Expand Down
14 changes: 10 additions & 4 deletions src/coreclr/jit/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,10 @@ class emitter

#define OPSIZE_INVALID ((opSize)0xffff)

#if DEBUG
static const emitter::opSize emitSizeEncode[];
static const emitAttr emitSizeDecode[];
#endif

static emitter::opSize emitEncodeSize(emitAttr size);
static emitAttr emitDecodeSize(emitter::opSize ensz);
Expand Down Expand Up @@ -1047,7 +1049,7 @@ class emitter
}
#endif // TARGET_LOONGARCH64

emitAttr idOpSize()
emitAttr idOpSize() const
{
return emitDecodeSize(_idOpSize);
}
Expand Down Expand Up @@ -2856,15 +2858,19 @@ inline emitAttr emitActualTypeSize(T type)
{
assert(size == EA_1BYTE || size == EA_2BYTE || size == EA_4BYTE || size == EA_8BYTE || size == EA_16BYTE ||
size == EA_32BYTE);
emitter::opSize result = static_cast<emitter::opSize>(genLog2(static_cast<uint32_t>(size)));

return emitSizeEncode[((int)size) - 1];
assert(result == emitSizeEncode[static_cast<uint32_t>(size) - 1]);
return result;
}

/* static */ inline emitAttr emitter::emitDecodeSize(emitter::opSize ensz)
{
assert(((unsigned)ensz) < OPSZ_COUNT);
assert(static_cast<uint32_t>(ensz) < OPSZ_COUNT);
emitAttr result = static_cast<emitAttr>(1 << static_cast<uint32_t>(ensz));

return emitSizeDecode[ensz];
assert(result == emitSizeDecode[ensz]);
return result;
}

/*****************************************************************************
Expand Down
8 changes: 6 additions & 2 deletions src/coreclr/jit/emitxarch.h
Original file line number Diff line number Diff line change
Expand Up @@ -705,15 +705,19 @@ void emitAdjustStackDepth(instruction ins, ssize_t val);
inline emitter::opSize emitEncodeScale(size_t scale)
{
assert(scale == 1 || scale == 2 || scale == 4 || scale == 8);
emitter::opSize result = static_cast<emitter::opSize>(genLog2(static_cast<uint32_t>(scale)));

return emitSizeEncode[scale - 1];
assert(result == emitSizeEncode[scale - 1]);
return result;
}

inline emitAttr emitDecodeScale(unsigned ensz)
{
assert(ensz < 4);
emitAttr result = static_cast<emitAttr>(1 << ensz);

return emitter::emitSizeDecode[ensz];
assert(result == emitter::emitSizeDecode[ensz]);
return result;
}

/************************************************************************/
Expand Down