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