@@ -3083,13 +3083,12 @@ AArch64TargetLowering::EmitGetSMESaveSize(MachineInstr &MI,
30833083 AArch64FunctionInfo *FuncInfo = MF->getInfo<AArch64FunctionInfo>();
30843084 const TargetInstrInfo *TII = Subtarget->getInstrInfo();
30853085 if (FuncInfo->isSMESaveBufferUsed()) {
3086+ RTLIB::Libcall LC = RTLIB::SMEABI_SME_STATE_SIZE;
30863087 const AArch64RegisterInfo *TRI = Subtarget->getRegisterInfo();
30873088 BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(AArch64::BL))
3088- .addExternalSymbol("__arm_sme_state_size" )
3089+ .addExternalSymbol(getLibcallName(LC) )
30893090 .addReg(AArch64::X0, RegState::ImplicitDefine)
3090- .addRegMask(TRI->getCallPreservedMask(
3091- *MF, CallingConv::
3092- AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1));
3091+ .addRegMask(TRI->getCallPreservedMask(*MF, getLibcallCallingConv(LC)));
30933092 BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(TargetOpcode::COPY),
30943093 MI.getOperand(0).getReg())
30953094 .addReg(AArch64::X0);
@@ -3109,13 +3108,12 @@ AArch64TargetLowering::EmitEntryPStateSM(MachineInstr &MI,
31093108 const TargetInstrInfo *TII = Subtarget->getInstrInfo();
31103109 Register ResultReg = MI.getOperand(0).getReg();
31113110 if (FuncInfo->isPStateSMRegUsed()) {
3111+ RTLIB::Libcall LC = RTLIB::SMEABI_SME_STATE;
31123112 const AArch64RegisterInfo *TRI = Subtarget->getRegisterInfo();
31133113 BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(AArch64::BL))
3114- .addExternalSymbol("__arm_sme_state" )
3114+ .addExternalSymbol(getLibcallName(LC) )
31153115 .addReg(AArch64::X0, RegState::ImplicitDefine)
3116- .addRegMask(TRI->getCallPreservedMask(
3117- *MF, CallingConv::
3118- AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2));
3116+ .addRegMask(TRI->getCallPreservedMask(*MF, getLibcallCallingConv(LC)));
31193117 BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(TargetOpcode::COPY), ResultReg)
31203118 .addReg(AArch64::X0);
31213119 } else {
@@ -5733,15 +5731,15 @@ static SDValue getSVEPredicateBitCast(EVT VT, SDValue Op, SelectionDAG &DAG) {
57335731SDValue AArch64TargetLowering::getRuntimePStateSM(SelectionDAG &DAG,
57345732 SDValue Chain, SDLoc DL,
57355733 EVT VT) const {
5736- SDValue Callee = DAG.getExternalSymbol("__arm_sme_state",
5734+ RTLIB::Libcall LC = RTLIB::SMEABI_SME_STATE;
5735+ SDValue Callee = DAG.getExternalSymbol(getLibcallName(LC),
57375736 getPointerTy(DAG.getDataLayout()));
57385737 Type *Int64Ty = Type::getInt64Ty(*DAG.getContext());
57395738 Type *RetTy = StructType::get(Int64Ty, Int64Ty);
57405739 TargetLowering::CallLoweringInfo CLI(DAG);
57415740 ArgListTy Args;
57425741 CLI.setDebugLoc(DL).setChain(Chain).setLibCallee(
5743- CallingConv::AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2,
5744- RetTy, Callee, std::move(Args));
5742+ getLibcallCallingConv(LC), RetTy, Callee, std::move(Args));
57455743 std::pair<SDValue, SDValue> CallResult = LowerCallTo(CLI);
57465744 SDValue Mask = DAG.getConstant(/*PSTATE.SM*/ 1, DL, MVT::i64);
57475745 return DAG.getNode(ISD::AND, DL, MVT::i64, CallResult.first.getOperand(0),
@@ -8594,12 +8592,12 @@ static void analyzeCallOperands(const AArch64TargetLowering &TLI,
85948592}
85958593
85968594static SMECallAttrs
8597- getSMECallAttrs(const Function &Caller,
8595+ getSMECallAttrs(const Function &Caller, const AArch64TargetLowering &TLI,
85988596 const TargetLowering::CallLoweringInfo &CLI) {
85998597 if (CLI.CB)
8600- return SMECallAttrs(*CLI.CB);
8598+ return SMECallAttrs(*CLI.CB, &TLI );
86018599 if (auto *ES = dyn_cast<ExternalSymbolSDNode>(CLI.Callee))
8602- return SMECallAttrs(SMEAttrs(Caller), SMEAttrs(ES->getSymbol()));
8600+ return SMECallAttrs(SMEAttrs(Caller), SMEAttrs(ES->getSymbol(), TLI ));
86038601 return SMECallAttrs(SMEAttrs(Caller), SMEAttrs(SMEAttrs::Normal));
86048602}
86058603
@@ -8621,7 +8619,7 @@ bool AArch64TargetLowering::isEligibleForTailCallOptimization(
86218619
86228620 // SME Streaming functions are not eligible for TCO as they may require
86238621 // the streaming mode or ZA to be restored after returning from the call.
8624- SMECallAttrs CallAttrs = getSMECallAttrs(CallerF, CLI);
8622+ SMECallAttrs CallAttrs = getSMECallAttrs(CallerF, *this, CLI);
86258623 if (CallAttrs.requiresSMChange() || CallAttrs.requiresLazySave() ||
86268624 CallAttrs.requiresPreservingAllZAState() ||
86278625 CallAttrs.caller().hasStreamingBody())
@@ -8913,14 +8911,14 @@ static SDValue emitSMEStateSaveRestore(const AArch64TargetLowering &TLI,
89138911 DAG.getCopyFromReg(Chain, DL, Info->getSMESaveBufferAddr(), MVT::i64),
89148912 PointerType::getUnqual(*DAG.getContext()));
89158913
8916- SDValue Callee =
8917- DAG.getExternalSymbol(IsSave ? "__arm_sme_save" : "__arm_sme_restore",
8918- TLI.getPointerTy(DAG.getDataLayout()));
8914+ RTLIB::Libcall LC =
8915+ IsSave ? RTLIB::SMEABI_SME_SAVE : RTLIB::SMEABI_SME_RESTORE;
8916+ SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC),
8917+ TLI.getPointerTy(DAG.getDataLayout()));
89198918 auto *RetTy = Type::getVoidTy(*DAG.getContext());
89208919 TargetLowering::CallLoweringInfo CLI(DAG);
89218920 CLI.setDebugLoc(DL).setChain(Chain).setLibCallee(
8922- CallingConv::AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1, RetTy,
8923- Callee, std::move(Args));
8921+ TLI.getLibcallCallingConv(LC), RetTy, Callee, std::move(Args));
89248922 return TLI.LowerCallTo(CLI).second;
89258923}
89268924
@@ -9108,7 +9106,7 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
91089106 }
91099107
91109108 // Determine whether we need any streaming mode changes.
9111- SMECallAttrs CallAttrs = getSMECallAttrs(MF.getFunction(), CLI);
9109+ SMECallAttrs CallAttrs = getSMECallAttrs(MF.getFunction(), *this, CLI);
91129110
91139111 auto DescribeCallsite =
91149112 [&](OptimizationRemarkAnalysis &R) -> OptimizationRemarkAnalysis & {
@@ -9685,11 +9683,12 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
96859683
96869684 if (RequiresLazySave) {
96879685 // Conditionally restore the lazy save using a pseudo node.
9686+ RTLIB::Libcall LC = RTLIB::SMEABI_TPIDR2_RESTORE;
96889687 TPIDR2Object &TPIDR2 = FuncInfo->getTPIDR2Obj();
96899688 SDValue RegMask = DAG.getRegisterMask(
9690- TRI->SMEABISupportRoutinesCallPreservedMaskFromX0( ));
9689+ TRI->getCallPreservedMask(MF, getLibcallCallingConv(LC) ));
96919690 SDValue RestoreRoutine = DAG.getTargetExternalSymbol(
9692- "__arm_tpidr2_restore" , getPointerTy(DAG.getDataLayout()));
9691+ getLibcallName(LC) , getPointerTy(DAG.getDataLayout()));
96939692 SDValue TPIDR2_EL0 = DAG.getNode(
96949693 ISD::INTRINSIC_W_CHAIN, DL, MVT::i64, Result,
96959694 DAG.getConstant(Intrinsic::aarch64_sme_get_tpidr2, DL, MVT::i32));
@@ -29028,7 +29027,7 @@ bool AArch64TargetLowering::fallBackToDAGISel(const Instruction &Inst) const {
2902829027
2902929028 // Checks to allow the use of SME instructions
2903029029 if (auto *Base = dyn_cast<CallBase>(&Inst)) {
29031- auto CallAttrs = SMECallAttrs(*Base);
29030+ auto CallAttrs = SMECallAttrs(*Base, this );
2903229031 if (CallAttrs.requiresSMChange() || CallAttrs.requiresLazySave() ||
2903329032 CallAttrs.requiresPreservingZT0() ||
2903429033 CallAttrs.requiresPreservingAllZAState())
0 commit comments