[libclc] r185839 - Implement mad24() and mul24() builtins
Tom Stellard
thomas.stellard at amd.com
Mon Jul 8 10:27:13 PDT 2013
Author: tstellar
Date: Mon Jul 8 12:27:13 2013
New Revision: 185839
URL: http://llvm.org/viewvc/llvm-project?rev=185839&view=rev
Log:
Implement mad24() and mul24() builtins
Reviewed-by: Aaron Watry <awatry at gmail.com>
Added:
libclc/trunk/generic/include/clc/integer/mad24.h
libclc/trunk/generic/include/clc/integer/mad24.inc
libclc/trunk/generic/include/clc/integer/mul24.h
libclc/trunk/generic/include/clc/integer/mul24.inc
libclc/trunk/generic/lib/integer/mad24.cl
libclc/trunk/generic/lib/integer/mad24.inc
libclc/trunk/generic/lib/integer/mul24.cl
libclc/trunk/generic/lib/integer/mul24.inc
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES
Modified: libclc/trunk/generic/include/clc/clc.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=185839&r1=185838&r2=185839&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Mon Jul 8 12:27:13 2013
@@ -64,6 +64,8 @@
#include <clc/integer/abs_diff.h>
#include <clc/integer/add_sat.h>
#include <clc/integer/clz.h>
+#include <clc/integer/mad24.h>
+#include <clc/integer/mul24.h>
#include <clc/integer/rotate.h>
#include <clc/integer/sub_sat.h>
Added: libclc/trunk/generic/include/clc/integer/mad24.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/integer/mad24.h?rev=185839&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/integer/mad24.h (added)
+++ libclc/trunk/generic/include/clc/integer/mad24.h Mon Jul 8 12:27:13 2013
@@ -0,0 +1,3 @@
+#define __CLC_BODY <clc/integer/mad24.inc>
+#include <clc/integer/integer-gentype.inc>
+#undef __CLC_BODY
Added: libclc/trunk/generic/include/clc/integer/mad24.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/integer/mad24.inc?rev=185839&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/integer/mad24.inc (added)
+++ libclc/trunk/generic/include/clc/integer/mad24.inc Mon Jul 8 12:27:13 2013
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE mad24(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_GENTYPE z);
Added: libclc/trunk/generic/include/clc/integer/mul24.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/integer/mul24.h?rev=185839&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/integer/mul24.h (added)
+++ libclc/trunk/generic/include/clc/integer/mul24.h Mon Jul 8 12:27:13 2013
@@ -0,0 +1,3 @@
+#define __CLC_BODY <clc/integer/mul24.inc>
+#include <clc/integer/integer-gentype.inc>
+#undef __CLC_BODY
Added: libclc/trunk/generic/include/clc/integer/mul24.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/integer/mul24.inc?rev=185839&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/integer/mul24.inc (added)
+++ libclc/trunk/generic/include/clc/integer/mul24.inc Mon Jul 8 12:27:13 2013
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE mul24(__CLC_GENTYPE x, __CLC_GENTYPE y);
Modified: libclc/trunk/generic/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=185839&r1=185838&r2=185839&view=diff
==============================================================================
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Mon Jul 8 12:27:13 2013
@@ -11,6 +11,8 @@ integer/add_sat_impl.ll
integer/clz.cl
integer/clz_if.ll
integer/clz_impl.ll
+integer/mad24.cl
+integer/mul24.cl
integer/rotate.cl
integer/sub_sat.cl
integer/sub_sat_if.ll
Added: libclc/trunk/generic/lib/integer/mad24.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/integer/mad24.cl?rev=185839&view=auto
==============================================================================
--- libclc/trunk/generic/lib/integer/mad24.cl (added)
+++ libclc/trunk/generic/lib/integer/mad24.cl Mon Jul 8 12:27:13 2013
@@ -0,0 +1,4 @@
+#include <clc/clc.h>
+
+#define __CLC_BODY <mad24.inc>
+#include <clc/integer/integer-gentype.inc>
Added: libclc/trunk/generic/lib/integer/mad24.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/integer/mad24.inc?rev=185839&view=auto
==============================================================================
--- libclc/trunk/generic/lib/integer/mad24.inc (added)
+++ libclc/trunk/generic/lib/integer/mad24.inc Mon Jul 8 12:27:13 2013
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE mad24(__CLC_GENTYPE x, __CLC_GENTYPE y, __CLC_GENTYPE z){
+ return mul24(x, y) + z;
+}
Added: libclc/trunk/generic/lib/integer/mul24.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/integer/mul24.cl?rev=185839&view=auto
==============================================================================
--- libclc/trunk/generic/lib/integer/mul24.cl (added)
+++ libclc/trunk/generic/lib/integer/mul24.cl Mon Jul 8 12:27:13 2013
@@ -0,0 +1,4 @@
+#include <clc/clc.h>
+
+#define __CLC_BODY <mul24.inc>
+#include <clc/integer/integer-gentype.inc>
Added: libclc/trunk/generic/lib/integer/mul24.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/integer/mul24.inc?rev=185839&view=auto
==============================================================================
--- libclc/trunk/generic/lib/integer/mul24.inc (added)
+++ libclc/trunk/generic/lib/integer/mul24.inc Mon Jul 8 12:27:13 2013
@@ -0,0 +1,11 @@
+
+// We need to use shifts here in order to mantain the sign bit for signed
+// integers. The compiler should optimize this to (x & 0x00FFFFFF) for
+// unsigned integers.
+#define CONVERT_TO_24BIT(x) (((x) << 8) >> 8)
+
+_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE mul24(__CLC_GENTYPE x, __CLC_GENTYPE y){
+ return CONVERT_TO_24BIT(x) * CONVERT_TO_24BIT(y);
+}
+
+#undef CONVERT_TO_24BIT
More information about the cfe-commits
mailing list