blob: a07b98c1eaeb199edafbdac5cec7815f4e2924cf [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 {
Charles Davis3a811f12010-05-25 19:52:27 +000037public:
Charles Davis071cc7d2010-08-16 03:33:14 +000038 virtual ~CGCXXABI();
Charles Davis3a811f12010-05-25 19:52:27 +000039
40 /// Gets the mangle context.
41 virtual MangleContext &getMangleContext() = 0;
John McCall93d557b2010-08-22 00:05:51 +000042
43 virtual llvm::Value *
44 EmitLoadOfMemberFunctionPointer(CodeGenFunction &CGF,
45 llvm::Value *&This,
46 llvm::Value *MemPtr,
47 const MemberPointerType *MPT);
John McCall3023def2010-08-22 03:04:22 +000048
John McCallcf2c85e2010-08-22 04:16:24 +000049 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 McCall875ab102010-08-22 06:43:33 +000074
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 Davis3a811f12010-05-25 19:52:27 +000080};
81
82/// Creates an instance of a C++ ABI class.
John McCallee79a4c2010-08-21 22:46:04 +000083CGCXXABI *CreateARMCXXABI(CodeGenModule &CGM);
Charles Davis071cc7d2010-08-16 03:33:14 +000084CGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM);
85CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM);
John McCall93d557b2010-08-22 00:05:51 +000086
Charles Davis3a811f12010-05-25 19:52:27 +000087}
88}
89
90#endif