[PATCH] D91531: [RFC][OpenCL] Provide mechanisms for defining extension macros

Anton Zabaznov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 23 15:08:37 PST 2020


azabaznov added a comment.

> So if I understand it well you are suggesting to perform a check for every parsed macro definition that would identify whether the macro has a name matching what is provided in -cl-ext=? Then if the name matches it would check whether the macro should be defined or not?

No, sorry for confusing. There is no need to check every parsed macro. For example an internal pragma can be used for these purposes (`#pragma OPENCL EXTENSION all : undef` in example below). So imagine if we can differentiate header-only extensions and features and all of them are defined in header. After the list of definitions the special pragma is used and is a processed in a way that it inserts undef for each macro definition which relates to header-only extension/feature and was turned off with the option (`-cl-ext=-cl_khr_depth_images`):

  #define cl_khr_depth_images 1
  #define cl_khr_fp64 1
  #define cl_khr_mipmap_image  1
  ...
  #pragma OPENCL EXTENSION all : undef

However, this might be hard to maintain and I'm not sure yet that this is even legally to do in current `Preprocessor` design, but this is at least more scalable than adding `#if defined(__undef_` for each extension in the end of the header.  Nevertheless, that's what I meant about preserving the current interface.

Also, I didn't quite get how the proposing hook will allow users to declare own extensions outside the codebase. Are you expecting them to use existing `-cl-ext` or `-Dcl_khr_depth_images`? In the later case they won't able to use `#pragma OPENCL EXTESNION cl_khr_depth_images : enable` (while the specification does not describe for which extensions pragma is exactly needed or not, but still)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91531/new/

https://reviews.llvm.org/D91531



More information about the cfe-commits mailing list