@@ -76,12 +76,74 @@ SDValue AArch64SelectionDAGInfo::EmitMOPS(AArch64ISD::NodeType SDOpcode,
76
76
}
77
77
}
78
78
79
+ SDValue AArch64SelectionDAGInfo::EmitSpecializedLibcall (
80
+ SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Src,
81
+ SDValue Size, RTLIB::Libcall LC) const {
82
+ const AArch64Subtarget &STI =
83
+ DAG.getMachineFunction ().getSubtarget <AArch64Subtarget>();
84
+ const AArch64TargetLowering *TLI = STI.getTargetLowering ();
85
+ TargetLowering::ArgListTy Args;
86
+ TargetLowering::ArgListEntry Entry;
87
+ Entry.Ty = DAG.getDataLayout ().getIntPtrType (*DAG.getContext ());
88
+ Entry.Node = Dst;
89
+ Args.push_back (Entry);
90
+
91
+ enum { SME_MEMCPY = 0 , SME_MEMMOVE, SME_MEMSET } SMELibcall;
92
+ switch (LC) {
93
+ case RTLIB::MEMCPY:
94
+ SMELibcall = SME_MEMCPY;
95
+ Entry.Node = Src;
96
+ Args.push_back (Entry);
97
+ break ;
98
+ case RTLIB::MEMMOVE:
99
+ SMELibcall = SME_MEMMOVE;
100
+ Entry.Node = Src;
101
+ Args.push_back (Entry);
102
+ break ;
103
+ case RTLIB::MEMSET:
104
+ SMELibcall = SME_MEMSET;
105
+ if (Src.getValueType ().bitsGT (MVT::i32 ))
106
+ Src = DAG.getNode (ISD::TRUNCATE, DL, MVT::i32 , Src);
107
+ else if (Src.getValueType ().bitsLT (MVT::i32 ))
108
+ Src = DAG.getNode (ISD::ZERO_EXTEND, DL, MVT::i32 , Src);
109
+ Entry.Node = Src;
110
+ Entry.Ty = Type::getInt32Ty (*DAG.getContext ());
111
+ Entry.IsSExt = false ;
112
+ Args.push_back (Entry);
113
+ break ;
114
+ default :
115
+ return SDValue ();
116
+ }
117
+ Entry.Node = Size;
118
+ Args.push_back (Entry);
119
+ char const *FunctionNames[3 ] = {" __arm_sc_memcpy" , " __arm_sc_memmove" ,
120
+ " __arm_sc_memset" };
121
+
122
+ TargetLowering::CallLoweringInfo CLI (DAG);
123
+ CLI.setDebugLoc (DL)
124
+ .setChain (Chain)
125
+ .setLibCallee (
126
+ TLI->getLibcallCallingConv (RTLIB::MEMCPY),
127
+ Type::getVoidTy (*DAG.getContext ()),
128
+ DAG.getExternalSymbol (FunctionNames[SMELibcall],
129
+ TLI->getPointerTy (DAG.getDataLayout ())),
130
+ std::move (Args))
131
+ .setDiscardResult ();
132
+ std::pair<SDValue, SDValue> CallResult = TLI->LowerCallTo (CLI);
133
+ return CallResult.second ;
134
+ }
135
+
79
136
SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemcpy (
80
137
SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Src,
81
138
SDValue Size, Align Alignment, bool isVolatile, bool AlwaysInline,
82
139
MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
83
140
const AArch64Subtarget &STI =
84
141
DAG.getMachineFunction ().getSubtarget <AArch64Subtarget>();
142
+
143
+ SMEAttrs Attrs (DAG.getMachineFunction ().getFunction ());
144
+ if (Attrs.hasStreamingBody () || Attrs.hasStreamingCompatibleInterface ())
145
+ return EmitSpecializedLibcall (DAG, DL, Chain, Dst, Src, Size,
146
+ RTLIB::MEMCPY);
85
147
if (STI.hasMOPS ())
86
148
return EmitMOPS (AArch64ISD::MOPS_MEMCOPY, DAG, DL, Chain, Dst, Src, Size,
87
149
Alignment, isVolatile, DstPtrInfo, SrcPtrInfo);
@@ -95,6 +157,11 @@ SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemset(
95
157
const AArch64Subtarget &STI =
96
158
DAG.getMachineFunction ().getSubtarget <AArch64Subtarget>();
97
159
160
+ SMEAttrs Attrs (DAG.getMachineFunction ().getFunction ());
161
+ if (Attrs.hasStreamingBody () || Attrs.hasStreamingCompatibleInterface ())
162
+ return EmitSpecializedLibcall (DAG, dl, Chain, Dst, Src, Size,
163
+ RTLIB::MEMSET);
164
+
98
165
if (STI.hasMOPS ()) {
99
166
return EmitMOPS (AArch64ISD::MOPS_MEMSET, DAG, dl, Chain, Dst, Src, Size,
100
167
Alignment, isVolatile, DstPtrInfo, MachinePointerInfo{});
@@ -108,6 +175,11 @@ SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemmove(
108
175
MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
109
176
const AArch64Subtarget &STI =
110
177
DAG.getMachineFunction ().getSubtarget <AArch64Subtarget>();
178
+
179
+ SMEAttrs Attrs (DAG.getMachineFunction ().getFunction ());
180
+ if (Attrs.hasStreamingBody () || Attrs.hasStreamingCompatibleInterface ())
181
+ return EmitSpecializedLibcall (DAG, dl, Chain, Dst, Src, Size,
182
+ RTLIB::MEMMOVE);
111
183
if (STI.hasMOPS ()) {
112
184
return EmitMOPS (AArch64ISD::MOPS_MEMMOVE, DAG, dl, Chain, Dst, Src, Size,
113
185
Alignment, isVolatile, DstPtrInfo, SrcPtrInfo);
0 commit comments