This is an archive of the discontinued LLVM Phabricator instance.

[RFC][OpenCL] Make Tablegen header work with extensions that are not added in clang
Needs ReviewPublic

Authored by Anastasia on Nov 16 2020, 5:53 AM.

Details

Summary

Not all extensions require compiler changes and therefore they can be easily added in the headers and linked libraries (see more details in https://reviews.llvm.org/D91531).

The current design of Tablegen header (enabled via -fdeclare-opencl-builtins) is bound to the extensions available in the clang source. This patch makes Tablegen work with extensions that are not added through the clang source code by checking the existance of predefined macros. This works uniformly regardless of where the macros are defined - implicitly in clang or during the parsing of the headers.

Note that as a byproduct this patch also fixes the bug in the diagnostic (https://godbolt.org/z/GTs1W3), when clang rejects the function call requiring the extension to be enabled even though the extension is unsupported. Furthermore, the patch adds FIXME because clang with Tablegen header currently requires pragma to call any function from the extensions. The spec doesn't say that the pragma is needed for this purpose and moreover the regular internal header (enabled by -finclude-default-header) doesn't behave in the same way. The fix for this is outside of the scope of this refactoring and it will be covered in a separate patch.

Diff Detail

Event Timeline

Anastasia created this revision.Nov 16 2020, 5:53 AM
Anastasia retitled this revision from [RFC][OpenCL] Make tablegen header work with extension that are not added in clang to [RFC][OpenCL] Make Tablegen header work with extensions that are not added in clang.Nov 16 2020, 6:00 AM
Anastasia edited the summary of this revision. (Show Details)
Anastasia updated this revision to Diff 305724.Nov 17 2020, 3:41 AM

Added full diffs.