@@ -71,14 +71,19 @@ class GlobalDecl {
71
71
GlobalDecl (const FunctionDecl *D, unsigned MVIndex = 0 )
72
72
: MultiVersionIndex(MVIndex) {
73
73
if (!D->hasAttr <CUDAGlobalAttr>()) {
74
+ if (D->hasAttr <OpenCLKernelAttr>()) {
75
+ Value.setPointerAndInt (D, unsigned (KernelReferenceKind::Kernel));
76
+ return ;
77
+ }
74
78
Init (D);
75
79
return ;
76
80
}
77
81
Value.setPointerAndInt (D, unsigned (getDefaultKernelReference (D)));
78
82
}
79
83
GlobalDecl (const FunctionDecl *D, KernelReferenceKind Kind)
80
84
: Value(D, unsigned (Kind)) {
81
- assert (D->hasAttr <CUDAGlobalAttr>() && " Decl is not a GPU kernel!" );
85
+ assert ((D->hasAttr <CUDAGlobalAttr>() && " Decl is not a GPU kernel!" ) ||
86
+ (D->hasAttr <OpenCLKernelAttr>() && " Decl is not a OpenCL kernel!" ));
82
87
}
83
88
GlobalDecl (const NamedDecl *D) { Init (D); }
84
89
GlobalDecl (const BlockDecl *D) { Init (D); }
@@ -130,13 +135,20 @@ class GlobalDecl {
130
135
}
131
136
132
137
KernelReferenceKind getKernelReferenceKind () const {
133
- assert (((isa<FunctionDecl>(getDecl ()) &&
134
- cast<FunctionDecl>(getDecl ())->hasAttr <CUDAGlobalAttr>()) ||
135
- (isa<FunctionTemplateDecl>(getDecl ()) &&
136
- cast<FunctionTemplateDecl>(getDecl ())
137
- ->getTemplatedDecl ()
138
- ->hasAttr <CUDAGlobalAttr>())) &&
139
- " Decl is not a GPU kernel!" );
138
+ assert ((((isa<FunctionDecl>(getDecl ()) &&
139
+ cast<FunctionDecl>(getDecl ())->hasAttr <CUDAGlobalAttr>()) ||
140
+ (isa<FunctionTemplateDecl>(getDecl ()) &&
141
+ cast<FunctionTemplateDecl>(getDecl ())
142
+ ->getTemplatedDecl ()
143
+ ->hasAttr <CUDAGlobalAttr>())) &&
144
+ " Decl is not a GPU kernel!" ) ||
145
+ (((isa<FunctionDecl>(getDecl ()) &&
146
+ cast<FunctionDecl>(getDecl ())->hasAttr <OpenCLKernelAttr>()) ||
147
+ (isa<FunctionTemplateDecl>(getDecl ()) &&
148
+ cast<FunctionTemplateDecl>(getDecl ())
149
+ ->getTemplatedDecl ()
150
+ ->hasAttr <OpenCLKernelAttr>())) &&
151
+ " Decl is not a OpenCL kernel!" ));
140
152
return static_cast <KernelReferenceKind>(Value.getInt ());
141
153
}
142
154
@@ -196,9 +208,12 @@ class GlobalDecl {
196
208
}
197
209
198
210
GlobalDecl getWithKernelReferenceKind (KernelReferenceKind Kind) {
199
- assert (isa<FunctionDecl>(getDecl ()) &&
200
- cast<FunctionDecl>(getDecl ())->hasAttr <CUDAGlobalAttr>() &&
201
- " Decl is not a GPU kernel!" );
211
+ assert ((isa<FunctionDecl>(getDecl ()) &&
212
+ cast<FunctionDecl>(getDecl ())->hasAttr <CUDAGlobalAttr>() &&
213
+ " Decl is not a GPU kernel!" ) ||
214
+ (isa<FunctionDecl>(getDecl ()) &&
215
+ cast<FunctionDecl>(getDecl ())->hasAttr <OpenCLKernelAttr>() &&
216
+ " Decl is not a OpenCL kernel!" ));
202
217
GlobalDecl Result (*this );
203
218
Result.Value .setInt (unsigned (Kind));
204
219
return Result;
0 commit comments