[llvm] [AArch64][SME] Allow memory operations lowering to custom SME functions. (PR #79263)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 19 02:33:38 PDT 2024
================
@@ -76,15 +82,85 @@ SDValue AArch64SelectionDAGInfo::EmitMOPS(AArch64ISD::NodeType SDOpcode,
}
}
+SDValue AArch64SelectionDAGInfo::EmitSpecializedLibcall(
+ SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Src,
+ SDValue Size, RTLIB::Libcall LC) const {
+ const AArch64Subtarget &STI =
+ DAG.getMachineFunction().getSubtarget<AArch64Subtarget>();
+ const AArch64TargetLowering *TLI = STI.getTargetLowering();
+ TargetLowering::ArgListTy Args;
+ TargetLowering::ArgListEntry DstEntry;
+ SDValue Symbol;
+ DstEntry.Ty = PointerType::getUnqual(*DAG.getContext());
+ DstEntry.Node = Dst;
+ Args.push_back(DstEntry);
+ EVT Ty = TLI->getPointerTy(DAG.getDataLayout());
+ PointerType *RetTy;
+
+ if (!LowerToSMERoutines)
+ return SDValue();
+
+ switch (LC) {
+ case RTLIB::MEMCPY: {
+ TargetLowering::ArgListEntry Entry;
+ Entry.Ty = PointerType::getUnqual(*DAG.getContext());
+ Symbol = DAG.getExternalSymbol("__arm_sc_memcpy", Ty);
+ Entry.Node = Src;
+ Args.push_back(Entry);
+ RetTy = PointerType::getUnqual(*DAG.getContext());
+ break;
+ }
+ case RTLIB::MEMMOVE: {
+ TargetLowering::ArgListEntry Entry;
+ Entry.Ty = PointerType::getUnqual(*DAG.getContext());
+ Symbol = DAG.getExternalSymbol("__arm_sc_memmove", Ty);
+ Entry.Node = Src;
+ Args.push_back(Entry);
+ RetTy = PointerType::getUnqual(*DAG.getContext());
+ break;
+ }
+ case RTLIB::MEMSET: {
+ TargetLowering::ArgListEntry Entry;
+ Entry.Ty = Type::getInt32Ty(*DAG.getContext());
+ Symbol = DAG.getExternalSymbol("__arm_sc_memset", Ty);
+ Src = DAG.getZExtOrTrunc(Src, DL, MVT::i32);
+ Entry.Node = Src;
+ Args.push_back(Entry);
+ RetTy = PointerType::getUnqual(*DAG.getContext());
+ break;
+ }
+ default:
+ return SDValue();
+ }
+ TargetLowering::ArgListEntry SizeEntry;
+ SizeEntry.Node = Size;
+ SizeEntry.Ty = PointerType::getUnqual(*DAG.getContext());
+ Args.push_back(SizeEntry);
+ assert(Symbol->getOpcode() == ISD::ExternalSymbol &&
+ "Function name is not set");
+
+ TargetLowering::CallLoweringInfo CLI(DAG);
+ CLI.setDebugLoc(DL).setChain(Chain).setLibCallee(
+ TLI->getLibcallCallingConv(LC), RetTy, Symbol, std::move(Args));
+ std::pair<SDValue, SDValue> CallResult = TLI->LowerCallTo(CLI);
+ return (isa<PointerType>(RetTy) ? CallResult.second : CallResult.first);
----------------
sdesmalen-arm wrote:
If you name this function appropriately (see my suggestion above), this can be reverted back to be:
```suggestion
return TLI->LowerCallTo(CLI).second;
```
https://github.com/llvm/llvm-project/pull/79263
More information about the llvm-commits
mailing list