]> granicus.if.org Git - clang/blob - lib/CodeGen/CGCXXABI.h
Extract member function pointer comparison and null comparison into
[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 public:
38   virtual ~CGCXXABI();
39
40   /// Gets the mangle context.
41   virtual MangleContext &getMangleContext() = 0;
42
43   virtual llvm::Value *
44   EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF,
45                                   llvm::Value *&This,
46                                   llvm::Value *MemPtr,
47                                   const MemberPointerType *MPT);
48
49   virtual void
50   EmitMemberFunctionPointerConversion(CodeGenFunction &CGF,
51                                       const CastExpr *E,
52                                       llvm::Value *Src,
53                                       llvm::Value *Dest,
54                                       bool VolatileDest);
55
56   virtual void EmitNullMemberFunctionPointer(CodeGenFunction &CGF,
57                                              const MemberPointerType *MPT,
58                                              llvm::Value *Dest,
59                                              bool VolatileDest);
60   
61   // Manipulations on constant expressions.
62
63   /// \brief Returns true if zero-initializing the given type requires
64   /// a constant other than the LLVM null value.
65   virtual bool RequiresNonZeroInitializer(QualType T);
66   virtual bool RequiresNonZeroInitializer(const CXXRecordDecl *D);
67
68   virtual llvm::Constant *
69   EmitMemberFunctionPointerConversion(llvm::Constant *C,
70                                       const CastExpr *E);
71
72   virtual llvm::Constant *
73   EmitNullMemberFunctionPointer(const MemberPointerType *MPT);
74
75   virtual llvm::Constant *EmitMemberFunctionPointer(const CXXMethodDecl *MD);
76   virtual void EmitMemberFunctionPointer(CodeGenFunction &CGF,
77                                          const CXXMethodDecl *MD,
78                                          llvm::Value *DestPtr,
79                                          bool VolatileDest);
80
81   virtual llvm::Value *
82   EmitMemberFunctionPointerComparison(CodeGenFunction &CGF,
83                                       llvm::Value *L,
84                                       llvm::Value *R,
85                                       const MemberPointerType *MPT,
86                                       bool Inequality);
87
88   virtual llvm::Value *
89   EmitMemberFunctionPointerIsNotNull(CodeGenFunction &CGF,
90                                      llvm::Value *Addr,
91                                      const MemberPointerType *MPT);
92 };
93
94 /// Creates an instance of a C++ ABI class.
95 CGCXXABI *CreateARMCXXABI(CodeGenModule &CGM);
96 CGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM);
97 CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM);
98
99 }
100 }
101
102 #endif