Implement fmax() and fmin() builtins

llvm-svn: 184987
This commit is contained in:
Tom Stellard 2013-06-26 18:20:25 +00:00
parent d84c7f5d0f
commit 509b3b2104
9 changed files with 76 additions and 0 deletions

View File

@ -38,6 +38,8 @@
#include <clc/math/fabs.h>
#include <clc/math/floor.h>
#include <clc/math/fma.h>
#include <clc/math/fmax.h>
#include <clc/math/fmin.h>
#include <clc/math/hypot.h>
#include <clc/math/log.h>
#include <clc/math/log2.h>

View File

@ -0,0 +1,6 @@
_CLC_OVERLOAD _CLC_DECL GENTYPE FUNCTION(GENTYPE a, GENTYPE b);
_CLC_OVERLOAD _CLC_DECL GENTYPE FUNCTION(GENTYPE a, float b);
#ifdef cl_khr_fp64
_CLC_OVERLOAD _CLC_DECL GENTYPE FUNCTION(GENTYPE a, double b);
#endif

View File

@ -0,0 +1,11 @@
#undef fmax
#define fmax __clc_fmax
#define BODY <clc/math/binary_decl.inc>
#define FUNCTION __clc_fmax
#include <clc/math/gentype.inc>
#undef BODY
#undef FUNCTION

View File

@ -0,0 +1,11 @@
#undef fmin
#define fmin __clc_fmin
#define BODY <clc/math/binary_decl.inc>
#define FUNCTION __clc_fmin
#include <clc/math/gentype.inc>
#undef BODY
#undef FUNCTION

View File

@ -1,6 +1,8 @@
#define GENTYPE float
#define SCALAR
#include BODY
#undef GENTYPE
#undef SCALAR
#define GENTYPE float2
#include BODY
@ -23,9 +25,11 @@
#undef GENTYPE
#ifdef cl_khr_fp64
#define SCALAR
#define GENTYPE double
#include BODY
#undef GENTYPE
#undef SCALAR
#define GENTYPE double2
#include BODY

View File

@ -10,6 +10,8 @@ integer/add_sat_impl.ll
integer/sub_sat.cl
integer/sub_sat.ll
integer/sub_sat_impl.ll
math/fmax.cl
math/fmin.cl
math/hypot.cl
math/mad.cl
relational/any.cl

View File

@ -0,0 +1,18 @@
#ifndef SCALAR
_CLC_OVERLOAD _CLC_DEF GENTYPE FUNCTION(GENTYPE x, GENTYPE y) {
return FUNCTION_IMPL(x, y);
}
#endif
_CLC_OVERLOAD _CLC_DEF GENTYPE FUNCTION(GENTYPE x, double y) {
GENTYPE vec_y = (GENTYPE) (y);
return FUNCTION_IMPL(x, vec_y);
}
_CLC_OVERLOAD _CLC_DEF GENTYPE FUNCTION(GENTYPE x, float y) {
GENTYPE vec_y = (GENTYPE) (y);
return FUNCTION_IMPL(x, vec_y);
}

View File

@ -0,0 +1,11 @@
#include <clc/clc.h>
#ifdef cl_khr_fp64
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
#endif
#define FUNCTION __clc_fmax
#define FUNCTION_IMPL(x, y) ((x) < (y) ? (y) : (x))
#define BODY <binary_impl.inc>
#include <clc/math/gentype.inc>

View File

@ -0,0 +1,11 @@
#include <clc/clc.h>
#ifdef cl_khr_fp64
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
#endif
#define FUNCTION __clc_fmin
#define FUNCTION_IMPL(x, y) ((y) < (x) ? (y) : (x))
#define BODY <binary_impl.inc>
#include <clc/math/gentype.inc>