[PATCH] D65597: WIP: Builtins: Start adding half versions of math builtins

Matt Arsenault via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 1 12:00:48 PDT 2019

arsenm created this revision.
arsenm added reviewers: rsmith, rjmccall, Anastasia, yaxunl.
Herald added a subscriber: wdng.

The implementation of the OpenCL builtin currently library uses 2 different hacks to get to the corresponding IR intrinsics from the source. This will allow removal of those.

I'm not sure this is the right naming scheme, but tries to follow the
single character suffix like f/l. This is a problem for sin/cos, since
__builtin_sinh already means double sinh etc. Another alternative might be _f16



Index: include/clang/Basic/Builtins.def
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -181,6 +181,7 @@
 BUILTIN(__builtin_ceil , "dd"  , "Fnc")
 BUILTIN(__builtin_ceilf, "ff"  , "Fnc")
 BUILTIN(__builtin_ceill, "LdLd", "Fnc")
+BUILTIN(__builtin_ceilh, "hh"  , "Fnc")
 BUILTIN(__builtin_cos , "dd"  , "Fne")
 BUILTIN(__builtin_cosf, "ff"  , "Fne")
 BUILTIN(__builtin_cosh , "dd"  , "Fne")
@@ -208,15 +209,19 @@
 BUILTIN(__builtin_floor , "dd"  , "Fnc")
 BUILTIN(__builtin_floorf, "ff"  , "Fnc")
 BUILTIN(__builtin_floorl, "LdLd", "Fnc")
+BUILTIN(__builtin_floorh, "hh"  , "Fnc")
 BUILTIN(__builtin_fma, "dddd", "Fne")
 BUILTIN(__builtin_fmaf, "ffff", "Fne")
 BUILTIN(__builtin_fmal, "LdLdLdLd", "Fne")
+BUILTIN(__builtin_fmah, "hhhh", "Fne")
 BUILTIN(__builtin_fmax, "ddd", "Fnc")
 BUILTIN(__builtin_fmaxf, "fff", "Fnc")
 BUILTIN(__builtin_fmaxl, "LdLdLd", "Fnc")
+BUILTIN(__builtin_fmaxf, "hhh", "Fnc")
 BUILTIN(__builtin_fmin, "ddd", "Fnc")
 BUILTIN(__builtin_fminf, "fff", "Fnc")
 BUILTIN(__builtin_fminl, "LdLdLd", "Fnc")
+BUILTIN(__builtin_fminh, "hhh", "Fnc")
 BUILTIN(__builtin_hypot , "ddd"  , "Fne")
 BUILTIN(__builtin_hypotf, "fff"  , "Fne")
 BUILTIN(__builtin_hypotl, "LdLdLd", "Fne")
@@ -271,6 +276,7 @@
 BUILTIN(__builtin_rint , "dd", "Fnc")
 BUILTIN(__builtin_rintf, "ff", "Fnc")
 BUILTIN(__builtin_rintl, "LdLd", "Fnc")
+BUILTIN(__builtin_rinth, "hh", "Fnc")
 BUILTIN(__builtin_round, "dd"  , "Fnc")
 BUILTIN(__builtin_roundf, "ff"  , "Fnc")
 BUILTIN(__builtin_roundl, "LdLd"  , "Fnc")
@@ -289,6 +295,7 @@
 BUILTIN(__builtin_sqrt , "dd"  , "Fne")
 BUILTIN(__builtin_sqrtf, "ff"  , "Fne")
 BUILTIN(__builtin_sqrtl, "LdLd", "Fne")
+BUILTIN(__builtin_sqrth, "ff"  , "Fne")
 BUILTIN(__builtin_tan , "dd"  , "Fne")
 BUILTIN(__builtin_tanf, "ff"  , "Fne")
 BUILTIN(__builtin_tanh , "dd"  , "Fne")
@@ -301,6 +308,7 @@
 BUILTIN(__builtin_trunc , "dd", "Fnc")
 BUILTIN(__builtin_truncf, "ff", "Fnc")
 BUILTIN(__builtin_truncl, "LdLd", "Fnc")
+BUILTIN(__builtin_trunch, "hh", "Fnc")
 // C99 complex builtins
 BUILTIN(__builtin_cabs, "dXd", "Fne")
@@ -395,6 +403,7 @@
 BUILTIN(__builtin_canonicalize, "dd", "nc")
 BUILTIN(__builtin_canonicalizef, "ff", "nc")
 BUILTIN(__builtin_canonicalizel, "LdLd", "nc")
+BUILTIN(__builtin_canonicalizeh, "hh", "nc")
 // Builtins for arithmetic.
 BUILTIN(__builtin_clzs , "iUs"  , "nc")

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65597.212873.patch
Type: text/x-patch
Size: 2429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190801/1e7bc5f5/attachment.bin>

More information about the cfe-commits mailing list