Chris Lattner | 0083664 | 2007-02-27 05:57:32 +0000 | [diff] [blame] | 1 | //===- TargetCallingConv.td - Target Calling Conventions ---*- tablegen -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Chris Lattner | 0083664 | 2007-02-27 05:57:32 +0000 | [diff] [blame] | 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 | |
Chris Lattner | 62247f6 | 2007-02-28 05:29:33 +0000 | [diff] [blame] | 24 | /// CCIfType - If the current argument is one of the specified types, apply |
Chris Lattner | 0083664 | 2007-02-27 05:57:32 +0000 | [diff] [blame] | 25 | /// Action A. |
Chris Lattner | 62247f6 | 2007-02-28 05:29:33 +0000 | [diff] [blame] | 26 | class CCIfType<list<ValueType> vts, CCAction A> : CCPredicateAction<A> { |
Chris Lattner | f458030 | 2007-02-27 20:45:02 +0000 | [diff] [blame] | 27 | list<ValueType> VTs = vts; |
Chris Lattner | 0083664 | 2007-02-27 05:57:32 +0000 | [diff] [blame] | 28 | } |
| 29 | |
Chris Lattner | 62247f6 | 2007-02-28 05:29:33 +0000 | [diff] [blame] | 30 | /// CCIf - If the predicate matches, apply A. |
| 31 | class CCIf<string predicate, CCAction A> : CCPredicateAction<A> { |
Chris Lattner | 0083664 | 2007-02-27 05:57:32 +0000 | [diff] [blame] | 32 | string Predicate = predicate; |
| 33 | } |
| 34 | |
Evan Cheng | 6bfa8a1 | 2008-01-15 03:34:58 +0000 | [diff] [blame] | 35 | /// CCIfByVal - If the current argument has ByVal parameter attribute, apply |
Rafael Espindola | 1aa7efb | 2007-07-06 10:57:03 +0000 | [diff] [blame] | 36 | /// Action A. |
Duncan Sands | 276dcbd | 2008-03-21 09:14:45 +0000 | [diff] [blame] | 37 | class CCIfByVal<CCAction A> : CCIf<"ArgFlags.isByVal()", A> { |
Rafael Espindola | 1aa7efb | 2007-07-06 10:57:03 +0000 | [diff] [blame] | 38 | } |
| 39 | |
Chris Lattner | 62247f6 | 2007-02-28 05:29:33 +0000 | [diff] [blame] | 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. |
Duncan Sands | 276dcbd | 2008-03-21 09:14:45 +0000 | [diff] [blame] | 46 | class CCIfInReg<CCAction A> : CCIf<"ArgFlags.isInReg()", A> {} |
Chris Lattner | 62247f6 | 2007-02-28 05:29:33 +0000 | [diff] [blame] | 47 | |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 48 | /// CCIfNest - If this argument is marked with the 'nest' attribute, apply |
| 49 | /// the specified action. |
Duncan Sands | 276dcbd | 2008-03-21 09:14:45 +0000 | [diff] [blame] | 50 | class CCIfNest<CCAction A> : CCIf<"ArgFlags.isNest()", A> {} |
Duncan Sands | 36397f5 | 2007-07-27 12:58:54 +0000 | [diff] [blame] | 51 | |
Chris Lattner | 52387be | 2007-06-19 00:13:10 +0000 | [diff] [blame] | 52 | /// CCIfNotVarArg - If the current function is not vararg - apply the action |
| 53 | class CCIfNotVarArg<CCAction A> : CCIf<"!State.isVarArg()", A> {} |
Chris Lattner | 0083664 | 2007-02-27 05:57:32 +0000 | [diff] [blame] | 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 | |
Anton Korobeynikov | 67073f1 | 2008-04-02 05:23:57 +0000 | [diff] [blame] | 62 | /// CCAssignToRegWithShadow - Same as CCAssignToReg, but with list of registers |
| 63 | /// which became shadowed, when some register is used. |
| 64 | class CCAssignToRegWithShadow<list<Register> regList, |
| 65 | list<Register> shadowList> : CCAction { |
| 66 | list<Register> RegList = regList; |
| 67 | list<Register> ShadowRegList = shadowList; |
| 68 | } |
| 69 | |
Chris Lattner | 0083664 | 2007-02-27 05:57:32 +0000 | [diff] [blame] | 70 | /// CCAssignToStack - This action always matches: it assigns the value to a |
Duncan Sands | 87b665d | 2007-11-14 08:29:13 +0000 | [diff] [blame] | 71 | /// stack slot of the specified size and alignment on the stack. If size is |
| 72 | /// zero then the ABI size is used; if align is zero then the ABI alignment |
| 73 | /// is used - these may depend on the target or subtarget. |
Chris Lattner | 0083664 | 2007-02-27 05:57:32 +0000 | [diff] [blame] | 74 | class CCAssignToStack<int size, int align> : CCAction { |
| 75 | int Size = size; |
| 76 | int Align = align; |
| 77 | } |
| 78 | |
Evan Cheng | 6bfa8a1 | 2008-01-15 03:34:58 +0000 | [diff] [blame] | 79 | /// CCPassByVal - This action always matches: it assigns the value to a stack |
| 80 | /// slot to implement ByVal aggregate parameter passing. Size and alignment |
| 81 | /// specify the minimum size and alignment for the stack slot. |
| 82 | class CCPassByVal<int size, int align> : CCAction { |
| 83 | int Size = size; |
| 84 | int Align = align; |
Rafael Espindola | 1aa7efb | 2007-07-06 10:57:03 +0000 | [diff] [blame] | 85 | } |
Chris Lattner | 0083664 | 2007-02-27 05:57:32 +0000 | [diff] [blame] | 86 | |
| 87 | /// CCPromoteToType - If applied, this promotes the specified current value to |
| 88 | /// the specified type. |
| 89 | class CCPromoteToType<ValueType destTy> : CCAction { |
| 90 | ValueType DestTy = destTy; |
| 91 | } |
| 92 | |
| 93 | /// CCDelegateTo - This action invokes the specified sub-calling-convention. It |
| 94 | /// is successful if the specified CC matches. |
| 95 | class CCDelegateTo<CallingConv cc> : CCAction { |
| 96 | CallingConv CC = cc; |
| 97 | } |
| 98 | |
| 99 | /// CallingConv - An instance of this is used to define each calling convention |
| 100 | /// that the target supports. |
| 101 | class CallingConv<list<CCAction> actions> { |
| 102 | list<CCAction> Actions = actions; |
| 103 | } |