-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[clang] Simplify device kernel attributes #137882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 5 commits
080a9d4
0c75247
1036640
47ae76a
421950d
66a7e1a
eeb377d
924839b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,9 +396,12 @@ any option of a multiversioned function is undefined. | |
}]; | ||
} | ||
|
||
def SYCLKernelDocs : Documentation { | ||
def DeviceKernelDocs : Documentation { | ||
let Category = DocCatFunction; | ||
let Heading = "device_kernel"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably list the other spellings of the attribute to the heading, that helps folks searching for those docs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in latest commit, thanks! |
||
let Content = [{ | ||
These attributes specify that the function represents a kernel for device offloading. | ||
The specific semantics depend on the offloading language, target, and attribute spelling. | ||
The ``sycl_kernel`` attribute specifies that a function template will be used | ||
to outline device code and to generate an OpenCL kernel. | ||
Here is a code example of the SYCL program, which demonstrates the compiler's | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3540,7 +3540,7 @@ bool FunctionDecl::isExternC() const { | |
} | ||
|
||
bool FunctionDecl::isInExternCContext() const { | ||
if (hasAttr<OpenCLKernelAttr>()) | ||
if (hasAttr<DeviceKernelAttr>() && getASTContext().getLangOpts().OpenCL) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really the same thing? Do we prevent enabling multiple kernel-defining languages at the same time? Should this instead check spelling? |
||
return true; | ||
return getLexicalDeclContext()->isExternCContext(); | ||
} | ||
|
@@ -5511,7 +5511,7 @@ FunctionDecl *FunctionDecl::CreateDeserialized(ASTContext &C, GlobalDeclID ID) { | |
} | ||
|
||
bool FunctionDecl::isReferenceableKernel() const { | ||
return hasAttr<CUDAGlobalAttr>() || hasAttr<OpenCLKernelAttr>(); | ||
return hasAttr<CUDAGlobalAttr>() || hasAttr<DeviceKernelAttr>(); | ||
} | ||
|
||
BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1556,7 +1556,8 @@ void CXXNameMangler::mangleUnqualifiedName( | |
FD && FD->hasAttr<CUDAGlobalAttr>() && | ||
GD.getKernelReferenceKind() == KernelReferenceKind::Stub; | ||
bool IsOCLDeviceStub = | ||
FD && FD->hasAttr<OpenCLKernelAttr>() && | ||
getASTContext().getLangOpts().OpenCL && FD && | ||
FD->hasAttr<DeviceKernelAttr>() && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here. |
||
GD.getKernelReferenceKind() == KernelReferenceKind::Stub; | ||
if (IsDeviceStub) | ||
mangleDeviceStubName(II); | ||
|
@@ -3529,10 +3530,9 @@ StringRef CXXNameMangler::getCallingConvQualifierName(CallingConv CC) { | |
case CC_AAPCS_VFP: | ||
case CC_AArch64VectorCall: | ||
case CC_AArch64SVEPCS: | ||
case CC_AMDGPUKernelCall: | ||
case CC_IntelOclBicc: | ||
case CC_SpirFunction: | ||
case CC_OpenCLKernel: | ||
case CC_DeviceKernel: | ||
case CC_PreserveMost: | ||
case CC_PreserveAll: | ||
case CC_M68kRTD: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1164,7 +1164,8 @@ void MicrosoftCXXNameMangler::mangleUnqualifiedName(GlobalDecl GD, | |
->hasAttr<CUDAGlobalAttr>())) && | ||
GD.getKernelReferenceKind() == KernelReferenceKind::Stub; | ||
bool IsOCLDeviceStub = | ||
ND && isa<FunctionDecl>(ND) && ND->hasAttr<OpenCLKernelAttr>() && | ||
getASTContext().getLangOpts().OpenCL && ND && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here :) |
||
isa<FunctionDecl>(ND) && ND->hasAttr<DeviceKernelAttr>() && | ||
GD.getKernelReferenceKind() == KernelReferenceKind::Stub; | ||
if (IsDeviceStub) | ||
mangleSourceName( | ||
|
Uh oh!
There was an error while loading. Please reload this page.