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

[Arm64] Replace pairs of str with stp #85032

Merged
merged 20 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
107 changes: 97 additions & 10 deletions src/coreclr/jit/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -782,17 +782,18 @@ class emitter
unsigned _idNoGC : 1; // Some helpers don't get recorded in GC tables

#ifdef TARGET_ARM64
opSize _idOpSize : 3; // operand size: 0=1 , 1=2 , 2=4 , 3=8, 4=16
insOpts _idInsOpt : 6; // options for instructions
unsigned _idLclVar : 1; // access a local on stack
opSize _idOpSize : 3; // operand size: 0=1 , 1=2 , 2=4 , 3=8, 4=16
insOpts _idInsOpt : 6; // options for instructions
unsigned _idLclVar : 1; // access a local on stack
unsigned _idLclVarPair : 1 // carries information for 2 GC lcl vars.
#endif

#ifdef TARGET_LOONGARCH64
// TODO-LoongArch64: maybe delete on future.
opSize _idOpSize : 3; // operand size: 0=1 , 1=2 , 2=4 , 3=8, 4=16
insOpts _idInsOpt : 6; // loongarch options for special: placeholders. e.g emitIns_R_C, also identifying the
// accessing a local on stack.
unsigned _idLclVar : 1; // access a local on stack.
// TODO-LoongArch64: maybe delete on future.
opSize _idOpSize : 3; // operand size: 0=1 , 1=2 , 2=4 , 3=8, 4=16
insOpts _idInsOpt : 6; // loongarch options for special: placeholders. e.g emitIns_R_C, also identifying the
// accessing a local on stack.
unsigned _idLclVar : 1; // access a local on stack.
#endif

#ifdef TARGET_RISCV64
Expand All @@ -815,7 +816,7 @@ class emitter
// x86: 46 bits
// amd64: 46 bits
// arm: 48 bits
// arm64: 49 bits
// arm64: 50 bits
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
// loongarch64: 46 bits

//
Expand All @@ -827,7 +828,7 @@ class emitter
#if defined(TARGET_ARM)
#define ID_EXTRA_BITFIELD_BITS (16)
#elif defined(TARGET_ARM64)
#define ID_EXTRA_BITFIELD_BITS (17)
#define ID_EXTRA_BITFIELD_BITS (18)
#elif defined(TARGET_XARCH) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
#define ID_EXTRA_BITFIELD_BITS (14)
#else
Expand Down Expand Up @@ -1371,6 +1372,17 @@ class emitter
_idLargeCns = 1;
}

#ifdef TARGET_ARM64
bool idIsLclVarPair() const
{
return _idLclVarPair != 0;
}
void isSetLclVarPair()
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
{
_idLclVarPair = 1;
}
#endif // TARGET_ARM64
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved

bool idIsLargeDsp() const
{
return _idLargeDsp != 0;
Expand Down Expand Up @@ -1819,6 +1831,20 @@ class emitter

#endif // TARGET_XARCH

#ifdef TARGET_ARM64
struct instrDescLclVarPair : instrDesc // contains 2 gc vars to be tracked
{
instrDescLclVarPair() = delete;

emitLclVarAddr iiaLclVar2;
};

struct instrDescLclVarPairCns : instrDescCns // contains 2 gc vars to be tracked, with large cons
{
emitLclVarAddr iiaLclVar2;
};
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
#endif

struct instrDescCGCA : instrDesc // call with ...
{
instrDescCGCA() = delete;
Expand Down Expand Up @@ -2600,6 +2626,23 @@ class emitter
#endif // EMITTER_STATS
return (instrDescLbl*)emitAllocAnyInstr(sizeof(instrDescLbl), EA_4BYTE);
}
#else
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
instrDescLclVarPair* emitAllocInstrLclVarPair(emitAttr attr)
{
instrDescLclVarPair* result = (instrDescLclVarPair*)emitAllocAnyInstr(sizeof(instrDescLclVarPair), attr);
result->isSetLclVarPair();
return result;
}

instrDescLclVarPairCns* emitAllocInstrLclVarPairCns(emitAttr attr, cnsval_size_t cns)
{
instrDescLclVarPairCns* result =
(instrDescLclVarPairCns*)emitAllocAnyInstr(sizeof(instrDescLclVarPairCns), attr);
result->idSetIsLargeCns();
result->isSetLclVarPair();
result->idcCnsVal = cns;
return result;
}
#endif // !TARGET_ARM64

instrDescCns* emitAllocInstrCns(emitAttr attr)
Expand Down Expand Up @@ -2686,6 +2729,8 @@ class emitter

#if !defined(TARGET_ARM64)
instrDescLbl* emitNewInstrLbl();
#else
instrDesc* emitNewInstrLclVarPair(emitAttr attr, cnsval_ssize_t cns);
#endif // !TARGET_ARM64

static const BYTE emitFmtToOps[];
Expand Down Expand Up @@ -3249,6 +3294,36 @@ inline emitter::instrDescLbl* emitter::emitNewInstrLbl()
{
return emitAllocInstrLbl();
}
#else
inline emitter::instrDesc* emitter::emitNewInstrLclVarPair(emitAttr attr, cnsval_ssize_t cns)
{
#if EMITTER_STATS
emitTotalIDescCnt++;
emitTotalIDescCnsCnt++;
#endif // EMITTER_STATS

if (instrDesc::fitsInSmallCns(cns))
{
instrDescLclVarPair* id = emitAllocInstrLclVarPair(attr);
id->idSmallCns(cns);
#if EMITTER_STATS
emitSmallCnsCnt++;
if ((cns - ID_MIN_SMALL_CNS) >= (SMALL_CNS_TSZ - 1))
emitSmallCns[SMALL_CNS_TSZ - 1]++;
else
emitSmallCns[cns - ID_MIN_SMALL_CNS]++;
#endif
return id;
}
else
{
instrDescLclVarPairCns* id = emitAllocInstrLclVarPairCns(attr, cns);
#if EMITTER_STATS
emitLargeCnsCnt++;
#endif
return id;
}
}
#endif // !TARGET_ARM64

inline emitter::instrDesc* emitter::emitNewInstrDsp(emitAttr attr, target_ssize_t dsp)
Expand Down Expand Up @@ -3329,10 +3404,22 @@ inline size_t emitter::emitGetInstrDescSize(const instrDesc* id)
}
else if (id->idIsLargeCns())
{
#ifdef TARGET_ARM64
if (id->idIsLclVarPair())
{
return sizeof(instrDescLclVarPairCns);
}
#endif
return sizeof(instrDescCns);
}
else
{
#ifdef TARGET_ARM64
if (id->idIsLclVarPair())
{
return sizeof(instrDescLclVarPair);
}
#endif
return sizeof(instrDesc);
}
}
Expand Down
Loading