Charles Davis | 3a811f1 | 2010-05-25 19:52:27 +0000 | [diff] [blame] | 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 | |
John McCall | 93d557b | 2010-08-22 00:05:51 +0000 | [diff] [blame] | 18 | namespace llvm { |
John McCall | cf2c85e | 2010-08-22 04:16:24 +0000 | [diff] [blame] | 19 | class Constant; |
John McCall | 93d557b | 2010-08-22 00:05:51 +0000 | [diff] [blame] | 20 | class Value; |
| 21 | } |
| 22 | |
Charles Davis | 3a811f1 | 2010-05-25 19:52:27 +0000 | [diff] [blame] | 23 | namespace clang { |
John McCall | 3023def | 2010-08-22 03:04:22 +0000 | [diff] [blame] | 24 | class CastExpr; |
John McCall | 875ab10 | 2010-08-22 06:43:33 +0000 | [diff] [blame] | 25 | class CXXMethodDecl; |
John McCall | cf2c85e | 2010-08-22 04:16:24 +0000 | [diff] [blame] | 26 | class CXXRecordDecl; |
John McCall | 93d557b | 2010-08-22 00:05:51 +0000 | [diff] [blame] | 27 | class MemberPointerType; |
John McCall | cf2c85e | 2010-08-22 04:16:24 +0000 | [diff] [blame] | 28 | class QualType; |
John McCall | 93d557b | 2010-08-22 00:05:51 +0000 | [diff] [blame] | 29 | |
Charles Davis | 3a811f1 | 2010-05-25 19:52:27 +0000 | [diff] [blame] | 30 | namespace CodeGen { |
John McCall | 93d557b | 2010-08-22 00:05:51 +0000 | [diff] [blame] | 31 | class CodeGenFunction; |
Charles Davis | 3a811f1 | 2010-05-25 19:52:27 +0000 | [diff] [blame] | 32 | class CodeGenModule; |
| 33 | class MangleContext; |
| 34 | |
| 35 | /// Implements C++ ABI-specific code generation functions. |
Charles Davis | 071cc7d | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 36 | class CGCXXABI { |
Charles Davis | 3a811f1 | 2010-05-25 19:52:27 +0000 | [diff] [blame] | 37 | public: |
Charles Davis | 071cc7d | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 38 | virtual ~CGCXXABI(); |
Charles Davis | 3a811f1 | 2010-05-25 19:52:27 +0000 | [diff] [blame] | 39 | |
| 40 | /// Gets the mangle context. |
| 41 | virtual MangleContext &getMangleContext() = 0; |
John McCall | 93d557b | 2010-08-22 00:05:51 +0000 | [diff] [blame] | 42 | |
| 43 | virtual llvm::Value * |
| 44 | EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF, |
| 45 | llvm::Value *&This, |
| 46 | llvm::Value *MemPtr, |
| 47 | const MemberPointerType *MPT); |
John McCall | 3023def | 2010-08-22 03:04:22 +0000 | [diff] [blame] | 48 | |
John McCall | cf2c85e | 2010-08-22 04:16:24 +0000 | [diff] [blame] | 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); |
John McCall | 875ab10 | 2010-08-22 06:43:33 +0000 | [diff] [blame] | 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); |
Charles Davis | 3a811f1 | 2010-05-25 19:52:27 +0000 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | /// Creates an instance of a C++ ABI class. |
John McCall | ee79a4c | 2010-08-21 22:46:04 +0000 | [diff] [blame] | 83 | CGCXXABI *CreateARMCXXABI(CodeGenModule &CGM); |
Charles Davis | 071cc7d | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 84 | CGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM); |
| 85 | CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM); |
John McCall | 93d557b | 2010-08-22 00:05:51 +0000 | [diff] [blame] | 86 | |
Charles Davis | 3a811f1 | 2010-05-25 19:52:27 +0000 | [diff] [blame] | 87 | } |
| 88 | } |
| 89 | |
| 90 | #endif |