diff --git a/clang/lib/Sema/OpenCLBuiltins.td b/clang/lib/Sema/OpenCLBuiltins.td index 38e07b21cb85d5..72b72f60a662fc 100644 --- a/clang/lib/Sema/OpenCLBuiltins.td +++ b/clang/lib/Sema/OpenCLBuiltins.td @@ -59,6 +59,10 @@ def FuncExtKhrLocalInt32BaseAtomics : FunctionExtension<"cl_khr_local_int32 def FuncExtKhrLocalInt32ExtendedAtomics : FunctionExtension<"cl_khr_local_int32_extended_atomics">; def FuncExtKhrInt64BaseAtomics : FunctionExtension<"cl_khr_int64_base_atomics">; def FuncExtKhrInt64ExtendedAtomics : FunctionExtension<"cl_khr_int64_extended_atomics">; +def FuncExtKhrMipmapImage : FunctionExtension<"cl_khr_mipmap_image">; + +// Multiple extensions +def FuncExtKhrMipmapAndWrite3d : FunctionExtension<"cl_khr_mipmap_image cl_khr_3d_image_writes">; // Qualified Type. These map to ASTContext::QualType. class QualType { @@ -1179,3 +1183,176 @@ let MinVersion = CL20 in { def get_num_sub_groups : Builtin<"get_num_sub_groups", [UInt]>; } } + +//-------------------------------------------------------------------- +// End of the builtin functions defined in the OpenCL C specification. +// Builtin functions defined in the OpenCL C Extension are below. +//-------------------------------------------------------------------- + + +// OpenCL Extension v2.0 s9.18 - Mipmaps +let Extension = FuncExtKhrMipmapImage in { + // Added to section 6.13.14.2. + foreach aQual = ["RO"] in { + foreach imgTy = [Image2d] in { + foreach name = ["read_imagef"] in { + def : Builtin, ImageType, Sampler, VectorType, Float], Attr.Pure>; + def : Builtin, ImageType, Sampler, VectorType, VectorType, VectorType], Attr.Pure>; + } + foreach name = ["read_imagei"] in { + def : Builtin, ImageType, Sampler, VectorType, Float], Attr.Pure>; + def : Builtin, ImageType, Sampler, VectorType, VectorType, VectorType], Attr.Pure>; + } + foreach name = ["read_imageui"] in { + def : Builtin, ImageType, Sampler, VectorType, Float], Attr.Pure>; + def : Builtin, ImageType, Sampler, VectorType, VectorType, VectorType], Attr.Pure>; + } + } + foreach imgTy = [Image2dDepth] in { + foreach name = ["read_imagef"] in { + def : Builtin, Sampler, VectorType, Float], Attr.Pure>; + def : Builtin, Sampler, VectorType, VectorType, VectorType], Attr.Pure>; + } + } + foreach imgTy = [Image1d] in { + foreach name = ["read_imagef"] in { + def : Builtin, ImageType, Sampler, Float, Float], Attr.Pure>; + def : Builtin, ImageType, Sampler, Float, Float, Float], Attr.Pure>; + } + foreach name = ["read_imagei"] in { + def : Builtin, ImageType, Sampler, Float, Float], Attr.Pure>; + def : Builtin, ImageType, Sampler, Float, Float, Float], Attr.Pure>; + } + foreach name = ["read_imageui"] in { + def : Builtin, ImageType, Sampler, Float, Float], Attr.Pure>; + def : Builtin, ImageType, Sampler, Float, Float, Float], Attr.Pure>; + } + } + foreach imgTy = [Image3d] in { + foreach name = ["read_imagef"] in { + def : Builtin, ImageType, Sampler, VectorType, VectorType, VectorType], Attr.Pure>; + def : Builtin, ImageType, Sampler, VectorType, Float], Attr.Pure>; + } + foreach name = ["read_imagei"] in { + def : Builtin, ImageType, Sampler, VectorType, VectorType, VectorType], Attr.Pure>; + def : Builtin, ImageType, Sampler, VectorType, Float], Attr.Pure>; + } + foreach name = ["read_imageui"] in { + def : Builtin, ImageType, Sampler, VectorType, VectorType, VectorType], Attr.Pure>; + def : Builtin, ImageType, Sampler, VectorType, Float], Attr.Pure>; + } + } + foreach imgTy = [Image1dArray] in { + foreach name = ["read_imagef"] in { + def : Builtin, ImageType, Sampler, VectorType, Float], Attr.Pure>; + def : Builtin, ImageType, Sampler, VectorType, Float, Float], Attr.Pure>; + } + foreach name = ["read_imagei"] in { + def : Builtin, ImageType, Sampler, VectorType, Float], Attr.Pure>; + def : Builtin, ImageType, Sampler, VectorType, Float, Float], Attr.Pure>; + } + foreach name = ["read_imageui"] in { + def : Builtin, ImageType, Sampler, VectorType, Float], Attr.Pure>; + def : Builtin, ImageType, Sampler, VectorType, Float, Float], Attr.Pure>; + } + } + foreach imgTy = [Image2dArray] in { + foreach name = ["read_imagef"] in { + def : Builtin, ImageType, Sampler, VectorType, Float], Attr.Pure>; + def : Builtin, ImageType, Sampler, VectorType, VectorType, VectorType], Attr.Pure>; + } + foreach name = ["read_imagei"] in { + def : Builtin, ImageType, Sampler, VectorType, Float], Attr.Pure>; + def : Builtin, ImageType, Sampler, VectorType, VectorType, VectorType], Attr.Pure>; + } + foreach name = ["read_imageui"] in { + def : Builtin, ImageType, Sampler, VectorType, Float], Attr.Pure>; + def : Builtin, ImageType, Sampler, VectorType, VectorType, VectorType], Attr.Pure>; + } + } + foreach imgTy = [Image2dArrayDepth] in { + foreach name = ["read_imagef"] in { + def : Builtin, ImageType, Sampler, VectorType, Float], Attr.Pure>; + def : Builtin, ImageType, Sampler, VectorType, VectorType, VectorType], Attr.Pure>; + } + } + } + // Added to section 6.13.14.4. + foreach aQual = ["WO"] in { + foreach imgTy = [Image2d] in { + foreach name = ["write_imagef"] in { + def : Builtin, VectorType, Int, VectorType]>; + } + foreach name = ["write_imagei"] in { + def : Builtin, VectorType, Int, VectorType]>; + } + foreach name = ["write_imageui"] in { + def : Builtin, VectorType, Int, VectorType]>; + } + } + foreach imgTy = [Image2dDepth] in { + foreach name = ["write_imagef"] in { + def : Builtin, VectorType, Int, Float]>; + } + } + foreach imgTy = [Image1d] in { + foreach name = ["write_imagef"] in { + def : Builtin, Int, Int, VectorType]>; + } + foreach name = ["write_imagei"] in { + def : Builtin, Int, Int, VectorType]>; + } + foreach name = ["write_imageui"] in { + def : Builtin, Int, Int, VectorType]>; + } + } + foreach imgTy = [Image1dArray] in { + foreach name = ["write_imagef"] in { + def : Builtin, VectorType, Int, VectorType]>; + } + foreach name = ["write_imagei"] in { + def : Builtin, VectorType, Int, VectorType]>; + } + foreach name = ["write_imageui"] in { + def : Builtin, VectorType, Int, VectorType]>; + } + } + foreach imgTy = [Image2dArray] in { + foreach name = ["write_imagef"] in { + def : Builtin, VectorType, Int, VectorType]>; + } + foreach name = ["write_imagei"] in { + def : Builtin, VectorType, Int, VectorType]>; + } + foreach name = ["write_imageui"] in { + def : Builtin, VectorType, Int, VectorType]>; + } + } + foreach imgTy = [Image2dArrayDepth] in { + foreach name = ["write_imagef"] in { + def : Builtin, VectorType, Int, Float]>; + } + } + let Extension = FuncExtKhrMipmapAndWrite3d in { + foreach imgTy = [Image3d] in { + foreach name = ["write_imagef"] in { + def : Builtin, VectorType, Int, VectorType]>; + } + foreach name = ["write_imagei"] in { + def : Builtin, VectorType, Int, VectorType]>; + } + foreach name = ["write_imageui"] in { + def : Builtin, VectorType, Int, VectorType]>; + } + } + } + } + // Added to section 6.13.14.5 + foreach aQual = ["RO", "WO", "RW"] in { + foreach name = ["get_image_num_mip_levels"] in { + foreach imgTy = [Image1d, Image2d, Image3d, Image1dArray, Image2dArray, Image2dDepth, Image2dArrayDepth] in { + def : Builtin]>; + } + } + } +}