]> granicus.if.org Git - clang/blob - lib/CodeGen/CGCXXABI.h
Go back to asking CodeGenTypes whether a type is zero-initializable.
[clang] / lib / CodeGen / CGCXXABI.h
1 //===----- CGCXXABI.h - Interface to C++ ABIs -------------------*- 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 // This provides an abstract class for C++ code generation. Concrete subclasses
11 // of this implement code generation for specific C++ ABIs.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef CLANG_CODEGEN_CXXABI_H
16 #define CLANG_CODEGEN_CXXABI_H
17
18 namespace llvm {
19   class Constant;
20   class Value;
21 }
22
23 namespace clang {
24   class CastExpr;
25   class CXXMethodDecl;
26   class CXXRecordDecl;
27   class MemberPointerType;
28   class QualType;
29
30 namespace CodeGen {
31   class CodeGenFunction;
32   class CodeGenModule;
33   class MangleContext;
34
35 /// Implements C++ ABI-specific code generation functions.
36 class CGCXXABI {
37 protected:
38   CodeGenModule &CGM;
39
40   CGCXXABI(CodeGenModule &CGM) : CGM(CGM) {}
41
42 public:
43
44   virtual ~CGCXXABI();
45
46   /// Gets the mangle context.
47   virtual MangleContext &getMangleContext() = 0;
48
49   virtual llvm::Value *
50   EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF,
51                                   llvm::Value *&This,
52                                   llvm::Value *MemPtr,
53                                   const MemberPointerType *MPT);
54
55   virtual llvm::Value *
56   EmitMemberFunctionPointerConversion(CodeGenFunction &CGF,
57                                       const CastExpr *E,
58                                       llvm::Value *Src);
59
60   // Manipulations on constant expressions.
61
62   /// \brief Returns true if the given member pointer can be
63   /// zero-initialized (in the C++ sense) with an LLVM
64   /// zeroinitialized.
65   virtual bool isZeroInitializable(const MemberPointerType *MPT);
66
67   virtual llvm::Constant *
68   EmitMemberFunctionPointerConversion(llvm::Constant *C,
69                                       const CastExpr *E);
70
71   virtual llvm::Constant *
72   EmitNullMemberFunctionPointer(const MemberPointerType *MPT);
73
74   virtual llvm::Constant *EmitMemberFunctionPointer(const CXXMethodDecl *MD);
75
76   virtual llvm::Value *
77   EmitMemberFunctionPointerComparison(CodeGenFunction &CGF,
78                                       llvm::Value *L,
79                                       llvm::Value *R,
80                                       const MemberPointerType *MPT,
81                                       bool Inequality);
82
83   virtual llvm::Value *
84   EmitMemberFunctionPointerIsNotNull(CodeGenFunction &CGF,
85                                      llvm::Value *MemPtr,
86                                      const MemberPointerType *MPT);
87 };
88
89 /// Creates an instance of a C++ ABI class.
90 CGCXXABI *CreateARMCXXABI(CodeGenModule &CGM);
91 CGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM);
92 CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM);
93
94 }
95 }
96
97 #endif