1 //===----- CGCXXABI.h - Interface to C++ ABIs -------------------*- 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 // This provides an abstract class for C++ code generation. Concrete subclasses
11 // of this implement code generation for specific C++ ABIs.
13 //===----------------------------------------------------------------------===//
15 #ifndef CLANG_CODEGEN_CXXABI_H
16 #define CLANG_CODEGEN_CXXABI_H
29 class MemberPointerType;
33 class CodeGenFunction;
37 /// Implements C++ ABI-specific code generation functions.
42 CGCXXABI(CodeGenModule &CGM) : CGM(CGM) {}
48 /// Gets the mangle context.
49 virtual MangleContext &getMangleContext() = 0;
51 /// Find the LLVM type used to represent the given member pointer
53 virtual const llvm::Type *
54 ConvertMemberPointerType(const MemberPointerType *MPT);
56 /// Load a member function from an object and a member function
57 /// pointer. Apply the this-adjustment and set 'This' to the
60 EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF,
63 const MemberPointerType *MPT);
65 /// Perform a derived-to-base or base-to-derived member pointer
67 virtual llvm::Value *EmitMemberPointerConversion(CodeGenFunction &CGF,
71 /// Perform a derived-to-base or base-to-derived member pointer
72 /// conversion on a constant member pointer.
73 virtual llvm::Constant *EmitMemberPointerConversion(llvm::Constant *C,
76 /// Return true if the given member pointer can be zero-initialized
77 /// (in the C++ sense) with an LLVM zeroinitializer.
78 virtual bool isZeroInitializable(const MemberPointerType *MPT);
80 /// Create a null member pointer of the given type.
81 virtual llvm::Constant *EmitNullMemberPointer(const MemberPointerType *MPT);
83 /// Create a member pointer for the given method.
84 virtual llvm::Constant *EmitMemberPointer(const CXXMethodDecl *MD);
86 /// Create a member pointer for the given field.
87 virtual llvm::Constant *EmitMemberPointer(const FieldDecl *FD);
89 /// Emit a comparison between two member pointers. Returns an i1.
91 EmitMemberPointerComparison(CodeGenFunction &CGF,
94 const MemberPointerType *MPT,
97 /// Determine if a member pointer is non-null. Returns an i1.
99 EmitMemberPointerIsNotNull(CodeGenFunction &CGF,
101 const MemberPointerType *MPT);
104 /// Creates an instance of a C++ ABI class.
105 CGCXXABI *CreateARMCXXABI(CodeGenModule &CGM);
106 CGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM);
107 CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM);