diff options
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenCXXABI.h')
| -rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenCXXABI.h | 93 |
1 files changed, 92 insertions, 1 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h index b5f2e1a06727..ae922599809b 100644 --- a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h +++ b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h @@ -37,19 +37,83 @@ public: void setCXXABIThisValue(CIRGenFunction &cgf, mlir::Value thisPtr); + /// Emit the code to initialize hidden members required to handle virtual + /// inheritance, if needed by the ABI. + virtual void + initializeHiddenVirtualInheritanceMembers(CIRGenFunction &cgf, + const CXXRecordDecl *rd) {} + /// Emit a single constructor/destructor with the gen type from a C++ /// constructor/destructor Decl. virtual void emitCXXStructor(clang::GlobalDecl gd) = 0; + virtual mlir::Value + getVirtualBaseClassOffset(mlir::Location loc, CIRGenFunction &cgf, + Address thisAddr, const CXXRecordDecl *classDecl, + const CXXRecordDecl *baseClassDecl) = 0; + public: + /// Similar to AddedStructorArgs, but only notes the number of additional + /// arguments. + struct AddedStructorArgCounts { + unsigned prefix = 0; + unsigned suffix = 0; + AddedStructorArgCounts() = default; + AddedStructorArgCounts(unsigned p, unsigned s) : prefix(p), suffix(s) {} + static AddedStructorArgCounts withPrefix(unsigned n) { return {n, 0}; } + static AddedStructorArgCounts withSuffix(unsigned n) { return {0, n}; } + }; + + /// Additional implicit arguments to add to the beginning (Prefix) and end + /// (Suffix) of a constructor / destructor arg list. + /// + /// Note that Prefix should actually be inserted *after* the first existing + /// arg; `this` arguments always come first. + struct AddedStructorArgs { + struct Arg { + mlir::Value value; + QualType type; + }; + llvm::SmallVector<Arg, 1> prefix; + llvm::SmallVector<Arg, 1> suffix; + AddedStructorArgs() = default; + AddedStructorArgs(llvm::SmallVector<Arg, 1> p, llvm::SmallVector<Arg, 1> s) + : prefix(std::move(p)), suffix(std::move(s)) {} + static AddedStructorArgs withPrefix(llvm::SmallVector<Arg, 1> args) { + return {std::move(args), {}}; + } + static AddedStructorArgs withSuffix(llvm::SmallVector<Arg, 1> args) { + return {{}, std::move(args)}; + } + }; + + /// 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'. + virtual AddedStructorArgCounts + buildStructorSignature(GlobalDecl gd, + llvm::SmallVectorImpl<CanQualType> &argTys) = 0; + + AddedStructorArgCounts + addImplicitConstructorArgs(CIRGenFunction &cgf, const CXXConstructorDecl *d, + CXXCtorType type, bool forVirtualBase, + bool delegating, CallArgList &args); + clang::ImplicitParamDecl *getThisDecl(CIRGenFunction &cgf) { return cgf.cxxabiThisDecl; } + virtual AddedStructorArgs + getImplicitConstructorArgs(CIRGenFunction &cgf, const CXXConstructorDecl *d, + CXXCtorType type, bool forVirtualBase, + bool delegating) = 0; + /// Emit the ABI-specific prolog for the function - virtual void emitInstanceFunctionProlog(SourceLocation Loc, + virtual void emitInstanceFunctionProlog(SourceLocation loc, CIRGenFunction &cgf) = 0; + virtual void emitRethrow(CIRGenFunction &cgf, bool isNoReturn) = 0; + /// 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 @@ -99,6 +163,10 @@ public: virtual void emitVTableDefinitions(CIRGenVTables &cgvt, const CXXRecordDecl *rd) = 0; + /// Emit any tables needed to implement virtual inheritance. For Itanium, + /// this emits virtual table tables. + virtual void emitVirtualInheritanceTables(const CXXRecordDecl *rd) = 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. @@ -132,6 +200,17 @@ public: CIRGenFunction &cgf, const CXXRecordDecl *vtableClass, BaseSubobject base, const CXXRecordDecl *nearestVBase) = 0; + /// 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. + virtual void addImplicitStructorParams(CIRGenFunction &cgf, + clang::QualType &resTy, + FunctionArgList ¶ms) = 0; + /// Checks if ABI requires to initialize vptrs for given dynamic class. virtual bool doStructorsInitializeVPtrs(const clang::CXXRecordDecl *vtableClass) = 0; @@ -150,6 +229,18 @@ public: /// Gets the mangle context. clang::MangleContext &getMangleContext() { return *mangleContext; } + + clang::ImplicitParamDecl *&getStructorImplicitParamDecl(CIRGenFunction &cgf) { + return cgf.cxxStructorImplicitParamDecl; + } + + mlir::Value getStructorImplicitParamValue(CIRGenFunction &cgf) { + return cgf.cxxStructorImplicitParamValue; + } + + void setStructorImplicitParamValue(CIRGenFunction &cgf, mlir::Value val) { + cgf.cxxStructorImplicitParamValue = val; + } }; /// Creates and Itanium-family ABI |
