@@ -65,7 +65,8 @@ class SYCLIntegrationHeader {
6565 kind_work_group_memory,
6666 kind_dynamic_work_group_memory,
6767 kind_dynamic_accessor,
68- kind_last = kind_dynamic_accessor
68+ kind_struct_with_special_type, // structs that contain special types
69+ kind_last = kind_struct_with_special_type
6970 };
7071
7172public:
@@ -118,6 +119,9 @@ class SYCLIntegrationHeader {
118119 // / integration header is required.
119120 void addHostPipeRegistration () { NeedToEmitHostPipeRegistration = true ; }
120121
122+ // / Set the ParentStruct field
123+ void setParentStruct (ParmVarDecl *parent);
124+
121125private:
122126 // Kernel actual parameter descriptor.
123127 struct KernelParamDesc {
@@ -205,6 +209,20 @@ class SYCLIntegrationHeader {
205209 // / Keeps track of whether declaration of __sycl_host_pipe_registration
206210 // / type and __sycl_host_pipe_registrar variable are required to emit.
207211 bool NeedToEmitHostPipeRegistration = false ;
212+
213+ // For free function kernels, keeps track of the parameter that is currently
214+ // being analyzed if it is a struct that contains special types.
215+ ParmVarDecl *ParentStruct = nullptr ;
216+
217+ // For every struct that contains a special type which is given by
218+ // the ParentStruct field above, record the offset and size of its fields
219+ // at any nesting level. Store the information in the variable below.
220+ llvm::DenseMap<ParmVarDecl *, llvm::SmallVector<std::pair<size_t , size_t >>>
221+ OffsetSizeInfo;
222+ // Likewise for the kind of a field i.e accessor, std_layout etc...
223+ llvm::DenseMap<ParmVarDecl *,
224+ llvm::SmallVector<SYCLIntegrationHeader::kernel_param_kind_t >>
225+ KindInfo;
208226};
209227
210228class SYCLIntegrationFooter {
@@ -267,6 +285,10 @@ class SemaSYCL : public SemaBase {
267285
268286 llvm::DenseSet<const FunctionDecl *> FreeFunctionDeclarations;
269287
288+ // A map that keeps track of all structs encountered with
289+ // special types inside. Relevant for free function kernels only.
290+ llvm::DenseSet<const RecordDecl *> StructsWithSpecialTypes;
291+
270292public:
271293 SemaSYCL (Sema &S);
272294
@@ -317,6 +339,13 @@ class SemaSYCL : public SemaBase {
317339 SYCLKernelFunctions.insert (FD);
318340 }
319341
342+ // / Add ParentStruct to StructsWithSpecialTypes.
343+ void addStructWithSpecialType (const RecordDecl *ParentStruct) {
344+ StructsWithSpecialTypes.insert (ParentStruct);
345+ }
346+
347+ auto &getStructsWithSpecialType () const { return StructsWithSpecialTypes; }
348+
320349 // / Lazily creates and returns SYCL integration header instance.
321350 SYCLIntegrationHeader &getSyclIntegrationHeader () {
322351 if (SyclIntHeader == nullptr )
0 commit comments