From 2fe674baa3f304b5fa497e71b51ea6315f89c5e0 Mon Sep 17 00:00:00 2001 From: Sven van Haastregt Date: Wed, 13 Nov 2019 10:16:33 +0000 Subject: [PATCH] [OpenCL] Add remaining vector data builtin functions Add the remaining half (fp16) vector data load and store builtin functions from the OpenCL C specification. Patch by Pierre Gondois and Sven van Haastregt. --- clang/lib/Sema/OpenCLBuiltins.td | 52 +++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/clang/lib/Sema/OpenCLBuiltins.td b/clang/lib/Sema/OpenCLBuiltins.td index 080963acd09b..0bd4c51a04c2 100644 --- a/clang/lib/Sema/OpenCLBuiltins.td +++ b/clang/lib/Sema/OpenCLBuiltins.td @@ -666,8 +666,9 @@ foreach name = ["select"] in { } +//-------------------------------------------------------------------- // OpenCL v1.1 s6.11.7, v1.2 s6.12.7, v2.0 s6.13.7 - Vector Data Load and Store Functions -// OpenCL Extension v1.1 s9.3.6 and s9.6.6, v1.2 s9.5.6, v2.0 s9.4.6, v2.0 s5.1.6 and 6.1.6 - Vector Data Load and Store Functions +// OpenCL Extension v1.1 s9.3.6 and s9.6.6, v1.2 s9.5.6, v2.0 s5.1.6 and s6.1.6 - Vector Data Load and Store Functions // --- Table 15 --- // Variants for OpenCL versions below 2.0, using pointers to the global, local // and private address spaces. @@ -778,6 +779,55 @@ foreach VSize = [2, 3, 4, 8, 16] in { } } } +let MaxVersion = CL20 in { + foreach AS = [GlobalAS, LocalAS, PrivateAS] in { + def : Builtin<"vload_half", [Float, Size, PointerType, AS>]>; + foreach VSize = [2, 3, 4, 8, 16] in { + foreach name = ["vload_half" # VSize] in { + def : Builtin, Size, PointerType, AS>]>; + } + } + foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in { + def : Builtin<"vstore_half" # rnd, [Void, Float, Size, PointerType]>; + def : Builtin<"vstore_half" # rnd, [Void, Double, Size, PointerType]>; + foreach VSize = [2, 3, 4, 8, 16] in { + foreach name = ["vstore_half" # VSize # rnd] in { + def : Builtin, Size, PointerType]>; + def : Builtin, Size, PointerType]>; + } + } + } + } +} +let MinVersion = CL20 in { + foreach AS = [GenericAS] in { + def : Builtin<"vload_half", [Float, Size, PointerType, AS>]>; + foreach VSize = [2, 3, 4, 8, 16] in { + foreach name = ["vload_half" # VSize] in { + def : Builtin, Size, PointerType, AS>]>; + } + } + foreach rnd = ["", "_rte", "_rtz", "_rtp", "_rtn"] in { + def : Builtin<"vstore_half" # rnd, [Void, Float, Size, PointerType]>; + def : Builtin<"vstore_half" # rnd, [Void, Double, Size, PointerType]>; + foreach VSize = [2, 3, 4, 8, 16] in { + foreach name = ["vstore_half" # VSize # rnd] in { + def : Builtin, Size, PointerType]>; + def : Builtin, Size, PointerType]>; + } + } + } + } +} + +foreach AS = [ConstantAS] in { + def : Builtin<"vload_half", [Float, Size, PointerType, AS>]>; + foreach VSize = [2, 3, 4, 8, 16] in { + foreach name = ["vload_half" # VSize] in { + def : Builtin, Size, PointerType, AS>]>; + } + } +} //-------------------------------------------------------------------- // OpenCL v1.1 s6.11.10, v1.2 s6.12.10, v2.0 s6.13.10: Async Copies from Global to Local Memory, Local to Global Memory, and Prefetch