[PATCH] D156743: clang/OpenCL: Add inline implementations of sqrt in builtin header

Sven van Haastregt via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 2 07:13:23 PDT 2023


svenvh added a comment.

If we go with this approach, please also remove sqrt from `clang/lib/Sema/OpenCLBuiltins.td` (and ideally add a comment pointing out that sqrt is handled in `opencl-c-base.h`)



================
Comment at: clang/lib/Headers/opencl-c-base.h:832
+
+inline float __ovld __cnfn sqrt(float __x) {
+  return __builtin_elementwise_sqrt(__x);
----------------
Anastasia wrote:
> Is this a generic implementation enough? Would some targets not need to do something different for this built-in?
> 
> Ideally this header is to be kept light so I am a bit worried about adding definitions of the functions here. Otherwise we will end up in the same situation as we one day were with opencl-c.h. So could these be left there instead? It might be good to check with @svenvh if TableGen header has already a way to do this function forwarding or can be extended to do such a thing. Then it would be implementable in the both header mechanisms. I don't know if Sven has some other ideas or opinions...
We did already discuss this a bit on the GitHub issue: https://github.com/llvm/llvm-project/issues/64264


================
Comment at: clang/lib/Headers/opencl-c-base.h:856-858
+// We only really want to define the float variants here. However bad things
+// seem to happen with -fdeclare-opencl-builtins and splitting the handling of
+// different overloads.
----------------



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156743/new/

https://reviews.llvm.org/D156743



More information about the cfe-commits mailing list