Page MenuHomePhabricator

[OpenCL] Add extension handling for builtin functions
Needs ReviewPublic

Authored by Pierre on Jun 19 2019, 8:00 AM.

Details

Reviewers
svenvh
Anastasia
Summary

Add the possibilty to bind functions or types to an OpenCL extension
(e.g.: cl_khr_fp16 for the "half" type, or
cl_khr_global_int32_base_atomics for functions).

Type extensions currently added are:
*cl_khr_fp16
*cl_khr_fp64
*cl_khr_gl_msaa_sharing

Function extensions currently added are:
*cl_khr_global_int32_base_atomics
*cl_khr_global_int32_extended_atomics

This mimics the following pragma:
\#pragma OPENCL EXTENSION <ExtName> : [begin|end]

The previously defined atomic functions are updated accordingly.

This depends on:
-1, splitting opencl-c.h file: https://reviews.llvm.org/D63256/new/
-2, Adding generic types: https://reviews.llvm.org/D63434
-3, Adding const, volatile and pointer types: https://reviews.llvm.org/D63442
-4, Adding image types: https://reviews.llvm.org/D63480
-5, Adding version handling: https://reviews.llvm.org/D63504

Diff Detail

Event Timeline

Pierre created this revision.Jun 19 2019, 8:00 AM
Anastasia added inline comments.Jun 21 2019, 7:03 AM
clang/lib/Sema/OpenCLBuiltins.td
63

Btw you are adding not only halfs. Please reflect this in the description of this review.

clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
35

Can extend tests for half and doubles too?

Pierre updated this revision to Diff 207503.Jul 2 2019, 3:31 AM
Pierre marked 3 inline comments as done.
Pierre edited the summary of this revision. (Show Details)

Update the commit message to specify which extensions are added, and add tests for the half and double type extensions

clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
35

This is curious that the error message is different for half and double types, when the issue is similar.

Pierre marked 2 inline comments as not done.Jul 2 2019, 3:31 AM
Pierre updated this revision to Diff 207506.Jul 2 2019, 3:44 AM

Rebase from previous patches.

Pierre updated this revision to Diff 207820.Jul 3 2019, 9:37 AM

Rebase on previous versions.

Anastasia added inline comments.Jul 3 2019, 10:59 AM
clang/lib/Sema/OpenCLBuiltins.td
45

should be used.

257–258

I am confused why do we need type extensions because we are not actually adding types in tablegen?

clang/lib/Sema/SemaLookup.cpp
773

-> static?

773

-> AddOpenCLExtensions?

clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
47

I think it's good to add line like above:

// Hold information...

55

I think it's good to add line like above:

// Hold information...

216

This is a map, not a list.

Pierre updated this revision to Diff 208348.Jul 8 2019, 3:13 AM