Currently, there is some refactoring needed in existing interface of OpenCL option settings to support OpenCL C 3.0. The problem is that OpenCL extensions and feature are not only determined by the target platform but also by the OpenCL version. Also, there are core extensions/features which are guaranteed to be supported by the target with specific OpenCL C version. In fact, these rules are not being followed for all targets. For example, there are some targets (as nvptx and r600) which don't support OpenCL C 2.0 core features (nvptx.languageOptsOpenCL.cl, r600.languageOptsOpenCL.cl):
... // Core feature in CL 2.0, but not supported on nvptx #ifdef cl_khr_3d_image_writes #error "Incorrect cl_khr_3d_image_writes define" #endif ...
This is erroneous since cl_khr_3d_image_writes is an OpenCL C 2.0 core feature. IMO these targets can't report OpenCL C 2.0 support, and they should use OpenCL C 3.0 since 3d image writes is optional feature in OpenCL C 3.0.
This patch also eliminates OpenCLOptions instance duplication from TargetOptions. OpenCLOptions instance should take place in Sema as it's going to be modified during parsing. Removing this duplication will also allow to generally simplify OpenCLOptions class for parsing purposes.