math: Implement minmag

Reviewer: Aaron Watry
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
llvm-svn: 318265
This commit is contained in:
Jan Vesely 2017-11-15 04:10:39 +00:00
parent 7ba243cc3d
commit fe7c045753
5 changed files with 17 additions and 0 deletions

View File

@ -84,6 +84,7 @@
#include <clc/math/logb.h>
#include <clc/math/mad.h>
#include <clc/math/maxmag.h>
#include <clc/math/minmag.h>
#include <clc/math/modf.h>
#include <clc/math/nextafter.h>
#include <clc/math/pow.h>

View File

@ -0,0 +1,7 @@
#define __CLC_BODY <clc/math/binary_decl_tt.inc>
#define __CLC_FUNCTION minmag
#include <clc/math/gentype.inc>
#undef __CLC_BODY
#undef __CLC_FUNCTION

View File

@ -119,6 +119,7 @@ math/log2.cl
math/logb.cl
math/mad.cl
math/maxmag.cl
math/minmag.cl
math/modf.cl
math/native_cos.cl
math/native_divide.cl

View File

@ -0,0 +1,4 @@
#include <clc/clc.h>
#define __CLC_BODY <minmag.inc>
#include <clc/math/gentype.inc>

View File

@ -0,0 +1,4 @@
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE minmag(__CLC_GENTYPE x, __CLC_GENTYPE y) {
const __CLC_GENTYPE res = select(y, x, isless(fabs(x), fabs(y)));
return select(res, fmin(x, y), isnan(x) | isnan(y) | isequal(fabs(x), fabs(y)));
}