[cfe-commits] [libclc] r157613 - in /libclc/trunk/generic: include/clc/clc.h include/clc/math/fma.h include/clc/math/hypot.h include/clc/math/hypot.inc include/clc/math/ternary_intrin.inc lib/SOURCES lib/math/hypot.cl lib/math/hypot.inc

Peter Collingbourne peter at pcc.me.uk
Tue May 29 06:35:28 PDT 2012


Author: pcc
Date: Tue May 29 08:35:28 2012
New Revision: 157613

URL: http://llvm.org/viewvc/llvm-project?rev=157613&view=rev
Log:
Add fma, hypot builtins.

Added:
    libclc/trunk/generic/include/clc/math/fma.h
    libclc/trunk/generic/include/clc/math/hypot.h
    libclc/trunk/generic/include/clc/math/hypot.inc
    libclc/trunk/generic/include/clc/math/ternary_intrin.inc
    libclc/trunk/generic/lib/math/hypot.cl
    libclc/trunk/generic/lib/math/hypot.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=157613&r1=157612&r2=157613&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Tue May 29 08:35:28 2012
@@ -36,6 +36,8 @@
 #include <clc/math/exp.h>
 #include <clc/math/exp2.h>
 #include <clc/math/fabs.h>
+#include <clc/math/fma.h>
+#include <clc/math/hypot.h>
 #include <clc/math/log.h>
 #include <clc/math/log2.h>
 #include <clc/math/mad.h>

Added: libclc/trunk/generic/include/clc/math/fma.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/fma.h?rev=157613&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/math/fma.h (added)
+++ libclc/trunk/generic/include/clc/math/fma.h Tue May 29 08:35:28 2012
@@ -0,0 +1,6 @@
+#undef fma
+#define fma __clc_fma
+
+#define FUNCTION __clc_fma
+#define INTRINSIC "llvm.fma"
+#include <clc/math/ternary_intrin.inc>

Added: libclc/trunk/generic/include/clc/math/hypot.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/hypot.h?rev=157613&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/math/hypot.h (added)
+++ libclc/trunk/generic/include/clc/math/hypot.h Tue May 29 08:35:28 2012
@@ -0,0 +1,2 @@
+#define BODY <clc/math/hypot.inc>
+#include <clc/math/gentype.inc>

Added: libclc/trunk/generic/include/clc/math/hypot.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/hypot.inc?rev=157613&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/math/hypot.inc (added)
+++ libclc/trunk/generic/include/clc/math/hypot.inc Tue May 29 08:35:28 2012
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL GENTYPE hypot(GENTYPE x, GENTYPE y);

Added: libclc/trunk/generic/include/clc/math/ternary_intrin.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/ternary_intrin.inc?rev=157613&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/math/ternary_intrin.inc (added)
+++ libclc/trunk/generic/include/clc/math/ternary_intrin.inc Tue May 29 08:35:28 2012
@@ -0,0 +1,18 @@
+_CLC_OVERLOAD float FUNCTION(float, float, float) __asm(INTRINSIC ".f32");
+_CLC_OVERLOAD float2 FUNCTION(float2, float2, float2) __asm(INTRINSIC ".v2f32");
+_CLC_OVERLOAD float3 FUNCTION(float3, float3, float3) __asm(INTRINSIC ".v3f32");
+_CLC_OVERLOAD float4 FUNCTION(float4, float4, float4) __asm(INTRINSIC ".v4f32");
+_CLC_OVERLOAD float8 FUNCTION(float8, float8, float8) __asm(INTRINSIC ".v8f32");
+_CLC_OVERLOAD float16 FUNCTION(float16, float16, float16) __asm(INTRINSIC ".v16f32");
+
+#ifdef cl_khr_fp64
+_CLC_OVERLOAD double FUNCTION(double, double, double) __asm(INTRINSIC ".f64");
+_CLC_OVERLOAD double2 FUNCTION(double2, double2, double2) __asm(INTRINSIC ".v2f64");
+_CLC_OVERLOAD double3 FUNCTION(double3, double3, double3) __asm(INTRINSIC ".v3f64");
+_CLC_OVERLOAD double4 FUNCTION(double4, double4, double4) __asm(INTRINSIC ".v4f64");
+_CLC_OVERLOAD double8 FUNCTION(double8, double8, double8) __asm(INTRINSIC ".v8f64");
+_CLC_OVERLOAD double16 FUNCTION(double16, double16, double16) __asm(INTRINSIC ".v16f64");
+#endif
+
+#undef FUNCTION
+#undef INTRINSIC

Modified: libclc/trunk/generic/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=157613&r1=157612&r2=157613&view=diff
==============================================================================
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Tue May 29 08:35:28 2012
@@ -7,4 +7,5 @@
 integer/add_sat.cl
 integer/add_sat.ll
 integer/add_sat_impl.ll
+math/hypot.cl
 math/mad.cl

Added: libclc/trunk/generic/lib/math/hypot.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/hypot.cl?rev=157613&view=auto
==============================================================================
--- libclc/trunk/generic/lib/math/hypot.cl (added)
+++ libclc/trunk/generic/lib/math/hypot.cl Tue May 29 08:35:28 2012
@@ -0,0 +1,8 @@
+#include <clc/clc.h>
+
+#ifdef cl_khr_fp64
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+#endif
+
+#define BODY <hypot.inc>
+#include <clc/math/gentype.inc>

Added: libclc/trunk/generic/lib/math/hypot.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/math/hypot.inc?rev=157613&view=auto
==============================================================================
--- libclc/trunk/generic/lib/math/hypot.inc (added)
+++ libclc/trunk/generic/lib/math/hypot.inc Tue May 29 08:35:28 2012
@@ -0,0 +1,3 @@
+_CLC_OVERLOAD _CLC_DEF GENTYPE hypot(GENTYPE x, GENTYPE y) {
+  return sqrt(x*x + y*y);
+}





More information about the cfe-commits mailing list