Author: Sven van Haastregt Date: 2021-03-31T09:54:18+01:00 New Revision: b5995fced41de0885a5ef8f1b8a25ef45d8be711
URL: https://github.com/llvm/llvm-project/commit/b5995fced41de0885a5ef8f1b8a25ef45d8be711 DIFF: https://github.com/llvm/llvm-project/commit/b5995fced41de0885a5ef8f1b8a25ef45d8be711.diff LOG: [OpenCL] Limit popcount to OpenCL 1.2 and above s6.15.3 of the OpenCL C Specification v3.0.6 states that OpenCL 1.2 or newer is required. Added: Modified: clang/lib/Headers/opencl-c.h clang/lib/Sema/OpenCLBuiltins.td Removed: ################################################################################ diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h index c0b7072d5b0ae..6a532db4b1cb2 100644 --- a/clang/lib/Headers/opencl-c.h +++ b/clang/lib/Headers/opencl-c.h @@ -9907,6 +9907,7 @@ ulong16 __ovld __cnfn upsample(uint16 hi, uint16 lo); /* * popcount(x): returns the number of set bit in x */ +#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) char __ovld __cnfn popcount(char x); uchar __ovld __cnfn popcount(uchar x); char2 __ovld __cnfn popcount(char2 x); @@ -9955,6 +9956,7 @@ long8 __ovld __cnfn popcount(long8 x); ulong8 __ovld __cnfn popcount(ulong8 x); long16 __ovld __cnfn popcount(long16 x); ulong16 __ovld __cnfn popcount(ulong16 x); +#endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2) /** * Multiply two 24-bit integer values x and y and add diff --git a/clang/lib/Sema/OpenCLBuiltins.td b/clang/lib/Sema/OpenCLBuiltins.td index 1ff658e567b84..2ea70ae3234d9 100644 --- a/clang/lib/Sema/OpenCLBuiltins.td +++ b/clang/lib/Sema/OpenCLBuiltins.td @@ -579,8 +579,9 @@ foreach name = ["half_divide", "half_powr", foreach name = ["abs"] in { def : Builtin<name, [AI2UGenTypeN, AIGenTypeN], Attr.Const>; } -foreach name = ["clz", "popcount"] in { - def : Builtin<name, [AIGenTypeN, AIGenTypeN], Attr.Const>; +def : Builtin<"clz", [AIGenTypeN, AIGenTypeN], Attr.Const>; +let MinVersion = CL12 in { + def : Builtin<"popcount", [AIGenTypeN, AIGenTypeN], Attr.Const>; } let MinVersion = CL20 in { foreach name = ["ctz"] in { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits