blob: 05029a01a6db6d4ad18779c282a1a3dcfaee39f9 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- 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
15class CCAction;
16class CallingConv;
17
18/// CCPredicateAction - Instances of this class check some predicate, then
19/// delegate to another action if the predicate is true.
20class 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.
26class CCIfType<list<ValueType> vts, CCAction A> : CCPredicateAction<A> {
27 list<ValueType> VTs = vts;
28}
29
30/// CCIf - If the predicate matches, apply A.
31class 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.
37class CCIfStruct<CCAction A> : CCIf<"ArgFlags & ISD::ParamFlags::ByVal", A> {
38}
39
40/// CCIfCC - Match of the current calling convention is 'CC'.
41class 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.
46class CCIfInReg<CCAction A> : CCIf<"ArgFlags & ISD::ParamFlags::InReg", A> {}
47
Duncan Sands38947cd2007-07-27 12:58:54 +000048/// CCIfNest - If this argument is marked with the 'nest' attribute, apply
49/// the specified action.
50class CCIfNest<CCAction A> : CCIf<"ArgFlags & ISD::ParamFlags::Nest", A> {}
51
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052/// CCIfNotVarArg - If the current function is not vararg - apply the action
53class 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.
58class 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.
64class CCAssignToStack<int size, int align> : CCAction {
65 int Size = size;
66 int Align = align;
67}
68
Dale Johannesen471b8182007-11-10 22:07:15 +000069/// CCAssignToStackABISizeAlign - This action always matches: it assigns
70/// the value to a stack slot of the ABISize and ABIAlignment for the type,
71/// which may depend on the target or subtarget.
72/// "ignored" is here because an empty arg list does not work.
73class CCAssignToStackABISizeAlign<int ignored> : CCAction {
74}
75
Dan Gohmanf17a25c2007-07-18 16:29:46 +000076/// CCStructAssign - This action always matches: it will use the C ABI and
77/// the register availability to decided whether to assign to a set of
78/// registers or to a stack slot.
79class CCStructAssign<list<Register> regList> : CCAction {
80 list<Register> RegList = regList;
81}
82
83/// CCPromoteToType - If applied, this promotes the specified current value to
84/// the specified type.
85class CCPromoteToType<ValueType destTy> : CCAction {
86 ValueType DestTy = destTy;
87}
88
89/// CCDelegateTo - This action invokes the specified sub-calling-convention. It
90/// is successful if the specified CC matches.
91class CCDelegateTo<CallingConv cc> : CCAction {
92 CallingConv CC = cc;
93}
94
95/// CallingConv - An instance of this is used to define each calling convention
96/// that the target supports.
97class CallingConv<list<CCAction> actions> {
98 list<CCAction> Actions = actions;
99}