diff options
author | Homer Hsing <homer.xing@intel.com> | 2013-10-18 10:26:56 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@linux.intel.com> | 2013-10-18 16:59:29 +0800 |
commit | b205fb67009947bd4242dad20bd3299b1a657a43 (patch) | |
tree | 1065755670aff273df4e1cd5e4d8521630eaf65b | |
parent | 29c26bce96f32441409206e98871988c99f7a231 (diff) |
support saturated converting from narrower type to wider type
This patch supports saturated converting from narrower type to wider type.
It simply returns the parameter.
version 2: not need convert_float_sat(*)
Signed-off-by: Homer Hsing <homer.xing@intel.com>
Reviewed-by: "Yang, Rong R" <rong.r.yang@intel.com>
-rw-r--r-- | backend/src/ocl_stdlib.tmpl.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/backend/src/ocl_stdlib.tmpl.h b/backend/src/ocl_stdlib.tmpl.h index 34379b3a..08c5fa45 100644 --- a/backend/src/ocl_stdlib.tmpl.h +++ b/backend/src/ocl_stdlib.tmpl.h @@ -282,6 +282,44 @@ INLINE_OVERLOADABLE ulong convert_ulong_sat(long x) { return x < 0 ? 0 : x; } +#define DEF(DSTTYPE, SRCTYPE) \ + INLINE_OVERLOADABLE DSTTYPE convert_ ## DSTTYPE ## _sat(SRCTYPE x) { \ + return x; \ + } +DEF(char, char); +DEF(uchar, uchar); +DEF(short, char); +DEF(short, uchar); +DEF(short, short); +DEF(ushort, char); +DEF(ushort, uchar); +DEF(ushort, ushort); +DEF(int, char); +DEF(int, uchar); +DEF(int, short); +DEF(int, ushort); +DEF(int, int); +DEF(uint, char); +DEF(uint, uchar); +DEF(uint, short); +DEF(uint, ushort); +DEF(uint, uint); +DEF(long, char); +DEF(long, uchar); +DEF(long, short); +DEF(long, ushort); +DEF(long, int); +DEF(long, uint); +DEF(long, long); +DEF(ulong, char); +DEF(ulong, uchar); +DEF(ulong, short); +DEF(ulong, ushort); +DEF(ulong, int); +DEF(ulong, uint); +DEF(ulong, ulong); +#undef DEF + INLINE_OVERLOADABLE int isfinite(float x) { return __builtin_isfinite(x); } INLINE_OVERLOADABLE int isinf(float x) { return __builtin_isinf(x); } INLINE_OVERLOADABLE int isnan(float x) { |