Warning, /include/llvm/Target/TargetCallingConv.td is written in an unsupported language. File is not indexed.
0001 //===- TargetCallingConv.td - Target Calling Conventions ---*- tablegen -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines the target-independent interfaces with which targets
0010 // describe their calling conventions.
0011 //
0012 //===----------------------------------------------------------------------===//
0013
0014 class CCAction;
0015 class CallingConv;
0016
0017 /// CCCustom - Calls a custom arg handling function.
0018 class CCCustom<string fn> : CCAction {
0019 string FuncName = fn;
0020 }
0021
0022 /// CCPredicateAction - Instances of this class check some predicate, then
0023 /// delegate to another action if the predicate is true.
0024 class CCPredicateAction<CCAction A> : CCAction {
0025 CCAction SubAction = A;
0026 }
0027
0028 /// CCIfType - If the current argument is one of the specified types, apply
0029 /// Action A.
0030 class CCIfType<list<ValueType> vts, CCAction A> : CCPredicateAction<A> {
0031 list<ValueType> VTs = vts;
0032 }
0033
0034 /// CCIf - If the predicate matches, apply A.
0035 class CCIf<string predicate, CCAction A> : CCPredicateAction<A> {
0036 string Predicate = predicate;
0037 }
0038
0039 /// CCIfByVal - If the current argument has ByVal parameter attribute, apply
0040 /// Action A.
0041 class CCIfByVal<CCAction A> : CCIf<"ArgFlags.isByVal()", A> {
0042 }
0043
0044 /// CCIfPreallocated - If the current argument has Preallocated parameter attribute,
0045 /// apply Action A.
0046 class CCIfPreallocated<CCAction A> : CCIf<"ArgFlags.isPreallocated()", A> {
0047 }
0048
0049 /// CCIfSwiftSelf - If the current argument has swiftself parameter attribute,
0050 /// apply Action A.
0051 class CCIfSwiftSelf<CCAction A> : CCIf<"ArgFlags.isSwiftSelf()", A> {
0052 }
0053
0054 /// CCIfSwiftAsync - If the current argument has swiftasync parameter attribute,
0055 /// apply Action A.
0056 class CCIfSwiftAsync<CCAction A> : CCIf<"ArgFlags.isSwiftAsync()", A> {
0057 }
0058
0059 /// CCIfSwiftError - If the current argument has swifterror parameter attribute,
0060 /// apply Action A.
0061 class CCIfSwiftError<CCAction A> : CCIf<"ArgFlags.isSwiftError()", A> {
0062 }
0063
0064 /// CCIfCFGuardTarget - If the current argument has cfguardtarget parameter
0065 /// attribute, apply Action A.
0066 class CCIfCFGuardTarget<CCAction A> : CCIf<"ArgFlags.isCFGuardTarget()", A> {
0067 }
0068
0069 /// CCIfConsecutiveRegs - If the current argument has InConsecutiveRegs
0070 /// parameter attribute, apply Action A.
0071 class CCIfConsecutiveRegs<CCAction A> : CCIf<"ArgFlags.isInConsecutiveRegs()", A> {
0072 }
0073
0074 /// CCIfCC - Match if the current calling convention is 'CC'.
0075 class CCIfCC<string CC, CCAction A>
0076 : CCIf<!strconcat("State.getCallingConv() == ", CC), A> {}
0077
0078 /// CCIfInReg - If this argument is marked with the 'inreg' attribute, apply
0079 /// the specified action.
0080 class CCIfInReg<CCAction A> : CCIf<"ArgFlags.isInReg()", A> {}
0081
0082 /// CCIfNest - If this argument is marked with the 'nest' attribute, apply
0083 /// the specified action.
0084 class CCIfNest<CCAction A> : CCIf<"ArgFlags.isNest()", A> {}
0085
0086 /// CCIfSplit - If this argument is marked with the 'split' attribute, apply
0087 /// the specified action.
0088 class CCIfSplit<CCAction A> : CCIf<"ArgFlags.isSplit()", A> {}
0089
0090 /// CCIfSRet - If this argument is marked with the 'sret' attribute, apply
0091 /// the specified action.
0092 class CCIfSRet<CCAction A> : CCIf<"ArgFlags.isSRet()", A> {}
0093
0094 /// CCIfVarArg - If the current function is vararg - apply the action
0095 class CCIfVarArg<CCAction A> : CCIf<"State.isVarArg()", A> {}
0096
0097 /// CCIfNotVarArg - If the current function is not vararg - apply the action
0098 class CCIfNotVarArg<CCAction A> : CCIf<"!State.isVarArg()", A> {}
0099
0100 /// CCIfPtrAddrSpace - If the top-level parent of the current argument has
0101 /// pointer type in the specified address-space.
0102 class CCIfPtrAddrSpace<int AS, CCAction A>
0103 : CCIf<"(ArgFlags.isPointer() && ArgFlags.getPointerAddrSpace() == " # AS # ")", A> {}
0104
0105 /// CCIfPtr - If the top-level parent of the current argument had
0106 /// pointer type in some address-space.
0107 class CCIfPtr<CCAction A> : CCIf<"ArgFlags.isPointer()", A> {}
0108
0109 /// CCAssignToReg - This action matches if there is a register in the specified
0110 /// list that is still available. If so, it assigns the value to the first
0111 /// available register and succeeds.
0112 class CCAssignToReg<list<Register> regList> : CCAction {
0113 list<Register> RegList = regList;
0114 }
0115
0116 /// CCAssignToRegWithShadow - Same as CCAssignToReg, but with list of registers
0117 /// which became shadowed, when some register is used.
0118 class CCAssignToRegWithShadow<list<Register> regList,
0119 list<Register> shadowList> : CCAction {
0120 list<Register> RegList = regList;
0121 list<Register> ShadowRegList = shadowList;
0122 }
0123
0124 /// CCAssignToStack - This action always matches: it assigns the value to a
0125 /// stack slot of the specified size and alignment on the stack. If size is
0126 /// zero then the ABI size is used; if align is zero then the ABI alignment
0127 /// is used - these may depend on the target or subtarget.
0128 class CCAssignToStack<int size, int align> : CCAction {
0129 int Size = size;
0130 int Align = align;
0131 }
0132
0133 /// CCAssignToStackWithShadow - Same as CCAssignToStack, but with a list of
0134 /// registers to be shadowed. Note that, unlike CCAssignToRegWithShadow, this
0135 /// shadows ALL of the registers in shadowList.
0136 class CCAssignToStackWithShadow<int size,
0137 int align,
0138 list<Register> shadowList> : CCAction {
0139 int Size = size;
0140 int Align = align;
0141 list<Register> ShadowRegList = shadowList;
0142 }
0143
0144 /// CCAssignToRegAndStack - Same as CCAssignToReg, but also allocates a stack
0145 /// slot, when some register is used. Basically, it works like:
0146 /// CCIf<CCAssignToReg<regList>, CCAssignToStack<size, align>>.
0147 class CCAssignToRegAndStack<list<Register> regList, int size, int align>
0148 : CCAssignToReg<regList> {
0149 int Size = size;
0150 int Align = align;
0151 }
0152
0153 /// CCPassByVal - This action always matches: it assigns the value to a stack
0154 /// slot to implement ByVal aggregate parameter passing. Size and alignment
0155 /// specify the minimum size and alignment for the stack slot.
0156 class CCPassByVal<int size, int align> : CCAction {
0157 int Size = size;
0158 int Align = align;
0159 }
0160
0161 /// CCPromoteToType - If applied, this promotes the specified current value to
0162 /// the specified type.
0163 class CCPromoteToType<ValueType destTy> : CCAction {
0164 ValueType DestTy = destTy;
0165 }
0166
0167 /// CCPromoteToUpperBitsInType - If applied, this promotes the specified current
0168 /// value to the specified type and shifts the value into the upper bits.
0169 class CCPromoteToUpperBitsInType<ValueType destTy> : CCAction {
0170 ValueType DestTy = destTy;
0171 }
0172
0173 /// CCBitConvertToType - If applied, this bitconverts the specified current
0174 /// value to the specified type.
0175 class CCBitConvertToType<ValueType destTy> : CCAction {
0176 ValueType DestTy = destTy;
0177 }
0178
0179 /// CCTruncToType - If applied, this truncates the specified current value to
0180 /// the specified type.
0181 class CCTruncToType<ValueType destTy> : CCAction {
0182 ValueType DestTy = destTy;
0183 }
0184
0185 /// CCPassIndirect - If applied, this stores the value to stack and passes the pointer
0186 /// as normal argument.
0187 class CCPassIndirect<ValueType destTy> : CCAction {
0188 ValueType DestTy = destTy;
0189 }
0190
0191 /// CCDelegateTo - This action invokes the specified sub-calling-convention. It
0192 /// is successful if the specified CC matches.
0193 class CCDelegateTo<CallingConv cc> : CCAction {
0194 CallingConv CC = cc;
0195 }
0196
0197 /// CallingConv - An instance of this is used to define each calling convention
0198 /// that the target supports.
0199 class CallingConv<list<CCAction> actions> {
0200 list<CCAction> Actions = actions;
0201
0202 /// If true, this calling convention will be emitted as externally visible in
0203 /// the llvm namespaces instead of as a static function.
0204 bit Entry = false;
0205
0206 bit Custom = false;
0207 }
0208
0209 /// CustomCallingConv - An instance of this is used to declare calling
0210 /// conventions that are implemented using a custom function of the same name.
0211 class CustomCallingConv : CallingConv<[]> {
0212 let Custom = true;
0213 }
0214
0215 /// CalleeSavedRegs - A list of callee saved registers for a given calling
0216 /// convention. The order of registers is used by PrologEpilogInsertion when
0217 /// allocation stack slots for saved registers.
0218 ///
0219 /// For each CalleeSavedRegs def, TableGen will emit a FOO_SaveList array for
0220 /// returning from getCalleeSavedRegs(), and a FOO_RegMask bit mask suitable for
0221 /// returning from getCallPreservedMask().
0222 class CalleeSavedRegs<dag saves> {
0223 dag SaveList = saves;
0224
0225 // Registers that are also preserved across function calls, but should not be
0226 // included in the generated FOO_SaveList array. These registers will be
0227 // included in the FOO_RegMask bit mask. This can be used for registers that
0228 // are saved automatically, like the SPARC register windows.
0229 dag OtherPreserved;
0230 }