mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-01 12:43:47 +00:00
Implement fmax() and fmin() builtins
llvm-svn: 184987
This commit is contained in:
parent
d84c7f5d0f
commit
509b3b2104
@ -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>
|
||||
|
6
libclc/generic/include/clc/math/binary_decl.inc
Normal file
6
libclc/generic/include/clc/math/binary_decl.inc
Normal 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
|
11
libclc/generic/include/clc/math/fmax.h
Normal file
11
libclc/generic/include/clc/math/fmax.h
Normal 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
|
||||
|
11
libclc/generic/include/clc/math/fmin.h
Normal file
11
libclc/generic/include/clc/math/fmin.h
Normal 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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
18
libclc/generic/lib/math/binary_impl.inc
Normal file
18
libclc/generic/lib/math/binary_impl.inc
Normal 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);
|
||||
}
|
11
libclc/generic/lib/math/fmax.cl
Normal file
11
libclc/generic/lib/math/fmax.cl
Normal 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>
|
11
libclc/generic/lib/math/fmin.cl
Normal file
11
libclc/generic/lib/math/fmin.cl
Normal 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>
|
Loading…
x
Reference in New Issue
Block a user