@@ -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 {
@@ -5739,15 +5737,15 @@ static SDValue getSVEPredicateBitCast(EVT VT, SDValue Op, SelectionDAG &DAG) {
57395737SDValue AArch64TargetLowering::getRuntimePStateSM(SelectionDAG &DAG,
57405738 SDValue Chain, SDLoc DL,
57415739 EVT VT) const {
5742- SDValue Callee = DAG.getExternalSymbol("__arm_sme_state",
5740+ RTLIB::Libcall LC = RTLIB::SMEABI_SME_STATE;
5741+ SDValue Callee = DAG.getExternalSymbol(getLibcallName(LC),
57435742 getPointerTy(DAG.getDataLayout()));
57445743 Type *Int64Ty = Type::getInt64Ty(*DAG.getContext());
57455744 Type *RetTy = StructType::get(Int64Ty, Int64Ty);
57465745 TargetLowering::CallLoweringInfo CLI(DAG);
57475746 ArgListTy Args;
57485747 CLI.setDebugLoc(DL).setChain(Chain).setLibCallee(
5749- CallingConv::AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2,
5750- RetTy, Callee, std::move(Args));
5748+ getLibcallCallingConv(LC), RetTy, Callee, std::move(Args));
57515749 std::pair<SDValue, SDValue> CallResult = LowerCallTo(CLI);
57525750 SDValue Mask = DAG.getConstant(/*PSTATE.SM*/ 1, DL, MVT::i64);
57535751 return DAG.getNode(ISD::AND, DL, MVT::i64, CallResult.first.getOperand(0),
@@ -8600,12 +8598,12 @@ static void analyzeCallOperands(const AArch64TargetLowering &TLI,
86008598}
86018599
86028600static SMECallAttrs
8603- getSMECallAttrs(const Function &Caller,
8601+ getSMECallAttrs(const Function &Caller, const TargetLowering &TLI,
86048602 const TargetLowering::CallLoweringInfo &CLI) {
86058603 if (CLI.CB)
8606- return SMECallAttrs(*CLI.CB);
8604+ return SMECallAttrs(*CLI.CB, &TLI );
86078605 if (auto *ES = dyn_cast<ExternalSymbolSDNode>(CLI.Callee))
8608- return SMECallAttrs(SMEAttrs(Caller), SMEAttrs(ES->getSymbol()));
8606+ return SMECallAttrs(SMEAttrs(Caller), SMEAttrs(ES->getSymbol(), TLI ));
86098607 return SMECallAttrs(SMEAttrs(Caller), SMEAttrs(SMEAttrs::Normal));
86108608}
86118609
@@ -8627,7 +8625,7 @@ bool AArch64TargetLowering::isEligibleForTailCallOptimization(
86278625
86288626 // SME Streaming functions are not eligible for TCO as they may require
86298627 // the streaming mode or ZA to be restored after returning from the call.
8630- SMECallAttrs CallAttrs = getSMECallAttrs(CallerF, CLI);
8628+ SMECallAttrs CallAttrs = getSMECallAttrs(CallerF, *this, CLI);
86318629 if (CallAttrs.requiresSMChange() || CallAttrs.requiresLazySave() ||
86328630 CallAttrs.requiresPreservingAllZAState() ||
86338631 CallAttrs.caller().hasStreamingBody())
@@ -8921,14 +8919,14 @@ static SDValue emitSMEStateSaveRestore(const AArch64TargetLowering &TLI,
89218919 DAG.getCopyFromReg(Chain, DL, Info->getSMESaveBufferAddr(), MVT::i64);
89228920 Args.push_back(Entry);
89238921
8924- SDValue Callee =
8925- DAG.getExternalSymbol(IsSave ? "__arm_sme_save" : "__arm_sme_restore",
8926- TLI.getPointerTy(DAG.getDataLayout()));
8922+ RTLIB::Libcall LC =
8923+ IsSave ? RTLIB::SMEABI_SME_SAVE : RTLIB::SMEABI_SME_RESTORE;
8924+ SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC),
8925+ TLI.getPointerTy(DAG.getDataLayout()));
89278926 auto *RetTy = Type::getVoidTy(*DAG.getContext());
89288927 TargetLowering::CallLoweringInfo CLI(DAG);
89298928 CLI.setDebugLoc(DL).setChain(Chain).setLibCallee(
8930- CallingConv::AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1, RetTy,
8931- Callee, std::move(Args));
8929+ TLI.getLibcallCallingConv(LC), RetTy, Callee, std::move(Args));
89328930 return TLI.LowerCallTo(CLI).second;
89338931}
89348932
@@ -9116,7 +9114,7 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
91169114 }
91179115
91189116 // Determine whether we need any streaming mode changes.
9119- SMECallAttrs CallAttrs = getSMECallAttrs(MF.getFunction(), CLI);
9117+ SMECallAttrs CallAttrs = getSMECallAttrs(MF.getFunction(), *this, CLI);
91209118
91219119 auto DescribeCallsite =
91229120 [&](OptimizationRemarkAnalysis &R) -> OptimizationRemarkAnalysis & {
@@ -9693,11 +9691,12 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
96939691
96949692 if (RequiresLazySave) {
96959693 // Conditionally restore the lazy save using a pseudo node.
9694+ RTLIB::Libcall LC = RTLIB::SMEABI_TPIDR2_RESTORE;
96969695 TPIDR2Object &TPIDR2 = FuncInfo->getTPIDR2Obj();
96979696 SDValue RegMask = DAG.getRegisterMask(
9698- TRI->SMEABISupportRoutinesCallPreservedMaskFromX0( ));
9697+ TRI->getCallPreservedMask(MF, getLibcallCallingConv(LC) ));
96999698 SDValue RestoreRoutine = DAG.getTargetExternalSymbol(
9700- "__arm_tpidr2_restore" , getPointerTy(DAG.getDataLayout()));
9699+ getLibcallName(LC) , getPointerTy(DAG.getDataLayout()));
97019700 SDValue TPIDR2_EL0 = DAG.getNode(
97029701 ISD::INTRINSIC_W_CHAIN, DL, MVT::i64, Result,
97039702 DAG.getConstant(Intrinsic::aarch64_sme_get_tpidr2, DL, MVT::i32));
@@ -29036,7 +29035,7 @@ bool AArch64TargetLowering::fallBackToDAGISel(const Instruction &Inst) const {
2903629035
2903729036 // Checks to allow the use of SME instructions
2903829037 if (auto *Base = dyn_cast<CallBase>(&Inst)) {
29039- auto CallAttrs = SMECallAttrs(*Base);
29038+ auto CallAttrs = SMECallAttrs(*Base, this );
2904029039 if (CallAttrs.requiresSMChange() || CallAttrs.requiresLazySave() ||
2904129040 CallAttrs.requiresPreservingZT0() ||
2904229041 CallAttrs.requiresPreservingAllZAState())
0 commit comments