OpenCL builtin functions

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,


builtin-functions.patch (5.07 KB)