]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/llvm/tools/clang/include/clang/Basic/ABI.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / llvm / tools / clang / include / clang / Basic / ABI.h
1 //===----- ABI.h - ABI related declarations ---------------------*- 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 /// \file
11 /// \brief Enums/classes describing ABI related information about constructors,
12 /// destructors and thunks.
13 ///
14 //===----------------------------------------------------------------------===//
15
16 #ifndef CLANG_BASIC_ABI_H
17 #define CLANG_BASIC_ABI_H
18
19 #include "llvm/Support/DataTypes.h"
20
21 namespace clang {
22
23 /// \brief C++ constructor types.
24 enum CXXCtorType {
25     Ctor_Complete,          ///< Complete object ctor
26     Ctor_Base,              ///< Base object ctor
27     Ctor_CompleteAllocating ///< Complete object allocating ctor
28 };
29
30 /// \brief C++ destructor types.
31 enum CXXDtorType {
32     Dtor_Deleting, ///< Deleting dtor
33     Dtor_Complete, ///< Complete object dtor
34     Dtor_Base      ///< Base object dtor
35 };
36
37 /// \brief A return adjustment.
38 struct ReturnAdjustment {
39   /// \brief The non-virtual adjustment from the derived object to its
40   /// nearest virtual base.
41   int64_t NonVirtual;
42   
43   /// \brief The offset (in bytes), relative to the address point 
44   /// of the virtual base class offset.
45   int64_t VBaseOffsetOffset;
46   
47   ReturnAdjustment() : NonVirtual(0), VBaseOffsetOffset(0) { }
48   
49   bool isEmpty() const { return !NonVirtual && !VBaseOffsetOffset; }
50
51   friend bool operator==(const ReturnAdjustment &LHS, 
52                          const ReturnAdjustment &RHS) {
53     return LHS.NonVirtual == RHS.NonVirtual && 
54       LHS.VBaseOffsetOffset == RHS.VBaseOffsetOffset;
55   }
56
57   friend bool operator<(const ReturnAdjustment &LHS,
58                         const ReturnAdjustment &RHS) {
59     if (LHS.NonVirtual < RHS.NonVirtual)
60       return true;
61     
62     return LHS.NonVirtual == RHS.NonVirtual && 
63       LHS.VBaseOffsetOffset < RHS.VBaseOffsetOffset;
64   }
65 };
66   
67 /// \brief A \c this pointer adjustment.
68 struct ThisAdjustment {
69   /// \brief The non-virtual adjustment from the derived object to its
70   /// nearest virtual base.
71   int64_t NonVirtual;
72
73   /// \brief The offset (in bytes), relative to the address point,
74   /// of the virtual call offset.
75   int64_t VCallOffsetOffset;
76   
77   ThisAdjustment() : NonVirtual(0), VCallOffsetOffset(0) { }
78
79   bool isEmpty() const { return !NonVirtual && !VCallOffsetOffset; }
80
81   friend bool operator==(const ThisAdjustment &LHS, 
82                          const ThisAdjustment &RHS) {
83     return LHS.NonVirtual == RHS.NonVirtual && 
84       LHS.VCallOffsetOffset == RHS.VCallOffsetOffset;
85   }
86   
87   friend bool operator<(const ThisAdjustment &LHS,
88                         const ThisAdjustment &RHS) {
89     if (LHS.NonVirtual < RHS.NonVirtual)
90       return true;
91     
92     return LHS.NonVirtual == RHS.NonVirtual && 
93       LHS.VCallOffsetOffset < RHS.VCallOffsetOffset;
94   }
95 };
96
97 /// \brief The \c this pointer adjustment as well as an optional return
98 /// adjustment for a thunk.
99 struct ThunkInfo {
100   /// \brief The \c this pointer adjustment.
101   ThisAdjustment This;
102     
103   /// \brief The return adjustment.
104   ReturnAdjustment Return;
105
106   ThunkInfo() { }
107
108   ThunkInfo(const ThisAdjustment &This, const ReturnAdjustment &Return)
109     : This(This), Return(Return) { }
110
111   friend bool operator==(const ThunkInfo &LHS, const ThunkInfo &RHS) {
112     return LHS.This == RHS.This && LHS.Return == RHS.Return;
113   }
114
115   friend bool operator<(const ThunkInfo &LHS, const ThunkInfo &RHS) {
116     if (LHS.This < RHS.This)
117       return true;
118       
119     return LHS.This == RHS.This && LHS.Return < RHS.Return;
120   }
121
122   bool isEmpty() const { return This.isEmpty() && Return.isEmpty(); }
123 };  
124
125 } // end namespace clang
126
127 #endif // CLANG_BASIC_ABI_H