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 /// 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> {}
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> {}
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;
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;
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 {
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,
123 list<Register> shadowList> : CCAction {
126 list<Register> ShadowRegList = shadowList;
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 {
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;
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;
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;
155 /// CCTruncToType - If applied, this truncates the specified current value to
156 /// the specified type.
157 class CCTruncToType<ValueType destTy> : CCAction {
158 ValueType DestTy = destTy;
161 /// CCPassIndirect - If applied, this stores the value to stack and passes the pointer
162 /// as normal argument.
163 class CCPassIndirect<ValueType destTy> : CCAction {
164 ValueType DestTy = destTy;
167 /// CCDelegateTo - This action invokes the specified sub-calling-convention. It
168 /// is successful if the specified CC matches.
169 class CCDelegateTo<CallingConv cc> : CCAction {
173 /// CallingConv - An instance of this is used to define each calling convention
174 /// that the target supports.
175 class CallingConv<list<CCAction> actions> {
176 list<CCAction> Actions = actions;
178 /// If true, this calling convention will be emitted as externally visible in
179 /// the llvm namespaces instead of as a static function.
185 /// CustomCallingConv - An instance of this is used to declare calling
186 /// conventions that are implemented using a custom function of the same name.
187 class CustomCallingConv : CallingConv<[]> {
191 /// CalleeSavedRegs - A list of callee saved registers for a given calling
192 /// convention. The order of registers is used by PrologEpilogInsertion when
193 /// allocation stack slots for saved registers.
195 /// For each CalleeSavedRegs def, TableGen will emit a FOO_SaveList array for
196 /// returning from getCalleeSavedRegs(), and a FOO_RegMask bit mask suitable for
197 /// returning from getCallPreservedMask().
198 class CalleeSavedRegs<dag saves> {
199 dag SaveList = saves;
201 // Registers that are also preserved across function calls, but should not be
202 // included in the generated FOO_SaveList array. These registers will be
203 // included in the FOO_RegMask bit mask. This can be used for registers that
204 // are saved automatically, like the SPARC register windows.