]> granicus.if.org Git - clang/blob - lib/CodeGen/CGCXXABI.h
Abstract more member-pointerness out.
[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 CXXRecordDecl;
26   class MemberPointerType;
27   class QualType;
28
29 namespace CodeGen {
30   class CodeGenFunction;
31   class CodeGenModule;
32   class MangleContext;
33
34 /// Implements C++ ABI-specific code generation functions.
35 class CGCXXABI {
36 public:
37   virtual ~CGCXXABI();
38
39   /// Gets the mangle context.
40   virtual MangleContext &getMangleContext() = 0;
41
42   virtual llvm::Value *
43   EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF,
44                                   llvm::Value *&This,
45                                   llvm::Value *MemPtr,
46                                   const MemberPointerType *MPT);
47
48   virtual void
49   EmitMemberFunctionPointerConversion(CodeGenFunction &CGF,
50                                       const CastExpr *E,
51                                       llvm::Value *Src,
52                                       llvm::Value *Dest,
53                                       bool VolatileDest);
54
55   virtual void EmitNullMemberFunctionPointer(CodeGenFunction &CGF,
56                                              const MemberPointerType *MPT,
57                                              llvm::Value *Dest,
58                                              bool VolatileDest);
59   
60   // Manipulations on constant expressions.
61
62   /// \brief Returns true if zero-initializing the given type requires
63   /// a constant other than the LLVM null value.
64   virtual bool RequiresNonZeroInitializer(QualType T);
65   virtual bool RequiresNonZeroInitializer(const CXXRecordDecl *D);
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
75 /// Creates an instance of a C++ ABI class.
76 CGCXXABI *CreateARMCXXABI(CodeGenModule &CGM);
77 CGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM);
78 CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM);
79
80 }
81 }
82
83 #endif