@@ -3083,12 +3083,13 @@ 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;
30873086 const AArch64RegisterInfo *TRI = Subtarget->getRegisterInfo();
30883087 BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(AArch64::BL))
3089- .addExternalSymbol(getLibcallName(LC) )
3088+ .addExternalSymbol("__arm_sme_state_size" )
30903089 .addReg(AArch64::X0, RegState::ImplicitDefine)
3091- .addRegMask(TRI->getCallPreservedMask(*MF, getLibcallCallingConv(LC)));
3090+ .addRegMask(TRI->getCallPreservedMask(
3091+ *MF, CallingConv::
3092+ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1));
30923093 BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(TargetOpcode::COPY),
30933094 MI.getOperand(0).getReg())
30943095 .addReg(AArch64::X0);
@@ -3108,12 +3109,13 @@ AArch64TargetLowering::EmitEntryPStateSM(MachineInstr &MI,
31083109 const TargetInstrInfo *TII = Subtarget->getInstrInfo();
31093110 Register ResultReg = MI.getOperand(0).getReg();
31103111 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(getLibcallName(LC) )
3114+ .addExternalSymbol("__arm_sme_state" )
31153115 .addReg(AArch64::X0, RegState::ImplicitDefine)
3116- .addRegMask(TRI->getCallPreservedMask(*MF, getLibcallCallingConv(LC)));
3116+ .addRegMask(TRI->getCallPreservedMask(
3117+ *MF, CallingConv::
3118+ AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2));
31173119 BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(TargetOpcode::COPY), ResultReg)
31183120 .addReg(AArch64::X0);
31193121 } else {
@@ -5737,15 +5739,15 @@ static SDValue getSVEPredicateBitCast(EVT VT, SDValue Op, SelectionDAG &DAG) {
57375739SDValue AArch64TargetLowering::getRuntimePStateSM(SelectionDAG &DAG,
57385740 SDValue Chain, SDLoc DL,
57395741 EVT VT) const {
5740- RTLIB::Libcall LC = RTLIB::SMEABI_SME_STATE;
5741- SDValue Callee = DAG.getExternalSymbol(getLibcallName(LC),
5742+ SDValue Callee = DAG.getExternalSymbol("__arm_sme_state",
57425743 getPointerTy(DAG.getDataLayout()));
57435744 Type *Int64Ty = Type::getInt64Ty(*DAG.getContext());
57445745 Type *RetTy = StructType::get(Int64Ty, Int64Ty);
57455746 TargetLowering::CallLoweringInfo CLI(DAG);
57465747 ArgListTy Args;
57475748 CLI.setDebugLoc(DL).setChain(Chain).setLibCallee(
5748- getLibcallCallingConv(LC), RetTy, Callee, std::move(Args));
5749+ CallingConv::AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2,
5750+ RetTy, Callee, std::move(Args));
57495751 std::pair<SDValue, SDValue> CallResult = LowerCallTo(CLI);
57505752 SDValue Mask = DAG.getConstant(/*PSTATE.SM*/ 1, DL, MVT::i64);
57515753 return DAG.getNode(ISD::AND, DL, MVT::i64, CallResult.first.getOperand(0),
@@ -8598,12 +8600,12 @@ static void analyzeCallOperands(const AArch64TargetLowering &TLI,
85988600}
85998601
86008602static SMECallAttrs
8601- getSMECallAttrs(const Function &Caller, const TargetLowering &TLI,
8603+ getSMECallAttrs(const Function &Caller,
86028604 const TargetLowering::CallLoweringInfo &CLI) {
86038605 if (CLI.CB)
8604- return SMECallAttrs(*CLI.CB, &TLI );
8606+ return SMECallAttrs(*CLI.CB);
86058607 if (auto *ES = dyn_cast<ExternalSymbolSDNode>(CLI.Callee))
8606- return SMECallAttrs(SMEAttrs(Caller), SMEAttrs(ES->getSymbol(), TLI ));
8608+ return SMECallAttrs(SMEAttrs(Caller), SMEAttrs(ES->getSymbol()));
86078609 return SMECallAttrs(SMEAttrs(Caller), SMEAttrs(SMEAttrs::Normal));
86088610}
86098611
@@ -8625,7 +8627,7 @@ bool AArch64TargetLowering::isEligibleForTailCallOptimization(
86258627
86268628 // SME Streaming functions are not eligible for TCO as they may require
86278629 // the streaming mode or ZA to be restored after returning from the call.
8628- SMECallAttrs CallAttrs = getSMECallAttrs(CallerF, *this, CLI);
8630+ SMECallAttrs CallAttrs = getSMECallAttrs(CallerF, CLI);
86298631 if (CallAttrs.requiresSMChange() || CallAttrs.requiresLazySave() ||
86308632 CallAttrs.requiresPreservingAllZAState() ||
86318633 CallAttrs.caller().hasStreamingBody())
@@ -8919,14 +8921,14 @@ static SDValue emitSMEStateSaveRestore(const AArch64TargetLowering &TLI,
89198921 DAG.getCopyFromReg(Chain, DL, Info->getSMESaveBufferAddr(), MVT::i64);
89208922 Args.push_back(Entry);
89218923
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()));
8924+ SDValue Callee =
8925+ DAG.getExternalSymbol(IsSave ? "__arm_sme_save" : "__arm_sme_restore",
8926+ TLI.getPointerTy(DAG.getDataLayout()));
89268927 auto *RetTy = Type::getVoidTy(*DAG.getContext());
89278928 TargetLowering::CallLoweringInfo CLI(DAG);
89288929 CLI.setDebugLoc(DL).setChain(Chain).setLibCallee(
8929- TLI.getLibcallCallingConv(LC), RetTy, Callee, std::move(Args));
8930+ CallingConv::AArch64_SME_ABI_Support_Routines_PreserveMost_From_X1, RetTy,
8931+ Callee, std::move(Args));
89308932 return TLI.LowerCallTo(CLI).second;
89318933}
89328934
@@ -9114,7 +9116,7 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
91149116 }
91159117
91169118 // Determine whether we need any streaming mode changes.
9117- SMECallAttrs CallAttrs = getSMECallAttrs(MF.getFunction(), *this, CLI);
9119+ SMECallAttrs CallAttrs = getSMECallAttrs(MF.getFunction(), CLI);
91189120
91199121 auto DescribeCallsite =
91209122 [&](OptimizationRemarkAnalysis &R) -> OptimizationRemarkAnalysis & {
@@ -9691,12 +9693,11 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
96919693
96929694 if (RequiresLazySave) {
96939695 // Conditionally restore the lazy save using a pseudo node.
9694- RTLIB::Libcall LC = RTLIB::SMEABI_TPIDR2_RESTORE;
96959696 TPIDR2Object &TPIDR2 = FuncInfo->getTPIDR2Obj();
96969697 SDValue RegMask = DAG.getRegisterMask(
9697- TRI->getCallPreservedMask(MF, getLibcallCallingConv(LC) ));
9698+ TRI->SMEABISupportRoutinesCallPreservedMaskFromX0( ));
96989699 SDValue RestoreRoutine = DAG.getTargetExternalSymbol(
9699- getLibcallName(LC) , getPointerTy(DAG.getDataLayout()));
9700+ "__arm_tpidr2_restore" , getPointerTy(DAG.getDataLayout()));
97009701 SDValue TPIDR2_EL0 = DAG.getNode(
97019702 ISD::INTRINSIC_W_CHAIN, DL, MVT::i64, Result,
97029703 DAG.getConstant(Intrinsic::aarch64_sme_get_tpidr2, DL, MVT::i32));
@@ -29035,7 +29036,7 @@ bool AArch64TargetLowering::fallBackToDAGISel(const Instruction &Inst) const {
2903529036
2903629037 // Checks to allow the use of SME instructions
2903729038 if (auto *Base = dyn_cast<CallBase>(&Inst)) {
29038- auto CallAttrs = SMECallAttrs(*Base, this );
29039+ auto CallAttrs = SMECallAttrs(*Base);
2903929040 if (CallAttrs.requiresSMChange() || CallAttrs.requiresLazySave() ||
2904029041 CallAttrs.requiresPreservingZT0() ||
2904129042 CallAttrs.requiresPreservingAllZAState())
0 commit comments