[libclc] r188131 - Add some missing convert_* functions

Tom Stellard thomas.stellard at amd.com
Fri Aug 9 20:40:38 PDT 2013


Author: tstellar
Date: Fri Aug  9 22:40:37 2013
New Revision: 188131

URL: http://llvm.org/viewvc/llvm-project?rev=188131&view=rev
Log:
Add some missing convert_* functions

Modified:
    libclc/trunk/generic/include/clc/convert.h
    libclc/trunk/generic/lib/convert.cl

Modified: libclc/trunk/generic/include/clc/convert.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/convert.h?rev=188131&r1=188130&r2=188131&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/convert.h (original)
+++ libclc/trunk/generic/include/clc/convert.h Fri Aug  9 22:40:37 2013
@@ -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) \

Modified: libclc/trunk/generic/lib/convert.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/convert.cl?rev=188131&r1=188130&r2=188131&view=diff
==============================================================================
--- libclc/trunk/generic/lib/convert.cl (original)
+++ libclc/trunk/generic/lib/convert.cl Fri Aug  9 22:40:37 2013
@@ -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;
 }





More information about the cfe-commits mailing list