forked from OSchip/llvm-project
parent
abbfd2bde0
commit
41ef85df0a
|
@ -1,37 +1,8 @@
|
|||
#define _CLC_CONVERT_DECL(FROM_TYPE, TO_TYPE, SUFFIX) \
|
||||
_CLC_OVERLOAD _CLC_DECL TO_TYPE convert_##TO_TYPE##SUFFIX(FROM_TYPE x);
|
||||
|
||||
_CLC_CONVERT_DECL(long, char, )
|
||||
_CLC_CONVERT_DECL(ulong, uchar, )
|
||||
_CLC_CONVERT_DECL(long, short, )
|
||||
_CLC_CONVERT_DECL(ulong, ushort, )
|
||||
_CLC_CONVERT_DECL(long, int, )
|
||||
_CLC_CONVERT_DECL(ulong, uint, )
|
||||
_CLC_CONVERT_DECL(long, long, )
|
||||
_CLC_CONVERT_DECL(ulong, ulong, )
|
||||
#ifdef cl_khr_fp64
|
||||
_CLC_CONVERT_DECL(double, float, )
|
||||
_CLC_CONVERT_DECL(double, double, )
|
||||
#else
|
||||
_CLC_CONVERT_DECL(float, float, )
|
||||
#endif
|
||||
|
||||
_CLC_CONVERT_DECL(long, char, _sat)
|
||||
_CLC_CONVERT_DECL(ulong, uchar, _sat)
|
||||
_CLC_CONVERT_DECL(long, short, _sat)
|
||||
_CLC_CONVERT_DECL(ulong, ushort, _sat)
|
||||
_CLC_CONVERT_DECL(long, int, _sat)
|
||||
_CLC_CONVERT_DECL(ulong, uint, _sat)
|
||||
_CLC_CONVERT_DECL(long, long, _sat)
|
||||
_CLC_CONVERT_DECL(ulong, ulong, _sat)
|
||||
#ifdef cl_khr_fp64
|
||||
_CLC_CONVERT_DECL(double, float, _sat)
|
||||
_CLC_CONVERT_DECL(double, double, _sat)
|
||||
#else
|
||||
_CLC_CONVERT_DECL(float, float, _sat)
|
||||
#endif
|
||||
|
||||
#define _CLC_VECTOR_CONVERT_DECL(FROM_TYPE, TO_TYPE, SUFFIX) \
|
||||
_CLC_CONVERT_DECL(FROM_TYPE, TO_TYPE, SUFFIX) \
|
||||
_CLC_CONVERT_DECL(FROM_TYPE##2, TO_TYPE##2, SUFFIX) \
|
||||
_CLC_CONVERT_DECL(FROM_TYPE##3, TO_TYPE##3, SUFFIX) \
|
||||
_CLC_CONVERT_DECL(FROM_TYPE##4, TO_TYPE##4, SUFFIX) \
|
||||
|
|
|
@ -30,21 +30,48 @@
|
|||
return (TO_TYPE##16)(convert_##TO_TYPE##8##SUFFIX(x.lo), convert_##TO_TYPE##8##SUFFIX(x.hi)); \
|
||||
}
|
||||
|
||||
CONVERT_ID(long, char, )
|
||||
CONVERT_ID(ulong, uchar, )
|
||||
CONVERT_ID(long, short, )
|
||||
CONVERT_ID(ulong, ushort, )
|
||||
CONVERT_ID(long, int, )
|
||||
CONVERT_ID(ulong, uint, )
|
||||
CONVERT_ID(long, long, )
|
||||
CONVERT_ID(ulong, ulong, )
|
||||
#define CONVERT_ID_FROM1(FROM_TYPE) \
|
||||
CONVERT_ID(FROM_TYPE, char, ) \
|
||||
CONVERT_ID(FROM_TYPE, uchar, ) \
|
||||
CONVERT_ID(FROM_TYPE, int, ) \
|
||||
CONVERT_ID(FROM_TYPE, uint, ) \
|
||||
CONVERT_ID(FROM_TYPE, short, ) \
|
||||
CONVERT_ID(FROM_TYPE, ushort, ) \
|
||||
CONVERT_ID(FROM_TYPE, long, ) \
|
||||
CONVERT_ID(FROM_TYPE, ulong, ) \
|
||||
CONVERT_ID(FROM_TYPE, float, )
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
CONVERT_ID(double, float, )
|
||||
CONVERT_ID(double, double, )
|
||||
#define CONVERT_ID_FROM(FROM_TYPE) \
|
||||
CONVERT_ID_FROM1(FROM_TYPE) \
|
||||
CONVERT_ID(FROM_TYPE, double, )
|
||||
#else
|
||||
CONVERT_ID(float, float, )
|
||||
#define CONVERT_ID_FROM(FROM_TYPE) \
|
||||
CONVERT_ID_FROM1(FROM_TYPE)
|
||||
#endif
|
||||
|
||||
#define CONVERT_ID_TO1()
|
||||
CONVERT_ID_FROM(char)
|
||||
CONVERT_ID_FROM(uchar)
|
||||
CONVERT_ID_FROM(int)
|
||||
CONVERT_ID_FROM(uint)
|
||||
CONVERT_ID_FROM(short)
|
||||
CONVERT_ID_FROM(ushort)
|
||||
CONVERT_ID_FROM(long)
|
||||
CONVERT_ID_FROM(ulong)
|
||||
CONVERT_ID_FROM(float)
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#define CONVERT_ID_TO() \
|
||||
CONVERT_ID_TO1() \
|
||||
CONVERT_ID_FROM(double)
|
||||
#else
|
||||
#define CONVERT_ID_TO() \
|
||||
CONVERT_ID_TO1()
|
||||
#endif
|
||||
|
||||
CONVERT_ID_TO()
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF char convert_char_sat(long l) {
|
||||
return l > 127 ? 127 : l < -128 ? -128 : l;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue