Fix typo (also tab character).
[oota-llvm.git] / include / llvm / Target / TargetCallingConv.h
1 //===-- llvm/Target/TargetCallingConv.h - Calling Convention ----*- C++ -*-===//
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 types for working with calling-convention information.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TARGET_TARGETCALLINGCONV_H
15 #define LLVM_TARGET_TARGETCALLINGCONV_H
16
17 #include "llvm/CodeGen/ValueTypes.h"
18 #include "llvm/Support/DataTypes.h"
19 #include "llvm/Support/MathExtras.h"
20 #include <string>
21
22 namespace llvm {
23
24 namespace ISD {
25   struct ArgFlagsTy {
26   private:
27     static const uint64_t NoFlagSet      = 0ULL;
28     static const uint64_t ZExt           = 1ULL<<0;  ///< Zero extended
29     static const uint64_t ZExtOffs       = 0;
30     static const uint64_t SExt           = 1ULL<<1;  ///< Sign extended
31     static const uint64_t SExtOffs       = 1;
32     static const uint64_t InReg          = 1ULL<<2;  ///< Passed in register
33     static const uint64_t InRegOffs      = 2;
34     static const uint64_t SRet           = 1ULL<<3;  ///< Hidden struct-ret ptr
35     static const uint64_t SRetOffs       = 3;
36     static const uint64_t ByVal          = 1ULL<<4;  ///< Struct passed by value
37     static const uint64_t ByValOffs      = 4;
38     static const uint64_t Nest           = 1ULL<<5;  ///< Nested fn static chain
39     static const uint64_t NestOffs       = 5;
40     static const uint64_t Returned       = 1ULL<<6;  ///< Always returned
41     static const uint64_t ReturnedOffs   = 6;
42     static const uint64_t ByValAlign     = 0xFULL<<7; ///< Struct alignment
43     static const uint64_t ByValAlignOffs = 7;
44     static const uint64_t Split          = 1ULL<<11;
45     static const uint64_t SplitOffs      = 11;
46     static const uint64_t InAlloca       = 1ULL<<12; ///< Passed with inalloca
47     static const uint64_t InAllocaOffs   = 12;
48     static const uint64_t OrigAlign      = 0x1FULL<<27;
49     static const uint64_t OrigAlignOffs  = 27;
50     static const uint64_t ByValSize      = 0xffffffffULL<<32; ///< Struct size
51     static const uint64_t ByValSizeOffs  = 32;
52
53     static const uint64_t One            = 1ULL; ///< 1 of this type, for shifts
54
55     uint64_t Flags;
56   public:
57     ArgFlagsTy() : Flags(0) { }
58
59     bool isZExt()      const { return Flags & ZExt; }
60     void setZExt()     { Flags |= One << ZExtOffs; }
61
62     bool isSExt()      const { return Flags & SExt; }
63     void setSExt()     { Flags |= One << SExtOffs; }
64
65     bool isInReg()     const { return Flags & InReg; }
66     void setInReg()    { Flags |= One << InRegOffs; }
67
68     bool isSRet()      const { return Flags & SRet; }
69     void setSRet()     { Flags |= One << SRetOffs; }
70
71     bool isByVal()     const { return Flags & ByVal; }
72     void setByVal()    { Flags |= One << ByValOffs; }
73
74     bool isInAlloca()  const { return Flags & InAlloca; }
75     void setInAlloca() { Flags |= One << InAllocaOffs; }
76
77     bool isNest()      const { return Flags & Nest; }
78     void setNest()     { Flags |= One << NestOffs; }
79
80     bool isReturned()  const { return Flags & Returned; }
81     void setReturned() { Flags |= One << ReturnedOffs; }
82
83     unsigned getByValAlign() const {
84       return (unsigned)
85         ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
86     }
87     void setByValAlign(unsigned A) {
88       Flags = (Flags & ~ByValAlign) |
89         (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
90     }
91
92     bool isSplit()   const { return Flags & Split; }
93     void setSplit()  { Flags |= One << SplitOffs; }
94
95     unsigned getOrigAlign() const {
96       return (unsigned)
97         ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
98     }
99     void setOrigAlign(unsigned A) {
100       Flags = (Flags & ~OrigAlign) |
101         (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
102     }
103
104     unsigned getByValSize() const {
105       return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
106     }
107     void setByValSize(unsigned S) {
108       Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
109     }
110
111     /// getRawBits - Represent the flags as a bunch of bits.
112     uint64_t getRawBits() const { return Flags; }
113   };
114
115   /// InputArg - This struct carries flags and type information about a
116   /// single incoming (formal) argument or incoming (from the perspective
117   /// of the caller) return value virtual register.
118   ///
119   struct InputArg {
120     ArgFlagsTy Flags;
121     MVT VT;
122     EVT ArgVT;
123     bool Used;
124
125     /// Index original Function's argument.
126     unsigned OrigArgIndex;
127
128     /// Offset in bytes of current input value relative to the beginning of
129     /// original argument. E.g. if argument was splitted into four 32 bit
130     /// registers, we got 4 InputArgs with PartOffsets 0, 4, 8 and 12.
131     unsigned PartOffset;
132
133     InputArg() : VT(MVT::Other), Used(false) {}
134     InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool used,
135              unsigned origIdx, unsigned partOffs)
136       : Flags(flags), Used(used), OrigArgIndex(origIdx), PartOffset(partOffs) {
137       VT = vt.getSimpleVT();
138       ArgVT = argvt;
139     }
140   };
141
142   /// OutputArg - This struct carries flags and a value for a
143   /// single outgoing (actual) argument or outgoing (from the perspective
144   /// of the caller) return value virtual register.
145   ///
146   struct OutputArg {
147     ArgFlagsTy Flags;
148     MVT VT;
149     EVT ArgVT;
150
151     /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
152     bool IsFixed;
153
154     /// Index original Function's argument.
155     unsigned OrigArgIndex;
156
157     /// Offset in bytes of current output value relative to the beginning of
158     /// original argument. E.g. if argument was splitted into four 32 bit
159     /// registers, we got 4 OutputArgs with PartOffsets 0, 4, 8 and 12.
160     unsigned PartOffset;
161
162     OutputArg() : IsFixed(false) {}
163     OutputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool isfixed,
164               unsigned origIdx, unsigned partOffs)
165       : Flags(flags), IsFixed(isfixed), OrigArgIndex(origIdx),
166         PartOffset(partOffs) {
167       VT = vt.getSimpleVT();
168       ArgVT = argvt;
169     }
170   };
171 }
172
173 } // end llvm namespace
174
175 #endif