@@ -47,11 +47,67 @@ class CIRGenCXXABI {
4747 // / constructor/destructor Decl.
4848 virtual void emitCXXStructor (clang::GlobalDecl gd) = 0;
4949
50+ virtual mlir::Value
51+ getVirtualBaseClassOffset (mlir::Location loc, CIRGenFunction &cgf,
52+ Address thisAddr, const CXXRecordDecl *classDecl,
53+ const CXXRecordDecl *baseClassDecl) = 0 ;
54+
5055public:
56+ // / Similar to AddedStructorArgs, but only notes the number of additional
57+ // / arguments.
58+ struct AddedStructorArgCounts {
59+ unsigned prefix = 0 ;
60+ unsigned suffix = 0 ;
61+ AddedStructorArgCounts () = default ;
62+ AddedStructorArgCounts (unsigned p, unsigned s) : prefix(p), suffix(s) {}
63+ static AddedStructorArgCounts withPrefix (unsigned n) { return {n, 0 }; }
64+ static AddedStructorArgCounts withSuffix (unsigned n) { return {0 , n}; }
65+ };
66+
67+ // / Additional implicit arguments to add to the beginning (Prefix) and end
68+ // / (Suffix) of a constructor / destructor arg list.
69+ // /
70+ // / Note that Prefix should actually be inserted *after* the first existing
71+ // / arg; `this` arguments always come first.
72+ struct AddedStructorArgs {
73+ struct Arg {
74+ mlir::Value value;
75+ QualType type;
76+ };
77+ llvm::SmallVector<Arg, 1 > prefix;
78+ llvm::SmallVector<Arg, 1 > suffix;
79+ AddedStructorArgs () = default ;
80+ AddedStructorArgs (llvm::SmallVector<Arg, 1 > p, llvm::SmallVector<Arg, 1 > s)
81+ : prefix(std::move(p)), suffix(std::move(s)) {}
82+ static AddedStructorArgs withPrefix (llvm::SmallVector<Arg, 1 > args) {
83+ return {std::move (args), {}};
84+ }
85+ static AddedStructorArgs withSuffix (llvm::SmallVector<Arg, 1 > args) {
86+ return {{}, std::move (args)};
87+ }
88+ };
89+
90+ // / Build the signature of the given constructor or destructor vairant by
91+ // / adding any required parameters. For convenience, ArgTys has been
92+ // / initialized with the type of 'this'.
93+ virtual AddedStructorArgCounts
94+ buildStructorSignature (GlobalDecl gd,
95+ llvm::SmallVectorImpl<CanQualType> &argTys) = 0 ;
96+
97+ AddedStructorArgCounts
98+ addImplicitConstructorArgs (CIRGenFunction &cgf, const CXXConstructorDecl *d,
99+ CXXCtorType type, bool forVirtualBase,
100+ bool delegating, CallArgList &args);
101+
51102 clang::ImplicitParamDecl *getThisDecl (CIRGenFunction &cgf) {
52103 return cgf.cxxabiThisDecl ;
53104 }
54105
106+ virtual AddedStructorArgs
107+ getImplicitConstructorArgs (CIRGenFunction &cgf, const CXXConstructorDecl *d,
108+ CXXCtorType type, bool forVirtualBase,
109+ bool delegating) = 0 ;
110+
55111 // / Emit the ABI-specific prolog for the function
56112 virtual void emitInstanceFunctionProlog (SourceLocation loc,
57113 CIRGenFunction &cgf) = 0;
@@ -144,6 +200,17 @@ class CIRGenCXXABI {
144200 CIRGenFunction &cgf, const CXXRecordDecl *vtableClass, BaseSubobject base,
145201 const CXXRecordDecl *nearestVBase) = 0;
146202
203+ // / Insert any ABI-specific implicit parameters into the parameter list for a
204+ // / function. This generally involves extra data for constructors and
205+ // / destructors.
206+ // /
207+ // / ABIs may also choose to override the return type, which has been
208+ // / initialized with the type of 'this' if HasThisReturn(CGF.CurGD) is true or
209+ // / the formal return type of the function otherwise.
210+ virtual void addImplicitStructorParams (CIRGenFunction &cgf,
211+ clang::QualType &resTy,
212+ FunctionArgList ¶ms) = 0;
213+
147214 // / Checks if ABI requires to initialize vptrs for given dynamic class.
148215 virtual bool
149216 doStructorsInitializeVPtrs (const clang::CXXRecordDecl *vtableClass) = 0;
@@ -162,6 +229,18 @@ class CIRGenCXXABI {
162229
163230 // / Gets the mangle context.
164231 clang::MangleContext &getMangleContext () { return *mangleContext; }
232+
233+ clang::ImplicitParamDecl *&getStructorImplicitParamDecl (CIRGenFunction &cgf) {
234+ return cgf.cxxStructorImplicitParamDecl ;
235+ }
236+
237+ mlir::Value getStructorImplicitParamValue (CIRGenFunction &cgf) {
238+ return cgf.cxxStructorImplicitParamValue ;
239+ }
240+
241+ void setStructorImplicitParamValue (CIRGenFunction &cgf, mlir::Value val) {
242+ cgf.cxxStructorImplicitParamValue = val;
243+ }
165244};
166245
167246// / Creates and Itanium-family ABI
0 commit comments