[PATCH] D17558: Add __builtin_canonicalize
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 23 19:34:35 PST 2016
arsenm updated this revision to Diff 48879.
arsenm added a comment.
Add long double version. Add the short summary before linking to the intrinsic doc
http://reviews.llvm.org/D17558
Files:
docs/LanguageExtensions.rst
include/clang/Basic/Builtins.def
lib/CodeGen/CGBuiltin.cpp
test/CodeGen/builtins.c
Index: test/CodeGen/builtins.c
===================================================================
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -250,6 +250,13 @@
// CHECK: call float @llvm.fabs.f32(float
// CHECK: call double @llvm.fabs.f64(double
// CHECK: call x86_fp80 @llvm.fabs.f80(x86_fp80
+
+ resf = __builtin_canonicalizef(F);
+ resd = __builtin_canonicalize(D);
+ resld = __builtin_canonicalizel(LD);
+ // CHECK: call float @llvm.canonicalize.f32(float
+ // CHECK: call double @llvm.canonicalize.f64(double
+ // CHECK: call x86_fp80 @llvm.canonicalize.f80(x86_fp80
}
// __builtin_longjmp isn't supported on all platforms, so only test it on X86.
Index: lib/CodeGen/CGBuiltin.cpp
===================================================================
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -2138,6 +2138,11 @@
case Builtin::BIprintf:
if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice)
return EmitCUDADevicePrintfCallExpr(E, ReturnValue);
+ break;
+ case Builtin::BI__builtin_canonicalize:
+ case Builtin::BI__builtin_canonicalizef:
+ case Builtin::BI__builtin_canonicalizel:
+ return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::canonicalize));
}
// If this is an alias for a lib function (e.g. __builtin_sin), emit
Index: include/clang/Basic/Builtins.def
===================================================================
--- include/clang/Basic/Builtins.def
+++ include/clang/Basic/Builtins.def
@@ -377,6 +377,11 @@
BUILTIN(__builtin_signbitf, "if", "Fnc")
BUILTIN(__builtin_signbitl, "iLd", "Fnc")
+// Special FP builtins.
+BUILTIN(__builtin_canonicalize, "dd", "nc")
+BUILTIN(__builtin_canonicalizef, "ff", "nc")
+BUILTIN(__builtin_canonicalizel, "LdLd", "nc")
+
// Builtins for arithmetic.
BUILTIN(__builtin_clzs , "iUs" , "nc")
BUILTIN(__builtin_clz , "iUi" , "nc")
Index: docs/LanguageExtensions.rst
===================================================================
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1728,6 +1728,24 @@
Query for this feature with ``__has_builtin(__builtin_add_overflow)``, etc.
+Floating point builtins
+---------------------------------------
+
+``__builtin_canonicalize``
+--------------------------
+
+.. code-block:: c
+
+ double __builtin_canonicalize(double);
+ float __builtin_canonicalizef(float);
+ long double__builtin_canonicalizel(long double);
+
+Returns the platform specific canonical encoding of a floating point
+number. This canonicalization is useful for implementing certain
+numeric primitives such as frexp. See `LLVM canonicalize intrinsic
+<http://llvm.org/docs/LangRef.html#llvm-canonicalize-intrinsic>`_ for
+more information on the semantics.
+
.. _langext-__c11_atomic:
__c11_atomic builtins
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17558.48879.patch
Type: text/x-patch
Size: 2808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160224/98c6794f/attachment.bin>
More information about the cfe-commits
mailing list