blob: c248f1d64d4a1dee9916cd79dee5aca824f29fcb [file] [log] [blame]
Charles Davis3a811f12010-05-25 19:52:27 +00001//===----- 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 McCall93d557b2010-08-22 00:05:51 +000018namespace llvm {
John McCallcf2c85e2010-08-22 04:16:24 +000019 class Constant;
John McCall93d557b2010-08-22 00:05:51 +000020 class Value;
21}
22
Charles Davis3a811f12010-05-25 19:52:27 +000023namespace clang {
John McCall3023def2010-08-22 03:04:22 +000024 class CastExpr;
John McCall875ab102010-08-22 06:43:33 +000025 class CXXMethodDecl;
John McCallcf2c85e2010-08-22 04:16:24 +000026 class CXXRecordDecl;
John McCall93d557b2010-08-22 00:05:51 +000027 class MemberPointerType;
John McCallcf2c85e2010-08-22 04:16:24 +000028 class QualType;
John McCall93d557b2010-08-22 00:05:51 +000029
Charles Davis3a811f12010-05-25 19:52:27 +000030namespace CodeGen {
John McCall93d557b2010-08-22 00:05:51 +000031 class CodeGenFunction;
Charles Davis3a811f12010-05-25 19:52:27 +000032 class CodeGenModule;
33 class MangleContext;
34
35/// Implements C++ ABI-specific code generation functions.
Charles Davis071cc7d2010-08-16 03:33:14 +000036class CGCXXABI {
John McCalld608cdb2010-08-22 10:59:02 +000037protected:
38 CodeGenModule &CGM;
39
40 CGCXXABI(CodeGenModule &CGM) : CGM(CGM) {}
41
Charles Davis3a811f12010-05-25 19:52:27 +000042public:
John McCalld608cdb2010-08-22 10:59:02 +000043
Charles Davis071cc7d2010-08-16 03:33:14 +000044 virtual ~CGCXXABI();
Charles Davis3a811f12010-05-25 19:52:27 +000045
46 /// Gets the mangle context.
47 virtual MangleContext &getMangleContext() = 0;
John McCall93d557b2010-08-22 00:05:51 +000048
49 virtual llvm::Value *
50 EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF,
51 llvm::Value *&This,
52 llvm::Value *MemPtr,
53 const MemberPointerType *MPT);
John McCall3023def2010-08-22 03:04:22 +000054
John McCalld608cdb2010-08-22 10:59:02 +000055 virtual llvm::Value *
John McCallcf2c85e2010-08-22 04:16:24 +000056 EmitMemberFunctionPointerConversion(CodeGenFunction &CGF,
57 const CastExpr *E,
John McCalld608cdb2010-08-22 10:59:02 +000058 llvm::Value *Src);
John McCallcf2c85e2010-08-22 04:16:24 +000059
John McCallcf2c85e2010-08-22 04:16:24 +000060 // Manipulations on constant expressions.
61
John McCallf16aa102010-08-22 21:01:12 +000062 /// \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 McCallcf2c85e2010-08-22 04:16:24 +000066
67 virtual llvm::Constant *
68 EmitMemberFunctionPointerConversion(llvm::Constant *C,
69 const CastExpr *E);
70
71 virtual llvm::Constant *
72 EmitNullMemberFunctionPointer(const MemberPointerType *MPT);
John McCall875ab102010-08-22 06:43:33 +000073
74 virtual llvm::Constant *EmitMemberFunctionPointer(const CXXMethodDecl *MD);
John McCalle9fd7eb2010-08-22 08:30:07 +000075
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 McCalld608cdb2010-08-22 10:59:02 +000085 llvm::Value *MemPtr,
John McCalle9fd7eb2010-08-22 08:30:07 +000086 const MemberPointerType *MPT);
Charles Davis3a811f12010-05-25 19:52:27 +000087};
88
89/// Creates an instance of a C++ ABI class.
John McCallee79a4c2010-08-21 22:46:04 +000090CGCXXABI *CreateARMCXXABI(CodeGenModule &CGM);
Charles Davis071cc7d2010-08-16 03:33:14 +000091CGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM);
92CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM);
John McCall93d557b2010-08-22 00:05:51 +000093
Charles Davis3a811f12010-05-25 19:52:27 +000094}
95}
96
97#endif