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