From: Sven van Haastregt Date: Mon, 30 Dec 2019 10:47:58 +0000 (+0000) Subject: [OpenCL] Add mipmap builtin functions X-Git-Tag: llvmorg-11-init~1240 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4a188fdfa79b4c1044cbb6fe0ede79583c71a56f;p=platform%2Fupstream%2Fllvm.git [OpenCL] Add mipmap builtin functions Add the mipmap builtin functions from the OpenCL extension specification. Patch by Pierre Gondois and Sven van Haastregt. --- diff --git a/clang/lib/Sema/OpenCLBuiltins.td b/clang/lib/Sema/OpenCLBuiltins.td index 38e07b2..72b72f6 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]>; + } + } + } +}