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 //===----------------------------------------------------------------------===//
10 // These enums/classes describe ABI related information about constructors,
11 // destructors and thunks.
13 //===----------------------------------------------------------------------===//
15 #ifndef CLANG_BASIC_ABI_H
16 #define CLANG_BASIC_ABI_H
18 #include "llvm/Support/DataTypes.h"
22 /// CXXCtorType - C++ constructor types
24 Ctor_Complete, // Complete object ctor
25 Ctor_Base, // Base object ctor
26 Ctor_CompleteAllocating // Complete object allocating ctor
29 /// CXXDtorType - C++ destructor types
31 Dtor_Deleting, // Deleting dtor
32 Dtor_Complete, // Complete object dtor
33 Dtor_Base // Base object dtor
36 /// ReturnAdjustment - A return adjustment.
37 struct ReturnAdjustment {
38 /// NonVirtual - The non-virtual adjustment from the derived object to its
39 /// nearest virtual base.
42 /// VBaseOffsetOffset - The offset (in bytes), relative to the address point
43 /// of the virtual base class offset.
44 int64_t VBaseOffsetOffset;
46 ReturnAdjustment() : NonVirtual(0), VBaseOffsetOffset(0) { }
48 bool isEmpty() const { return !NonVirtual && !VBaseOffsetOffset; }
50 friend bool operator==(const ReturnAdjustment &LHS,
51 const ReturnAdjustment &RHS) {
52 return LHS.NonVirtual == RHS.NonVirtual &&
53 LHS.VBaseOffsetOffset == RHS.VBaseOffsetOffset;
56 friend bool operator<(const ReturnAdjustment &LHS,
57 const ReturnAdjustment &RHS) {
58 if (LHS.NonVirtual < RHS.NonVirtual)
61 return LHS.NonVirtual == RHS.NonVirtual &&
62 LHS.VBaseOffsetOffset < RHS.VBaseOffsetOffset;
66 /// ThisAdjustment - A 'this' pointer adjustment.
67 struct ThisAdjustment {
68 /// NonVirtual - The non-virtual adjustment from the derived object to its
69 /// nearest virtual base.
72 /// VCallOffsetOffset - The offset (in bytes), relative to the address point,
73 /// of the virtual call offset.
74 int64_t VCallOffsetOffset;
76 ThisAdjustment() : NonVirtual(0), VCallOffsetOffset(0) { }
78 bool isEmpty() const { return !NonVirtual && !VCallOffsetOffset; }
80 friend bool operator==(const ThisAdjustment &LHS,
81 const ThisAdjustment &RHS) {
82 return LHS.NonVirtual == RHS.NonVirtual &&
83 LHS.VCallOffsetOffset == RHS.VCallOffsetOffset;
86 friend bool operator<(const ThisAdjustment &LHS,
87 const ThisAdjustment &RHS) {
88 if (LHS.NonVirtual < RHS.NonVirtual)
91 return LHS.NonVirtual == RHS.NonVirtual &&
92 LHS.VCallOffsetOffset < RHS.VCallOffsetOffset;
96 /// ThunkInfo - The 'this' pointer adjustment as well as an optional return
97 /// adjustment for a thunk.
99 /// This - The 'this' pointer adjustment.
102 /// Return - The return adjustment.
103 ReturnAdjustment Return;
107 ThunkInfo(const ThisAdjustment &This, const ReturnAdjustment &Return)
108 : This(This), Return(Return) { }
110 friend bool operator==(const ThunkInfo &LHS, const ThunkInfo &RHS) {
111 return LHS.This == RHS.This && LHS.Return == RHS.Return;
114 friend bool operator<(const ThunkInfo &LHS, const ThunkInfo &RHS) {
115 if (LHS.This < RHS.This)
118 return LHS.This == RHS.This && LHS.Return < RHS.Return;
121 bool isEmpty() const { return This.isEmpty() && Return.isEmpty(); }
124 } // end namespace clang
126 #endif // CLANG_BASIC_ABI_H