1 //=- AArch64CallingConv.td - Calling Conventions for AArch64 -*- tablegen -*-=//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This describes the calling conventions for AArch64 architecture.
11 //===----------------------------------------------------------------------===//
13 /// CCIfAlign - Match of the original alignment of the arg
14 class CCIfAlign<string Align, CCAction A> :
15 CCIf<!strconcat("ArgFlags.getOrigAlign() == ", Align), A>;
16 /// CCIfBigEndian - Match only if we're in big endian mode.
17 class CCIfBigEndian<CCAction A> :
18 CCIf<"State.getMachineFunction().getDataLayout().isBigEndian()", A>;
20 class CCIfILP32<CCAction A> :
21 CCIf<"State.getMachineFunction().getDataLayout().getPointerSize() == 4", A>;
24 //===----------------------------------------------------------------------===//
25 // ARM AAPCS64 Calling Convention
26 //===----------------------------------------------------------------------===//
29 def CC_AArch64_AAPCS : CallingConv<[
30 CCIfType<[iPTR], CCBitConvertToType<i64>>,
31 CCIfType<[v2f32], CCBitConvertToType<v2i32>>,
32 CCIfType<[v2f64, v4f32], CCBitConvertToType<v2i64>>,
34 // Big endian vectors must be passed as if they were 1-element vectors so that
35 // their lanes are in a consistent order.
36 CCIfBigEndian<CCIfType<[v2i32, v2f32, v4i16, v4f16, v8i8],
37 CCBitConvertToType<f64>>>,
38 CCIfBigEndian<CCIfType<[v2i64, v2f64, v4i32, v4f32, v8i16, v8f16, v16i8],
39 CCBitConvertToType<f128>>>,
41 // In AAPCS, an SRet is passed in X8, not X0 like a normal pointer parameter.
42 // However, on windows, in some circumstances, the SRet is passed in X0 or X1
43 // instead. The presence of the inreg attribute indicates that SRet is
44 // passed in the alternative register (X0 or X1), not X8:
45 // - X0 for non-instance methods.
46 // - X1 for instance methods.
48 // The "sret" attribute identifies indirect returns.
49 // The "inreg" attribute identifies non-aggregate types.
50 // The position of the "sret" attribute identifies instance/non-instance
52 // "sret" on argument 0 means non-instance methods.
53 // "sret" on argument 1 means instance methods.
55 CCIfInReg<CCIfType<[i64],
56 CCIfSRet<CCIfType<[i64], CCAssignToRegWithShadow<[X0, X1], [W0, W1]>>>>>,
58 CCIfSRet<CCIfType<[i64], CCAssignToRegWithShadow<[X8], [W8]>>>,
60 // Put ByVal arguments directly on the stack. Minimum size and alignment of a
62 CCIfByVal<CCPassByVal<8, 8>>,
64 // The 'nest' parameter, if any, is passed in X18.
65 // Darwin uses X18 as the platform register and hence 'nest' isn't currently
67 CCIfNest<CCAssignToReg<[X18]>>,
69 // Pass SwiftSelf in a callee saved register.
70 CCIfSwiftSelf<CCIfType<[i64], CCAssignToRegWithShadow<[X20], [W20]>>>,
72 // A SwiftError is passed in X21.
73 CCIfSwiftError<CCIfType<[i64], CCAssignToRegWithShadow<[X21], [W21]>>>,
75 CCIfConsecutiveRegs<CCCustom<"CC_AArch64_Custom_Block">>,
77 CCIfType<[nxv16i8, nxv8i16, nxv4i32, nxv2i64, nxv2f16, nxv4f16, nxv8f16,
78 nxv1f32, nxv2f32, nxv4f32, nxv1f64, nxv2f64],
79 CCAssignToReg<[Z0, Z1, Z2, Z3, Z4, Z5, Z6, Z7]>>,
80 CCIfType<[nxv16i8, nxv8i16, nxv4i32, nxv2i64, nxv2f16, nxv4f16, nxv8f16,
81 nxv1f32, nxv2f32, nxv4f32, nxv1f64, nxv2f64],
84 CCIfType<[nxv2i1, nxv4i1, nxv8i1, nxv16i1],
85 CCAssignToReg<[P0, P1, P2, P3]>>,
86 CCIfType<[nxv2i1, nxv4i1, nxv8i1, nxv16i1],
89 // Handle i1, i8, i16, i32, i64, f32, f64 and v2f64 by passing in registers,
90 // up to eight each of GPR and FPR.
91 CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
92 CCIfType<[i32], CCAssignToRegWithShadow<[W0, W1, W2, W3, W4, W5, W6, W7],
93 [X0, X1, X2, X3, X4, X5, X6, X7]>>,
94 // i128 is split to two i64s, we can't fit half to register X7.
95 CCIfType<[i64], CCIfSplit<CCAssignToRegWithShadow<[X0, X2, X4, X6],
98 // i128 is split to two i64s, and its stack alignment is 16 bytes.
99 CCIfType<[i64], CCIfSplit<CCAssignToStackWithShadow<8, 16, [X7]>>>,
101 CCIfType<[i64], CCAssignToRegWithShadow<[X0, X1, X2, X3, X4, X5, X6, X7],
102 [W0, W1, W2, W3, W4, W5, W6, W7]>>,
103 CCIfType<[f16], CCAssignToRegWithShadow<[H0, H1, H2, H3, H4, H5, H6, H7],
104 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
105 CCIfType<[f32], CCAssignToRegWithShadow<[S0, S1, S2, S3, S4, S5, S6, S7],
106 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
107 CCIfType<[f64], CCAssignToRegWithShadow<[D0, D1, D2, D3, D4, D5, D6, D7],
108 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
109 CCIfType<[v1i64, v2i32, v4i16, v8i8, v1f64, v2f32, v4f16],
110 CCAssignToRegWithShadow<[D0, D1, D2, D3, D4, D5, D6, D7],
111 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
112 CCIfType<[f128, v2i64, v4i32, v8i16, v16i8, v4f32, v2f64, v8f16],
113 CCAssignToReg<[Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
115 // If more than will fit in registers, pass them on the stack instead.
116 CCIfType<[i1, i8, i16, f16], CCAssignToStack<8, 8>>,
117 CCIfType<[i32, f32], CCAssignToStack<8, 8>>,
118 CCIfType<[i64, f64, v1f64, v2f32, v1i64, v2i32, v4i16, v8i8, v4f16],
119 CCAssignToStack<8, 8>>,
120 CCIfType<[f128, v2i64, v4i32, v8i16, v16i8, v4f32, v2f64, v8f16],
121 CCAssignToStack<16, 16>>
125 def RetCC_AArch64_AAPCS : CallingConv<[
126 CCIfType<[iPTR], CCBitConvertToType<i64>>,
127 CCIfType<[v2f32], CCBitConvertToType<v2i32>>,
128 CCIfType<[v2f64, v4f32], CCBitConvertToType<v2i64>>,
130 CCIfConsecutiveRegs<CCCustom<"CC_AArch64_Custom_Block">>,
131 CCIfSwiftError<CCIfType<[i64], CCAssignToRegWithShadow<[X21], [W21]>>>,
133 // Big endian vectors must be passed as if they were 1-element vectors so that
134 // their lanes are in a consistent order.
135 CCIfBigEndian<CCIfType<[v2i32, v2f32, v4i16, v4f16, v8i8],
136 CCBitConvertToType<f64>>>,
137 CCIfBigEndian<CCIfType<[v2i64, v2f64, v4i32, v4f32, v8i16, v8f16, v16i8],
138 CCBitConvertToType<f128>>>,
140 CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
141 CCIfType<[i32], CCAssignToRegWithShadow<[W0, W1, W2, W3, W4, W5, W6, W7],
142 [X0, X1, X2, X3, X4, X5, X6, X7]>>,
143 CCIfType<[i64], CCAssignToRegWithShadow<[X0, X1, X2, X3, X4, X5, X6, X7],
144 [W0, W1, W2, W3, W4, W5, W6, W7]>>,
145 CCIfType<[f16], CCAssignToRegWithShadow<[H0, H1, H2, H3, H4, H5, H6, H7],
146 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
147 CCIfType<[f32], CCAssignToRegWithShadow<[S0, S1, S2, S3, S4, S5, S6, S7],
148 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
149 CCIfType<[f64], CCAssignToRegWithShadow<[D0, D1, D2, D3, D4, D5, D6, D7],
150 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
151 CCIfType<[v1i64, v2i32, v4i16, v8i8, v1f64, v2f32, v4f16],
152 CCAssignToRegWithShadow<[D0, D1, D2, D3, D4, D5, D6, D7],
153 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
154 CCIfType<[f128, v2i64, v4i32, v8i16, v16i8, v4f32, v2f64, v8f16],
155 CCAssignToReg<[Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
157 CCIfType<[nxv16i8, nxv8i16, nxv4i32, nxv2i64, nxv2f16, nxv4f16, nxv8f16,
158 nxv1f32, nxv2f32, nxv4f32, nxv1f64, nxv2f64],
159 CCAssignToReg<[Z0, Z1, Z2, Z3, Z4, Z5, Z6, Z7]>>,
161 CCIfType<[nxv2i1, nxv4i1, nxv8i1, nxv16i1],
162 CCAssignToReg<[P0, P1, P2, P3]>>
165 // Vararg functions on windows pass floats in integer registers
167 def CC_AArch64_Win64_VarArg : CallingConv<[
168 CCIfType<[f16, f32], CCPromoteToType<f64>>,
169 CCIfType<[f64], CCBitConvertToType<i64>>,
170 CCDelegateTo<CC_AArch64_AAPCS>
174 // Darwin uses a calling convention which differs in only two ways
175 // from the standard one at this level:
176 // + i128s (i.e. split i64s) don't need even registers.
177 // + Stack slots are sized as needed rather than being at least 64-bit.
179 def CC_AArch64_DarwinPCS : CallingConv<[
180 CCIfType<[iPTR], CCBitConvertToType<i64>>,
181 CCIfType<[v2f32], CCBitConvertToType<v2i32>>,
182 CCIfType<[v2f64, v4f32, f128], CCBitConvertToType<v2i64>>,
184 // An SRet is passed in X8, not X0 like a normal pointer parameter.
185 CCIfSRet<CCIfType<[i64], CCAssignToRegWithShadow<[X8], [W8]>>>,
187 // Put ByVal arguments directly on the stack. Minimum size and alignment of a
189 CCIfByVal<CCPassByVal<8, 8>>,
191 // Pass SwiftSelf in a callee saved register.
192 CCIfSwiftSelf<CCIfType<[i64], CCAssignToRegWithShadow<[X20], [W20]>>>,
194 // A SwiftError is passed in X21.
195 CCIfSwiftError<CCIfType<[i64], CCAssignToRegWithShadow<[X21], [W21]>>>,
197 CCIfConsecutiveRegs<CCCustom<"CC_AArch64_Custom_Block">>,
199 // Handle i1, i8, i16, i32, i64, f32, f64 and v2f64 by passing in registers,
200 // up to eight each of GPR and FPR.
201 CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
202 CCIfType<[i32], CCAssignToRegWithShadow<[W0, W1, W2, W3, W4, W5, W6, W7],
203 [X0, X1, X2, X3, X4, X5, X6, X7]>>,
204 // i128 is split to two i64s, we can't fit half to register X7.
206 CCIfSplit<CCAssignToRegWithShadow<[X0, X1, X2, X3, X4, X5, X6],
207 [W0, W1, W2, W3, W4, W5, W6]>>>,
208 // i128 is split to two i64s, and its stack alignment is 16 bytes.
209 CCIfType<[i64], CCIfSplit<CCAssignToStackWithShadow<8, 16, [X7]>>>,
211 CCIfType<[i64], CCAssignToRegWithShadow<[X0, X1, X2, X3, X4, X5, X6, X7],
212 [W0, W1, W2, W3, W4, W5, W6, W7]>>,
213 CCIfType<[f16], CCAssignToRegWithShadow<[H0, H1, H2, H3, H4, H5, H6, H7],
214 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
215 CCIfType<[f32], CCAssignToRegWithShadow<[S0, S1, S2, S3, S4, S5, S6, S7],
216 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
217 CCIfType<[f64], CCAssignToRegWithShadow<[D0, D1, D2, D3, D4, D5, D6, D7],
218 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
219 CCIfType<[v1i64, v2i32, v4i16, v8i8, v1f64, v2f32, v4f16],
220 CCAssignToRegWithShadow<[D0, D1, D2, D3, D4, D5, D6, D7],
221 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
222 CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32, v2f64, v8f16],
223 CCAssignToReg<[Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
225 // If more than will fit in registers, pass them on the stack instead.
226 CCIf<"ValVT == MVT::i1 || ValVT == MVT::i8", CCAssignToStack<1, 1>>,
227 CCIf<"ValVT == MVT::i16 || ValVT == MVT::f16", CCAssignToStack<2, 2>>,
228 CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
230 // Re-demote pointers to 32-bits so we don't end up storing 64-bit
231 // values and clobbering neighbouring stack locations. Not very pretty.
232 CCIfPtr<CCIfILP32<CCTruncToType<i32>>>,
233 CCIfPtr<CCIfILP32<CCAssignToStack<4, 4>>>,
235 CCIfType<[i64, f64, v1f64, v2f32, v1i64, v2i32, v4i16, v8i8, v4f16],
236 CCAssignToStack<8, 8>>,
237 CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32, v2f64, v8f16],
238 CCAssignToStack<16, 16>>
242 def CC_AArch64_DarwinPCS_VarArg : CallingConv<[
243 CCIfType<[iPTR], CCBitConvertToType<i64>>,
244 CCIfType<[v2f32], CCBitConvertToType<v2i32>>,
245 CCIfType<[v2f64, v4f32, f128], CCBitConvertToType<v2i64>>,
247 CCIfConsecutiveRegs<CCCustom<"CC_AArch64_Custom_Stack_Block">>,
249 // Handle all scalar types as either i64 or f64.
250 CCIfType<[i8, i16, i32], CCPromoteToType<i64>>,
251 CCIfType<[f16, f32], CCPromoteToType<f64>>,
253 // Everything is on the stack.
254 // i128 is split to two i64s, and its stack alignment is 16 bytes.
255 CCIfType<[i64], CCIfSplit<CCAssignToStack<8, 16>>>,
256 CCIfType<[i64, f64, v1i64, v2i32, v4i16, v8i8, v1f64, v2f32, v4f16],
257 CCAssignToStack<8, 8>>,
258 CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32, v2f64, v8f16],
259 CCAssignToStack<16, 16>>
262 // In the ILP32 world, the minimum stack slot size is 4 bytes. Otherwise the
263 // same as the normal Darwin VarArgs handling.
265 def CC_AArch64_DarwinPCS_ILP32_VarArg : CallingConv<[
266 CCIfType<[v2f32], CCBitConvertToType<v2i32>>,
267 CCIfType<[v2f64, v4f32, f128], CCBitConvertToType<v2i64>>,
269 // Handle all scalar types as either i32 or f32.
270 CCIfType<[i8, i16], CCPromoteToType<i32>>,
271 CCIfType<[f16], CCPromoteToType<f32>>,
273 // Everything is on the stack.
274 // i128 is split to two i64s, and its stack alignment is 16 bytes.
275 CCIfPtr<CCIfILP32<CCTruncToType<i32>>>,
276 CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
277 CCIfType<[i64], CCIfSplit<CCAssignToStack<8, 16>>>,
278 CCIfType<[i64, f64, v1i64, v2i32, v4i16, v8i8, v1f64, v2f32, v4f16],
279 CCAssignToStack<8, 8>>,
280 CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32, v2f64, v8f16],
281 CCAssignToStack<16, 16>>
285 // The WebKit_JS calling convention only passes the first argument (the callee)
286 // in register and the remaining arguments on stack. We allow 32bit stack slots,
287 // so that WebKit can write partial values in the stack and define the other
288 // 32bit quantity as undef.
290 def CC_AArch64_WebKit_JS : CallingConv<[
291 // Handle i1, i8, i16, i32, and i64 passing in register X0 (W0).
292 CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
293 CCIfType<[i32], CCAssignToRegWithShadow<[W0], [X0]>>,
294 CCIfType<[i64], CCAssignToRegWithShadow<[X0], [W0]>>,
296 // Pass the remaining arguments on the stack instead.
297 CCIfType<[i32, f32], CCAssignToStack<4, 4>>,
298 CCIfType<[i64, f64], CCAssignToStack<8, 8>>
302 def RetCC_AArch64_WebKit_JS : CallingConv<[
303 CCIfType<[i32], CCAssignToRegWithShadow<[W0, W1, W2, W3, W4, W5, W6, W7],
304 [X0, X1, X2, X3, X4, X5, X6, X7]>>,
305 CCIfType<[i64], CCAssignToRegWithShadow<[X0, X1, X2, X3, X4, X5, X6, X7],
306 [W0, W1, W2, W3, W4, W5, W6, W7]>>,
307 CCIfType<[f32], CCAssignToRegWithShadow<[S0, S1, S2, S3, S4, S5, S6, S7],
308 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>,
309 CCIfType<[f64], CCAssignToRegWithShadow<[D0, D1, D2, D3, D4, D5, D6, D7],
310 [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>
313 //===----------------------------------------------------------------------===//
314 // ARM64 Calling Convention for GHC
315 //===----------------------------------------------------------------------===//
317 // This calling convention is specific to the Glasgow Haskell Compiler.
318 // The only documentation is the GHC source code, specifically the C header
321 // https://github.com/ghc/ghc/blob/master/includes/stg/MachRegs.h
323 // which defines the registers for the Spineless Tagless G-Machine (STG) that
324 // GHC uses to implement lazy evaluation. The generic STG machine has a set of
325 // registers which are mapped to appropriate set of architecture specific
326 // registers for each CPU architecture.
328 // The STG Machine is documented here:
330 // https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/GeneratedCode
332 // The AArch64 register mapping is under the heading "The ARMv8/AArch64 ABI
333 // register mapping".
336 def CC_AArch64_GHC : CallingConv<[
337 CCIfType<[iPTR], CCBitConvertToType<i64>>,
339 // Handle all vector types as either f64 or v2f64.
340 CCIfType<[v1i64, v2i32, v4i16, v8i8, v2f32], CCBitConvertToType<f64>>,
341 CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32, f128], CCBitConvertToType<v2f64>>,
343 CCIfType<[v2f64], CCAssignToReg<[Q4, Q5]>>,
344 CCIfType<[f32], CCAssignToReg<[S8, S9, S10, S11]>>,
345 CCIfType<[f64], CCAssignToReg<[D12, D13, D14, D15]>>,
347 // Promote i8/i16/i32 arguments to i64.
348 CCIfType<[i8, i16, i32], CCPromoteToType<i64>>,
350 // Pass in STG registers: Base, Sp, Hp, R1, R2, R3, R4, R5, R6, SpLim
351 CCIfType<[i64], CCAssignToReg<[X19, X20, X21, X22, X23, X24, X25, X26, X27, X28]>>
354 // The order of the callee-saves in this file is important, because the
355 // FrameLowering code will use this order to determine the layout the
356 // callee-save area in the stack frame. As can be observed below, Darwin
357 // requires the frame-record (LR, FP) to be at the top the callee-save area,
358 // whereas for other platforms they are at the bottom.
360 // FIXME: LR is only callee-saved in the sense that *we* preserve it and are
361 // presumably a callee to someone. External functions may not do so, but this
362 // is currently safe since BL has LR as an implicit-def and what happens after a
363 // tail call doesn't matter.
365 // It would be better to model its preservation semantics properly (create a
366 // vreg on entry, use it in RET & tail call generation; make that vreg def if we
367 // end up saving LR as part of a call frame). Watch this space...
368 def CSR_AArch64_AAPCS : CalleeSavedRegs<(add X19, X20, X21, X22, X23, X24,
369 X25, X26, X27, X28, LR, FP,
371 D12, D13, D14, D15)>;
373 // Darwin puts the frame-record at the top of the callee-save area.
374 def CSR_Darwin_AArch64_AAPCS : CalleeSavedRegs<(add LR, FP, X19, X20, X21, X22,
375 X23, X24, X25, X26, X27, X28,
377 D12, D13, D14, D15)>;
379 // Win64 has unwinding codes for an (FP,LR) pair, save_fplr and save_fplr_x.
380 // We put FP before LR, so that frame lowering logic generates (FP,LR) pairs,
381 // and not (LR,FP) pairs.
382 def CSR_Win_AArch64_AAPCS : CalleeSavedRegs<(add X19, X20, X21, X22, X23, X24,
383 X25, X26, X27, X28, FP, LR,
385 D12, D13, D14, D15)>;
387 // AArch64 PCS for vector functions (VPCS)
388 // must (additionally) preserve full Q8-Q23 registers
389 def CSR_AArch64_AAVPCS : CalleeSavedRegs<(add X19, X20, X21, X22, X23, X24,
390 X25, X26, X27, X28, LR, FP,
391 (sequence "Q%u", 8, 23))>;
393 // Functions taking SVE arguments or returning an SVE type
394 // must (additionally) preserve full Z8-Z23 and predicate registers P4-P15
395 def CSR_AArch64_SVE_AAPCS : CalleeSavedRegs<(add X19, X20, X21, X22, X23, X24,
396 X25, X26, X27, X28, LR, FP,
397 (sequence "Z%u", 8, 23),
398 (sequence "P%u", 4, 15))>;
400 // Constructors and destructors return 'this' in the iOS 64-bit C++ ABI; since
401 // 'this' and the pointer return value are both passed in X0 in these cases,
402 // this can be partially modelled by treating X0 as a callee-saved register;
403 // only the resulting RegMask is used; the SaveList is ignored
405 // (For generic ARM 64-bit ABI code, clang will not generate constructors or
406 // destructors with 'this' returns, so this RegMask will not be used in that
408 def CSR_AArch64_AAPCS_ThisReturn : CalleeSavedRegs<(add CSR_AArch64_AAPCS, X0)>;
410 def CSR_AArch64_AAPCS_SwiftError
411 : CalleeSavedRegs<(sub CSR_Darwin_AArch64_AAPCS, X21)>;
413 // The function used by Darwin to obtain the address of a thread-local variable
414 // guarantees more than a normal AAPCS function. x16 and x17 are used on the
415 // fast path for calculation, but other registers except X0 (argument/return)
416 // and LR (it is a call, after all) are preserved.
417 def CSR_AArch64_TLS_Darwin
418 : CalleeSavedRegs<(add (sub (sequence "X%u", 1, 28), X16, X17),
420 (sequence "Q%u", 0, 31))>;
422 // We can only handle a register pair with adjacent registers, the register pair
423 // should belong to the same class as well. Since the access function on the
424 // fast path calls a function that follows CSR_AArch64_TLS_Darwin,
425 // CSR_AArch64_CXX_TLS_Darwin should be a subset of CSR_AArch64_TLS_Darwin.
426 def CSR_AArch64_CXX_TLS_Darwin
427 : CalleeSavedRegs<(add CSR_Darwin_AArch64_AAPCS,
428 (sub (sequence "X%u", 1, 28), X15, X16, X17, X18),
429 (sequence "D%u", 0, 31))>;
431 // CSRs that are handled by prologue, epilogue.
432 def CSR_AArch64_CXX_TLS_Darwin_PE
433 : CalleeSavedRegs<(add LR, FP)>;
435 // CSRs that are handled explicitly via copies.
436 def CSR_AArch64_CXX_TLS_Darwin_ViaCopy
437 : CalleeSavedRegs<(sub CSR_AArch64_CXX_TLS_Darwin, LR, FP)>;
439 // The ELF stub used for TLS-descriptor access saves every feasible
440 // register. Only X0 and LR are clobbered.
441 def CSR_AArch64_TLS_ELF
442 : CalleeSavedRegs<(add (sequence "X%u", 1, 28), FP,
443 (sequence "Q%u", 0, 31))>;
445 def CSR_AArch64_AllRegs
446 : CalleeSavedRegs<(add (sequence "W%u", 0, 30), WSP,
447 (sequence "X%u", 0, 28), FP, LR, SP,
448 (sequence "B%u", 0, 31), (sequence "H%u", 0, 31),
449 (sequence "S%u", 0, 31), (sequence "D%u", 0, 31),
450 (sequence "Q%u", 0, 31))>;
452 def CSR_AArch64_NoRegs : CalleeSavedRegs<(add)>;
454 def CSR_AArch64_RT_MostRegs : CalleeSavedRegs<(add CSR_AArch64_AAPCS,
455 (sequence "X%u", 9, 15))>;
457 def CSR_AArch64_StackProbe_Windows
458 : CalleeSavedRegs<(add (sequence "X%u", 0, 15),
459 (sequence "X%u", 18, 28), FP, SP,
460 (sequence "Q%u", 0, 31))>;
462 // Variants of the standard calling conventions for shadow call stack.
463 // These all preserve x18 in addition to any other registers.
464 def CSR_AArch64_NoRegs_SCS
465 : CalleeSavedRegs<(add CSR_AArch64_NoRegs, X18)>;
466 def CSR_AArch64_AllRegs_SCS
467 : CalleeSavedRegs<(add CSR_AArch64_AllRegs, X18)>;
468 def CSR_AArch64_CXX_TLS_Darwin_SCS
469 : CalleeSavedRegs<(add CSR_AArch64_CXX_TLS_Darwin, X18)>;
470 def CSR_AArch64_AAPCS_SwiftError_SCS
471 : CalleeSavedRegs<(add CSR_AArch64_AAPCS_SwiftError, X18)>;
472 def CSR_AArch64_RT_MostRegs_SCS
473 : CalleeSavedRegs<(add CSR_AArch64_RT_MostRegs, X18)>;
474 def CSR_AArch64_AAVPCS_SCS
475 : CalleeSavedRegs<(add CSR_AArch64_AAVPCS, X18)>;
476 def CSR_AArch64_AAPCS_SCS
477 : CalleeSavedRegs<(add CSR_AArch64_AAPCS, X18)>;