@@ -6842,39 +6842,31 @@ void CodeGen::genEmitHelperCall(unsigned helper,
68426842
68436843 if (addr == nullptr )
68446844 {
6845- NYI (" genEmitHelperCall indirect" );
6846- #if 0
6847- assert(pAddr != nullptr);
6848- if (genAddrCanBeEncodedAsPCRelOffset((size_t)pAddr))
6845+ // This is call to a runtime helper.
6846+ // adrp x, [reloc:rel page addr]
6847+ // add x, x, [reloc:page offset]
6848+ // ldr x, [x]
6849+ // br x
6850+
6851+ if (callTargetReg == REG_NA)
68496852 {
6850- // generate call whose target is specified by PC-relative 32-bit offset.
6851- callType = emitter::EC_FUNC_TOKEN_INDIR;
6852- addr = pAddr ;
6853+ // If a callTargetReg has not been explicitly provided, we will use REG_DEFAULT_HELPER_CALL_TARGET, but
6854+ // this is only a valid assumption if the helper call is known to kill REG_DEFAULT_HELPER_CALL_TARGET.
6855+ callTargetReg = REG_DEFAULT_HELPER_CALL_TARGET ;
68536856 }
6854- else
6855- {
6856- // If this address cannot be encoded as PC-relative 32-bit offset, load it into REG_HELPER_CALL_TARGET
6857- // and use register indirect addressing mode to make the call.
6858- // mov reg, addr
6859- // call [reg]
6860- if (callTargetReg == REG_NA)
6861- {
6862- // If a callTargetReg has not been explicitly provided, we will use REG_DEFAULT_HELPER_CALL_TARGET, but
6863- // this is only a valid assumption if the helper call is known to kill REG_DEFAULT_HELPER_CALL_TARGET.
6864- callTargetReg = REG_DEFAULT_HELPER_CALL_TARGET;
6865- }
68666857
6867- regMaskTP callTargetMask = genRegMask(callTargetReg);
6868- regMaskTP callKillSet = compiler->compHelperCallKillSet((CorInfoHelpFunc)helper);
6858+ regMaskTP callTargetMask = genRegMask (callTargetReg);
6859+ regMaskTP callKillSet = compiler->compHelperCallKillSet ((CorInfoHelpFunc)helper);
68696860
6870- // assert that all registers in callTargetMask are in the callKillSet
6871- noway_assert((callTargetMask & callKillSet) == callTargetMask);
6861+ // assert that all registers in callTargetMask are in the callKillSet
6862+ noway_assert ((callTargetMask & callKillSet) == callTargetMask);
68726863
6873- callTarget = callTargetReg;
6874- CodeGen::genSetRegToIcon(callTarget, (ssize_t) pAddr, TYP_I_IMPL);
6875- callType = emitter::EC_INDIR_ARD;
6876- }
6877- #endif // 0
6864+ callTarget = callTargetReg;
6865+
6866+ // adrp + add with relocations will be emitted
6867+ getEmitter ()->emitIns_R_AI (INS_adrp, EA_PTR_DSP_RELOC, callTarget, (ssize_t )pAddr);
6868+ getEmitter ()->emitIns_R_R (INS_ldr, EA_PTRSIZE, callTarget, callTarget);
6869+ callType = emitter::EC_INDIR_R;
68786870 }
68796871
68806872 getEmitter ()->emitIns_Call (callType,
0 commit comments