blob: 94193200eaa40866ea4f754ec57e3cf65aa418ac [file] [log] [blame]
Chris Lattner00836642007-02-27 05:57:32 +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
Chris Lattner62247f62007-02-28 05:29:33 +000024/// CCIfType - If the current argument is one of the specified types, apply
Chris Lattner00836642007-02-27 05:57:32 +000025/// Action A.
Chris Lattner62247f62007-02-28 05:29:33 +000026class CCIfType<list<ValueType> vts, CCAction A> : CCPredicateAction<A> {
Chris Lattnerf4580302007-02-27 20:45:02 +000027 list<ValueType> VTs = vts;
Chris Lattner00836642007-02-27 05:57:32 +000028}
29
Chris Lattner62247f62007-02-28 05:29:33 +000030/// CCIf - If the predicate matches, apply A.
31class CCIf<string predicate, CCAction A> : CCPredicateAction<A> {
Chris Lattner00836642007-02-27 05:57:32 +000032 string Predicate = predicate;
33}
34
Rafael Espindola1aa7efb2007-07-06 10:57:03 +000035/// CCIfStruct - If the current argument is a struct, apply
36/// Action A.
37class CCIfStruct<CCAction A> : CCIf<"ArgFlags & ISD::ParamFlags::ByVal", A> {
38}
39
Chris Lattner62247f62007-02-28 05:29:33 +000040/// 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.
Anton Korobeynikovd0b82b32007-03-07 16:25:09 +000046class CCIfInReg<CCAction A> : CCIf<"ArgFlags & ISD::ParamFlags::InReg", A> {}
Chris Lattner62247f62007-02-28 05:29:33 +000047
Chris Lattner52387be2007-06-19 00:13:10 +000048/// CCIfNotVarArg - If the current function is not vararg - apply the action
49class CCIfNotVarArg<CCAction A> : CCIf<"!State.isVarArg()", A> {}
Chris Lattner00836642007-02-27 05:57:32 +000050
51/// CCAssignToReg - This action matches if there is a register in the specified
52/// list that is still available. If so, it assigns the value to the first
53/// available register and succeeds.
54class CCAssignToReg<list<Register> regList> : CCAction {
55 list<Register> RegList = regList;
56}
57
58/// CCAssignToStack - This action always matches: it assigns the value to a
59/// stack slot of the specified size and alignment on the stack.
60class CCAssignToStack<int size, int align> : CCAction {
61 int Size = size;
62 int Align = align;
63}
64
Rafael Espindola1aa7efb2007-07-06 10:57:03 +000065/// CCStructAssign - This action always matches: it will use the C ABI and
66/// the register availability to decided whether to assign to a set of
67/// registers or to a stack slot.
68class CCStructAssign<list<Register> regList> : CCAction {
69 list<Register> RegList = regList;
70}
Chris Lattner00836642007-02-27 05:57:32 +000071
72/// CCPromoteToType - If applied, this promotes the specified current value to
73/// the specified type.
74class CCPromoteToType<ValueType destTy> : CCAction {
75 ValueType DestTy = destTy;
76}
77
78/// CCDelegateTo - This action invokes the specified sub-calling-convention. It
79/// is successful if the specified CC matches.
80class CCDelegateTo<CallingConv cc> : CCAction {
81 CallingConv CC = cc;
82}
83
84/// CallingConv - An instance of this is used to define each calling convention
85/// that the target supports.
86class CallingConv<list<CCAction> actions> {
87 list<CCAction> Actions = actions;
88}