]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/llvm/include/llvm/Target/TargetCallingConv.h
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / contrib / llvm / 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 namespace llvm {
18
19 namespace ISD {
20   struct ArgFlagsTy {
21   private:
22     static const uint64_t NoFlagSet      = 0ULL;
23     static const uint64_t ZExt           = 1ULL<<0;  ///< Zero extended
24     static const uint64_t ZExtOffs       = 0;
25     static const uint64_t SExt           = 1ULL<<1;  ///< Sign extended
26     static const uint64_t SExtOffs       = 1;
27     static const uint64_t InReg          = 1ULL<<2;  ///< Passed in register
28     static const uint64_t InRegOffs      = 2;
29     static const uint64_t SRet           = 1ULL<<3;  ///< Hidden struct-ret ptr
30     static const uint64_t SRetOffs       = 3;
31     static const uint64_t ByVal          = 1ULL<<4;  ///< Struct passed by value
32     static const uint64_t ByValOffs      = 4;
33     static const uint64_t Nest           = 1ULL<<5;  ///< Nested fn static chain
34     static const uint64_t NestOffs       = 5;
35     static const uint64_t ByValAlign     = 0xFULL << 6; //< Struct alignment
36     static const uint64_t ByValAlignOffs = 6;
37     static const uint64_t Split          = 1ULL << 10;
38     static const uint64_t SplitOffs      = 10;
39     static const uint64_t OrigAlign      = 0x1FULL<<27;
40     static const uint64_t OrigAlignOffs  = 27;
41     static const uint64_t ByValSize      = 0xffffffffULL << 32; //< Struct size
42     static const uint64_t ByValSizeOffs  = 32;
43
44     static const uint64_t One            = 1ULL; //< 1 of this type, for shifts
45
46     uint64_t Flags;
47   public:
48     ArgFlagsTy() : Flags(0) { }
49
50     bool isZExt()   const { return Flags & ZExt; }
51     void setZExt()  { Flags |= One << ZExtOffs; }
52
53     bool isSExt()   const { return Flags & SExt; }
54     void setSExt()  { Flags |= One << SExtOffs; }
55
56     bool isInReg()  const { return Flags & InReg; }
57     void setInReg() { Flags |= One << InRegOffs; }
58
59     bool isSRet()   const { return Flags & SRet; }
60     void setSRet()  { Flags |= One << SRetOffs; }
61
62     bool isByVal()  const { return Flags & ByVal; }
63     void setByVal() { Flags |= One << ByValOffs; }
64
65     bool isNest()   const { return Flags & Nest; }
66     void setNest()  { Flags |= One << NestOffs; }
67
68     unsigned getByValAlign() const {
69       return (unsigned)
70         ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
71     }
72     void setByValAlign(unsigned A) {
73       Flags = (Flags & ~ByValAlign) |
74         (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
75     }
76
77     bool isSplit()   const { return Flags & Split; }
78     void setSplit()  { Flags |= One << SplitOffs; }
79
80     unsigned getOrigAlign() const {
81       return (unsigned)
82         ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
83     }
84     void setOrigAlign(unsigned A) {
85       Flags = (Flags & ~OrigAlign) |
86         (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
87     }
88
89     unsigned getByValSize() const {
90       return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
91     }
92     void setByValSize(unsigned S) {
93       Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
94     }
95
96     /// getArgFlagsString - Returns the flags as a string, eg: "zext align:4".
97     std::string getArgFlagsString();
98
99     /// getRawBits - Represent the flags as a bunch of bits.
100     uint64_t getRawBits() const { return Flags; }
101   };
102
103   /// InputArg - This struct carries flags and type information about a
104   /// single incoming (formal) argument or incoming (from the perspective
105   /// of the caller) return value virtual register.
106   ///
107   struct InputArg {
108     ArgFlagsTy Flags;
109     MVT VT;
110     bool Used;
111
112     InputArg() : VT(MVT::Other), Used(false) {}
113     InputArg(ArgFlagsTy flags, EVT vt, bool used)
114       : Flags(flags), Used(used) {
115       VT = vt.getSimpleVT();
116     }
117   };
118
119   /// OutputArg - This struct carries flags and a value for a
120   /// single outgoing (actual) argument or outgoing (from the perspective
121   /// of the caller) return value virtual register.
122   ///
123   struct OutputArg {
124     ArgFlagsTy Flags;
125     MVT VT;
126
127     /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
128     bool IsFixed;
129
130     OutputArg() : IsFixed(false) {}
131     OutputArg(ArgFlagsTy flags, EVT vt, bool isfixed)
132       : Flags(flags), IsFixed(isfixed) {
133       VT = vt.getSimpleVT();
134     }
135   };
136 }
137
138 } // end llvm namespace
139
140 #endif