1 //===- TargetCallingConv.td - Target Calling Conventions ---*- 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 file defines the target-independent interfaces with which targets
10 // describe their calling conventions.
12 //===----------------------------------------------------------------------===//
17 /// CCCustom - Calls a custom arg handling function.
18 class CCCustom<string fn> : CCAction {
22 /// CCPredicateAction - Instances of this class check some predicate, then
23 /// delegate to another action if the predicate is true.
24 class CCPredicateAction<CCAction A> : CCAction {
25 CCAction SubAction = A;
28 /// CCIfType - If the current argument is one of the specified types, apply
30 class CCIfType<list<ValueType> vts, CCAction A> : CCPredicateAction<A> {
31 list<ValueType> VTs = vts;
34 /// CCIf - If the predicate matches, apply A.
35 class CCIf<string predicate, CCAction A> : CCPredicateAction<A> {
36 string Predicate = predicate;
39 /// CCIfByVal - If the current argument has ByVal parameter attribute, apply
41 class CCIfByVal<CCAction A> : CCIf<"ArgFlags.isByVal()", A> {
44 /// CCIfSwiftSelf - If the current argument has swiftself parameter attribute,
46 class CCIfSwiftSelf<CCAction A> : CCIf<"ArgFlags.isSwiftSelf()", A> {
49 /// CCIfSwiftError - If the current argument has swifterror parameter attribute,
51 class CCIfSwiftError<CCAction A> : CCIf<"ArgFlags.isSwiftError()", A> {
54 /// CCIfConsecutiveRegs - If the current argument has InConsecutiveRegs
55 /// parameter attribute, apply Action A.
56 class CCIfConsecutiveRegs<CCAction A> : CCIf<"ArgFlags.isInConsecutiveRegs()", A> {
59 /// CCIfCC - Match if the current calling convention is 'CC'.
60 class CCIfCC<string CC, CCAction A>
61 : CCIf<!strconcat("State.getCallingConv() == ", CC), A> {}
63 /// CCIfInReg - If this argument is marked with the 'inreg' attribute, apply
64 /// the specified action.
65 class CCIfInReg<CCAction A> : CCIf<"ArgFlags.isInReg()", A> {}
67 /// CCIfNest - If this argument is marked with the 'nest' attribute, apply
68 /// the specified action.
69 class CCIfNest<CCAction A> : CCIf<"ArgFlags.isNest()", A> {}
71 /// CCIfSplit - If this argument is marked with the 'split' attribute, apply
72 /// the specified action.
73 class CCIfSplit<CCAction A> : CCIf<"ArgFlags.isSplit()", A> {}
75 /// CCIfSRet - If this argument is marked with the 'sret' attribute, apply
76 /// the specified action.
77 class CCIfSRet<CCAction A> : CCIf<"ArgFlags.isSRet()", A> {}
79 /// CCIfVarArg - If the current function is vararg - apply the action
80 class CCIfVarArg<CCAction A> : CCIf<"State.isVarArg()", A> {}
82 /// CCIfNotVarArg - If the current function is not vararg - apply the action
83 class CCIfNotVarArg<CCAction A> : CCIf<"!State.isVarArg()", A> {}
85 /// CCAssignToReg - This action matches if there is a register in the specified
86 /// list that is still available. If so, it assigns the value to the first
87 /// available register and succeeds.
88 class CCAssignToReg<list<Register> regList> : CCAction {
89 list<Register> RegList = regList;
92 /// CCAssignToRegWithShadow - Same as CCAssignToReg, but with list of registers
93 /// which became shadowed, when some register is used.
94 class CCAssignToRegWithShadow<list<Register> regList,
95 list<Register> shadowList> : CCAction {
96 list<Register> RegList = regList;
97 list<Register> ShadowRegList = shadowList;
100 /// CCAssignToStack - This action always matches: it assigns the value to a
101 /// stack slot of the specified size and alignment on the stack. If size is
102 /// zero then the ABI size is used; if align is zero then the ABI alignment
103 /// is used - these may depend on the target or subtarget.
104 class CCAssignToStack<int size, int align> : CCAction {
109 /// CCAssignToStackWithShadow - Same as CCAssignToStack, but with a list of
110 /// registers to be shadowed. Note that, unlike CCAssignToRegWithShadow, this
111 /// shadows ALL of the registers in shadowList.
112 class CCAssignToStackWithShadow<int size,
114 list<Register> shadowList> : CCAction {
117 list<Register> ShadowRegList = shadowList;
120 /// CCPassByVal - This action always matches: it assigns the value to a stack
121 /// slot to implement ByVal aggregate parameter passing. Size and alignment
122 /// specify the minimum size and alignment for the stack slot.
123 class CCPassByVal<int size, int align> : CCAction {
128 /// CCPromoteToType - If applied, this promotes the specified current value to
129 /// the specified type.
130 class CCPromoteToType<ValueType destTy> : CCAction {
131 ValueType DestTy = destTy;
134 /// CCPromoteToUpperBitsInType - If applied, this promotes the specified current
135 /// value to the specified type and shifts the value into the upper bits.
136 class CCPromoteToUpperBitsInType<ValueType destTy> : CCAction {
137 ValueType DestTy = destTy;
140 /// CCBitConvertToType - If applied, this bitconverts the specified current
141 /// value to the specified type.
142 class CCBitConvertToType<ValueType destTy> : CCAction {
143 ValueType DestTy = destTy;
146 /// CCPassIndirect - If applied, this stores the value to stack and passes the pointer
147 /// as normal argument.
148 class CCPassIndirect<ValueType destTy> : CCAction {
149 ValueType DestTy = destTy;
152 /// CCDelegateTo - This action invokes the specified sub-calling-convention. It
153 /// is successful if the specified CC matches.
154 class CCDelegateTo<CallingConv cc> : CCAction {
158 /// CallingConv - An instance of this is used to define each calling convention
159 /// that the target supports.
160 class CallingConv<list<CCAction> actions> {
161 list<CCAction> Actions = actions;
163 /// If true, this calling convention will be emitted as externally visible in
164 /// the llvm namespaces instead of as a static function.
170 /// CustomCallingConv - An instance of this is used to declare calling
171 /// conventions that are implemented using a custom function of the same name.
172 class CustomCallingConv : CallingConv<[]> {
176 /// CalleeSavedRegs - A list of callee saved registers for a given calling
177 /// convention. The order of registers is used by PrologEpilogInsertion when
178 /// allocation stack slots for saved registers.
180 /// For each CalleeSavedRegs def, TableGen will emit a FOO_SaveList array for
181 /// returning from getCalleeSavedRegs(), and a FOO_RegMask bit mask suitable for
182 /// returning from getCallPreservedMask().
183 class CalleeSavedRegs<dag saves> {
184 dag SaveList = saves;
186 // Registers that are also preserved across function calls, but should not be
187 // included in the generated FOO_SaveList array. These registers will be
188 // included in the FOO_RegMask bit mask. This can be used for registers that
189 // are saved automatically, like the SPARC register windows.