@@ -2176,27 +2176,10 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
2176
2176
2177
2177
void addParam (const FieldDecl *FD, QualType ArgTy,
2178
2178
SYCLIntegrationHeader::kernel_param_kind_t Kind) {
2179
- addParam (FD, ArgTy, Kind, IsArrayElement (FD, ArgTy));
2180
- }
2181
- void addParam (const FieldDecl *FD, QualType ArgTy,
2182
- SYCLIntegrationHeader::kernel_param_kind_t Kind,
2183
- bool IsArrayElem) {
2184
2179
uint64_t Size;
2185
2180
Size = SemaRef.getASTContext ().getTypeSizeInChars (ArgTy).getQuantity ();
2186
- uint64_t Offset = CurOffset;
2187
- if (!IsArrayElem)
2188
- Offset += offsetOf (FD);
2189
2181
Header.addParamDesc (Kind, static_cast <unsigned >(Size),
2190
- static_cast <unsigned >(Offset));
2191
- }
2192
-
2193
- // Returns 'true' if the thing we're visiting (Based on the FD/QualType pair)
2194
- // is an element of an array. This will determine whether we do
2195
- // MemberExprBases in some cases or not, AND determines how we initialize
2196
- // values.
2197
- bool IsArrayElement (const FieldDecl *FD, QualType Ty) const {
2198
- SemaRef.getASTContext ().hasSameType (FD->getType (), Ty);
2199
- return FD->getType () != Ty;
2182
+ static_cast <unsigned >(CurOffset + offsetOf (FD)));
2200
2183
}
2201
2184
2202
2185
public:
@@ -2232,10 +2215,8 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
2232
2215
AccTy->getTemplateArgs ()[1 ].getAsIntegral ().getExtValue ());
2233
2216
int Info = getAccessTarget (AccTy) | (Dims << 11 );
2234
2217
2235
- uint64_t Offset = CurOffset;
2236
- if (!IsArrayElement (FD, FieldTy))
2237
- Offset += offsetOf (FD);
2238
- Header.addParamDesc (SYCLIntegrationHeader::kind_accessor, Info, Offset);
2218
+ Header.addParamDesc (SYCLIntegrationHeader::kind_accessor, Info,
2219
+ CurOffset + offsetOf (FD));
2239
2220
return true ;
2240
2221
}
2241
2222
@@ -2249,8 +2230,7 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
2249
2230
const ParmVarDecl *SamplerArg = InitMethod->getParamDecl (0 );
2250
2231
assert (SamplerArg && " sampler __init method must have sampler parameter" );
2251
2232
2252
- addParam (FD, SamplerArg->getType (), SYCLIntegrationHeader::kind_sampler,
2253
- IsArrayElement (FD, FieldTy));
2233
+ addParam (FD, SamplerArg->getType (), SYCLIntegrationHeader::kind_sampler);
2254
2234
return true ;
2255
2235
}
2256
2236
@@ -2303,31 +2283,35 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
2303
2283
return true ;
2304
2284
}
2305
2285
2306
- bool enterStream (const CXXRecordDecl *, FieldDecl *FD, QualType Ty ) final {
2286
+ bool enterStream (const CXXRecordDecl *, FieldDecl *FD, QualType) final {
2307
2287
++StructDepth;
2308
- if (!IsArrayElement (FD, Ty))
2309
- CurOffset += offsetOf (FD);
2288
+ // TODO: Is this right?! I think this only needs to be incremented when we
2289
+ // aren't in an array, otherwise 'enterArray's base offsets should handle
2290
+ // this right. Otherwise an array of structs is going to be in the middle
2291
+ // of nowhere.
2292
+ CurOffset += offsetOf (FD);
2310
2293
return true ;
2311
2294
}
2312
2295
2313
- bool leaveStream (const CXXRecordDecl *, FieldDecl *FD, QualType Ty ) final {
2296
+ bool leaveStream (const CXXRecordDecl *, FieldDecl *FD, QualType) final {
2314
2297
--StructDepth;
2315
- if (!IsArrayElement (FD, Ty))
2316
- CurOffset -= offsetOf (FD);
2298
+ CurOffset -= offsetOf (FD);
2317
2299
return true ;
2318
2300
}
2319
2301
2320
- bool enterStruct (const CXXRecordDecl *, FieldDecl *FD, QualType Ty ) final {
2302
+ bool enterStruct (const CXXRecordDecl *, FieldDecl *FD, QualType) final {
2321
2303
++StructDepth;
2322
- if (!IsArrayElement (FD, Ty))
2323
- CurOffset += offsetOf (FD);
2304
+ // TODO: Is this right?! I think this only needs to be incremented when we
2305
+ // aren't in an array, otherwise 'enterArray's base offsets should handle
2306
+ // this right. Otherwise an array of structs is going to be in the middle
2307
+ // of nowhere.
2308
+ CurOffset += offsetOf (FD);
2324
2309
return true ;
2325
2310
}
2326
2311
2327
- bool leaveStruct (const CXXRecordDecl *, FieldDecl *FD, QualType Ty ) final {
2312
+ bool leaveStruct (const CXXRecordDecl *, FieldDecl *FD, QualType) final {
2328
2313
--StructDepth;
2329
- if (!IsArrayElement (FD, Ty))
2330
- CurOffset -= offsetOf (FD);
2314
+ CurOffset -= offsetOf (FD);
2331
2315
return true ;
2332
2316
}
2333
2317
@@ -2343,12 +2327,8 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
2343
2327
return true ;
2344
2328
}
2345
2329
2346
- bool enterArray (FieldDecl *FD, QualType ArrayTy, QualType) final {
2347
- uint64_t Offset = CurOffset;
2348
- if (!IsArrayElement (FD, ArrayTy))
2349
- Offset += offsetOf (FD);
2350
-
2351
- ArrayBaseOffsets.push_back (Offset);
2330
+ bool enterArray (FieldDecl *, QualType, QualType) final {
2331
+ ArrayBaseOffsets.push_back (CurOffset);
2352
2332
return true ;
2353
2333
}
2354
2334
0 commit comments