1 //===----- ABI.h - ABI related declarations ---------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief Enums/classes describing ABI related information about constructors,
12 /// destructors and thunks.
14 //===----------------------------------------------------------------------===//
16 #ifndef CLANG_BASIC_ABI_H
17 #define CLANG_BASIC_ABI_H
19 #include "llvm/Support/DataTypes.h"
23 /// \brief C++ constructor types.
25 Ctor_Complete, ///< Complete object ctor
26 Ctor_Base, ///< Base object ctor
27 Ctor_CompleteAllocating ///< Complete object allocating ctor
30 /// \brief C++ destructor types.
32 Dtor_Deleting, ///< Deleting dtor
33 Dtor_Complete, ///< Complete object dtor
34 Dtor_Base ///< Base object dtor
37 /// \brief A return adjustment.
38 struct ReturnAdjustment {
39 /// \brief The non-virtual adjustment from the derived object to its
40 /// nearest virtual base.
43 /// \brief The offset (in bytes), relative to the address point
44 /// of the virtual base class offset.
45 int64_t VBaseOffsetOffset;
47 ReturnAdjustment() : NonVirtual(0), VBaseOffsetOffset(0) { }
49 bool isEmpty() const { return !NonVirtual && !VBaseOffsetOffset; }
51 friend bool operator==(const ReturnAdjustment &LHS,
52 const ReturnAdjustment &RHS) {
53 return LHS.NonVirtual == RHS.NonVirtual &&
54 LHS.VBaseOffsetOffset == RHS.VBaseOffsetOffset;
57 friend bool operator<(const ReturnAdjustment &LHS,
58 const ReturnAdjustment &RHS) {
59 if (LHS.NonVirtual < RHS.NonVirtual)
62 return LHS.NonVirtual == RHS.NonVirtual &&
63 LHS.VBaseOffsetOffset < RHS.VBaseOffsetOffset;
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.
73 /// \brief The offset (in bytes), relative to the address point,
74 /// of the virtual call offset.
75 int64_t VCallOffsetOffset;
77 ThisAdjustment() : NonVirtual(0), VCallOffsetOffset(0) { }
79 bool isEmpty() const { return !NonVirtual && !VCallOffsetOffset; }
81 friend bool operator==(const ThisAdjustment &LHS,
82 const ThisAdjustment &RHS) {
83 return LHS.NonVirtual == RHS.NonVirtual &&
84 LHS.VCallOffsetOffset == RHS.VCallOffsetOffset;
87 friend bool operator<(const ThisAdjustment &LHS,
88 const ThisAdjustment &RHS) {
89 if (LHS.NonVirtual < RHS.NonVirtual)
92 return LHS.NonVirtual == RHS.NonVirtual &&
93 LHS.VCallOffsetOffset < RHS.VCallOffsetOffset;
97 /// \brief The \c this pointer adjustment as well as an optional return
98 /// adjustment for a thunk.
100 /// \brief The \c this pointer adjustment.
103 /// \brief The return adjustment.
104 ReturnAdjustment Return;
108 ThunkInfo(const ThisAdjustment &This, const ReturnAdjustment &Return)
109 : This(This), Return(Return) { }
111 friend bool operator==(const ThunkInfo &LHS, const ThunkInfo &RHS) {
112 return LHS.This == RHS.This && LHS.Return == RHS.Return;
115 friend bool operator<(const ThunkInfo &LHS, const ThunkInfo &RHS) {
116 if (LHS.This < RHS.This)
119 return LHS.This == RHS.This && LHS.Return < RHS.Return;
122 bool isEmpty() const { return This.isEmpty() && Return.isEmpty(); }
125 } // end namespace clang
127 #endif // CLANG_BASIC_ABI_H