[libclc] r197769 - Implement trunc builtin.

Tom Stellard thomas.stellard at amd.com
Thu Dec 19 18:08:46 PST 2013


Author: tstellar
Date: Thu Dec 19 20:08:46 2013
New Revision: 197769

URL: http://llvm.org/viewvc/llvm-project?rev=197769&view=rev
Log:
Implement trunc builtin.

OpenCL C lang says that trunc rounds towards zero.
llvm.trunc.* intrinsic rounds to integer not larger in magnitude.
These definitions are equivalent.

Patch by: Jan Vesely

Reviewed-by: Tom Stellard <thomas.stellard at amd.com>
Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>

Added:
    libclc/trunk/generic/include/clc/math/trunc.h
Modified:
    libclc/trunk/generic/include/clc/clc.h

Modified: libclc/trunk/generic/include/clc/clc.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=197769&r1=197768&r2=197769&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Thu Dec 19 20:08:46 2013
@@ -51,6 +51,7 @@
 #include <clc/math/round.h>
 #include <clc/math/sin.h>
 #include <clc/math/sqrt.h>
+#include <clc/math/trunc.h>
 #include <clc/math/native_cos.h>
 #include <clc/math/native_divide.h>
 #include <clc/math/native_exp.h>

Added: libclc/trunk/generic/include/clc/math/trunc.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/trunc.h?rev=197769&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/math/trunc.h (added)
+++ libclc/trunk/generic/include/clc/math/trunc.h Thu Dec 19 20:08:46 2013
@@ -0,0 +1,9 @@
+#undef trunc
+#define trunc __clc_trunc
+
+#define __CLC_FUNCTION __clc_trunc
+#define __CLC_INTRINSIC "llvm.trunc"
+#include <clc/math/unary_intrin.inc>
+
+#undef __CLC_FUNCTION
+#undef __CLC_INTRINSIC





More information about the cfe-commits mailing list