]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/include/llvm/Target/TargetCallingConv.td
MFC r355940:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / include / llvm / Target / TargetCallingConv.td
1 //===- TargetCallingConv.td - Target Calling Conventions ---*- tablegen -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the target-independent interfaces with which targets
10 // describe their calling conventions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 class CCAction;
15 class CallingConv;
16
17 /// CCCustom - Calls a custom arg handling function.
18 class CCCustom<string fn> : CCAction {
19   string FuncName = fn;
20 }
21
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;
26 }
27
28 /// CCIfType - If the current argument is one of the specified types, apply
29 /// Action A.
30 class CCIfType<list<ValueType> vts, CCAction A> : CCPredicateAction<A> {
31   list<ValueType> VTs = vts;
32 }
33
34 /// CCIf - If the predicate matches, apply A.
35 class CCIf<string predicate, CCAction A> : CCPredicateAction<A> {
36   string Predicate = predicate;
37 }
38
39 /// CCIfByVal - If the current argument has ByVal parameter attribute, apply
40 /// Action A.
41 class CCIfByVal<CCAction A> : CCIf<"ArgFlags.isByVal()", A> {
42 }
43
44 /// CCIfSwiftSelf - If the current argument has swiftself parameter attribute,
45 /// apply Action A.
46 class CCIfSwiftSelf<CCAction A> : CCIf<"ArgFlags.isSwiftSelf()", A> {
47 }
48
49 /// CCIfSwiftError - If the current argument has swifterror parameter attribute,
50 /// apply Action A.
51 class CCIfSwiftError<CCAction A> : CCIf<"ArgFlags.isSwiftError()", A> {
52 }
53
54 /// CCIfConsecutiveRegs - If the current argument has InConsecutiveRegs
55 /// parameter attribute, apply Action A.
56 class CCIfConsecutiveRegs<CCAction A> : CCIf<"ArgFlags.isInConsecutiveRegs()", A> {
57 }
58
59 /// CCIfCC - Match if the current calling convention is 'CC'.
60 class CCIfCC<string CC, CCAction A>
61   : CCIf<!strconcat("State.getCallingConv() == ", CC), A> {}
62
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> {}
66
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> {}
70
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> {}
74
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> {}
78
79 /// CCIfVarArg - If the current function is vararg - apply the action
80 class CCIfVarArg<CCAction A> : CCIf<"State.isVarArg()", A> {}
81
82 /// CCIfNotVarArg - If the current function is not vararg - apply the action
83 class CCIfNotVarArg<CCAction A> : CCIf<"!State.isVarArg()", A> {}
84
85 /// CCIfPtrAddrSpace - If the top-level parent of the current argument has
86 /// pointer type in the specified address-space.
87 class CCIfPtrAddrSpace<int AS, CCAction A>
88     : CCIf<"(ArgFlags.isPointer() && ArgFlags.getPointerAddrSpace() == " # AS # ")", A> {}
89
90 /// CCIfPtr - If the top-level parent of the current argument had
91 /// pointer type in some address-space.
92 class CCIfPtr<CCAction A> : CCIf<"ArgFlags.isPointer()", A> {}
93
94 /// CCAssignToReg - This action matches if there is a register in the specified
95 /// list that is still available.  If so, it assigns the value to the first
96 /// available register and succeeds.
97 class CCAssignToReg<list<Register> regList> : CCAction {
98   list<Register> RegList = regList;
99 }
100
101 /// CCAssignToRegWithShadow - Same as CCAssignToReg, but with list of registers
102 /// which became shadowed, when some register is used.
103 class CCAssignToRegWithShadow<list<Register> regList,
104                               list<Register> shadowList> : CCAction {
105   list<Register> RegList = regList;
106   list<Register> ShadowRegList = shadowList;
107 }
108
109 /// CCAssignToStack - This action always matches: it assigns the value to a
110 /// stack slot of the specified size and alignment on the stack.  If size is
111 /// zero then the ABI size is used; if align is zero then the ABI alignment
112 /// is used - these may depend on the target or subtarget.
113 class CCAssignToStack<int size, int align> : CCAction {
114   int Size = size;
115   int Align = align;
116 }
117
118 /// CCAssignToStackWithShadow - Same as CCAssignToStack, but with a list of
119 /// registers to be shadowed. Note that, unlike CCAssignToRegWithShadow, this
120 /// shadows ALL of the registers in shadowList.
121 class CCAssignToStackWithShadow<int size,
122                                 int align,
123                                 list<Register> shadowList> : CCAction {
124   int Size = size;
125   int Align = align;
126   list<Register> ShadowRegList = shadowList;
127 }
128
129 /// CCPassByVal - This action always matches: it assigns the value to a stack
130 /// slot to implement ByVal aggregate parameter passing. Size and alignment
131 /// specify the minimum size and alignment for the stack slot.
132 class CCPassByVal<int size, int align> : CCAction {
133   int Size = size;
134   int Align = align;
135 }
136
137 /// CCPromoteToType - If applied, this promotes the specified current value to
138 /// the specified type.
139 class CCPromoteToType<ValueType destTy> : CCAction {
140   ValueType DestTy = destTy;
141 }
142
143 /// CCPromoteToUpperBitsInType - If applied, this promotes the specified current
144 /// value to the specified type and shifts the value into the upper bits.
145 class CCPromoteToUpperBitsInType<ValueType destTy> : CCAction {
146   ValueType DestTy = destTy;
147 }
148
149 /// CCBitConvertToType - If applied, this bitconverts the specified current
150 /// value to the specified type.
151 class CCBitConvertToType<ValueType destTy> : CCAction {
152   ValueType DestTy = destTy;
153 }
154
155 /// CCPassIndirect - If applied, this stores the value to stack and passes the pointer
156 /// as normal argument.
157 class CCPassIndirect<ValueType destTy> : CCAction {
158   ValueType DestTy = destTy;
159 }
160
161 /// CCDelegateTo - This action invokes the specified sub-calling-convention.  It
162 /// is successful if the specified CC matches.
163 class CCDelegateTo<CallingConv cc> : CCAction {
164   CallingConv CC = cc;
165 }
166
167 /// CallingConv - An instance of this is used to define each calling convention
168 /// that the target supports.
169 class CallingConv<list<CCAction> actions> {
170   list<CCAction> Actions = actions;
171
172   /// If true, this calling convention will be emitted as externally visible in
173   /// the llvm namespaces instead of as a static function.
174   bit Entry = 0;
175
176   bit Custom = 0;
177 }
178
179 /// CustomCallingConv - An instance of this is used to declare calling
180 /// conventions that are implemented using a custom function of the same name.
181 class CustomCallingConv : CallingConv<[]> {
182   let Custom = 1;
183 }
184
185 /// CalleeSavedRegs - A list of callee saved registers for a given calling
186 /// convention.  The order of registers is used by PrologEpilogInsertion when
187 /// allocation stack slots for saved registers.
188 ///
189 /// For each CalleeSavedRegs def, TableGen will emit a FOO_SaveList array for
190 /// returning from getCalleeSavedRegs(), and a FOO_RegMask bit mask suitable for
191 /// returning from getCallPreservedMask().
192 class CalleeSavedRegs<dag saves> {
193   dag SaveList = saves;
194
195   // Registers that are also preserved across function calls, but should not be
196   // included in the generated FOO_SaveList array. These registers will be
197   // included in the FOO_RegMask bit mask. This can be used for registers that
198   // are saved automatically, like the SPARC register windows.
199   dag OtherPreserved;
200 }