[libclc] r185002 - libclc: Implement the min(vec, scalar) version of the min builtin.

Tom Stellard thomas.stellard at amd.com
Wed Jun 26 11:21:44 PDT 2013


Author: tstellar
Date: Wed Jun 26 13:21:44 2013
New Revision: 185002

URL: http://llvm.org/viewvc/llvm-project?rev=185002&view=rev
Log:
libclc: Implement the min(vec, scalar) version of the min builtin.

Checks if the current GENTYPE is scalar, and if not, then defines a separate
implementation of the function which casts the second arg to vector before
proceeding.

Patch by: Aaron Watry

Modified:
    libclc/trunk/generic/include/clc/integer/gentype.inc
    libclc/trunk/generic/include/clc/math/gentype.inc
    libclc/trunk/generic/include/clc/shared/min.inc
    libclc/trunk/generic/lib/shared/min.inc

Modified: libclc/trunk/generic/include/clc/integer/gentype.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/integer/gentype.inc?rev=185002&r1=185001&r2=185002&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/integer/gentype.inc (original)
+++ libclc/trunk/generic/include/clc/integer/gentype.inc Wed Jun 26 13:21:44 2013
@@ -1,4 +1,8 @@
+//These 2 defines only change when switching between data sizes or base types to
+//keep this file manageable.
 #define GENSIZE 8
+#define SCALAR_GENTYPE char
+
 #define GENTYPE char
 #define UGENTYPE uchar
 #define SGENTYPE char
@@ -49,6 +53,9 @@
 #undef UGENTYPE
 #undef SGENTYPE
 
+#undef SCALAR_GENTYPE
+#define SCALAR_GENTYPE uchar
+
 #define GENTYPE uchar
 #define UGENTYPE uchar
 #define SGENTYPE char
@@ -101,6 +108,8 @@
 
 #undef GENSIZE
 #define GENSIZE 16
+#undef SCALAR_GENTYPE
+#define SCALAR_GENTYPE short
 
 #define GENTYPE short
 #define UGENTYPE ushort
@@ -152,6 +161,9 @@
 #undef UGENTYPE
 #undef SGENTYPE
 
+#undef SCALAR_GENTYPE
+#define SCALAR_GENTYPE ushort
+
 #define GENTYPE ushort
 #define UGENTYPE ushort
 #define SGENTYPE short
@@ -204,6 +216,8 @@
 
 #undef GENSIZE
 #define GENSIZE 32
+#undef SCALAR_GENTYPE
+#define SCALAR_GENTYPE int
 
 #define GENTYPE int
 #define UGENTYPE uint
@@ -255,6 +269,9 @@
 #undef UGENTYPE
 #undef SGENTYPE
 
+#undef SCALAR_GENTYPE
+#define SCALAR_GENTYPE uint
+
 #define GENTYPE uint
 #define UGENTYPE uint
 #define SGENTYPE int
@@ -307,6 +324,8 @@
 
 #undef GENSIZE
 #define GENSIZE 64
+#undef SCALAR_GENTYPE
+#define SCALAR_GENTYPE long
 
 #define GENTYPE long
 #define UGENTYPE ulong
@@ -358,6 +377,9 @@
 #undef UGENTYPE
 #undef SGENTYPE
 
+#undef SCALAR_GENTYPE
+#define SCALAR_GENTYPE ulong
+
 #define GENTYPE ulong
 #define UGENTYPE ulong
 #define SGENTYPE long
@@ -409,4 +431,5 @@
 #undef SGENTYPE
 
 #undef GENSIZE
+#undef SCALAR_GENTYPE
 #undef BODY

Modified: libclc/trunk/generic/include/clc/math/gentype.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/math/gentype.inc?rev=185002&r1=185001&r2=185002&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/math/gentype.inc (original)
+++ libclc/trunk/generic/include/clc/math/gentype.inc Wed Jun 26 13:21:44 2013
@@ -1,3 +1,5 @@
+#define SCALAR_GENTYPE float
+
 #define GENTYPE float
 #define SCALAR
 #include BODY
@@ -24,7 +26,11 @@
 #include BODY
 #undef GENTYPE
 
+#undef SCALAR_GENTYPE
+
 #ifdef cl_khr_fp64
+#define SCALAR_GENTYPE double
+
 #define SCALAR
 #define GENTYPE double
 #include BODY
@@ -50,6 +56,8 @@
 #define GENTYPE double16
 #include BODY
 #undef GENTYPE
+
+#undef SCALAR_GENTYPE
 #endif
 
 #undef BODY

Modified: libclc/trunk/generic/include/clc/shared/min.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/shared/min.inc?rev=185002&r1=185001&r2=185002&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/shared/min.inc (original)
+++ libclc/trunk/generic/include/clc/shared/min.inc Wed Jun 26 13:21:44 2013
@@ -1 +1,5 @@
 _CLC_OVERLOAD _CLC_DECL GENTYPE min(GENTYPE a, GENTYPE b);
+
+#ifndef SCALAR
+_CLC_OVERLOAD _CLC_DECL GENTYPE min(GENTYPE a, SCALAR_GENTYPE b);
+#endif
\ No newline at end of file

Modified: libclc/trunk/generic/lib/shared/min.inc
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/shared/min.inc?rev=185002&r1=185001&r2=185002&view=diff
==============================================================================
--- libclc/trunk/generic/lib/shared/min.inc (original)
+++ libclc/trunk/generic/lib/shared/min.inc Wed Jun 26 13:21:44 2013
@@ -1,3 +1,9 @@
 _CLC_OVERLOAD _CLC_DEF GENTYPE min(GENTYPE a, GENTYPE b) {
   return (a < b ? a : b);
 }
+
+#ifndef SCALAR
+_CLC_OVERLOAD _CLC_DEF GENTYPE min(GENTYPE a, SCALAR_GENTYPE b) {
+  return (a < (GENTYPE)b ? a : (GENTYPE)b);
+}
+#endif





More information about the cfe-commits mailing list