@@ -191,7 +191,8 @@ def FunctionPointer : SubsetSubject<DeclBase,
191191
192192def OpenCLKernelFunction
193193 : SubsetSubject<Function, [{S->getASTContext().getLangOpts().OpenCL &&
194- S->hasAttr<DeviceKernelAttr>()}],
194+ DeviceKernelAttr::isOpenCLSpelling(
195+ S->getAttr<DeviceKernelAttr>()}],
195196 "kernel functions">;
196197
197198// HasFunctionProto is a more strict version of FunctionLike, so it should
@@ -1556,18 +1557,38 @@ def DeviceKernel : DeclOrTypeAttr {
15561557 A.getAttributeSpellingListIndex() == CXX11_clang_amdgpu_kernel ||
15571558 A.getAttributeSpellingListIndex() == C23_clang_amdgpu_kernel;
15581559 }
1560+ static inline bool isAMDGPUSpelling(const AttributeCommonInfo* A) {
1561+ if(!A) return false;
1562+ return isAMDGPUSpelling(*A);
1563+ }
15591564 static inline bool isNVPTXSpelling(const AttributeCommonInfo& A) {
15601565 return A.getAttributeSpellingListIndex() == GNU_nvptx_kernel ||
15611566 A.getAttributeSpellingListIndex() == CXX11_clang_nvptx_kernel ||
15621567 A.getAttributeSpellingListIndex() == C23_clang_nvptx_kernel;
15631568 }
1569+ static inline bool isNVPTXSpelling(const AttributeCommonInfo* A) {
1570+ if(!A) return false;
1571+ return isNVPTXSpelling(*A);
1572+ }
15641573 static inline bool isSYCLSpelling(const AttributeCommonInfo& A) {
15651574 return A.getAttributeSpellingListIndex() == GNU_sycl_kernel ||
15661575 A.getAttributeSpellingListIndex() == CXX11_clang_sycl_kernel ||
15671576 A.getAttributeSpellingListIndex() == C23_clang_sycl_kernel;
15681577 }
1578+ static inline bool isSYCLSpelling(const AttributeCommonInfo* A) {
1579+ if(!A) return false;
1580+ return isSYCLSpelling(*A);
1581+ }
15691582 static inline bool isOpenCLSpelling(const AttributeCommonInfo& A) {
1570- return A.getAttributeSpellingListIndex() == Keyword_kernel;
1583+ // Tablegen trips underscores from spellings to build the spelling
1584+ // list, but here we have the same spelling with unscores and without,
1585+ // so handle that case manually.
1586+ return A.getAttributeSpellingListIndex() == Keyword_kernel ||
1587+ A.getAttrName()->getName() == "kernel";
1588+ }
1589+ static inline bool isOpenCLSpelling(const AttributeCommonInfo* A) {
1590+ if (!A) return false;
1591+ return isOpenCLSpelling(*A);
15711592 }
15721593}];
15731594}
0 commit comments