More templatization.
[oota-llvm.git] / lib / Target / TargetCallingConv.td
1 //===- TargetCallingConv.td - Target Calling Conventions ---*- tablegen -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by Chris Lattner and is distributed under
6 // the University of Illinois Open Source 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 /// CCPredicateAction - Instances of this class check some predicate, then
19 /// delegate to another action if the predicate is true.
20 class CCPredicateAction<CCAction A> : CCAction {
21   CCAction SubAction = A;
22 }
23
24 /// CCIfType - If the current argument is one of the specified types, apply
25 /// Action A.
26 class CCIfType<list<ValueType> vts, CCAction A> : CCPredicateAction<A> {
27   list<ValueType> VTs = vts;
28 }
29
30 /// CCIf - If the predicate matches, apply A.
31 class CCIf<string predicate, CCAction A> : CCPredicateAction<A> {
32   string Predicate = predicate;
33 }
34
35 /// CCIfStruct - If the current argument is a struct, apply
36 /// Action A.
37 class CCIfStruct<CCAction A> : CCIf<"ArgFlags & ISD::ParamFlags::ByVal", A> {
38 }
39
40 /// CCIfCC - Match of the current calling convention is 'CC'.
41 class CCIfCC<string CC, CCAction A>
42   : CCIf<!strconcat("State.getCallingConv() == ", CC), A> {}
43
44 /// CCIfInReg - If this argument is marked with the 'inreg' attribute, apply
45 /// the specified action.
46 class CCIfInReg<CCAction A> : CCIf<"ArgFlags & ISD::ParamFlags::InReg", A> {}
47
48 /// CCIfNest - If this argument is marked with the 'nest' attribute, apply
49 /// the specified action.
50 class CCIfNest<CCAction A> : CCIf<"ArgFlags & ISD::ParamFlags::Nest", A> {}
51
52 /// CCIfNotVarArg - If the current function is not vararg - apply the action
53 class CCIfNotVarArg<CCAction A> : CCIf<"!State.isVarArg()", A> {}
54
55 /// CCAssignToReg - This action matches if there is a register in the specified
56 /// list that is still available.  If so, it assigns the value to the first
57 /// available register and succeeds.
58 class CCAssignToReg<list<Register> regList> : CCAction {
59   list<Register> RegList = regList;
60 }
61
62 /// CCAssignToStack - This action always matches: it assigns the value to a
63 /// stack slot of the specified size and alignment on the stack.  If size is
64 /// zero then the ABI size is used; if align is zero then the ABI alignment
65 /// is used - these may depend on the target or subtarget.
66 class CCAssignToStack<int size, int align> : CCAction {
67   int Size = size;
68   int Align = align;
69 }
70
71 /// CCStructAssign - This action always matches: it will use the C ABI and
72 /// the register availability to decided whether to assign to a set of
73 /// registers or to a stack slot.
74 class CCStructAssign<list<Register> regList> : CCAction {
75   list<Register> RegList = regList;
76 }
77
78 /// CCPromoteToType - If applied, this promotes the specified current value to
79 /// the specified type.
80 class CCPromoteToType<ValueType destTy> : CCAction {
81   ValueType DestTy = destTy;
82 }
83
84 /// CCDelegateTo - This action invokes the specified sub-calling-convention.  It
85 /// is successful if the specified CC matches.
86 class CCDelegateTo<CallingConv cc> : CCAction {
87   CallingConv CC = cc;
88 }
89
90 /// CallingConv - An instance of this is used to define each calling convention
91 /// that the target supports.
92 class CallingConv<list<CCAction> actions> {
93   list<CCAction> Actions = actions;
94 }