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 { |
John McCall | d608cdb | 2010-08-22 10:59:02 +0000 | [diff] [blame] | 37 | protected: |
| 38 | CodeGenModule &CGM; |
| 39 | |
| 40 | CGCXXABI(CodeGenModule &CGM) : CGM(CGM) {} |
| 41 | |
Charles Davis | 3a811f1 | 2010-05-25 19:52:27 +0000 | [diff] [blame] | 42 | public: |
John McCall | d608cdb | 2010-08-22 10:59:02 +0000 | [diff] [blame] | 43 | |
Charles Davis | 071cc7d | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 44 | virtual ~CGCXXABI(); |
Charles Davis | 3a811f1 | 2010-05-25 19:52:27 +0000 | [diff] [blame] | 45 | |
| 46 | /// Gets the mangle context. |
| 47 | virtual MangleContext &getMangleContext() = 0; |
John McCall | 93d557b | 2010-08-22 00:05:51 +0000 | [diff] [blame] | 48 | |
| 49 | virtual llvm::Value * |
| 50 | EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF, |
| 51 | llvm::Value *&This, |
| 52 | llvm::Value *MemPtr, |
| 53 | const MemberPointerType *MPT); |
John McCall | 3023def | 2010-08-22 03:04:22 +0000 | [diff] [blame] | 54 | |
John McCall | d608cdb | 2010-08-22 10:59:02 +0000 | [diff] [blame] | 55 | virtual llvm::Value * |
John McCall | cf2c85e | 2010-08-22 04:16:24 +0000 | [diff] [blame] | 56 | EmitMemberFunctionPointerConversion(CodeGenFunction &CGF, |
| 57 | const CastExpr *E, |
John McCall | d608cdb | 2010-08-22 10:59:02 +0000 | [diff] [blame] | 58 | llvm::Value *Src); |
John McCall | cf2c85e | 2010-08-22 04:16:24 +0000 | [diff] [blame] | 59 | |
John McCall | cf2c85e | 2010-08-22 04:16:24 +0000 | [diff] [blame] | 60 | // Manipulations on constant expressions. |
| 61 | |
John McCall | f16aa10 | 2010-08-22 21:01:12 +0000 | [diff] [blame^] | 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); |
John McCall | cf2c85e | 2010-08-22 04:16:24 +0000 | [diff] [blame] | 66 | |
| 67 | virtual llvm::Constant * |
| 68 | EmitMemberFunctionPointerConversion(llvm::Constant *C, |
| 69 | const CastExpr *E); |
| 70 | |
| 71 | virtual llvm::Constant * |
| 72 | EmitNullMemberFunctionPointer(const MemberPointerType *MPT); |
John McCall | 875ab10 | 2010-08-22 06:43:33 +0000 | [diff] [blame] | 73 | |
| 74 | virtual llvm::Constant *EmitMemberFunctionPointer(const CXXMethodDecl *MD); |
John McCall | e9fd7eb | 2010-08-22 08:30:07 +0000 | [diff] [blame] | 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, |
John McCall | d608cdb | 2010-08-22 10:59:02 +0000 | [diff] [blame] | 85 | llvm::Value *MemPtr, |
John McCall | e9fd7eb | 2010-08-22 08:30:07 +0000 | [diff] [blame] | 86 | const MemberPointerType *MPT); |
Charles Davis | 3a811f1 | 2010-05-25 19:52:27 +0000 | [diff] [blame] | 87 | }; |
| 88 | |
| 89 | /// Creates an instance of a C++ ABI class. |
John McCall | ee79a4c | 2010-08-21 22:46:04 +0000 | [diff] [blame] | 90 | CGCXXABI *CreateARMCXXABI(CodeGenModule &CGM); |
Charles Davis | 071cc7d | 2010-08-16 03:33:14 +0000 | [diff] [blame] | 91 | CGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM); |
| 92 | CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM); |
John McCall | 93d557b | 2010-08-22 00:05:51 +0000 | [diff] [blame] | 93 | |
Charles Davis | 3a811f1 | 2010-05-25 19:52:27 +0000 | [diff] [blame] | 94 | } |
| 95 | } |
| 96 | |
| 97 | #endif |