|
clang 22.0.0git
|
Implements C++ ABI-specific code generation functions. More...
#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/CIR/CodeGen/CIRGenCXXABI.h"
Classes | |
| struct | AddedStructorArgCounts |
| Similar to AddedStructorArgs, but only notes the number of additional arguments. More... | |
| struct | AddedStructorArgs |
| Additional implicit arguments to add to the beginning (Prefix) and end (Suffix) of a constructor / destructor arg list. More... | |
Public Types | |
| using | DeleteOrMemberCallExpr |
Public Member Functions | |
| CIRGenCXXABI (CIRGenModule &cgm) | |
| virtual | ~CIRGenCXXABI () |
| void | setCXXABIThisValue (CIRGenFunction &cgf, mlir::Value thisPtr) |
| virtual void | initializeHiddenVirtualInheritanceMembers (CIRGenFunction &cgf, const CXXRecordDecl *rd) |
| Emit the code to initialize hidden members required to handle virtual inheritance, if needed by the ABI. | |
| virtual void | emitCXXStructor (clang::GlobalDecl gd)=0 |
| Emit a single constructor/destructor with the gen type from a C++ constructor/destructor Decl. | |
| virtual mlir::Value | getVirtualBaseClassOffset (mlir::Location loc, CIRGenFunction &cgf, Address thisAddr, const CXXRecordDecl *classDecl, const CXXRecordDecl *baseClassDecl)=0 |
| virtual mlir::Value | emitDynamicCast (CIRGenFunction &cgf, mlir::Location loc, QualType srcRecordTy, QualType destRecordTy, cir::PointerType destCIRTy, bool isRefCast, Address src)=0 |
| virtual AddedStructorArgCounts | buildStructorSignature (GlobalDecl gd, llvm::SmallVectorImpl< CanQualType > &argTys)=0 |
| Build the signature of the given constructor or destructor vairant by adding any required parameters. | |
| AddedStructorArgCounts | addImplicitConstructorArgs (CIRGenFunction &cgf, const CXXConstructorDecl *d, CXXCtorType type, bool forVirtualBase, bool delegating, CallArgList &args) |
| clang::ImplicitParamDecl * | getThisDecl (CIRGenFunction &cgf) |
| virtual AddedStructorArgs | getImplicitConstructorArgs (CIRGenFunction &cgf, const CXXConstructorDecl *d, CXXCtorType type, bool forVirtualBase, bool delegating)=0 |
| virtual void | emitInstanceFunctionProlog (SourceLocation loc, CIRGenFunction &cgf)=0 |
| Emit the ABI-specific prolog for the function. | |
| virtual void | emitRethrow (CIRGenFunction &cgf, bool isNoReturn)=0 |
| virtual void | emitThrow (CIRGenFunction &cgf, const CXXThrowExpr *e)=0 |
| virtual void | emitBadCastCall (CIRGenFunction &cgf, mlir::Location loc)=0 |
| virtual mlir::Attribute | getAddrOfRTTIDescriptor (mlir::Location loc, QualType ty)=0 |
| virtual const clang::CXXRecordDecl * | getThisArgumentTypeForMethod (const clang::CXXMethodDecl *md) |
| Get the type of the implicit "this" parameter used by a method. | |
| virtual bool | needsVTTParameter (clang::GlobalDecl gd) |
| Return whether the given global decl needs a VTT (virtual table table) parameter. | |
| virtual Address | adjustThisArgumentForVirtualFunctionCall (CIRGenFunction &cgf, clang::GlobalDecl gd, Address thisPtr, bool virtualCall) |
| Perform ABI-specific "this" argument adjustment required prior to a call of a virtual function. | |
| void | buildThisParam (CIRGenFunction &cgf, FunctionArgList ¶ms) |
| Build a parameter variable suitable for 'this'. | |
| mlir::Value | loadIncomingCXXThis (CIRGenFunction &cgf) |
| Loads the incoming C++ this pointer as it was passed by the caller. | |
| virtual CatchTypeInfo | getCatchAllTypeInfo () |
| virtual mlir::Value | getCXXDestructorImplicitParam (CIRGenFunction &cgf, const CXXDestructorDecl *dd, CXXDtorType type, bool forVirtualBase, bool delegating)=0 |
| Get the implicit (second) parameter that comes after the "this" pointer, or nullptr if there is isn't one. | |
| virtual void | emitCXXConstructors (const clang::CXXConstructorDecl *d)=0 |
| Emit constructor variants required by this ABI. | |
| virtual void | emitCXXDestructors (const clang::CXXDestructorDecl *d)=0 |
| Emit dtor variants required by this ABI. | |
| virtual void | emitDestructorCall (CIRGenFunction &cgf, const CXXDestructorDecl *dd, CXXDtorType type, bool forVirtualBase, bool delegating, Address thisAddr, QualType thisTy)=0 |
| virtual void | registerGlobalDtor (const VarDecl *vd, cir::FuncOp dtor, mlir::Value addr)=0 |
| Emit code to force the execution of a destructor during global teardown. | |
| virtual bool | isVirtualOffsetNeededForVTableField (CIRGenFunction &cgf, CIRGenFunction::VPtr vptr)=0 |
| Checks if ABI requires extra virtual offset for vtable field. | |
| virtual void | emitVTableDefinitions (CIRGenVTables &cgvt, const CXXRecordDecl *rd)=0 |
| Emits the VTable definitions required for the given record type. | |
| virtual mlir::Value | emitVirtualDestructorCall (CIRGenFunction &cgf, const CXXDestructorDecl *dtor, CXXDtorType dtorType, Address thisAddr, DeleteOrMemberCallExpr e)=0 |
| virtual void | emitVirtualInheritanceTables (const CXXRecordDecl *rd)=0 |
| Emit any tables needed to implement virtual inheritance. | |
| virtual bool | useThunkForDtorVariant (const CXXDestructorDecl *dtor, CXXDtorType dt) const =0 |
| Returns true if the given destructor type should be emitted as a linkonce delegating thunk, regardless of whether the dtor is defined in this TU or not. | |
| virtual cir::GlobalLinkageKind | getCXXDestructorLinkage (GVALinkage linkage, const CXXDestructorDecl *dtor, CXXDtorType dt) const |
| virtual cir::GlobalOp | getAddrOfVTable (const CXXRecordDecl *rd, CharUnits vptrOffset)=0 |
| Get the address of the vtable for the given record decl which should be used for the vptr at the given offset in RD. | |
| virtual CIRGenCallee | getVirtualFunctionPointer (CIRGenFunction &cgf, clang::GlobalDecl gd, Address thisAddr, mlir::Type ty, SourceLocation loc)=0 |
| Build a virtual function pointer in the ABI-specific way. | |
| virtual mlir::Value | getVTableAddressPoint (BaseSubobject base, const CXXRecordDecl *vtableClass)=0 |
| Get the address point of the vtable for the given base subobject. | |
| virtual mlir::Value | getVTableAddressPointInStructor (CIRGenFunction &cgf, const CXXRecordDecl *vtableClass, BaseSubobject base, const CXXRecordDecl *nearestVBase)=0 |
| Get the address point of the vtable for the given base subobject while building a constructor or a destructor. | |
| virtual void | addImplicitStructorParams (CIRGenFunction &cgf, clang::QualType &resTy, FunctionArgList ¶ms)=0 |
| Insert any ABI-specific implicit parameters into the parameter list for a function. | |
| virtual bool | doStructorsInitializeVPtrs (const clang::CXXRecordDecl *vtableClass)=0 |
| Checks if ABI requires to initialize vptrs for given dynamic class. | |
| virtual bool | hasThisReturn (clang::GlobalDecl gd) const |
| Returns true if the given constructor or destructor is one of the kinds that the ABI says returns 'this' (only applies when called non-virtually for destructors). | |
| virtual bool | hasMostDerivedReturn (clang::GlobalDecl gd) const |
| virtual bool | canCallMismatchedFunctionType () const |
| Returns true if the target allows calling a function through a pointer with a different signature than the actual function (or equivalently, bitcasting a function or function pointer to a different function type). | |
| clang::MangleContext & | getMangleContext () |
| Gets the mangle context. | |
| clang::ImplicitParamDecl *& | getStructorImplicitParamDecl (CIRGenFunction &cgf) |
| mlir::Value | getStructorImplicitParamValue (CIRGenFunction &cgf) |
| void | setStructorImplicitParamValue (CIRGenFunction &cgf, mlir::Value val) |
| virtual CharUnits | getArrayCookieSize (const CXXNewExpr *e) |
| Returns the extra size required in order to store the array cookie for the given new-expression. | |
| virtual Address | initializeArrayCookie (CIRGenFunction &cgf, Address newPtr, mlir::Value numElements, const CXXNewExpr *e, QualType elementType)=0 |
| Initialize the array cookie for the given allocation. | |
Protected Member Functions | |
| virtual bool | requiresArrayCookie (const CXXNewExpr *e) |
| virtual CharUnits | getArrayCookieSizeImpl (QualType elementType)=0 |
| Returns the extra size required in order to store the array cookie for the given type. | |
Protected Attributes | |
| CIRGenModule & | cgm |
| std::unique_ptr< clang::MangleContext > | mangleContext |
Implements C++ ABI-specific code generation functions.
Definition at line 27 of file CIRGenCXXABI.h.
Definition at line 199 of file CIRGenCXXABI.h.
|
inline |
Definition at line 37 of file CIRGenCXXABI.h.
References cgm, and mangleContext.
|
virtual |
Definition at line 24 of file CIRGenCXXABI.cpp.
| CIRGenCXXABI::AddedStructorArgCounts CIRGenCXXABI::addImplicitConstructorArgs | ( | CIRGenFunction & | cgf, |
| const CXXConstructorDecl * | d, | ||
| CXXCtorType | type, | ||
| bool | forVirtualBase, | ||
| bool | delegating, | ||
| CallArgList & | args ) |
|
pure virtual |
Insert any ABI-specific implicit parameters into the parameter list for a function.
This generally involves extra data for constructors and destructors.
ABIs may also choose to override the return type, which has been initialized with the type of 'this' if HasThisReturn(CGF.CurGD) is true or the formal return type of the function otherwise.
|
inlinevirtual |
Perform ABI-specific "this" argument adjustment required prior to a call of a virtual function.
The "VirtualCall" argument is true iff the call itself is virtual.
Definition at line 148 of file CIRGenCXXABI.h.
|
pure virtual |
Build the signature of the given constructor or destructor vairant by adding any required parameters.
For convenience, ArgTys has been initialized with the type of 'this'.
References clang::ast_matchers::type.
| void CIRGenCXXABI::buildThisParam | ( | CIRGenFunction & | cgf, |
| FunctionArgList & | params ) |
Build a parameter variable suitable for 'this'.
Definition at line 44 of file CIRGenCXXABI.cpp.
References clang::cast(), cgm, clang::ImplicitParamDecl::Create(), clang::CIRGen::CIRGenFunction::curGD, cir::MissingFeatures::cxxabiThisAlignment(), clang::CIRGen::CIRGenFunction::cxxabiThisDecl, clang::CXXThis, and clang::GlobalDecl::getDecl().
|
inlinevirtual |
Returns true if the target allows calling a function through a pointer with a different signature than the actual function (or equivalently, bitcasting a function or function pointer to a different function type).
In principle in the most general case this could depend on the target, the calling convention, and the actual types of the arguments and return value. Here it just means whether the signature mismatch could ever be allowed; in other words, does the target do strict checking of signatures for all calls.
Definition at line 280 of file CIRGenCXXABI.h.
Referenced by emitDeclDestroy().
|
pure virtual |
Checks if ABI requires to initialize vptrs for given dynamic class.
|
pure virtual |
Referenced by emitDynamicCastToNull().
|
pure virtual |
Emit constructor variants required by this ABI.
Referenced by clang::CIRGen::CIRGenModule::emitTopLevelDecl().
|
pure virtual |
Emit dtor variants required by this ABI.
Referenced by clang::CIRGen::CIRGenModule::emitTopLevelDecl().
|
pure virtual |
Emit a single constructor/destructor with the gen type from a C++ constructor/destructor Decl.
|
pure virtual |
References clang::ast_matchers::type.
|
pure virtual |
|
pure virtual |
Emit the ABI-specific prolog for the function.
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
Emit any tables needed to implement virtual inheritance.
For Itanium, this emits virtual table tables.
|
pure virtual |
Emits the VTable definitions required for the given record type.
|
pure virtual |
Referenced by clang::CIRGen::CIRGenModule::getAddrOfRTTIDescriptor().
|
pure virtual |
Get the address of the vtable for the given record decl which should be used for the vptr at the given offset in RD.
Referenced by getAddrOfVTTVTable().
|
virtual |
Returns the extra size required in order to store the array cookie for the given new-expression.
May return 0 to indicate that no array cookie is required.
Several cases are filtered out before this method is called:
| e | - the new-expression being allocated. |
Definition at line 84 of file CIRGenCXXABI.cpp.
References clang::CXXNewExpr::getAllocatedType(), getArrayCookieSizeImpl(), requiresArrayCookie(), and clang::CharUnits::Zero().
Referenced by calculateCookiePadding().
|
protectedpure virtual |
Returns the extra size required in order to store the array cookie for the given type.
Assumes that an array cookie is required.
Referenced by getArrayCookieSize().
|
virtual |
Definition at line 40 of file CIRGenCXXABI.cpp.
|
pure virtual |
Get the implicit (second) parameter that comes after the "this" pointer, or nullptr if there is isn't one.
References clang::ast_matchers::type.
|
virtual |
Definition at line 63 of file CIRGenCXXABI.cpp.
References cgm.
Referenced by clang::CIRGen::CIRGenModule::getFunctionLinkage().
|
pure virtual |
References clang::ast_matchers::type.
Referenced by addImplicitConstructorArgs().
|
inline |
Gets the mangle context.
Definition at line 283 of file CIRGenCXXABI.h.
References mangleContext.
Referenced by getMangledNameImpl().
|
inline |
Definition at line 285 of file CIRGenCXXABI.h.
References clang::CIRGen::CIRGenFunction::cxxStructorImplicitParamDecl.
|
inline |
Definition at line 289 of file CIRGenCXXABI.h.
References clang::CIRGen::CIRGenFunction::cxxStructorImplicitParamValue.
|
inlinevirtual |
Get the type of the implicit "this" parameter used by a method.
May return zero if no specific type is applicable, e.g. if the ABI expects the "this" parameter to point to some artificial offset in a complete object due to vbases being reordered.
Definition at line 137 of file CIRGenCXXABI.h.
References clang::CXXMethodDecl::getParent().
Referenced by commonBuildCXXMemberOrOperatorCall().
|
inline |
Definition at line 111 of file CIRGenCXXABI.h.
References clang::CIRGen::CIRGenFunction::cxxabiThisDecl.
Referenced by loadIncomingCXXThis(), and setCXXABIThisValue().
|
pure virtual |
|
pure virtual |
Build a virtual function pointer in the ABI-specific way.
Referenced by clang::CIRGen::CIRGenCallee::prepareConcreteCallee().
|
pure virtual |
Get the address point of the vtable for the given base subobject.
|
pure virtual |
Get the address point of the vtable for the given base subobject while building a constructor or a destructor.
|
inlinevirtual |
Definition at line 268 of file CIRGenCXXABI.h.
|
inlinevirtual |
Returns true if the given constructor or destructor is one of the kinds that the ABI says returns 'this' (only applies when called non-virtually for destructors).
There currently is no way to indicate if a destructor returns 'this' when called virtually, and CIR generation does not support this case.
Definition at line 266 of file CIRGenCXXABI.h.
|
pure virtual |
Initialize the array cookie for the given allocation.
| newPtr | - a char* which is the presumed-non-null return value of the allocation function |
| numElements | - the computed number of elements, potentially collapsed from the multidimensional array case; always a size_t |
| elementType | - the base element allocated type, i.e. the allocated type after stripping all array types |
|
inlinevirtual |
Emit the code to initialize hidden members required to handle virtual inheritance, if needed by the ABI.
Definition at line 46 of file CIRGenCXXABI.h.
|
pure virtual |
Checks if ABI requires extra virtual offset for vtable field.
| mlir::Value CIRGenCXXABI::loadIncomingCXXThis | ( | CIRGenFunction & | cgf | ) |
Loads the incoming C++ this pointer as it was passed by the caller.
Definition at line 70 of file CIRGenCXXABI.cpp.
References clang::CIRGen::CIRGenFunction::getAddrOfLocalVar(), clang::CIRGen::CIRGenFunction::getBuilder(), clang::CIRGen::Address::getElementType(), clang::CIRGen::CIRGenFunction::getLoc(), clang::Decl::getLocation(), clang::CIRGen::Address::getPointer(), and getThisDecl().
|
inlinevirtual |
Return whether the given global decl needs a VTT (virtual table table) parameter.
Definition at line 143 of file CIRGenCXXABI.h.
|
pure virtual |
Emit code to force the execution of a destructor during global teardown.
The default implementation of this uses atexit.
| dtor | - a function taking a single pointer argument |
| addr | - a pointer to pass to the destructor function. |
Referenced by emitDeclDestroy().
|
protectedvirtual |
Definition at line 91 of file CIRGenCXXABI.cpp.
References clang::CXXNewExpr::doesUsualArrayDeleteWantSize(), clang::CXXNewExpr::getAllocatedType(), and clang::QualType::isDestructedType().
Referenced by getArrayCookieSize().
| void CIRGenCXXABI::setCXXABIThisValue | ( | CIRGenFunction & | cgf, |
| mlir::Value | thisPtr ) |
Initialize the 'this' slot.
Definition at line 77 of file CIRGenCXXABI.cpp.
References clang::CIRGen::CIRGenFunction::cxxabiThisValue, and getThisDecl().
|
inline |
Definition at line 293 of file CIRGenCXXABI.h.
References clang::CIRGen::CIRGenFunction::cxxStructorImplicitParamValue.
|
pure virtual |
Returns true if the given destructor type should be emitted as a linkonce delegating thunk, regardless of whether the dtor is defined in this TU or not.
|
protected |
Definition at line 29 of file CIRGenCXXABI.h.
Referenced by buildThisParam(), CIRGenCXXABI(), and getCXXDestructorLinkage().
|
protected |
Definition at line 30 of file CIRGenCXXABI.h.
Referenced by CIRGenCXXABI(), and getMangleContext().