@@ -18,6 +18,16 @@ using namespace clang;
18
18
19
19
typedef llvm::DenseMap<DeclaratorDecl *, DeclaratorDecl *> DeclMap;
20
20
21
+ enum target {
22
+ global_buffer = 2014 ,
23
+ constant_buffer,
24
+ local,
25
+ image,
26
+ host_buffer,
27
+ host_image,
28
+ image_array
29
+ };
30
+
21
31
class KernelBodyTransform : public TreeTransform <KernelBodyTransform> {
22
32
public:
23
33
KernelBodyTransform (llvm::DenseMap<DeclaratorDecl *, DeclaratorDecl *> &Map,
@@ -161,7 +171,7 @@ CompoundStmt *CreateSYCLKernelBody(Sema &S, FunctionDecl *KernelHelper,
161
171
ParamStmts.push_back (Res);
162
172
163
173
// lambda.accessor.__set_pointer(kernel_parameter)
164
- CXXMemberCallExpr *Call = new (S. Context ) CXXMemberCallExpr (
174
+ CXXMemberCallExpr *Call = CXXMemberCallExpr::Create (
165
175
S.Context , ME, ParamStmts, ResultTy, VK, SourceLocation ());
166
176
BodyStmts.push_back (Call);
167
177
}
@@ -208,10 +218,27 @@ void BuildArgTys(ASTContext &Context,
208
218
const auto *TemplateDecl =
209
219
dyn_cast<ClassTemplateSpecializationDecl>(RecordDecl);
210
220
if (TemplateDecl) {
221
+ // First parameter - data type
211
222
QualType PointeeType = TemplateDecl->getTemplateArgs ()[0 ].getAsType ();
223
+ // Fourth parameter - access target
224
+ auto AccessQualifier = TemplateDecl->getTemplateArgs ()[3 ].getAsIntegral ();
225
+ int64_t AccessTarget = AccessQualifier.getExtValue ();
212
226
Qualifiers Quals = PointeeType.getQualifiers ();
227
+ // TODO: Support all access targets
228
+ switch (AccessTarget) {
229
+ case target::global_buffer:
230
+ Quals.setAddressSpace (LangAS::opencl_global);
231
+ break ;
232
+ case target::constant_buffer:
233
+ Quals.setAddressSpace (LangAS::opencl_constant);
234
+ break ;
235
+ case target::local:
236
+ Quals.setAddressSpace (LangAS::opencl_local);
237
+ break ;
238
+ default :
239
+ llvm_unreachable (" Unsupported access target" );
240
+ }
213
241
// TODO: get address space from accessor template parameter.
214
- Quals.setAddressSpace (LangAS::opencl_global);
215
242
PointeeType =
216
243
Context.getQualifiedType (PointeeType.getUnqualifiedType (), Quals);
217
244
QualType PointerType = Context.getPointerType (PointeeType);
0 commit comments