Taints the non-acquire RMW's store address with the load part
[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 #include <limits.h>
22
23 namespace llvm {
24
25 namespace ISD {
26   struct ArgFlagsTy {
27   private:
28     static const uint64_t NoFlagSet      = 0ULL;
29     static const uint64_t ZExt           = 1ULL<<0;  ///< Zero extended
30     static const uint64_t ZExtOffs       = 0;
31     static const uint64_t SExt           = 1ULL<<1;  ///< Sign extended
32     static const uint64_t SExtOffs       = 1;
33     static const uint64_t InReg          = 1ULL<<2;  ///< Passed in register
34     static const uint64_t InRegOffs      = 2;
35     static const uint64_t SRet           = 1ULL<<3;  ///< Hidden struct-ret ptr
36     static const uint64_t SRetOffs       = 3;
37     static const uint64_t ByVal          = 1ULL<<4;  ///< Struct passed by value
38     static const uint64_t ByValOffs      = 4;
39     static const uint64_t Nest           = 1ULL<<5;  ///< Nested fn static chain
40     static const uint64_t NestOffs       = 5;
41     static const uint64_t Returned       = 1ULL<<6;  ///< Always returned
42     static const uint64_t ReturnedOffs   = 6;
43     static const uint64_t ByValAlign     = 0xFULL<<7; ///< Struct alignment
44     static const uint64_t ByValAlignOffs = 7;
45     static const uint64_t Split          = 1ULL<<11;
46     static const uint64_t SplitOffs      = 11;
47     static const uint64_t InAlloca       = 1ULL<<12; ///< Passed with inalloca
48     static const uint64_t InAllocaOffs   = 12;
49     static const uint64_t SplitEnd       = 1ULL<<13; ///< Last part of a split
50     static const uint64_t SplitEndOffs   = 13;
51     static const uint64_t OrigAlign      = 0x1FULL<<27;
52     static const uint64_t OrigAlignOffs  = 27;
53     static const uint64_t ByValSize      = 0x3fffffffULL<<32; ///< Struct size
54     static const uint64_t ByValSizeOffs  = 32;
55     static const uint64_t InConsecutiveRegsLast      = 0x1ULL<<62; ///< Struct size
56     static const uint64_t InConsecutiveRegsLastOffs  = 62;
57     static const uint64_t InConsecutiveRegs      = 0x1ULL<<63; ///< Struct size
58     static const uint64_t InConsecutiveRegsOffs  = 63;
59
60     static const uint64_t One            = 1ULL; ///< 1 of this type, for shifts
61
62     uint64_t Flags;
63   public:
64     ArgFlagsTy() : Flags(0) { }
65
66     bool isZExt()      const { return Flags & ZExt; }
67     void setZExt()     { Flags |= One << ZExtOffs; }
68
69     bool isSExt()      const { return Flags & SExt; }
70     void setSExt()     { Flags |= One << SExtOffs; }
71
72     bool isInReg()     const { return Flags & InReg; }
73     void setInReg()    { Flags |= One << InRegOffs; }
74
75     bool isSRet()      const { return Flags & SRet; }
76     void setSRet()     { Flags |= One << SRetOffs; }
77
78     bool isByVal()     const { return Flags & ByVal; }
79     void setByVal()    { Flags |= One << ByValOffs; }
80
81     bool isInAlloca()  const { return Flags & InAlloca; }
82     void setInAlloca() { Flags |= One << InAllocaOffs; }
83
84     bool isNest()      const { return Flags & Nest; }
85     void setNest()     { Flags |= One << NestOffs; }
86
87     bool isReturned()  const { return Flags & Returned; }
88     void setReturned() { Flags |= One << ReturnedOffs; }
89
90     bool isInConsecutiveRegs()  const { return Flags & InConsecutiveRegs; }
91     void setInConsecutiveRegs() { Flags |= One << InConsecutiveRegsOffs; }
92
93     bool isInConsecutiveRegsLast()  const { return Flags & InConsecutiveRegsLast; }
94     void setInConsecutiveRegsLast() { Flags |= One << InConsecutiveRegsLastOffs; }
95
96     unsigned getByValAlign() const {
97       return (unsigned)
98         ((One << ((Flags & ByValAlign) >> ByValAlignOffs)) / 2);
99     }
100     void setByValAlign(unsigned A) {
101       Flags = (Flags & ~ByValAlign) |
102         (uint64_t(Log2_32(A) + 1) << ByValAlignOffs);
103     }
104
105     bool isSplit()   const { return Flags & Split; }
106     void setSplit()  { Flags |= One << SplitOffs; }
107
108     bool isSplitEnd()   const { return Flags & SplitEnd; }
109     void setSplitEnd()  { Flags |= One << SplitEndOffs; }
110
111     unsigned getOrigAlign() const {
112       return (unsigned)
113         ((One << ((Flags & OrigAlign) >> OrigAlignOffs)) / 2);
114     }
115     void setOrigAlign(unsigned A) {
116       Flags = (Flags & ~OrigAlign) |
117         (uint64_t(Log2_32(A) + 1) << OrigAlignOffs);
118     }
119
120     unsigned getByValSize() const {
121       return (unsigned)((Flags & ByValSize) >> ByValSizeOffs);
122     }
123     void setByValSize(unsigned S) {
124       Flags = (Flags & ~ByValSize) | (uint64_t(S) << ByValSizeOffs);
125     }
126
127     /// getRawBits - Represent the flags as a bunch of bits.
128     uint64_t getRawBits() const { return Flags; }
129   };
130
131   /// InputArg - This struct carries flags and type information about a
132   /// single incoming (formal) argument or incoming (from the perspective
133   /// of the caller) return value virtual register.
134   ///
135   struct InputArg {
136     ArgFlagsTy Flags;
137     MVT VT;
138     EVT ArgVT;
139     bool Used;
140
141     /// Index original Function's argument.
142     unsigned OrigArgIndex;
143     /// Sentinel value for implicit machine-level input arguments.
144     static const unsigned NoArgIndex = UINT_MAX;
145
146     /// Offset in bytes of current input value relative to the beginning of
147     /// original argument. E.g. if argument was splitted into four 32 bit
148     /// registers, we got 4 InputArgs with PartOffsets 0, 4, 8 and 12.
149     unsigned PartOffset;
150
151     InputArg() : VT(MVT::Other), Used(false) {}
152     InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool used,
153              unsigned origIdx, unsigned partOffs)
154       : Flags(flags), Used(used), OrigArgIndex(origIdx), PartOffset(partOffs) {
155       VT = vt.getSimpleVT();
156       ArgVT = argvt;
157     }
158
159     bool isOrigArg() const {
160       return OrigArgIndex != NoArgIndex;
161     }
162
163     unsigned getOrigArgIndex() const {
164       assert(OrigArgIndex != NoArgIndex && "Implicit machine-level argument");
165       return OrigArgIndex;
166     }
167   };
168
169   /// OutputArg - This struct carries flags and a value for a
170   /// single outgoing (actual) argument or outgoing (from the perspective
171   /// of the caller) return value virtual register.
172   ///
173   struct OutputArg {
174     ArgFlagsTy Flags;
175     MVT VT;
176     EVT ArgVT;
177
178     /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...".
179     bool IsFixed;
180
181     /// Index original Function's argument.
182     unsigned OrigArgIndex;
183
184     /// Offset in bytes of current output value relative to the beginning of
185     /// original argument. E.g. if argument was splitted into four 32 bit
186     /// registers, we got 4 OutputArgs with PartOffsets 0, 4, 8 and 12.
187     unsigned PartOffset;
188
189     OutputArg() : IsFixed(false) {}
190     OutputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool isfixed,
191               unsigned origIdx, unsigned partOffs)
192       : Flags(flags), IsFixed(isfixed), OrigArgIndex(origIdx),
193         PartOffset(partOffs) {
194       VT = vt.getSimpleVT();
195       ArgVT = argvt;
196     }
197   };
198 }
199
200 } // end llvm namespace
201
202 #endif