clang API Documentation

ABI.h
Go to the documentation of this file.
00001 //===----- ABI.h - ABI related declarations ---------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // These enums/classes describe ABI related information about constructors,
00011 // destructors and thunks.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef CLANG_BASIC_ABI_H
00016 #define CLANG_BASIC_ABI_H
00017 
00018 #include "llvm/Support/DataTypes.h"
00019 
00020 namespace clang {
00021 
00022 /// CXXCtorType - C++ constructor types
00023 enum CXXCtorType {
00024     Ctor_Complete,          // Complete object ctor
00025     Ctor_Base,              // Base object ctor
00026     Ctor_CompleteAllocating // Complete object allocating ctor
00027 };
00028 
00029 /// CXXDtorType - C++ destructor types
00030 enum CXXDtorType {
00031     Dtor_Deleting, // Deleting dtor
00032     Dtor_Complete, // Complete object dtor
00033     Dtor_Base      // Base object dtor
00034 };
00035 
00036 /// ReturnAdjustment - A return adjustment.
00037 struct ReturnAdjustment {
00038   /// NonVirtual - The non-virtual adjustment from the derived object to its
00039   /// nearest virtual base.
00040   int64_t NonVirtual;
00041   
00042   /// VBaseOffsetOffset - The offset (in bytes), relative to the address point 
00043   /// of the virtual base class offset.
00044   int64_t VBaseOffsetOffset;
00045   
00046   ReturnAdjustment() : NonVirtual(0), VBaseOffsetOffset(0) { }
00047   
00048   bool isEmpty() const { return !NonVirtual && !VBaseOffsetOffset; }
00049 
00050   friend bool operator==(const ReturnAdjustment &LHS, 
00051                          const ReturnAdjustment &RHS) {
00052     return LHS.NonVirtual == RHS.NonVirtual && 
00053       LHS.VBaseOffsetOffset == RHS.VBaseOffsetOffset;
00054   }
00055 
00056   friend bool operator<(const ReturnAdjustment &LHS,
00057                         const ReturnAdjustment &RHS) {
00058     if (LHS.NonVirtual < RHS.NonVirtual)
00059       return true;
00060     
00061     return LHS.NonVirtual == RHS.NonVirtual && 
00062       LHS.VBaseOffsetOffset < RHS.VBaseOffsetOffset;
00063   }
00064 };
00065   
00066 /// ThisAdjustment - A 'this' pointer adjustment.
00067 struct ThisAdjustment {
00068   /// NonVirtual - The non-virtual adjustment from the derived object to its
00069   /// nearest virtual base.
00070   int64_t NonVirtual;
00071 
00072   /// VCallOffsetOffset - The offset (in bytes), relative to the address point,
00073   /// of the virtual call offset.
00074   int64_t VCallOffsetOffset;
00075   
00076   ThisAdjustment() : NonVirtual(0), VCallOffsetOffset(0) { }
00077 
00078   bool isEmpty() const { return !NonVirtual && !VCallOffsetOffset; }
00079 
00080   friend bool operator==(const ThisAdjustment &LHS, 
00081                          const ThisAdjustment &RHS) {
00082     return LHS.NonVirtual == RHS.NonVirtual && 
00083       LHS.VCallOffsetOffset == RHS.VCallOffsetOffset;
00084   }
00085   
00086   friend bool operator<(const ThisAdjustment &LHS,
00087                         const ThisAdjustment &RHS) {
00088     if (LHS.NonVirtual < RHS.NonVirtual)
00089       return true;
00090     
00091     return LHS.NonVirtual == RHS.NonVirtual && 
00092       LHS.VCallOffsetOffset < RHS.VCallOffsetOffset;
00093   }
00094 };
00095 
00096 /// ThunkInfo - The 'this' pointer adjustment as well as an optional return
00097 /// adjustment for a thunk.
00098 struct ThunkInfo {
00099   /// This - The 'this' pointer adjustment.
00100   ThisAdjustment This;
00101     
00102   /// Return - The return adjustment.
00103   ReturnAdjustment Return;
00104 
00105   ThunkInfo() { }
00106 
00107   ThunkInfo(const ThisAdjustment &This, const ReturnAdjustment &Return)
00108     : This(This), Return(Return) { }
00109 
00110   friend bool operator==(const ThunkInfo &LHS, const ThunkInfo &RHS) {
00111     return LHS.This == RHS.This && LHS.Return == RHS.Return;
00112   }
00113 
00114   friend bool operator<(const ThunkInfo &LHS, const ThunkInfo &RHS) {
00115     if (LHS.This < RHS.This)
00116       return true;
00117       
00118     return LHS.This == RHS.This && LHS.Return < RHS.Return;
00119   }
00120 
00121   bool isEmpty() const { return This.isEmpty() && Return.isEmpty(); }
00122 };  
00123 
00124 } // end namespace clang
00125 
00126 #endif // CLANG_BASIC_ABI_H