[clang] [llvm] [clang] Add spir_kernel attribute (PR #137882)
Erich Keane via llvm-commits
llvm-commits at lists.llvm.org
Thu May 8 06:01:38 PDT 2025
================
@@ -1538,11 +1533,44 @@ def CUDAShared : InheritableAttr {
}
def : MutualExclusions<[CUDAConstant, CUDAShared, HIPManaged]>;
-def SYCLKernel : InheritableAttr {
- let Spellings = [Clang<"sycl_kernel">];
- let Subjects = SubjectList<[FunctionTmpl]>;
- let LangOpts = [SYCLDevice];
+def DeviceKernel : DeclOrTypeAttr {
+ let Spellings = [Clang<"device_kernel">, Clang<"sycl_kernel">,
+ Clang<"nvptx_kernel">, Clang<"amdgpu_kernel">,
+ CustomKeyword<"__kernel">, CustomKeyword<"kernel">];
+ let LangOpts = [];
let Documentation = [SYCLKernelDocs];
+ let AdditionalMembers =
+ [{
+ inline bool isAMDGPUSpelling() const {
+ return isAMDGPUSpelling(*this);
+ }
+ template<typename T>
+ static inline bool isAMDGPUSpelling(const T& Attr) {
+ return Attr.getAttrName()->getName() == "amdgpu_kernel";
+ }
+ inline bool isNVPTXSpelling() const {
+ return isNVPTXSpelling(*this);
+ }
+ template<typename T>
+ static inline bool isNVPTXSpelling(const T& Attr) {
+ return Attr.getAttrName()->getName() == "nvptx_kernel";
+ }
+ inline bool isOpenCLSpelling() const {
+ return isOpenCLSpelling(*this);
+ }
+ template<typename T>
+ static inline bool isOpenCLSpelling(const T& Attr) {
+ return Attr.getAttrName()->getName() == "kernel" ||
----------------
erichkeane wrote:
Even without the `Accessors` thing that Aaron suggests, you can check the spelling-id vs the generated enums which is better than string compares.
https://github.com/llvm/llvm-project/pull/137882
More information about the llvm-commits
mailing list