1 //===- TargetCallingConv.td - Target Calling Conventions ---*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the target-independent interfaces with which targets
11 // describe their calling conventions.
13 //===----------------------------------------------------------------------===//
18 /// CCCustom - Calls a custom arg handling function.
19 class CCCustom<string fn> : CCAction {
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;
29 /// CCIfType - If the current argument is one of the specified types, apply
31 class CCIfType<list<ValueType> vts, CCAction A> : CCPredicateAction<A> {
32 list<ValueType> VTs = vts;
35 /// CCIf - If the predicate matches, apply A.
36 class CCIf<string predicate, CCAction A> : CCPredicateAction<A> {
37 string Predicate = predicate;
40 /// CCIfByVal - If the current argument has ByVal parameter attribute, apply
42 class CCIfByVal<CCAction A> : CCIf<"ArgFlags.isByVal()", A> {
45 /// CCIfCC - Match if the current calling convention is 'CC'.
46 class CCIfCC<string CC, CCAction A>
47 : CCIf<!strconcat("State.getCallingConv() == ", CC), A> {}
49 /// CCIfInReg - If this argument is marked with the 'inreg' attribute, apply
50 /// the specified action.
51 class CCIfInReg<CCAction A> : CCIf<"ArgFlags.isInReg()", A> {}
53 /// CCIfNest - If this argument is marked with the 'nest' attribute, apply
54 /// the specified action.
55 class CCIfNest<CCAction A> : CCIf<"ArgFlags.isNest()", A> {}
57 /// CCIfSplit - If this argument is marked with the 'split' attribute, apply
58 /// the specified action.
59 class CCIfSplit<CCAction A> : CCIf<"ArgFlags.isSplit()", A> {}
61 /// CCIfSRet - If this argument is marked with the 'sret' attribute, apply
62 /// the specified action.
63 class CCIfSRet<CCAction A> : CCIf<"ArgFlags.isSRet()", A> {}
65 /// CCIfNotVarArg - If the current function is not vararg - apply the action
66 class CCIfNotVarArg<CCAction A> : CCIf<"!State.isVarArg()", A> {}
68 /// CCAssignToReg - This action matches if there is a register in the specified
69 /// list that is still available. If so, it assigns the value to the first
70 /// available register and succeeds.
71 class CCAssignToReg<list<Register> regList> : CCAction {
72 list<Register> RegList = regList;
75 /// CCAssignToRegWithShadow - Same as CCAssignToReg, but with list of registers
76 /// which became shadowed, when some register is used.
77 class CCAssignToRegWithShadow<list<Register> regList,
78 list<Register> shadowList> : CCAction {
79 list<Register> RegList = regList;
80 list<Register> ShadowRegList = shadowList;
83 /// CCAssignToStack - This action always matches: it assigns the value to a
84 /// stack slot of the specified size and alignment on the stack. If size is
85 /// zero then the ABI size is used; if align is zero then the ABI alignment
86 /// is used - these may depend on the target or subtarget.
87 class CCAssignToStack<int size, int align> : CCAction {
92 /// CCAssignToStackWithShadow - Same as CCAssignToStack, but with a register
94 class CCAssignToStackWithShadow<int size, int align, Register reg> :
95 CCAssignToStack<size, align> {
96 Register ShadowReg = reg;
99 /// CCPassByVal - This action always matches: it assigns the value to a stack
100 /// slot to implement ByVal aggregate parameter passing. Size and alignment
101 /// specify the minimum size and alignment for the stack slot.
102 class CCPassByVal<int size, int align> : CCAction {
107 /// CCPromoteToType - If applied, this promotes the specified current value to
108 /// the specified type.
109 class CCPromoteToType<ValueType destTy> : CCAction {
110 ValueType DestTy = destTy;
113 /// CCBitConvertToType - If applied, this bitconverts the specified current
114 /// value to the specified type.
115 class CCBitConvertToType<ValueType destTy> : CCAction {
116 ValueType DestTy = destTy;
119 /// CCPassIndirect - If applied, this stores the value to stack and passes the pointer
120 /// as normal argument.
121 class CCPassIndirect<ValueType destTy> : CCAction {
122 ValueType DestTy = destTy;
125 /// CCDelegateTo - This action invokes the specified sub-calling-convention. It
126 /// is successful if the specified CC matches.
127 class CCDelegateTo<CallingConv cc> : CCAction {
131 /// CallingConv - An instance of this is used to define each calling convention
132 /// that the target supports.
133 class CallingConv<list<CCAction> actions> {
134 list<CCAction> Actions = actions;
137 /// CalleeSavedRegs - A list of callee saved registers for a given calling
138 /// convention. The order of registers is used by PrologEpilogInsertion when
139 /// allocation stack slots for saved registers.
141 /// For each CalleeSavedRegs def, TableGen will emit a FOO_SaveList array for
142 /// returning from getCalleeSavedRegs(), and a FOO_RegMask bit mask suitable for
143 /// returning from getCallPreservedMask().
144 class CalleeSavedRegs<dag saves> {
145 dag SaveList = saves;