Skip to content

JIT: Add a type for call emission parameters #114542

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

Merged
merged 5 commits into from
Apr 16, 2025
Merged
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
28 changes: 2 additions & 26 deletions src/coreclr/jit/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ class CodeGen final : public CodeGenInterface
public:
void genSpillVar(GenTree* tree);

void genEmitCallWithCurrentGC(EmitCallParams& callParams);

protected:
void genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, regNumber callTarget = REG_NA);

Expand Down Expand Up @@ -549,32 +551,6 @@ class CodeGen final : public CodeGenInterface
void genProfilingLeaveCallback(unsigned helper);
#endif // PROFILING_SUPPORTED

// clang-format off
void genEmitCall(int callType,
CORINFO_METHOD_HANDLE methHnd,
INDEBUG_LDISASM_COMMA(CORINFO_SIG_INFO* sigInfo)
void* addr
X86_ARG(int argSize),
emitAttr retSize
MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize),
const DebugInfo& di,
regNumber base,
bool isJump,
bool noSafePoint = false);
// clang-format on

// clang-format off
void genEmitCallIndir(int callType,
CORINFO_METHOD_HANDLE methHnd,
INDEBUG_LDISASM_COMMA(CORINFO_SIG_INFO* sigInfo)
GenTreeIndir* indir
X86_ARG(int argSize),
emitAttr retSize
MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize),
const DebugInfo& di,
bool isJump);
// clang-format on

//
// Epilog functions
//
Expand Down
25 changes: 11 additions & 14 deletions src/coreclr/jit/codegenarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1619,6 +1619,12 @@ void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize,
addr = compiler->compGetHelperFtn((CorInfoHelpFunc)helper, (void**)&pAddr);
}

EmitCallParams params;

params.methHnd = compiler->eeFindHelper(helper);
params.argSize = argSize;
params.retSize = retSize;

if (!addr || !validImmForBL((ssize_t)addr))
{
if (callTargetReg == REG_NA)
Expand All @@ -1639,23 +1645,14 @@ void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize,
regSet.verifyRegUsed(callTargetReg);
}

GetEmitter()->emitIns_Call(emitter::EC_INDIR_R, compiler->eeFindHelper(helper),
INDEBUG_LDISASM_COMMA(nullptr) NULL, // addr
argSize, retSize, gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur,
gcInfo.gcRegByrefSetCur, DebugInfo(),
callTargetReg, // ireg
REG_NA, 0, 0, // xreg, xmul, disp
false // isJump
);
params.callType = EC_INDIR_R;
params.ireg = callTargetReg;
genEmitCallWithCurrentGC(params);
}
else
{
GetEmitter()->emitIns_Call(emitter::EC_FUNC_TOKEN, compiler->eeFindHelper(helper),
INDEBUG_LDISASM_COMMA(nullptr) addr, argSize, retSize, gcInfo.gcVarPtrSetCur,
gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur, DebugInfo(), REG_NA, REG_NA, 0,
0, /* ilOffset, ireg, xreg, xmul, disp */
false /* isJump */
);
params.callType = EC_FUNC_TOKEN;
genEmitCallWithCurrentGC(params);
}

regSet.verifyRegistersUsed(RBM_CALLEE_TRASH);
Expand Down
40 changes: 18 additions & 22 deletions src/coreclr/jit/codegenarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5317,14 +5317,14 @@ bool CodeGen::IsSaveFpLrWithAllCalleeSavedRegisters() const

void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize, regNumber callTargetReg /*= REG_NA */)
{
void* addr = nullptr;
void* pAddr = nullptr;

emitter::EmitCallType callType = emitter::EC_FUNC_TOKEN;
addr = compiler->compGetHelperFtn((CorInfoHelpFunc)helper, &pAddr);
regNumber callTarget = REG_NA;
EmitCallParams params;
params.callType = EC_FUNC_TOKEN;
params.addr = compiler->compGetHelperFtn((CorInfoHelpFunc)helper, &pAddr);
regMaskTP killSet = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);

if (addr == nullptr)
if (params.addr == nullptr)
{
// This is call to a runtime helper.
// adrp x, [reloc:rel page addr]
Expand All @@ -5340,37 +5340,33 @@ void CodeGen::genEmitHelperCall(unsigned helper, int argSize, emitAttr retSize,
}

regMaskTP callTargetMask = genRegMask(callTargetReg);
regMaskTP callKillSet = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);

// assert that all registers in callTargetMask are in the callKillSet
noway_assert((callTargetMask & callKillSet) == callTargetMask);

callTarget = callTargetReg;
noway_assert((callTargetMask & killSet) == callTargetMask);

if (compiler->opts.compReloc)
{
// adrp + add with relocations will be emitted
GetEmitter()->emitIns_R_AI(INS_adrp, EA_PTR_DSP_RELOC, callTarget,
GetEmitter()->emitIns_R_AI(INS_adrp, EA_PTR_DSP_RELOC, callTargetReg,
(ssize_t)pAddr DEBUGARG((size_t)compiler->eeFindHelper(helper))
DEBUGARG(GTF_ICON_METHOD_HDL));
}
else
{
instGen_Set_Reg_To_Imm(EA_PTRSIZE, callTarget, (ssize_t)addr);
instGen_Set_Reg_To_Imm(EA_PTRSIZE, callTargetReg, (ssize_t)pAddr);
}
GetEmitter()->emitIns_R_R(INS_ldr, EA_PTRSIZE, callTarget, callTarget);
callType = emitter::EC_INDIR_R;
GetEmitter()->emitIns_R_R(INS_ldr, EA_PTRSIZE, callTargetReg, callTargetReg);

params.callType = EC_INDIR_R;
params.ireg = callTargetReg;
}

GetEmitter()->emitIns_Call(callType, compiler->eeFindHelper(helper), INDEBUG_LDISASM_COMMA(nullptr) addr, argSize,
retSize, EA_UNKNOWN, gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur,
gcInfo.gcRegByrefSetCur, DebugInfo(), callTarget, /* ireg */
REG_NA, 0, 0, /* xreg, xmul, disp */
false /* isJump */
);
params.methHnd = compiler->eeFindHelper(helper);
params.argSize = argSize;
params.retSize = retSize;

genEmitCallWithCurrentGC(params);

regMaskTP killMask = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);
regSet.verifyRegistersUsed(killMask);
regSet.verifyRegistersUsed(killSet);
}

#ifdef FEATURE_SIMD
Expand Down
Loading
Loading