[Libclc-dev] [PATCH] Move clcmacro.h to avoid cluttering user namespace
Tom Stellard
tom at stellard.net
Mon Jun 23 09:10:48 PDT 2014
On Mon, Jun 23, 2014 at 03:24:56PM +0100, Jeroen Ketema wrote:
> ---
> generic/include/clc/clc.h | 3 ---
> generic/include/clc/clcmacro.h | 54 ---------------------------------------
> generic/lib/clcmacro.h | 54 +++++++++++++++++++++++++++++++++++++++
> generic/lib/common/sign.cl | 1 +
> generic/lib/integer/add_sat.cl | 1 +
> generic/lib/integer/clz.cl | 1 +
> generic/lib/integer/sub_sat.cl | 1 +
> generic/lib/math/clc_nextafter.cl | 1 +
> generic/lib/math/nextafter.cl | 1 +
> generic/lib/math/pown.cl | 1 +
> generic/lib/relational/isnan.cl | 1 +
> 11 files changed, 62 insertions(+), 57 deletions(-)
> delete mode 100644 generic/include/clc/clcmacro.h
> create mode 100644 generic/lib/clcmacro.h
>
> diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
> index a975c0d..c7c8dfb 100644
> --- a/generic/include/clc/clc.h
> +++ b/generic/include/clc/clc.h
> @@ -11,9 +11,6 @@
> /* Function Attributes */
> #include <clc/clcfunc.h>
>
> -/* Pattern Macro Definitions */
> -#include <clc/clcmacro.h>
> -
> /* 6.1 Supported Data Types */
> #include <clc/clctypes.h>
>
> diff --git a/generic/include/clc/clcmacro.h b/generic/include/clc/clcmacro.h
> deleted file mode 100644
> index 730073a..0000000
> --- a/generic/include/clc/clcmacro.h
> +++ /dev/null
> @@ -1,54 +0,0 @@
> -#define _CLC_UNARY_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE) \
> - DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x) { \
> - return (RET_TYPE##2)(FUNCTION(x.x), FUNCTION(x.y)); \
> - } \
> -\
> - DECLSPEC RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x) { \
> - return (RET_TYPE##3)(FUNCTION(x.x), FUNCTION(x.y), FUNCTION(x.z)); \
> - } \
> -\
> - DECLSPEC RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x) { \
> - return (RET_TYPE##4)(FUNCTION(x.lo), FUNCTION(x.hi)); \
> - } \
> -\
> - DECLSPEC RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x) { \
> - return (RET_TYPE##8)(FUNCTION(x.lo), FUNCTION(x.hi)); \
> - } \
> -\
> - DECLSPEC RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x) { \
> - return (RET_TYPE##16)(FUNCTION(x.lo), FUNCTION(x.hi)); \
> - }
> -
> -#define _CLC_BINARY_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE, ARG2_TYPE) \
> - DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x, ARG2_TYPE##2 y) { \
> - return (RET_TYPE##2)(FUNCTION(x.x, y.x), FUNCTION(x.y, y.y)); \
> - } \
> -\
> - DECLSPEC RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x, ARG2_TYPE##3 y) { \
> - return (RET_TYPE##3)(FUNCTION(x.x, y.x), FUNCTION(x.y, y.y), \
> - FUNCTION(x.z, y.z)); \
> - } \
> -\
> - DECLSPEC RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x, ARG2_TYPE##4 y) { \
> - return (RET_TYPE##4)(FUNCTION(x.lo, y.lo), FUNCTION(x.hi, y.hi)); \
> - } \
> -\
> - DECLSPEC RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x, ARG2_TYPE##8 y) { \
> - return (RET_TYPE##8)(FUNCTION(x.lo, y.lo), FUNCTION(x.hi, y.hi)); \
> - } \
> -\
> - DECLSPEC RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x, ARG2_TYPE##16 y) { \
> - return (RET_TYPE##16)(FUNCTION(x.lo, y.lo), FUNCTION(x.hi, y.hi)); \
> - }
> -
> -#define _CLC_DEFINE_BINARY_BUILTIN(RET_TYPE, FUNCTION, BUILTIN, ARG1_TYPE, ARG2_TYPE) \
> -_CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \
> - return BUILTIN(x, y); \
> -} \
> -_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, RET_TYPE, FUNCTION, ARG1_TYPE, ARG2_TYPE)
> -
> -#define _CLC_DEFINE_UNARY_BUILTIN(RET_TYPE, FUNCTION, BUILTIN, ARG1_TYPE) \
> -_CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x) { \
> - return BUILTIN(x); \
> -} \
> -_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, RET_TYPE, FUNCTION, ARG1_TYPE)
> diff --git a/generic/lib/clcmacro.h b/generic/lib/clcmacro.h
> new file mode 100644
> index 0000000..730073a
> --- /dev/null
> +++ b/generic/lib/clcmacro.h
> @@ -0,0 +1,54 @@
> +#define _CLC_UNARY_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE) \
> + DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x) { \
> + return (RET_TYPE##2)(FUNCTION(x.x), FUNCTION(x.y)); \
> + } \
> +\
> + DECLSPEC RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x) { \
> + return (RET_TYPE##3)(FUNCTION(x.x), FUNCTION(x.y), FUNCTION(x.z)); \
> + } \
> +\
> + DECLSPEC RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x) { \
> + return (RET_TYPE##4)(FUNCTION(x.lo), FUNCTION(x.hi)); \
> + } \
> +\
> + DECLSPEC RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x) { \
> + return (RET_TYPE##8)(FUNCTION(x.lo), FUNCTION(x.hi)); \
> + } \
> +\
> + DECLSPEC RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x) { \
> + return (RET_TYPE##16)(FUNCTION(x.lo), FUNCTION(x.hi)); \
> + }
> +
> +#define _CLC_BINARY_VECTORIZE(DECLSPEC, RET_TYPE, FUNCTION, ARG1_TYPE, ARG2_TYPE) \
> + DECLSPEC RET_TYPE##2 FUNCTION(ARG1_TYPE##2 x, ARG2_TYPE##2 y) { \
> + return (RET_TYPE##2)(FUNCTION(x.x, y.x), FUNCTION(x.y, y.y)); \
> + } \
> +\
> + DECLSPEC RET_TYPE##3 FUNCTION(ARG1_TYPE##3 x, ARG2_TYPE##3 y) { \
> + return (RET_TYPE##3)(FUNCTION(x.x, y.x), FUNCTION(x.y, y.y), \
> + FUNCTION(x.z, y.z)); \
> + } \
> +\
> + DECLSPEC RET_TYPE##4 FUNCTION(ARG1_TYPE##4 x, ARG2_TYPE##4 y) { \
> + return (RET_TYPE##4)(FUNCTION(x.lo, y.lo), FUNCTION(x.hi, y.hi)); \
> + } \
> +\
> + DECLSPEC RET_TYPE##8 FUNCTION(ARG1_TYPE##8 x, ARG2_TYPE##8 y) { \
> + return (RET_TYPE##8)(FUNCTION(x.lo, y.lo), FUNCTION(x.hi, y.hi)); \
> + } \
> +\
> + DECLSPEC RET_TYPE##16 FUNCTION(ARG1_TYPE##16 x, ARG2_TYPE##16 y) { \
> + return (RET_TYPE##16)(FUNCTION(x.lo, y.lo), FUNCTION(x.hi, y.hi)); \
> + }
> +
> +#define _CLC_DEFINE_BINARY_BUILTIN(RET_TYPE, FUNCTION, BUILTIN, ARG1_TYPE, ARG2_TYPE) \
> +_CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x, ARG2_TYPE y) { \
> + return BUILTIN(x, y); \
> +} \
> +_CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, RET_TYPE, FUNCTION, ARG1_TYPE, ARG2_TYPE)
> +
> +#define _CLC_DEFINE_UNARY_BUILTIN(RET_TYPE, FUNCTION, BUILTIN, ARG1_TYPE) \
> +_CLC_DEF _CLC_OVERLOAD RET_TYPE FUNCTION(ARG1_TYPE x) { \
> + return BUILTIN(x); \
> +} \
> +_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, RET_TYPE, FUNCTION, ARG1_TYPE)
> diff --git a/generic/lib/common/sign.cl b/generic/lib/common/sign.cl
> index 070abd5..a976c88 100644
> --- a/generic/lib/common/sign.cl
> +++ b/generic/lib/common/sign.cl
> @@ -1,4 +1,5 @@
> #include <clc/clc.h>
> +#include <../clcmacro.h>
Shouldn't these includes be in quotes "" ?
-Tom
>
> #define SIGN(TYPE, F) \
> _CLC_DEF _CLC_OVERLOAD TYPE sign(TYPE x) { \
> diff --git a/generic/lib/integer/add_sat.cl b/generic/lib/integer/add_sat.cl
> index 7eb4e39..01c9560 100644
> --- a/generic/lib/integer/add_sat.cl
> +++ b/generic/lib/integer/add_sat.cl
> @@ -1,4 +1,5 @@
> #include <clc/clc.h>
> +#include <../clcmacro.h>
>
> // From add_sat.ll
> _CLC_DECL char __clc_add_sat_s8(char, char);
> diff --git a/generic/lib/integer/clz.cl b/generic/lib/integer/clz.cl
> index 83ef2dd..e771ff5 100644
> --- a/generic/lib/integer/clz.cl
> +++ b/generic/lib/integer/clz.cl
> @@ -1,4 +1,5 @@
> #include <clc/clc.h>
> +#include <../clcmacro.h>
>
> // From clz.ll
> _CLC_DECL char __clc_clz_s8(char);
> diff --git a/generic/lib/integer/sub_sat.cl b/generic/lib/integer/sub_sat.cl
> index 9555b6d..96aa071 100644
> --- a/generic/lib/integer/sub_sat.cl
> +++ b/generic/lib/integer/sub_sat.cl
> @@ -1,4 +1,5 @@
> #include <clc/clc.h>
> +#include <../clcmacro.h>
>
> // From sub_sat.ll
> _CLC_DECL char __clc_sub_sat_s8(char, char);
> diff --git a/generic/lib/math/clc_nextafter.cl b/generic/lib/math/clc_nextafter.cl
> index 92b990d..4fd955f 100644
> --- a/generic/lib/math/clc_nextafter.cl
> +++ b/generic/lib/math/clc_nextafter.cl
> @@ -1,4 +1,5 @@
> #include <clc/clc.h>
> +#include <../clcmacro.h>
>
> // This file provides OpenCL C implementations of nextafter for targets that
> // don't support the clang builtin.
> diff --git a/generic/lib/math/nextafter.cl b/generic/lib/math/nextafter.cl
> index 1a7f169..ffd164c 100644
> --- a/generic/lib/math/nextafter.cl
> +++ b/generic/lib/math/nextafter.cl
> @@ -1,4 +1,5 @@
> #include <clc/clc.h>
> +#include <../clcmacro.h>
>
> _CLC_DEFINE_BINARY_BUILTIN(float, nextafter, __builtin_nextafterf, float, float)
>
> diff --git a/generic/lib/math/pown.cl b/generic/lib/math/pown.cl
> index 46b354b..84ed08a 100644
> --- a/generic/lib/math/pown.cl
> +++ b/generic/lib/math/pown.cl
> @@ -1,4 +1,5 @@
> #include <clc/clc.h>
> +#include <../clcmacro.h>
>
> _CLC_BINARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, float, pown, float, int)
>
> diff --git a/generic/lib/relational/isnan.cl b/generic/lib/relational/isnan.cl
> index 1a64f67..d1bbb89 100644
> --- a/generic/lib/relational/isnan.cl
> +++ b/generic/lib/relational/isnan.cl
> @@ -1,4 +1,5 @@
> #include <clc/clc.h>
> +#include <../clcmacro.h>
>
> _CLC_DEFINE_UNARY_BUILTIN(int, isnan, __builtin_isnan, float)
>
> --
> 1.8.5.2 (Apple Git-48)
>
>
> _______________________________________________
> Libclc-dev mailing list
> Libclc-dev at pcc.me.uk
> http://www.pcc.me.uk/cgi-bin/mailman/listinfo/libclc-dev
More information about the Libclc-dev
mailing list