xref: /freebsd/contrib/llvm-project/llvm/lib/Target/ARM/ARMCallingConv.td (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
10b57cec5SDimitry Andric//===-- ARMCallingConv.td - Calling Conventions for ARM ----*- tablegen -*-===//
20b57cec5SDimitry Andric//
30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric//
70b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric// This describes the calling conventions for ARM architecture.
90b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
100b57cec5SDimitry Andric
110b57cec5SDimitry Andric/// CCIfAlign - Match of the original alignment of the arg
120b57cec5SDimitry Andricclass CCIfAlign<string Align, CCAction A>:
135ffd83dbSDimitry Andric  CCIf<!strconcat("ArgFlags.getNonZeroOrigAlign() == ", Align), A>;
140b57cec5SDimitry Andric
150b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
160b57cec5SDimitry Andric// ARM APCS Calling Convention
170b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
180b57cec5SDimitry Andriclet Entry = 1 in
190b57cec5SDimitry Andricdef CC_ARM_APCS : CallingConv<[
200b57cec5SDimitry Andric
210b57cec5SDimitry Andric  // Handles byval parameters.
220b57cec5SDimitry Andric  CCIfByVal<CCPassByVal<4, 4>>,
230b57cec5SDimitry Andric
240b57cec5SDimitry Andric  CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
250b57cec5SDimitry Andric
260b57cec5SDimitry Andric  // Pass SwiftSelf in a callee saved register.
270b57cec5SDimitry Andric  CCIfSwiftSelf<CCIfType<[i32], CCAssignToReg<[R10]>>>,
280b57cec5SDimitry Andric
290b57cec5SDimitry Andric  // A SwiftError is passed in R8.
300b57cec5SDimitry Andric  CCIfSwiftError<CCIfType<[i32], CCAssignToReg<[R8]>>>,
310b57cec5SDimitry Andric
320b57cec5SDimitry Andric  // Handle all vector types as either f64 or v2f64.
335ffd83dbSDimitry Andric  CCIfType<[v1i64, v2i32, v4i16, v4f16, v4bf16, v8i8, v2f32], CCBitConvertToType<f64>>,
345ffd83dbSDimitry Andric  CCIfType<[v2i64, v4i32, v8i16, v8f16, v8bf16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
350b57cec5SDimitry Andric
360b57cec5SDimitry Andric  // f64 and v2f64 are passed in adjacent GPRs, possibly split onto the stack
370b57cec5SDimitry Andric  CCIfType<[f64, v2f64], CCCustom<"CC_ARM_APCS_Custom_f64">>,
380b57cec5SDimitry Andric
390b57cec5SDimitry Andric  CCIfType<[f32], CCBitConvertToType<i32>>,
400b57cec5SDimitry Andric  CCIfType<[i32], CCAssignToReg<[R0, R1, R2, R3]>>,
410b57cec5SDimitry Andric
420b57cec5SDimitry Andric  CCIfType<[i32], CCAssignToStack<4, 4>>,
430b57cec5SDimitry Andric  CCIfType<[f64], CCAssignToStack<8, 4>>,
440b57cec5SDimitry Andric  CCIfType<[v2f64], CCAssignToStack<16, 4>>
450b57cec5SDimitry Andric]>;
460b57cec5SDimitry Andric
470b57cec5SDimitry Andriclet Entry = 1 in
480b57cec5SDimitry Andricdef RetCC_ARM_APCS : CallingConv<[
490b57cec5SDimitry Andric  CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
500b57cec5SDimitry Andric  CCIfType<[f32], CCBitConvertToType<i32>>,
510b57cec5SDimitry Andric
520b57cec5SDimitry Andric  // Pass SwiftSelf in a callee saved register.
530b57cec5SDimitry Andric  CCIfSwiftSelf<CCIfType<[i32], CCAssignToReg<[R10]>>>,
540b57cec5SDimitry Andric
550b57cec5SDimitry Andric  // A SwiftError is returned in R8.
560b57cec5SDimitry Andric  CCIfSwiftError<CCIfType<[i32], CCAssignToReg<[R8]>>>,
570b57cec5SDimitry Andric
580b57cec5SDimitry Andric  // Handle all vector types as either f64 or v2f64.
595ffd83dbSDimitry Andric  CCIfType<[v1i64, v2i32, v4i16, v4f16, v4bf16, v8i8, v2f32], CCBitConvertToType<f64>>,
605ffd83dbSDimitry Andric  CCIfType<[v2i64, v4i32, v8i16, v8f16, v8bf16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
610b57cec5SDimitry Andric
620b57cec5SDimitry Andric  CCIfType<[f64, v2f64], CCCustom<"RetCC_ARM_APCS_Custom_f64">>,
630b57cec5SDimitry Andric
640b57cec5SDimitry Andric  CCIfType<[i32], CCAssignToReg<[R0, R1, R2, R3]>>,
650b57cec5SDimitry Andric  CCIfType<[i64], CCAssignToRegWithShadow<[R0, R2], [R1, R3]>>
660b57cec5SDimitry Andric]>;
670b57cec5SDimitry Andric
680b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
690b57cec5SDimitry Andric// ARM APCS Calling Convention for FastCC (when VFP2 or later is available)
700b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
710b57cec5SDimitry Andriclet Entry = 1 in
720b57cec5SDimitry Andricdef FastCC_ARM_APCS : CallingConv<[
730b57cec5SDimitry Andric  // Handle all vector types as either f64 or v2f64.
745ffd83dbSDimitry Andric  CCIfType<[v1i64, v2i32, v4i16, v4f16, v4bf16, v8i8, v2f32], CCBitConvertToType<f64>>,
755ffd83dbSDimitry Andric  CCIfType<[v2i64, v4i32, v8i16, v8f16, v8bf16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
760b57cec5SDimitry Andric
770b57cec5SDimitry Andric  CCIfType<[v2f64], CCAssignToReg<[Q0, Q1, Q2, Q3]>>,
780b57cec5SDimitry Andric  CCIfType<[f64], CCAssignToReg<[D0, D1, D2, D3, D4, D5, D6, D7]>>,
790b57cec5SDimitry Andric  CCIfType<[f32], CCAssignToReg<[S0, S1, S2, S3, S4, S5, S6, S7, S8,
800b57cec5SDimitry Andric                                 S9, S10, S11, S12, S13, S14, S15]>>,
810b57cec5SDimitry Andric
820b57cec5SDimitry Andric  // CPRCs may be allocated to co-processor registers or the stack - they
830b57cec5SDimitry Andric  // may never be allocated to core registers.
840b57cec5SDimitry Andric  CCIfType<[f32], CCAssignToStackWithShadow<4, 4, [Q0, Q1, Q2, Q3]>>,
850b57cec5SDimitry Andric  CCIfType<[f64], CCAssignToStackWithShadow<8, 4, [Q0, Q1, Q2, Q3]>>,
860b57cec5SDimitry Andric  CCIfType<[v2f64], CCAssignToStackWithShadow<16, 4, [Q0, Q1, Q2, Q3]>>,
870b57cec5SDimitry Andric
880b57cec5SDimitry Andric  CCDelegateTo<CC_ARM_APCS>
890b57cec5SDimitry Andric]>;
900b57cec5SDimitry Andric
910b57cec5SDimitry Andriclet Entry = 1 in
920b57cec5SDimitry Andricdef RetFastCC_ARM_APCS : CallingConv<[
930b57cec5SDimitry Andric  // Handle all vector types as either f64 or v2f64.
945ffd83dbSDimitry Andric  CCIfType<[v1i64, v2i32, v4i16, v4f16, v4bf16, v8i8, v2f32], CCBitConvertToType<f64>>,
955ffd83dbSDimitry Andric  CCIfType<[v2i64, v4i32, v8i16, v8f16, v8bf16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
960b57cec5SDimitry Andric
970b57cec5SDimitry Andric  CCIfType<[v2f64], CCAssignToReg<[Q0, Q1, Q2, Q3]>>,
980b57cec5SDimitry Andric  CCIfType<[f64], CCAssignToReg<[D0, D1, D2, D3, D4, D5, D6, D7]>>,
990b57cec5SDimitry Andric  CCIfType<[f32], CCAssignToReg<[S0, S1, S2, S3, S4, S5, S6, S7, S8,
1000b57cec5SDimitry Andric                                 S9, S10, S11, S12, S13, S14, S15]>>,
1010b57cec5SDimitry Andric  CCDelegateTo<RetCC_ARM_APCS>
1020b57cec5SDimitry Andric]>;
1030b57cec5SDimitry Andric
1040b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1050b57cec5SDimitry Andric// ARM APCS Calling Convention for GHC
1060b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1070b57cec5SDimitry Andric
1080b57cec5SDimitry Andriclet Entry = 1 in
1090b57cec5SDimitry Andricdef CC_ARM_APCS_GHC : CallingConv<[
1100b57cec5SDimitry Andric  // Handle all vector types as either f64 or v2f64.
1115ffd83dbSDimitry Andric  CCIfType<[v1i64, v2i32, v4i16, v4f16, v4bf16, v8i8, v2f32], CCBitConvertToType<f64>>,
1125ffd83dbSDimitry Andric  CCIfType<[v2i64, v4i32, v8i16, v8f16, v8bf16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
1130b57cec5SDimitry Andric
1140b57cec5SDimitry Andric  CCIfType<[v2f64], CCAssignToReg<[Q4, Q5]>>,
1150b57cec5SDimitry Andric  CCIfType<[f64], CCAssignToReg<[D8, D9, D10, D11]>>,
1160b57cec5SDimitry Andric  CCIfType<[f32], CCAssignToReg<[S16, S17, S18, S19, S20, S21, S22, S23]>>,
1170b57cec5SDimitry Andric
1180b57cec5SDimitry Andric  // Promote i8/i16 arguments to i32.
1190b57cec5SDimitry Andric  CCIfType<[i8, i16], CCPromoteToType<i32>>,
1200b57cec5SDimitry Andric
1210b57cec5SDimitry Andric  // Pass in STG registers: Base, Sp, Hp, R1, R2, R3, R4, SpLim
1220b57cec5SDimitry Andric  CCIfType<[i32], CCAssignToReg<[R4, R5, R6, R7, R8, R9, R10, R11]>>
1230b57cec5SDimitry Andric]>;
1240b57cec5SDimitry Andric
1250b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1260b57cec5SDimitry Andric// ARM AAPCS (EABI) Calling Convention, common parts
1270b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1280b57cec5SDimitry Andric
1290b57cec5SDimitry Andricdef CC_ARM_AAPCS_Common : CallingConv<[
1300b57cec5SDimitry Andric
1310b57cec5SDimitry Andric  CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
1320b57cec5SDimitry Andric
1330b57cec5SDimitry Andric  // i64/f64 is passed in even pairs of GPRs
1340b57cec5SDimitry Andric  // i64 is 8-aligned i32 here, so we may need to eat R1 as a pad register
1350b57cec5SDimitry Andric  // (and the same is true for f64 if VFP is not enabled)
1360b57cec5SDimitry Andric  CCIfType<[i32], CCIfAlign<"8", CCAssignToRegWithShadow<[R0, R2], [R0, R1]>>>,
1375ffd83dbSDimitry Andric  CCIfType<[i32], CCIf<"ArgFlags.getNonZeroOrigAlign() != Align(8)",
1380b57cec5SDimitry Andric                       CCAssignToReg<[R0, R1, R2, R3]>>>,
1390b57cec5SDimitry Andric
1400b57cec5SDimitry Andric  CCIfType<[i32], CCIfAlign<"8", CCAssignToStackWithShadow<4, 8, [R0, R1, R2, R3]>>>,
1410b57cec5SDimitry Andric  CCIfType<[i32], CCAssignToStackWithShadow<4, 4, [R0, R1, R2, R3]>>,
1425ffd83dbSDimitry Andric  CCIfType<[f16, bf16, f32], CCAssignToStackWithShadow<4, 4, [Q0, Q1, Q2, Q3]>>,
1430b57cec5SDimitry Andric  CCIfType<[f64], CCAssignToStackWithShadow<8, 8, [Q0, Q1, Q2, Q3]>>,
1440b57cec5SDimitry Andric  CCIfType<[v2f64], CCIfAlign<"16",
1450b57cec5SDimitry Andric           CCAssignToStackWithShadow<16, 16, [Q0, Q1, Q2, Q3]>>>,
1460b57cec5SDimitry Andric  CCIfType<[v2f64], CCAssignToStackWithShadow<16, 8, [Q0, Q1, Q2, Q3]>>
1470b57cec5SDimitry Andric]>;
1480b57cec5SDimitry Andric
1490b57cec5SDimitry Andricdef RetCC_ARM_AAPCS_Common : CallingConv<[
1500b57cec5SDimitry Andric  CCIfType<[i1, i8, i16], CCPromoteToType<i32>>,
1510b57cec5SDimitry Andric  CCIfType<[i32], CCAssignToReg<[R0, R1, R2, R3]>>,
1520b57cec5SDimitry Andric  CCIfType<[i64], CCAssignToRegWithShadow<[R0, R2], [R1, R3]>>
1530b57cec5SDimitry Andric]>;
1540b57cec5SDimitry Andric
1550b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1560b57cec5SDimitry Andric// ARM AAPCS (EABI) Calling Convention
1570b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
1580b57cec5SDimitry Andric
1590b57cec5SDimitry Andriclet Entry = 1 in
1600b57cec5SDimitry Andricdef CC_ARM_AAPCS : CallingConv<[
1610b57cec5SDimitry Andric  // Handles byval parameters.
1620b57cec5SDimitry Andric  CCIfByVal<CCPassByVal<4, 4>>,
1630b57cec5SDimitry Andric
1640b57cec5SDimitry Andric  // The 'nest' parameter, if any, is passed in R12.
1650b57cec5SDimitry Andric  CCIfNest<CCAssignToReg<[R12]>>,
1660b57cec5SDimitry Andric
1670b57cec5SDimitry Andric  // Handle all vector types as either f64 or v2f64.
1685ffd83dbSDimitry Andric  CCIfType<[v1i64, v2i32, v4i16, v4f16, v4bf16, v8i8, v2f32], CCBitConvertToType<f64>>,
1695ffd83dbSDimitry Andric  CCIfType<[v2i64, v4i32, v8i16, v8f16, v8bf16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
1700b57cec5SDimitry Andric
1710b57cec5SDimitry Andric  // Pass SwiftSelf in a callee saved register.
1720b57cec5SDimitry Andric  CCIfSwiftSelf<CCIfType<[i32], CCAssignToReg<[R10]>>>,
1730b57cec5SDimitry Andric
1740b57cec5SDimitry Andric  // A SwiftError is passed in R8.
1750b57cec5SDimitry Andric  CCIfSwiftError<CCIfType<[i32], CCAssignToReg<[R8]>>>,
1760b57cec5SDimitry Andric
1770b57cec5SDimitry Andric  CCIfType<[f64, v2f64], CCCustom<"CC_ARM_AAPCS_Custom_f64">>,
1780b57cec5SDimitry Andric  CCIfType<[f32], CCBitConvertToType<i32>>,
1795ffd83dbSDimitry Andric  CCIfType<[f16, bf16], CCCustom<"CC_ARM_AAPCS_Custom_f16">>,
1800b57cec5SDimitry Andric  CCDelegateTo<CC_ARM_AAPCS_Common>
1810b57cec5SDimitry Andric]>;
1820b57cec5SDimitry Andric
1830b57cec5SDimitry Andriclet Entry = 1 in
1840b57cec5SDimitry Andricdef RetCC_ARM_AAPCS : CallingConv<[
1850b57cec5SDimitry Andric  // Handle all vector types as either f64 or v2f64.
1865ffd83dbSDimitry Andric  CCIfType<[v1i64, v2i32, v4i16, v4f16, v4bf16, v8i8, v2f32], CCBitConvertToType<f64>>,
1875ffd83dbSDimitry Andric  CCIfType<[v2i64, v4i32, v8i16, v8f16, v8bf16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
1880b57cec5SDimitry Andric
1890b57cec5SDimitry Andric  // Pass SwiftSelf in a callee saved register.
1900b57cec5SDimitry Andric  CCIfSwiftSelf<CCIfType<[i32], CCAssignToReg<[R10]>>>,
1910b57cec5SDimitry Andric
1920b57cec5SDimitry Andric  // A SwiftError is returned in R8.
1930b57cec5SDimitry Andric  CCIfSwiftError<CCIfType<[i32], CCAssignToReg<[R8]>>>,
1940b57cec5SDimitry Andric
1950b57cec5SDimitry Andric  CCIfType<[f64, v2f64], CCCustom<"RetCC_ARM_AAPCS_Custom_f64">>,
1960b57cec5SDimitry Andric  CCIfType<[f32], CCBitConvertToType<i32>>,
1975ffd83dbSDimitry Andric  CCIfType<[f16, bf16], CCCustom<"CC_ARM_AAPCS_Custom_f16">>,
1980b57cec5SDimitry Andric
1990b57cec5SDimitry Andric  CCDelegateTo<RetCC_ARM_AAPCS_Common>
2000b57cec5SDimitry Andric]>;
2010b57cec5SDimitry Andric
2020b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
2030b57cec5SDimitry Andric// ARM AAPCS-VFP (EABI) Calling Convention
2040b57cec5SDimitry Andric// Also used for FastCC (when VFP2 or later is available)
2050b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
2060b57cec5SDimitry Andric
2070b57cec5SDimitry Andriclet Entry = 1 in
2080b57cec5SDimitry Andricdef CC_ARM_AAPCS_VFP : CallingConv<[
2090b57cec5SDimitry Andric  // Handles byval parameters.
2100b57cec5SDimitry Andric  CCIfByVal<CCPassByVal<4, 4>>,
2110b57cec5SDimitry Andric
2120b57cec5SDimitry Andric  // Handle all vector types as either f64 or v2f64.
2135ffd83dbSDimitry Andric  CCIfType<[v1i64, v2i32, v4i16, v4f16, v4bf16, v8i8, v2f32], CCBitConvertToType<f64>>,
2145ffd83dbSDimitry Andric  CCIfType<[v2i64, v4i32, v8i16, v8f16, v8bf16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
2150b57cec5SDimitry Andric
2160b57cec5SDimitry Andric  // Pass SwiftSelf in a callee saved register.
2170b57cec5SDimitry Andric  CCIfSwiftSelf<CCIfType<[i32], CCAssignToReg<[R10]>>>,
2180b57cec5SDimitry Andric
2190b57cec5SDimitry Andric  // A SwiftError is passed in R8.
2200b57cec5SDimitry Andric  CCIfSwiftError<CCIfType<[i32], CCAssignToReg<[R8]>>>,
2210b57cec5SDimitry Andric
2220b57cec5SDimitry Andric  // HFAs are passed in a contiguous block of registers, or on the stack
2230b57cec5SDimitry Andric  CCIfConsecutiveRegs<CCCustom<"CC_ARM_AAPCS_Custom_Aggregate">>,
2240b57cec5SDimitry Andric
2250b57cec5SDimitry Andric  CCIfType<[v2f64], CCAssignToReg<[Q0, Q1, Q2, Q3]>>,
2260b57cec5SDimitry Andric  CCIfType<[f64], CCAssignToReg<[D0, D1, D2, D3, D4, D5, D6, D7]>>,
2270b57cec5SDimitry Andric  CCIfType<[f32], CCAssignToReg<[S0, S1, S2, S3, S4, S5, S6, S7, S8,
2280b57cec5SDimitry Andric                                 S9, S10, S11, S12, S13, S14, S15]>>,
2295ffd83dbSDimitry Andric  CCIfType<[f16, bf16], CCCustom<"CC_ARM_AAPCS_VFP_Custom_f16">>,
2300b57cec5SDimitry Andric  CCDelegateTo<CC_ARM_AAPCS_Common>
2310b57cec5SDimitry Andric]>;
2320b57cec5SDimitry Andric
2330b57cec5SDimitry Andriclet Entry = 1 in
2340b57cec5SDimitry Andricdef RetCC_ARM_AAPCS_VFP : CallingConv<[
2350b57cec5SDimitry Andric  // Handle all vector types as either f64 or v2f64.
2365ffd83dbSDimitry Andric  CCIfType<[v1i64, v2i32, v4i16, v4f16, v4bf16, v8i8, v2f32], CCBitConvertToType<f64>>,
2375ffd83dbSDimitry Andric  CCIfType<[v2i64, v4i32, v8i16, v8f16, v8bf16, v16i8, v4f32], CCBitConvertToType<v2f64>>,
2380b57cec5SDimitry Andric
2390b57cec5SDimitry Andric  // Pass SwiftSelf in a callee saved register.
2400b57cec5SDimitry Andric  CCIfSwiftSelf<CCIfType<[i32], CCAssignToReg<[R10]>>>,
2410b57cec5SDimitry Andric
2420b57cec5SDimitry Andric  // A SwiftError is returned in R8.
2430b57cec5SDimitry Andric  CCIfSwiftError<CCIfType<[i32], CCAssignToReg<[R8]>>>,
2440b57cec5SDimitry Andric
2450b57cec5SDimitry Andric  CCIfType<[v2f64], CCAssignToReg<[Q0, Q1, Q2, Q3]>>,
2460b57cec5SDimitry Andric  CCIfType<[f64], CCAssignToReg<[D0, D1, D2, D3, D4, D5, D6, D7]>>,
2470b57cec5SDimitry Andric  CCIfType<[f32], CCAssignToReg<[S0, S1, S2, S3, S4, S5, S6, S7, S8,
2480b57cec5SDimitry Andric                                 S9, S10, S11, S12, S13, S14, S15]>>,
2495ffd83dbSDimitry Andric  CCIfType<[f16, bf16], CCCustom<"CC_ARM_AAPCS_VFP_Custom_f16">>,
2500b57cec5SDimitry Andric  CCDelegateTo<RetCC_ARM_AAPCS_Common>
2510b57cec5SDimitry Andric]>;
2520b57cec5SDimitry Andric
253480093f4SDimitry Andric
254480093f4SDimitry Andric// Windows Control Flow Guard checks take a single argument (the target function
255480093f4SDimitry Andric// address) and have no return value.
256480093f4SDimitry Andriclet Entry = 1 in
257480093f4SDimitry Andricdef CC_ARM_Win32_CFGuard_Check : CallingConv<[
258480093f4SDimitry Andric  CCIfType<[i32], CCAssignToReg<[R0]>>
259480093f4SDimitry Andric]>;
260480093f4SDimitry Andric
261480093f4SDimitry Andric
262480093f4SDimitry Andric
2630b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
2640b57cec5SDimitry Andric// Callee-saved register lists.
2650b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
2660b57cec5SDimitry Andric
2670b57cec5SDimitry Andricdef CSR_NoRegs : CalleeSavedRegs<(add)>;
2680b57cec5SDimitry Andricdef CSR_FPRegs : CalleeSavedRegs<(add (sequence "D%u", 0, 31))>;
2690b57cec5SDimitry Andric
2700b57cec5SDimitry Andricdef CSR_AAPCS : CalleeSavedRegs<(add LR, R11, R10, R9, R8, R7, R6, R5, R4,
2710b57cec5SDimitry Andric                                     (sequence "D%u", 15, 8))>;
2720b57cec5SDimitry Andric
273480093f4SDimitry Andric// The Windows Control Flow Guard Check function preserves the same registers as
274480093f4SDimitry Andric// AAPCS, and also preserves all floating point registers.
275480093f4SDimitry Andricdef CSR_Win_AAPCS_CFGuard_Check : CalleeSavedRegs<(add LR, R11, R10, R9, R8, R7,
276480093f4SDimitry Andric                                     R6, R5, R4, (sequence "D%u", 15, 0))>;
277480093f4SDimitry Andric
2780b57cec5SDimitry Andric// R8 is used to pass swifterror, remove it from CSR.
2790b57cec5SDimitry Andricdef CSR_AAPCS_SwiftError : CalleeSavedRegs<(sub CSR_AAPCS, R8)>;
2800b57cec5SDimitry Andric
281fe6060f1SDimitry Andric// R10 is used to pass swiftself, remove it from CSR.
282fe6060f1SDimitry Andricdef CSR_AAPCS_SwiftTail : CalleeSavedRegs<(sub CSR_AAPCS, R10)>;
283fe6060f1SDimitry Andric
2840b57cec5SDimitry Andric// The order of callee-saved registers needs to match the order we actually push
2850b57cec5SDimitry Andric// them in FrameLowering, because this order is what's used by
2860b57cec5SDimitry Andric// PrologEpilogInserter to allocate frame index slots. So when R7 is the frame
287*81ad6265SDimitry Andric// pointer, we use this ATPCS alternative.
288*81ad6265SDimitry Andricdef CSR_ATPCS_SplitPush : CalleeSavedRegs<(add LR, R7, R6, R5, R4,
2890b57cec5SDimitry Andric                                               R11, R10, R9, R8,
2900b57cec5SDimitry Andric                                               (sequence "D%u", 15, 8))>;
2910b57cec5SDimitry Andric
292*81ad6265SDimitry Andricdef CSR_Win_SplitFP : CalleeSavedRegs<(add R10, R9, R8, R7, R6, R5, R4,
293*81ad6265SDimitry Andric                                               (sequence "D%u", 15, 8),
294*81ad6265SDimitry Andric                                               LR, R11)>;
295*81ad6265SDimitry Andric
2960b57cec5SDimitry Andric// R8 is used to pass swifterror, remove it from CSR.
297*81ad6265SDimitry Andricdef CSR_ATPCS_SplitPush_SwiftError : CalleeSavedRegs<(sub CSR_ATPCS_SplitPush,
2980b57cec5SDimitry Andric                                                      R8)>;
2990b57cec5SDimitry Andric
300fe6060f1SDimitry Andric// R10 is used to pass swifterror, remove it from CSR.
301*81ad6265SDimitry Andricdef CSR_ATPCS_SplitPush_SwiftTail : CalleeSavedRegs<(sub CSR_ATPCS_SplitPush,
302fe6060f1SDimitry Andric                                                     R10)>;
303fe6060f1SDimitry Andric
304*81ad6265SDimitry Andric// When enforcing an AAPCS compliant frame chain, R11 is used as the frame
305*81ad6265SDimitry Andric// pointer even for Thumb targets, where split pushes are necessary.
306*81ad6265SDimitry Andric// This AAPCS alternative makes sure the frame index slots match the push
307*81ad6265SDimitry Andric// order in that case.
308*81ad6265SDimitry Andricdef CSR_AAPCS_SplitPush : CalleeSavedRegs<(add LR, R11,
309*81ad6265SDimitry Andric                                               R7, R6, R5, R4,
310*81ad6265SDimitry Andric                                               R10, R9, R8,
311*81ad6265SDimitry Andric                                               (sequence "D%u", 15, 8))>;
312*81ad6265SDimitry Andric
3130b57cec5SDimitry Andric// Constructors and destructors return 'this' in the ARM C++ ABI; since 'this'
3140b57cec5SDimitry Andric// and the pointer return value are both passed in R0 in these cases, this can
3150b57cec5SDimitry Andric// be partially modelled by treating R0 as a callee-saved register
3160b57cec5SDimitry Andric// Only the resulting RegMask is used; the SaveList is ignored
3170b57cec5SDimitry Andricdef CSR_AAPCS_ThisReturn : CalleeSavedRegs<(add LR, R11, R10, R9, R8, R7, R6,
3180b57cec5SDimitry Andric                                            R5, R4, (sequence "D%u", 15, 8),
3190b57cec5SDimitry Andric                                            R0)>;
3200b57cec5SDimitry Andric
3210b57cec5SDimitry Andric// iOS ABI deviates from ARM standard ABI. R9 is not a callee-saved register.
3220b57cec5SDimitry Andric// Also save R7-R4 first to match the stack frame fixed spill areas.
3230b57cec5SDimitry Andricdef CSR_iOS : CalleeSavedRegs<(add LR, R7, R6, R5, R4, (sub CSR_AAPCS, R9))>;
3240b57cec5SDimitry Andric
3250b57cec5SDimitry Andric// R8 is used to pass swifterror, remove it from CSR.
3260b57cec5SDimitry Andricdef CSR_iOS_SwiftError : CalleeSavedRegs<(sub CSR_iOS, R8)>;
3270b57cec5SDimitry Andric
328fe6060f1SDimitry Andric// R10 is used to pass swiftself, remove it from CSR.
329fe6060f1SDimitry Andricdef CSR_iOS_SwiftTail : CalleeSavedRegs<(sub CSR_iOS, R10)>;
330fe6060f1SDimitry Andric
3310b57cec5SDimitry Andricdef CSR_iOS_ThisReturn : CalleeSavedRegs<(add LR, R7, R6, R5, R4,
3320b57cec5SDimitry Andric                                         (sub CSR_AAPCS_ThisReturn, R9))>;
3330b57cec5SDimitry Andric
3340b57cec5SDimitry Andricdef CSR_iOS_TLSCall
3350b57cec5SDimitry Andric    : CalleeSavedRegs<(add LR, SP, (sub(sequence "R%u", 12, 1), R9, R12),
3360b57cec5SDimitry Andric                      (sequence "D%u", 31, 0))>;
3370b57cec5SDimitry Andric
3380b57cec5SDimitry Andric// C++ TLS access function saves all registers except SP. Try to match
3390b57cec5SDimitry Andric// the order of CSRs in CSR_iOS.
3400b57cec5SDimitry Andricdef CSR_iOS_CXX_TLS : CalleeSavedRegs<(add CSR_iOS, (sequence "R%u", 12, 1),
3410b57cec5SDimitry Andric                                           (sequence "D%u", 31, 0))>;
3420b57cec5SDimitry Andric
3430b57cec5SDimitry Andric// CSRs that are handled by prologue, epilogue.
3440b57cec5SDimitry Andricdef CSR_iOS_CXX_TLS_PE : CalleeSavedRegs<(add LR, R12, R11, R7, R5, R4)>;
3450b57cec5SDimitry Andric
3460b57cec5SDimitry Andric// CSRs that are handled explicitly via copies.
3470b57cec5SDimitry Andricdef CSR_iOS_CXX_TLS_ViaCopy : CalleeSavedRegs<(sub CSR_iOS_CXX_TLS,
3480b57cec5SDimitry Andric                                                   CSR_iOS_CXX_TLS_PE)>;
3490b57cec5SDimitry Andric
3500b57cec5SDimitry Andric// The "interrupt" attribute is used to generate code that is acceptable in
3510b57cec5SDimitry Andric// exception-handlers of various kinds. It makes us use a different return
3520b57cec5SDimitry Andric// instruction (handled elsewhere) and affects which registers we must return to
3530b57cec5SDimitry Andric// our "caller" in the same state as we receive them.
3540b57cec5SDimitry Andric
3550b57cec5SDimitry Andric// For most interrupts, all registers except SP and LR are shared with
3560b57cec5SDimitry Andric// user-space. We mark LR to be saved anyway, since this is what the ARM backend
3570b57cec5SDimitry Andric// generally does rather than tracking its liveness as a normal register.
3580b57cec5SDimitry Andricdef CSR_GenericInt : CalleeSavedRegs<(add LR, (sequence "R%u", 12, 0))>;
3590b57cec5SDimitry Andric
3600b57cec5SDimitry Andric// The fast interrupt handlers have more private state and get their own copies
3610b57cec5SDimitry Andric// of R8-R12, in addition to SP and LR. As before, mark LR for saving too.
3620b57cec5SDimitry Andric
3630b57cec5SDimitry Andric// FIXME: we mark R11 as callee-saved since it's often the frame-pointer, and
3640b57cec5SDimitry Andric// current frame lowering expects to encounter it while processing callee-saved
3650b57cec5SDimitry Andric// registers.
3660b57cec5SDimitry Andricdef CSR_FIQ : CalleeSavedRegs<(add LR, R11, (sequence "R%u", 7, 0))>;
3670b57cec5SDimitry Andric
3680b57cec5SDimitry Andric
369