This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Add TableGen emitter for OpenCL builtin header
ClosedPublic

Authored by svenvh on Jun 10 2021, 9:02 AM.

Details

Summary

Add an emitter to produce something similar to opencl-c.h from the
OpenCL builtin descriptions in OpenCLBuiltins.td

Factor out functionality that can be shared between the test emitter
and the header emitter into a new base class.

This only adds the emitter, without any use of it currently.

Example output excerpt (the full output is about 16k lines):

...
__ovld __cnfn size_t get_global_id(uint);
__ovld __cnfn size_t get_local_size(uint);
__ovld __cnfn size_t get_local_id(uint);
__ovld __cnfn size_t get_num_groups(uint);
__ovld __cnfn size_t get_group_id(uint);
__ovld __cnfn size_t get_global_offset(uint);
#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
__ovld size_t get_enqueued_local_size(uint);
#endif // MinVersion
...

Diff Detail

Event Timeline

svenvh created this revision.Jun 10 2021, 9:02 AM
svenvh requested review of this revision.Jun 10 2021, 9:02 AM
azabaznov accepted this revision.Jun 17 2021, 4:11 AM

Thanks for working on this! That's cool, I managed to reproduce something similar to https://reviews.llvm.org/D99577.

This revision is now accepted and ready to land.Jun 17 2021, 4:11 AM
Anastasia accepted this revision.Jun 17 2021, 4:34 AM

Do you think we could add any test for this yet? Or do we have to wait until we have other pieces in place for diffing to opencl-c.h? We could add a test for parsing the header but it is probably going to be very slow test?

Do you think we could add any test for this yet? Or do we have to wait until we have other pieces in place for diffing to opencl-c.h? We could add a test for parsing the header but it is probably going to be very slow test?

The question is what we actually want to test at this point? I am wondering if it would make more sense to work towards equivalence of opencl-c.h and the generated header file. We can prove equivalence offline, as a one-off without needing to commit changes to the AST printer. If they are equivalent, we can commit the generated header file in place of opencl-c.h. After that, adding a test for diffing both should be fairly trivial.

svenvh updated this revision to Diff 417678.Mar 23 2022, 10:06 AM

Rebased on latest main.

Also takes TypeExtensions into account now.

Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2022, 10:06 AM
Herald added a subscriber: Naghasan. · View Herald Transcript
This revision was automatically updated to reflect the committed changes.