@@ -3083,13 +3083,12 @@ AArch64TargetLowering::EmitGetSMESaveSize(MachineInstr &MI,
3083
3083
AArch64FunctionInfo *FuncInfo = MF->getInfo<AArch64FunctionInfo>();
3084
3084
const TargetInstrInfo *TII = Subtarget->getInstrInfo();
3085
3085
if (FuncInfo->isSMESaveBufferUsed()) {
3086
+ RTLIB::Libcall LC = RTLIB::SMEABI_SME_STATE_SIZE;
3086
3087
const AArch64RegisterInfo *TRI = Subtarget->getRegisterInfo();
3087
3088
BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(AArch64::BL))
3088
- .addExternalSymbol("__arm_sme_state_size" )
3089
+ .addExternalSymbol(getLibcallName(LC) )
3089
3090
.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)));
3093
3092
BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(TargetOpcode::COPY),
3094
3093
MI.getOperand(0).getReg())
3095
3094
.addReg(AArch64::X0);
@@ -3109,13 +3108,12 @@ AArch64TargetLowering::EmitEntryPStateSM(MachineInstr &MI,
3109
3108
const TargetInstrInfo *TII = Subtarget->getInstrInfo();
3110
3109
Register ResultReg = MI.getOperand(0).getReg();
3111
3110
if (FuncInfo->isPStateSMRegUsed()) {
3111
+ RTLIB::Libcall LC = RTLIB::SMEABI_SME_STATE;
3112
3112
const AArch64RegisterInfo *TRI = Subtarget->getRegisterInfo();
3113
3113
BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(AArch64::BL))
3114
- .addExternalSymbol("__arm_sme_state" )
3114
+ .addExternalSymbol(getLibcallName(LC) )
3115
3115
.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)));
3119
3117
BuildMI(*BB, MI, MI.getDebugLoc(), TII->get(TargetOpcode::COPY), ResultReg)
3120
3118
.addReg(AArch64::X0);
3121
3119
} else {
@@ -5739,15 +5737,15 @@ static SDValue getSVEPredicateBitCast(EVT VT, SDValue Op, SelectionDAG &DAG) {
5739
5737
SDValue AArch64TargetLowering::getRuntimePStateSM(SelectionDAG &DAG,
5740
5738
SDValue Chain, SDLoc DL,
5741
5739
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),
5743
5742
getPointerTy(DAG.getDataLayout()));
5744
5743
Type *Int64Ty = Type::getInt64Ty(*DAG.getContext());
5745
5744
Type *RetTy = StructType::get(Int64Ty, Int64Ty);
5746
5745
TargetLowering::CallLoweringInfo CLI(DAG);
5747
5746
ArgListTy Args;
5748
5747
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));
5751
5749
std::pair<SDValue, SDValue> CallResult = LowerCallTo(CLI);
5752
5750
SDValue Mask = DAG.getConstant(/*PSTATE.SM*/ 1, DL, MVT::i64);
5753
5751
return DAG.getNode(ISD::AND, DL, MVT::i64, CallResult.first.getOperand(0),
@@ -8600,12 +8598,12 @@ static void analyzeCallOperands(const AArch64TargetLowering &TLI,
8600
8598
}
8601
8599
8602
8600
static SMECallAttrs
8603
- getSMECallAttrs(const Function &Caller,
8601
+ getSMECallAttrs(const Function &Caller, const TargetLowering &TLI,
8604
8602
const TargetLowering::CallLoweringInfo &CLI) {
8605
8603
if (CLI.CB)
8606
- return SMECallAttrs(*CLI.CB);
8604
+ return SMECallAttrs(*CLI.CB, &TLI );
8607
8605
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 ));
8609
8607
return SMECallAttrs(SMEAttrs(Caller), SMEAttrs(SMEAttrs::Normal));
8610
8608
}
8611
8609
@@ -8627,7 +8625,7 @@ bool AArch64TargetLowering::isEligibleForTailCallOptimization(
8627
8625
8628
8626
// SME Streaming functions are not eligible for TCO as they may require
8629
8627
// 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);
8631
8629
if (CallAttrs.requiresSMChange() || CallAttrs.requiresLazySave() ||
8632
8630
CallAttrs.requiresPreservingAllZAState() ||
8633
8631
CallAttrs.caller().hasStreamingBody())
@@ -8921,14 +8919,14 @@ static SDValue emitSMEStateSaveRestore(const AArch64TargetLowering &TLI,
8921
8919
DAG.getCopyFromReg(Chain, DL, Info->getSMESaveBufferAddr(), MVT::i64);
8922
8920
Args.push_back(Entry);
8923
8921
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()));
8927
8926
auto *RetTy = Type::getVoidTy(*DAG.getContext());
8928
8927
TargetLowering::CallLoweringInfo CLI(DAG);
8929
8928
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));
8932
8930
return TLI.LowerCallTo(CLI).second;
8933
8931
}
8934
8932
@@ -9116,7 +9114,7 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
9116
9114
}
9117
9115
9118
9116
// Determine whether we need any streaming mode changes.
9119
- SMECallAttrs CallAttrs = getSMECallAttrs(MF.getFunction(), CLI);
9117
+ SMECallAttrs CallAttrs = getSMECallAttrs(MF.getFunction(), *this, CLI);
9120
9118
9121
9119
auto DescribeCallsite =
9122
9120
[&](OptimizationRemarkAnalysis &R) -> OptimizationRemarkAnalysis & {
@@ -9693,11 +9691,12 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
9693
9691
9694
9692
if (RequiresLazySave) {
9695
9693
// Conditionally restore the lazy save using a pseudo node.
9694
+ RTLIB::Libcall LC = RTLIB::SMEABI_TPIDR2_RESTORE;
9696
9695
TPIDR2Object &TPIDR2 = FuncInfo->getTPIDR2Obj();
9697
9696
SDValue RegMask = DAG.getRegisterMask(
9698
- TRI->SMEABISupportRoutinesCallPreservedMaskFromX0( ));
9697
+ TRI->getCallPreservedMask(MF, getLibcallCallingConv(LC) ));
9699
9698
SDValue RestoreRoutine = DAG.getTargetExternalSymbol(
9700
- "__arm_tpidr2_restore" , getPointerTy(DAG.getDataLayout()));
9699
+ getLibcallName(LC) , getPointerTy(DAG.getDataLayout()));
9701
9700
SDValue TPIDR2_EL0 = DAG.getNode(
9702
9701
ISD::INTRINSIC_W_CHAIN, DL, MVT::i64, Result,
9703
9702
DAG.getConstant(Intrinsic::aarch64_sme_get_tpidr2, DL, MVT::i32));
@@ -29036,7 +29035,7 @@ bool AArch64TargetLowering::fallBackToDAGISel(const Instruction &Inst) const {
29036
29035
29037
29036
// Checks to allow the use of SME instructions
29038
29037
if (auto *Base = dyn_cast<CallBase>(&Inst)) {
29039
- auto CallAttrs = SMECallAttrs(*Base);
29038
+ auto CallAttrs = SMECallAttrs(*Base, this );
29040
29039
if (CallAttrs.requiresSMChange() || CallAttrs.requiresLazySave() ||
29041
29040
CallAttrs.requiresPreservingZT0() ||
29042
29041
CallAttrs.requiresPreservingAllZAState())
0 commit comments