d0bdd369839f35c20b4b1301f2e02ad370d315cf
[oota-llvm.git] / include / llvm / Target / TargetCallingConv.td
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 /// CCIfConsecutiveRegs - If the current argument has InConsecutiveRegs
46 /// parameter attribute, apply Action A.
47 class CCIfConsecutiveRegs<CCAction A> : CCIf<"ArgFlags.isInConsecutiveRegs()", A> {
48 }
49
50 /// CCIfCC - Match if the current calling convention is 'CC'.
51 class CCIfCC<string CC, CCAction A>
52   : CCIf<!strconcat("State.getCallingConv() == ", CC), A> {}
53
54 /// CCIfInReg - If this argument is marked with the 'inreg' attribute, apply
55 /// the specified action.
56 class CCIfInReg<CCAction A> : CCIf<"ArgFlags.isInReg()", A> {}
57
58 /// CCIfNest - If this argument is marked with the 'nest' attribute, apply
59 /// the specified action.
60 class CCIfNest<CCAction A> : CCIf<"ArgFlags.isNest()", A> {}
61
62 /// CCIfSplit - If this argument is marked with the 'split' attribute, apply
63 /// the specified action.
64 class CCIfSplit<CCAction A> : CCIf<"ArgFlags.isSplit()", A> {}
65
66 /// CCIfSRet - If this argument is marked with the 'sret' attribute, apply
67 /// the specified action.
68 class CCIfSRet<CCAction A> : CCIf<"ArgFlags.isSRet()", A> {}
69
70 /// CCIfNotVarArg - If the current function is not vararg - apply the action
71 class CCIfNotVarArg<CCAction A> : CCIf<"!State.isVarArg()", A> {}
72
73 /// CCAssignToReg - This action matches if there is a register in the specified
74 /// list that is still available.  If so, it assigns the value to the first
75 /// available register and succeeds.
76 class CCAssignToReg<list<Register> regList> : CCAction {
77   list<Register> RegList = regList;
78 }
79
80 /// CCAssignToRegWithShadow - Same as CCAssignToReg, but with list of registers
81 /// which became shadowed, when some register is used.
82 class CCAssignToRegWithShadow<list<Register> regList,
83                               list<Register> shadowList> : CCAction {
84   list<Register> RegList = regList;
85   list<Register> ShadowRegList = shadowList;
86 }
87
88 /// CCAssignToStack - This action always matches: it assigns the value to a
89 /// stack slot of the specified size and alignment on the stack.  If size is
90 /// zero then the ABI size is used; if align is zero then the ABI alignment
91 /// is used - these may depend on the target or subtarget.
92 class CCAssignToStack<int size, int align> : CCAction {
93   int Size = size;
94   int Align = align;
95 }
96
97 /// CCAssignToStackWithShadow - Same as CCAssignToStack, but with a list of
98 /// registers to be shadowed. Note that, unlike CCAssignToRegWithShadow, this
99 /// shadows ALL of the registers in shadowList.
100 class CCAssignToStackWithShadow<int size,
101                                 int align,
102                                 list<Register> shadowList> : CCAction {
103   int Size = size;
104   int Align = align;
105   list<Register> ShadowRegList = shadowList;
106 }
107
108 /// CCPassByVal - This action always matches: it assigns the value to a stack
109 /// slot to implement ByVal aggregate parameter passing. Size and alignment
110 /// specify the minimum size and alignment for the stack slot.
111 class CCPassByVal<int size, int align> : CCAction {
112   int Size = size;
113   int Align = align;
114 }
115
116 /// CCPromoteToType - If applied, this promotes the specified current value to
117 /// the specified type.
118 class CCPromoteToType<ValueType destTy> : CCAction {
119   ValueType DestTy = destTy;
120 }
121
122 /// CCPromoteToUpperBitsInType - If applied, this promotes the specified current
123 /// value to the specified type and shifts the value into the upper bits.
124 class CCPromoteToUpperBitsInType<ValueType destTy> : CCAction {
125   ValueType DestTy = destTy;
126 }
127
128 /// CCBitConvertToType - If applied, this bitconverts the specified current
129 /// value to the specified type.
130 class CCBitConvertToType<ValueType destTy> : CCAction {
131   ValueType DestTy = destTy;
132 }
133
134 /// CCPassIndirect - If applied, this stores the value to stack and passes the pointer
135 /// as normal argument.
136 class CCPassIndirect<ValueType destTy> : CCAction {
137   ValueType DestTy = destTy;
138 }
139
140 /// CCDelegateTo - This action invokes the specified sub-calling-convention.  It
141 /// is successful if the specified CC matches.
142 class CCDelegateTo<CallingConv cc> : CCAction {
143   CallingConv CC = cc;
144 }
145
146 /// CallingConv - An instance of this is used to define each calling convention
147 /// that the target supports.
148 class CallingConv<list<CCAction> actions> {
149   list<CCAction> Actions = actions;
150 }
151
152 /// CalleeSavedRegs - A list of callee saved registers for a given calling
153 /// convention.  The order of registers is used by PrologEpilogInsertion when
154 /// allocation stack slots for saved registers.
155 ///
156 /// For each CalleeSavedRegs def, TableGen will emit a FOO_SaveList array for
157 /// returning from getCalleeSavedRegs(), and a FOO_RegMask bit mask suitable for
158 /// returning from getCallPreservedMask().
159 class CalleeSavedRegs<dag saves> {
160   dag SaveList = saves;
161
162   // Registers that are also preserved across function calls, but should not be
163   // included in the generated FOO_SaveList array. These registers will be
164   // included in the FOO_RegMask bit mask. This can be used for registers that
165   // are saved automatically, like the SPARC register windows.
166   dag OtherPreserved;
167 }