13a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis//===----- CGCXXABI.h - Interface to C++ ABIs -------------------*- C++ -*-===// 23a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// 33a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// The LLVM Compiler Infrastructure 43a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// 53a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// This file is distributed under the University of Illinois Open Source 63a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// License. See LICENSE.TXT for details. 73a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// 83a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis//===----------------------------------------------------------------------===// 93a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// 103a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// This provides an abstract class for C++ code generation. Concrete subclasses 113a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// of this implement code generation for specific C++ ABIs. 123a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis// 133a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis//===----------------------------------------------------------------------===// 143a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis 153a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis#ifndef CLANG_CODEGEN_CXXABI_H 163a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis#define CLANG_CODEGEN_CXXABI_H 173a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis 184c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall#include "CodeGenFunction.h" 1955fc873017f10f6f566b182b70f6fc22aefa3464Chandler Carruth#include "clang/Basic/LLVM.h" 204c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall 2193d557bc1867b7d7b102f87290194b4be7932c92John McCallnamespace llvm { 226bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesclass Constant; 236bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesclass Type; 246bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesclass Value; 2593d557bc1867b7d7b102f87290194b4be7932c92John McCall} 2693d557bc1867b7d7b102f87290194b4be7932c92John McCall 273a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davisnamespace clang { 286bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesclass CastExpr; 296bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesclass CXXConstructorDecl; 306bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesclass CXXDestructorDecl; 316bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesclass CXXMethodDecl; 326bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesclass CXXRecordDecl; 336bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesclass FieldDecl; 346bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesclass MangleContext; 3593d557bc1867b7d7b102f87290194b4be7932c92John McCall 363a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davisnamespace CodeGen { 376bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesclass CodeGenFunction; 386bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hinesclass CodeGenModule; 393a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis 403b2adf237ab033173d7789ec1214d654eec17697James Dennett/// \brief Implements C++ ABI-specific code generation functions. 41071cc7deffad608165b1ddd5263e8bf181861520Charles Davisclass CGCXXABI { 42d608cdb7c044365cf4e8764ade1e11e99c176078John McCallprotected: 43d608cdb7c044365cf4e8764ade1e11e99c176078John McCall CodeGenModule &CGM; 44651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines std::unique_ptr<MangleContext> MangleCtx; 45d608cdb7c044365cf4e8764ade1e11e99c176078John McCall 4614110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne CGCXXABI(CodeGenModule &CGM) 4714110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne : CGM(CGM), MangleCtx(CGM.getContext().createMangleContext()) {} 48d608cdb7c044365cf4e8764ade1e11e99c176078John McCall 494c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCallprotected: 504c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall ImplicitParamDecl *&getThisDecl(CodeGenFunction &CGF) { 51cec5ebd4a6a89a7023d04cec728fd340b541ed61Eli Friedman return CGF.CXXABIThisDecl; 524c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall } 534c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall llvm::Value *&getThisValue(CodeGenFunction &CGF) { 54cec5ebd4a6a89a7023d04cec728fd340b541ed61Eli Friedman return CGF.CXXABIThisValue; 554c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall } 564c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall 57a8a0f769ff4113a7f98c232fb0fc773a65371559Reid Kleckner /// Issue a diagnostic about unsupported features in the ABI. 58a8a0f769ff4113a7f98c232fb0fc773a65371559Reid Kleckner void ErrorUnsupportedABI(CodeGenFunction &CGF, StringRef S); 59a8a0f769ff4113a7f98c232fb0fc773a65371559Reid Kleckner 60a8a0f769ff4113a7f98c232fb0fc773a65371559Reid Kleckner /// Get a null value for unsupported member pointers. 61a8a0f769ff4113a7f98c232fb0fc773a65371559Reid Kleckner llvm::Constant *GetBogusMemberPointer(QualType T); 62a8a0f769ff4113a7f98c232fb0fc773a65371559Reid Kleckner 6359660c21178b6af518bd4b564e032d5c9cc218cbTimur Iskhodzhanov ImplicitParamDecl *&getStructorImplicitParamDecl(CodeGenFunction &CGF) { 6459660c21178b6af518bd4b564e032d5c9cc218cbTimur Iskhodzhanov return CGF.CXXStructorImplicitParamDecl; 6559660c21178b6af518bd4b564e032d5c9cc218cbTimur Iskhodzhanov } 6659660c21178b6af518bd4b564e032d5c9cc218cbTimur Iskhodzhanov llvm::Value *&getStructorImplicitParamValue(CodeGenFunction &CGF) { 6759660c21178b6af518bd4b564e032d5c9cc218cbTimur Iskhodzhanov return CGF.CXXStructorImplicitParamValue; 684c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall } 694c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall 704c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall /// Perform prolog initialization of the parameter variable suitable 71651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// for 'this' emitted by buildThisParam. 724c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall void EmitThisParam(CodeGenFunction &CGF); 734c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall 741e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall ASTContext &getContext() const { return CGM.getContext(); } 751e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall 76e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall virtual bool requiresArrayCookie(const CXXDeleteExpr *E, QualType eltType); 77e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall virtual bool requiresArrayCookie(const CXXNewExpr *E); 78e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall 793a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davispublic: 80d608cdb7c044365cf4e8764ade1e11e99c176078John McCall 811af610f8533b8b4a7b0b176aa8082f5b6dde904cAnders Carlsson virtual ~CGCXXABI(); 823a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis 833a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis /// Gets the mangle context. 8414110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne MangleContext &getMangleContext() { 8514110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne return *MangleCtx; 8614110477887e3dc168ffc6c191e72d705051f99ePeter Collingbourne } 8793d557bc1867b7d7b102f87290194b4be7932c92John McCall 883b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// Returns true if the given constructor or destructor is one of the 893b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// kinds that the ABI says returns 'this' (only applies when called 903b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// non-virtually for destructors). 913b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// 923b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// There currently is no way to indicate if a destructor returns 'this' 933b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// when called virtually, and code generation does not support the case. 9463fd408a61ae9b94e8d8a986832f526f7cdbfa84Manman Ren virtual bool HasThisReturn(GlobalDecl GD) const { return false; } 9563fd408a61ae9b94e8d8a986832f526f7cdbfa84Manman Ren 966bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// If the C++ ABI requires the given type be returned in a particular way, 976bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// this method sets RetAI and returns true. 986bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines virtual bool classifyReturnType(CGFunctionInfo &FI) const = 0; 99ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov 100ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov /// Specify how one should pass an argument of a record type. 101ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov enum RecordArgABI { 102ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov /// Pass it using the normal C aggregate rules for the ABI, potentially 103ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov /// introducing extra copies and passing some or all of it in registers. 104ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov RAA_Default = 0, 105ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov 106ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov /// Pass it on the stack using its defined layout. The argument must be 107ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov /// evaluated directly into the correct stack position in the arguments area, 108ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov /// and the call machinery must not move it or introduce extra copies. 109ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov RAA_DirectInMemory, 110ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov 111ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov /// Pass it as a pointer to temporary memory. 112ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov RAA_Indirect 113ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov }; 114ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov 1156bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// Returns true if C++ allows us to copy the memory of an object of type RD 1166bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// when it is passed as an argument. 1176bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines bool canCopyArgument(const CXXRecordDecl *RD) const; 1186bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 119ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov /// Returns how an argument of the given record type should be passed. 120ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov virtual RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const = 0; 121ed23bdf69dd63e4fd01c02b12a13d1e6cbff9c2fTimur Iskhodzhanov 1226bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// Returns true if the implicit 'sret' parameter comes after the implicit 1236bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines /// 'this' parameter of C++ instance methods. 1246bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines virtual bool isSRetParameterAfterThis() const { return false; } 1256bcf27bb9a4b5c3f79cb44c0e4654a6d7619ad89Stephen Hines 1260bab0cdab751248ca389a5592bcb70eac5d39260John McCall /// Find the LLVM type used to represent the given member pointer 1270bab0cdab751248ca389a5592bcb70eac5d39260John McCall /// type. 1289cbe4f0ba01ec304e1e3d071c071f7bca33631c0Chris Lattner virtual llvm::Type * 1290bab0cdab751248ca389a5592bcb70eac5d39260John McCall ConvertMemberPointerType(const MemberPointerType *MPT); 1300bab0cdab751248ca389a5592bcb70eac5d39260John McCall 1310bab0cdab751248ca389a5592bcb70eac5d39260John McCall /// Load a member function from an object and a member function 1320bab0cdab751248ca389a5592bcb70eac5d39260John McCall /// pointer. Apply the this-adjustment and set 'This' to the 1330bab0cdab751248ca389a5592bcb70eac5d39260John McCall /// adjusted value. 134651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines virtual llvm::Value *EmitLoadOfMemberFunctionPointer( 135651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines CodeGenFunction &CGF, const Expr *E, llvm::Value *&This, 136651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines llvm::Value *MemPtr, const MemberPointerType *MPT); 1373023def6bea3af6dbb51eea51f8cb8ea892d26cfJohn McCall 1386c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall /// Calculate an l-value from an object and a data member pointer. 139651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines virtual llvm::Value * 140651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines EmitMemberDataPointerAddress(CodeGenFunction &CGF, const Expr *E, 141651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines llvm::Value *Base, llvm::Value *MemPtr, 142651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines const MemberPointerType *MPT); 1436c2ab1d578c6cc1f3ddcc948532cd625f1092ef2John McCall 1444d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall /// Perform a derived-to-base, base-to-derived, or bitcast member 1454d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall /// pointer conversion. 1460bab0cdab751248ca389a5592bcb70eac5d39260John McCall virtual llvm::Value *EmitMemberPointerConversion(CodeGenFunction &CGF, 1470bab0cdab751248ca389a5592bcb70eac5d39260John McCall const CastExpr *E, 1480bab0cdab751248ca389a5592bcb70eac5d39260John McCall llvm::Value *Src); 149d608cdb7c044365cf4e8764ade1e11e99c176078John McCall 1504d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall /// Perform a derived-to-base, base-to-derived, or bitcast member 1514d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall /// pointer conversion on a constant value. 1524d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall virtual llvm::Constant *EmitMemberPointerConversion(const CastExpr *E, 1534d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall llvm::Constant *Src); 1544d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall 1550bab0cdab751248ca389a5592bcb70eac5d39260John McCall /// Return true if the given member pointer can be zero-initialized 1560bab0cdab751248ca389a5592bcb70eac5d39260John McCall /// (in the C++ sense) with an LLVM zeroinitializer. 157f16aa103d3afd42fbca2ab346f191bf745cec092John McCall virtual bool isZeroInitializable(const MemberPointerType *MPT); 158cf2c85e76fdafe7e634810a292321a6c8322483dJohn McCall 1590bab0cdab751248ca389a5592bcb70eac5d39260John McCall /// Create a null member pointer of the given type. 1600bab0cdab751248ca389a5592bcb70eac5d39260John McCall virtual llvm::Constant *EmitNullMemberPointer(const MemberPointerType *MPT); 161cf2c85e76fdafe7e634810a292321a6c8322483dJohn McCall 1620bab0cdab751248ca389a5592bcb70eac5d39260John McCall /// Create a member pointer for the given method. 163755d8497e39071aa24acc173ff07083e3256b8f8John McCall virtual llvm::Constant *EmitMemberPointer(const CXXMethodDecl *MD); 164875ab10245d3bf37252dd822aa1616bb0a391095John McCall 1650bab0cdab751248ca389a5592bcb70eac5d39260John McCall /// Create a member pointer for the given field. 1665808ce43f8d7e71f5acacc9ca320268c4f37565aJohn McCall virtual llvm::Constant *EmitMemberDataPointer(const MemberPointerType *MPT, 1675808ce43f8d7e71f5acacc9ca320268c4f37565aJohn McCall CharUnits offset); 168e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall 1692d6a5670465cb3f1d811695a9f23e372508240d2Richard Smith /// Create a member pointer for the given member pointer constant. 1702d6a5670465cb3f1d811695a9f23e372508240d2Richard Smith virtual llvm::Constant *EmitMemberPointer(const APValue &MP, QualType MPT); 1712d6a5670465cb3f1d811695a9f23e372508240d2Richard Smith 1720bab0cdab751248ca389a5592bcb70eac5d39260John McCall /// Emit a comparison between two member pointers. Returns an i1. 173e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall virtual llvm::Value * 1740bab0cdab751248ca389a5592bcb70eac5d39260John McCall EmitMemberPointerComparison(CodeGenFunction &CGF, 1750bab0cdab751248ca389a5592bcb70eac5d39260John McCall llvm::Value *L, 1760bab0cdab751248ca389a5592bcb70eac5d39260John McCall llvm::Value *R, 1770bab0cdab751248ca389a5592bcb70eac5d39260John McCall const MemberPointerType *MPT, 1780bab0cdab751248ca389a5592bcb70eac5d39260John McCall bool Inequality); 179e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall 1800bab0cdab751248ca389a5592bcb70eac5d39260John McCall /// Determine if a member pointer is non-null. Returns an i1. 181e9fd7eb6c67676dc27e84eac429aec4f3be51f26John McCall virtual llvm::Value * 1820bab0cdab751248ca389a5592bcb70eac5d39260John McCall EmitMemberPointerIsNotNull(CodeGenFunction &CGF, 1830bab0cdab751248ca389a5592bcb70eac5d39260John McCall llvm::Value *MemPtr, 1840bab0cdab751248ca389a5592bcb70eac5d39260John McCall const MemberPointerType *MPT); 1854c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall 1864d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCallprotected: 1874d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall /// A utility method for computing the offset required for the given 1884d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall /// base-to-derived or derived-to-base member-pointer conversion. 1894d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall /// Does not handle virtual conversions (in case we ever fully 1904d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall /// support an ABI that allows this). Returns null if no adjustment 1914d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall /// is required. 1924d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall llvm::Constant *getMemberPointerAdjustment(const CastExpr *E); 1934d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCall 194f632730ffb0b8ca531a35e737b29cc9f9774ca1dReid Kleckner /// \brief Computes the non-virtual adjustment needed for a member pointer 195f632730ffb0b8ca531a35e737b29cc9f9774ca1dReid Kleckner /// conversion along an inheritance path stored in an APValue. Unlike 196f632730ffb0b8ca531a35e737b29cc9f9774ca1dReid Kleckner /// getMemberPointerAdjustment(), the adjustment can be negative if the path 197f632730ffb0b8ca531a35e737b29cc9f9774ca1dReid Kleckner /// is from a derived type to a base type. 198f632730ffb0b8ca531a35e737b29cc9f9774ca1dReid Kleckner CharUnits getMemberPointerPathAdjustment(const APValue &MP); 199f632730ffb0b8ca531a35e737b29cc9f9774ca1dReid Kleckner 2004d4e5c1ae83f4510caa486b3ad19de13048f9f04John McCallpublic: 201ecd03b447bb0e2ed1954c77441d49a4a17ca8138John McCall /// Adjust the given non-null pointer to an object of polymorphic 202ecd03b447bb0e2ed1954c77441d49a4a17ca8138John McCall /// type to point to the complete object. 203ecd03b447bb0e2ed1954c77441d49a4a17ca8138John McCall /// 204ecd03b447bb0e2ed1954c77441d49a4a17ca8138John McCall /// The IR type of the result should be a pointer but is otherwise 205ecd03b447bb0e2ed1954c77441d49a4a17ca8138John McCall /// irrelevant. 206ecd03b447bb0e2ed1954c77441d49a4a17ca8138John McCall virtual llvm::Value *adjustToCompleteObject(CodeGenFunction &CGF, 207ecd03b447bb0e2ed1954c77441d49a4a17ca8138John McCall llvm::Value *ptr, 208ecd03b447bb0e2ed1954c77441d49a4a17ca8138John McCall QualType type) = 0; 209ecd03b447bb0e2ed1954c77441d49a4a17ca8138John McCall 210ef8225444452a1486bd721f3285301fe84643b00Stephen Hines virtual llvm::Constant *getAddrOfRTTIDescriptor(QualType Ty) = 0; 211ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 212ef8225444452a1486bd721f3285301fe84643b00Stephen Hines virtual bool shouldTypeidBeNullChecked(bool IsDeref, 213ef8225444452a1486bd721f3285301fe84643b00Stephen Hines QualType SrcRecordTy) = 0; 214ef8225444452a1486bd721f3285301fe84643b00Stephen Hines virtual void EmitBadTypeidCall(CodeGenFunction &CGF) = 0; 215ef8225444452a1486bd721f3285301fe84643b00Stephen Hines virtual llvm::Value *EmitTypeid(CodeGenFunction &CGF, QualType SrcRecordTy, 216ef8225444452a1486bd721f3285301fe84643b00Stephen Hines llvm::Value *ThisPtr, 217ef8225444452a1486bd721f3285301fe84643b00Stephen Hines llvm::Type *StdTypeInfoPtrTy) = 0; 218ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 219ef8225444452a1486bd721f3285301fe84643b00Stephen Hines virtual bool shouldDynamicCastCallBeNullChecked(bool SrcIsPtr, 220ef8225444452a1486bd721f3285301fe84643b00Stephen Hines QualType SrcRecordTy) = 0; 221ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 222ef8225444452a1486bd721f3285301fe84643b00Stephen Hines virtual llvm::Value * 223ef8225444452a1486bd721f3285301fe84643b00Stephen Hines EmitDynamicCastCall(CodeGenFunction &CGF, llvm::Value *Value, 224ef8225444452a1486bd721f3285301fe84643b00Stephen Hines QualType SrcRecordTy, QualType DestTy, 225ef8225444452a1486bd721f3285301fe84643b00Stephen Hines QualType DestRecordTy, llvm::BasicBlock *CastEnd) = 0; 226ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 227ef8225444452a1486bd721f3285301fe84643b00Stephen Hines virtual llvm::Value *EmitDynamicCastToVoid(CodeGenFunction &CGF, 228ef8225444452a1486bd721f3285301fe84643b00Stephen Hines llvm::Value *Value, 229ef8225444452a1486bd721f3285301fe84643b00Stephen Hines QualType SrcRecordTy, 230ef8225444452a1486bd721f3285301fe84643b00Stephen Hines QualType DestTy) = 0; 231ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 232ef8225444452a1486bd721f3285301fe84643b00Stephen Hines virtual bool EmitBadCastCall(CodeGenFunction &CGF) = 0; 233ef8225444452a1486bd721f3285301fe84643b00Stephen Hines 234b0f533e716ae5a21ca5682ea235a68082fd5ed28Reid Kleckner virtual llvm::Value *GetVirtualBaseClassOffset(CodeGenFunction &CGF, 235b0f533e716ae5a21ca5682ea235a68082fd5ed28Reid Kleckner llvm::Value *This, 236b0f533e716ae5a21ca5682ea235a68082fd5ed28Reid Kleckner const CXXRecordDecl *ClassDecl, 237b0f533e716ae5a21ca5682ea235a68082fd5ed28Reid Kleckner const CXXRecordDecl *BaseClassDecl) = 0; 238b0f533e716ae5a21ca5682ea235a68082fd5ed28Reid Kleckner 2394c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall /// Build the signature of the given constructor variant by adding 2403b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// any required parameters. For convenience, ArgTys has been initialized 2413b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// with the type of 'this' and ResTy has been initialized with the type of 2423b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// 'this' if HasThisReturn(GlobalDecl(Ctor, T)) is true or 'void' otherwise 2433b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// (although both may be changed by the ABI). 2444c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall /// 2454c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall /// If there are ever any ABIs where the implicit parameters are 2464c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall /// intermixed with the formal parameters, we can address those 2474c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall /// then. 2484c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall virtual void BuildConstructorSignature(const CXXConstructorDecl *Ctor, 2494c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall CXXCtorType T, 2504c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall CanQualType &ResTy, 251686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<CanQualType> &ArgTys) = 0; 2524c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall 2539063302a82423cb83f002257a416741850739a70Reid Kleckner virtual llvm::BasicBlock *EmitCtorCompleteObjectHandler(CodeGenFunction &CGF, 2549063302a82423cb83f002257a416741850739a70Reid Kleckner const CXXRecordDecl *RD); 2551d4fff5551c2347010b955b4337a2aa7d65a050eTimur Iskhodzhanov 2565bd0d44c8da50f3a629c90fee92ce5cf1e31c9ffTimur Iskhodzhanov /// Emit the code to initialize hidden members required 2575bd0d44c8da50f3a629c90fee92ce5cf1e31c9ffTimur Iskhodzhanov /// to handle virtual inheritance, if needed by the ABI. 2585bd0d44c8da50f3a629c90fee92ce5cf1e31c9ffTimur Iskhodzhanov virtual void 2595bd0d44c8da50f3a629c90fee92ce5cf1e31c9ffTimur Iskhodzhanov initializeHiddenVirtualInheritanceMembers(CodeGenFunction &CGF, 2605bd0d44c8da50f3a629c90fee92ce5cf1e31c9ffTimur Iskhodzhanov const CXXRecordDecl *RD) {} 2615bd0d44c8da50f3a629c90fee92ce5cf1e31c9ffTimur Iskhodzhanov 262bb1b797d2e432293563747bd9704b22cf0787061Timur Iskhodzhanov /// Emit constructor variants required by this ABI. 263bb1b797d2e432293563747bd9704b22cf0787061Timur Iskhodzhanov virtual void EmitCXXConstructors(const CXXConstructorDecl *D) = 0; 264bb1b797d2e432293563747bd9704b22cf0787061Timur Iskhodzhanov 2654c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall /// Build the signature of the given destructor variant by adding 2663b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// any required parameters. For convenience, ArgTys has been initialized 2673b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// with the type of 'this' and ResTy has been initialized with the type of 2683b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// 'this' if HasThisReturn(GlobalDecl(Dtor, T)) is true or 'void' otherwise 2693b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// (although both may be changed by the ABI). 2704c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall virtual void BuildDestructorSignature(const CXXDestructorDecl *Dtor, 2714c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall CXXDtorType T, 2724c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall CanQualType &ResTy, 273686775deca8b8685eb90801495880e3abdd844c2Chris Lattner SmallVectorImpl<CanQualType> &ArgTys) = 0; 2744c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall 275a4130baad9d10b7feabb7e003da53424e986d269Reid Kleckner /// Returns true if the given destructor type should be emitted as a linkonce 276a4130baad9d10b7feabb7e003da53424e986d269Reid Kleckner /// delegating thunk, regardless of whether the dtor is defined in this TU or 277a4130baad9d10b7feabb7e003da53424e986d269Reid Kleckner /// not. 278a4130baad9d10b7feabb7e003da53424e986d269Reid Kleckner virtual bool useThunkForDtorVariant(const CXXDestructorDecl *Dtor, 279a4130baad9d10b7feabb7e003da53424e986d269Reid Kleckner CXXDtorType DT) const = 0; 280a4130baad9d10b7feabb7e003da53424e986d269Reid Kleckner 281a4130baad9d10b7feabb7e003da53424e986d269Reid Kleckner /// Emit destructor variants required by this ABI. 282a4130baad9d10b7feabb7e003da53424e986d269Reid Kleckner virtual void EmitCXXDestructors(const CXXDestructorDecl *D) = 0; 283a4130baad9d10b7feabb7e003da53424e986d269Reid Kleckner 2848f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov /// Get the type of the implicit "this" parameter used by a method. May return 2858f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov /// zero if no specific type is applicable, e.g. if the ABI expects the "this" 2868f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov /// parameter to point to some artificial offset in a complete object due to 2878f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov /// vbases being reordered. 2888f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov virtual const CXXRecordDecl * 2898f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov getThisArgumentTypeForMethod(const CXXMethodDecl *MD) { 2908f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov return MD->getParent(); 2918f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov } 2928f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov 2938f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov /// Perform ABI-specific "this" argument adjustment required prior to 294651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// a call of a virtual function. 295651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// The "VirtualCall" argument is true iff the call itself is virtual. 296651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines virtual llvm::Value * 297651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines adjustThisArgumentForVirtualFunctionCall(CodeGenFunction &CGF, GlobalDecl GD, 298651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines llvm::Value *This, 299651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool VirtualCall) { 3008f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov return This; 3018f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov } 3028f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov 303651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// Build a parameter variable suitable for 'this'. 304651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines void buildThisParam(CodeGenFunction &CGF, FunctionArgList &Params); 305651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 306651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// Insert any ABI-specific implicit parameters into the parameter list for a 307651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// function. This generally involves extra data for constructors and 308651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// destructors. 3094c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall /// 3104c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall /// ABIs may also choose to override the return type, which has been 3113b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// initialized with the type of 'this' if HasThisReturn(CGF.CurGD) is true or 3123b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin /// the formal return type of the function otherwise. 313651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines virtual void addImplicitStructorParams(CodeGenFunction &CGF, QualType &ResTy, 314651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines FunctionArgList &Params) = 0; 3154c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall 3168f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov /// Perform ABI-specific "this" parameter adjustment in a virtual function 3178f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov /// prologue. 3188f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov virtual llvm::Value *adjustThisParameterInVirtualFunctionPrologue( 3198f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov CodeGenFunction &CGF, GlobalDecl GD, llvm::Value *This) { 3208f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov return This; 3218f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov } 3228f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov 3234c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall /// Emit the ABI-specific prolog for the function. 3244c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall virtual void EmitInstanceFunctionProlog(CodeGenFunction &CGF) = 0; 3254c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall 326651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// Add any ABI-specific implicit arguments needed to call a constructor. 327651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// 328651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// \return The number of args added to the call, which is typically zero or 329651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// one. 330651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines virtual unsigned 331651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines addImplicitConstructorArgs(CodeGenFunction &CGF, const CXXConstructorDecl *D, 332651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines CXXCtorType Type, bool ForVirtualBase, 333651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool Delegating, CallArgList &Args) = 0; 334651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines 335651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines /// Emit the destructor call. 336651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines virtual void EmitDestructorCall(CodeGenFunction &CGF, 337651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines const CXXDestructorDecl *DD, CXXDtorType Type, 338651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines bool ForVirtualBase, bool Delegating, 339651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines llvm::Value *This) = 0; 3401d4fff5551c2347010b955b4337a2aa7d65a050eTimur Iskhodzhanov 341a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov /// Emits the VTable definitions required for the given record type. 342a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov virtual void emitVTableDefinitions(CodeGenVTables &CGVT, 343a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov const CXXRecordDecl *RD) = 0; 344a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov 345a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov /// Get the address point of the vtable for the given base subobject while 346a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov /// building a constructor or a destructor. On return, NeedsVirtualOffset 347a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov /// tells if a virtual base adjustment is needed in order to get the offset 348a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov /// of the base subobject. 349a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov virtual llvm::Value *getVTableAddressPointInStructor( 350a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov CodeGenFunction &CGF, const CXXRecordDecl *RD, BaseSubobject Base, 351a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov const CXXRecordDecl *NearestVBase, bool &NeedsVirtualOffset) = 0; 352a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov 353a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov /// Get the address point of the vtable for the given base subobject while 354a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov /// building a constexpr. 355a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov virtual llvm::Constant * 356a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov getVTableAddressPointForConstExpr(BaseSubobject Base, 357a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov const CXXRecordDecl *VTableClass) = 0; 358a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov 359a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov /// Get the address of the vtable for the given record decl which should be 360a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov /// used for the vptr at the given offset in RD. 361a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov virtual llvm::GlobalVariable *getAddrOfVTable(const CXXRecordDecl *RD, 362a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov CharUnits VPtrOffset) = 0; 363a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov 3648f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov /// Build a virtual function pointer in the ABI-specific way. 3658f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov virtual llvm::Value *getVirtualFunctionPointer(CodeGenFunction &CGF, 3668f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov GlobalDecl GD, 3678f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov llvm::Value *This, 3688f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov llvm::Type *Ty) = 0; 3698f189a9911a992a5c4118c3789485a85bd96e045Timur Iskhodzhanov 3700f9827f5d6248d7008063768eb5f2c3e6ba83e94Timur Iskhodzhanov /// Emit the ABI-specific virtual destructor call. 3713b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin virtual void EmitVirtualDestructorCall(CodeGenFunction &CGF, 3723b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin const CXXDestructorDecl *Dtor, 3733b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin CXXDtorType DtorType, 3743b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin SourceLocation CallLoc, 3753b50e8d78c34fc57e25781015a2cb0536ca54f89Stephen Lin llvm::Value *This) = 0; 3760f9827f5d6248d7008063768eb5f2c3e6ba83e94Timur Iskhodzhanov 3772cb17a06befb61b1434aaa991652fea4338c95d7Timur Iskhodzhanov virtual void adjustCallArgsForDestructorThunk(CodeGenFunction &CGF, 3782cb17a06befb61b1434aaa991652fea4338c95d7Timur Iskhodzhanov GlobalDecl GD, 3792cb17a06befb61b1434aaa991652fea4338c95d7Timur Iskhodzhanov CallArgList &CallArgs) {} 3802cb17a06befb61b1434aaa991652fea4338c95d7Timur Iskhodzhanov 3819063302a82423cb83f002257a416741850739a70Reid Kleckner /// Emit any tables needed to implement virtual inheritance. For Itanium, 3829063302a82423cb83f002257a416741850739a70Reid Kleckner /// this emits virtual table tables. For the MSVC++ ABI, this emits virtual 3839063302a82423cb83f002257a416741850739a70Reid Kleckner /// base tables. 384a53d7a0259ff88f78ba8ecac7d0cb3ea96302b1dTimur Iskhodzhanov virtual void emitVirtualInheritanceTables(const CXXRecordDecl *RD) = 0; 3859063302a82423cb83f002257a416741850739a70Reid Kleckner 386ef8225444452a1486bd721f3285301fe84643b00Stephen Hines virtual void setThunkLinkage(llvm::Function *Thunk, bool ForVTable, 387ef8225444452a1486bd721f3285301fe84643b00Stephen Hines GlobalDecl GD, bool ReturnAdjustment) = 0; 3882cb17a06befb61b1434aaa991652fea4338c95d7Timur Iskhodzhanov 389c70cc5d90403f99ccce5cab3a6c022ad9cdcb66cTimur Iskhodzhanov virtual llvm::Value *performThisAdjustment(CodeGenFunction &CGF, 390c70cc5d90403f99ccce5cab3a6c022ad9cdcb66cTimur Iskhodzhanov llvm::Value *This, 391c70cc5d90403f99ccce5cab3a6c022ad9cdcb66cTimur Iskhodzhanov const ThisAdjustment &TA) = 0; 392c70cc5d90403f99ccce5cab3a6c022ad9cdcb66cTimur Iskhodzhanov 393c70cc5d90403f99ccce5cab3a6c022ad9cdcb66cTimur Iskhodzhanov virtual llvm::Value *performReturnAdjustment(CodeGenFunction &CGF, 394c70cc5d90403f99ccce5cab3a6c022ad9cdcb66cTimur Iskhodzhanov llvm::Value *Ret, 395c70cc5d90403f99ccce5cab3a6c022ad9cdcb66cTimur Iskhodzhanov const ReturnAdjustment &RA) = 0; 396c70cc5d90403f99ccce5cab3a6c022ad9cdcb66cTimur Iskhodzhanov 3974c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall virtual void EmitReturnFromThunk(CodeGenFunction &CGF, 3984c40d98ab7acf5f27fa89b17bd8fc0ef7683df37John McCall RValue RV, QualType ResultType); 3991e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall 400285baac67d722beb6854f5faa45ee1aa62a7ce92Joao Matos /// Gets the pure virtual member call function. 401285baac67d722beb6854f5faa45ee1aa62a7ce92Joao Matos virtual StringRef GetPureVirtualCallName() = 0; 402285baac67d722beb6854f5faa45ee1aa62a7ce92Joao Matos 4032eb9a959d24ad757a82ecab61f343635ad67749aDavid Blaikie /// Gets the deleted virtual member call name. 4042eb9a959d24ad757a82ecab61f343635ad67749aDavid Blaikie virtual StringRef GetDeletedVirtualCallName() = 0; 4052eb9a959d24ad757a82ecab61f343635ad67749aDavid Blaikie 4060cbb3ed856d7b9059c6b52cdeb38db2a5d1a3a66Bill Wendling /// \brief Returns true iff static data members that are initialized in the 4070cbb3ed856d7b9059c6b52cdeb38db2a5d1a3a66Bill Wendling /// class definition should have linkonce linkage. 4080cbb3ed856d7b9059c6b52cdeb38db2a5d1a3a66Bill Wendling virtual bool isInlineInitializedStaticDataMemberLinkOnce() { return false; } 4090cbb3ed856d7b9059c6b52cdeb38db2a5d1a3a66Bill Wendling 4101e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /**************************** Array cookies ******************************/ 4111e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall 4121e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// Returns the extra size required in order to store the array 41316ae9de07730832945204877d752db7f1c070962James Dennett /// cookie for the given new-expression. May return 0 to indicate that no 4141e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// array cookie is required. 4151e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// 4161e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// Several cases are filtered out before this method is called: 4171e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// - non-array allocations never need a cookie 4185900103d6606edef5fc81bbac685fa3651f1b936James Dennett /// - calls to \::operator new(size_t, void*) never need a cookie 4191e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// 42016ae9de07730832945204877d752db7f1c070962James Dennett /// \param expr - the new-expression being allocated. 4216ec278d1a354517e20f13a877481453ee7940c78John McCall virtual CharUnits GetArrayCookieSize(const CXXNewExpr *expr); 4221e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall 4231e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// Initialize the array cookie for the given allocation. 4241e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// 4251e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// \param NewPtr - a char* which is the presumed-non-null 4261e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// return value of the allocation function 4271e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// \param NumElements - the computed number of elements, 428e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall /// potentially collapsed from the multidimensional array case; 429e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall /// always a size_t 4301e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// \param ElementType - the base element allocated type, 4311e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// i.e. the allocated type after stripping all array types 4321e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall virtual llvm::Value *InitializeArrayCookie(CodeGenFunction &CGF, 4331e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall llvm::Value *NewPtr, 4341e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall llvm::Value *NumElements, 4356ec278d1a354517e20f13a877481453ee7940c78John McCall const CXXNewExpr *expr, 4361e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall QualType ElementType); 4371e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall 4381e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// Reads the array cookie associated with the given pointer, 4391e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// if it has one. 4401e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// 4411e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// \param Ptr - a pointer to the first element in the array 4421e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// \param ElementType - the base element type of elements of the array 4431e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// \param NumElements - an out parameter which will be initialized 4441e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// with the number of elements allocated, or zero if there is no 4451e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// cookie 4461e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// \param AllocPtr - an out parameter which will be initialized 4471e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// with a char* pointing to the address returned by the allocation 4481e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// function 4491e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// \param CookieSize - an out parameter which will be initialized 4501e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall /// with the size of the cookie, or zero if there is no cookie 4511e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall virtual void ReadArrayCookie(CodeGenFunction &CGF, llvm::Value *Ptr, 4526ec278d1a354517e20f13a877481453ee7940c78John McCall const CXXDeleteExpr *expr, 4531e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall QualType ElementType, llvm::Value *&NumElements, 4541e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall llvm::Value *&AllocPtr, CharUnits &CookieSize); 4551e7fe751466ea82665fd21e9162fd7cc9c5f412dJohn McCall 456e1e35f761970fd662696b803a839c1f4a56f61b2Peter Collingbourne /// Return whether the given global decl needs a VTT parameter. 457e1e35f761970fd662696b803a839c1f4a56f61b2Peter Collingbourne virtual bool NeedsVTTParameter(GlobalDecl GD); 458e1e35f761970fd662696b803a839c1f4a56f61b2Peter Collingbourne 459e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCallprotected: 460e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall /// Returns the extra size required in order to store the array 461e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall /// cookie for the given type. Assumes that an array cookie is 462e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall /// required. 463e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall virtual CharUnits getArrayCookieSizeImpl(QualType elementType); 464e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall 465e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall /// Reads the array cookie for an allocation which is known to have one. 466e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall /// This is called by the standard implementation of ReadArrayCookie. 467e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall /// 468e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall /// \param ptr - a pointer to the allocation made for an array, as a char* 469e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall /// \param cookieSize - the computed cookie size of an array 4703b2adf237ab033173d7789ec1214d654eec17697James Dennett /// 471e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall /// Other parameters are as above. 4723b2adf237ab033173d7789ec1214d654eec17697James Dennett /// 473e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall /// \return a size_t 474e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall virtual llvm::Value *readArrayCookieImpl(CodeGenFunction &IGF, 475e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall llvm::Value *ptr, 476e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall CharUnits cookieSize); 477e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall 478e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCallpublic: 479e2b45e2a43ae46bc00026b63ba7c04ef2b78c3ffJohn McCall 4805cd91b513455fd7753e8815b54f0a49bbca6602dJohn McCall /*************************** Static local guards ****************************/ 4815cd91b513455fd7753e8815b54f0a49bbca6602dJohn McCall 4823030eb82593097502469a8b3fc26112c79c75605John McCall /// Emits the guarded initializer and destructor setup for the given 4833030eb82593097502469a8b3fc26112c79c75605John McCall /// variable, given that it couldn't be emitted as a constant. 4847ca4850a3e3530fa6c93b64b740446e32c97f992Richard Smith /// If \p PerformInit is false, the initialization has been folded to a 4857ca4850a3e3530fa6c93b64b740446e32c97f992Richard Smith /// constant and should not be performed. 4863030eb82593097502469a8b3fc26112c79c75605John McCall /// 4873030eb82593097502469a8b3fc26112c79c75605John McCall /// The variable may be: 4883030eb82593097502469a8b3fc26112c79c75605John McCall /// - a static local variable 4893030eb82593097502469a8b3fc26112c79c75605John McCall /// - a static data member of a class template instantiation 4903030eb82593097502469a8b3fc26112c79c75605John McCall virtual void EmitGuardedInit(CodeGenFunction &CGF, const VarDecl &D, 491942f9fe11d3a9583eef6bc4ca2549b1f0d1694daReid Kleckner llvm::GlobalVariable *DeclPtr, 492942f9fe11d3a9583eef6bc4ca2549b1f0d1694daReid Kleckner bool PerformInit) = 0; 4935cd91b513455fd7753e8815b54f0a49bbca6602dJohn McCall 49420bb175cb8ae5844034828db094fb948c0e3454aJohn McCall /// Emit code to force the execution of a destructor during global 49520bb175cb8ae5844034828db094fb948c0e3454aJohn McCall /// teardown. The default implementation of this uses atexit. 49620bb175cb8ae5844034828db094fb948c0e3454aJohn McCall /// 49720bb175cb8ae5844034828db094fb948c0e3454aJohn McCall /// \param dtor - a function taking a single pointer argument 49820bb175cb8ae5844034828db094fb948c0e3454aJohn McCall /// \param addr - a pointer to pass to the destructor function. 49904e517650569598e847c2ab609672e6df93effe5Richard Smith virtual void registerGlobalDtor(CodeGenFunction &CGF, const VarDecl &D, 50004e517650569598e847c2ab609672e6df93effe5Richard Smith llvm::Constant *dtor, llvm::Constant *addr); 501b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith 502b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith /*************************** thread_local initialization ********************/ 503b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith 504b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith /// Emits ABI-required functions necessary to initialize thread_local 505b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith /// variables in this translation unit. 506b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith /// 507b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith /// \param Decls The thread_local declarations in this translation unit. 508b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith /// \param InitFunc If this translation unit contains any non-constant 509b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith /// initialization or non-trivial destruction for thread_local 510b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith /// variables, a function to perform the initialization. Otherwise, 0. 511b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith virtual void EmitThreadLocalInitFuncs( 512ef8225444452a1486bd721f3285301fe84643b00Stephen Hines ArrayRef<std::pair<const VarDecl *, llvm::GlobalVariable *> > Decls, 513b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith llvm::Function *InitFunc); 514b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith 515b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith /// Emit a reference to a non-local thread_local variable (including 516b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith /// triggering the initialization of all thread_local variables in its 517b80a16eadd0dacabfc1c32412e243ccb99dd664dRichard Smith /// translation unit). 518651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines virtual LValue EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF, 519651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines const VarDecl *VD, 520651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines QualType LValType); 5213a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis}; 5223a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis 52396fcde0b8ed8bdf99d326312ca7be6447b0fe5fcJohn McCall// Create an instance of a C++ ABI class: 52496fcde0b8ed8bdf99d326312ca7be6447b0fe5fcJohn McCall 52596fcde0b8ed8bdf99d326312ca7be6447b0fe5fcJohn McCall/// Creates an Itanium-family ABI. 526071cc7deffad608165b1ddd5263e8bf181861520Charles DavisCGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM); 52796fcde0b8ed8bdf99d326312ca7be6447b0fe5fcJohn McCall 52896fcde0b8ed8bdf99d326312ca7be6447b0fe5fcJohn McCall/// Creates a Microsoft-family ABI. 529071cc7deffad608165b1ddd5263e8bf181861520Charles DavisCGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM); 53093d557bc1867b7d7b102f87290194b4be7932c92John McCall 5313a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis} 5323a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis} 5333a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis 5343a811f1f4286ee3fd0c563c1cfe623956f3caa24Charles Davis#endif 535