[cfe-dev] OpenCL builtin functions

Alberto Magni alberto.magni86 at gmail.com
Thu Apr 14 09:12:10 PDT 2011


Hi everybody,

my question is about how to manage OpenCL builtin functions.
Attached you can find a patch which adds the support for the
"barrier" OpenCL function. This is not a real patch, just a stub to
verify my approach.

The following are the main characteristics of the approach:

1) OpenCL functions should be added to Builtins.def using the
LIBBUILTIN macro and introducing a new language macro:
OPENCL_LANG. The associated opencl.h header is the file
which contains all the OpenCL additions.

2) OpenCL builtin functions will be treated as libc functions, generating
their declaration in the LLVM module.

3) The addition of the builtin function to the list of supported functions
is done during the initialization of the preprocessor in the method:
Builtin::Context::InitializeBuiltins in Builtins.cpp
Here a builtin function is not added to the list of available builtins only
if the current builtin belongs to the ObjC and the current language is
not Obj.
I modified the current convention using the following rule:
the builtin function is added only if is defined with the macro ALL_LANGUAGES or
if the current language matches the builtin's.
Do you agree with this criteria ?


Suggestions on this approach are the welcome.

Thank you in advance,

Alberto
-------------- next part --------------
A non-text attachment was scrubbed...
Name: builtin-functions.patch
Type: text/x-patch
Size: 5187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110414/ff4136d7/attachment.bin>


More information about the cfe-dev mailing list