Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libclc/clc/include/clc/relational/clc_signbit.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#ifndef __CLC_RELATIONAL_CLC_SIGNBIT_H__
#define __CLC_RELATIONAL_CLC_SIGNBIT_H__

#include "clc/internal/clc.h"

#define __CLC_FUNCTION __clc_signbit
#define __CLC_BODY "clc/relational/unary_decl.inc"

Expand Down
88 changes: 3 additions & 85 deletions libclc/clc/lib/generic/relational/clc_signbit.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,89 +6,7 @@
//
//===----------------------------------------------------------------------===//

#include "clc/internal/clc.h"
#include "clc/relational/relational.h"
#include "clc/relational/clc_signbit.h"

#define _CLC_DEFINE_RELATIONAL_UNARY_VEC2(RET_TYPE, __CLC_FUNCTION, ARG_TYPE) \
_CLC_DEF _CLC_OVERLOAD RET_TYPE __CLC_FUNCTION(ARG_TYPE x) { \
return (RET_TYPE)((RET_TYPE){__CLC_FUNCTION(x.lo), \
__CLC_FUNCTION(x.hi)} != (RET_TYPE)0); \
}

#define _CLC_DEFINE_RELATIONAL_UNARY_VEC3(RET_TYPE, __CLC_FUNCTION, ARG_TYPE) \
_CLC_DEF _CLC_OVERLOAD RET_TYPE __CLC_FUNCTION(ARG_TYPE x) { \
return (RET_TYPE)((RET_TYPE){__CLC_FUNCTION(x.s0), __CLC_FUNCTION(x.s1), \
__CLC_FUNCTION(x.s2)} != (RET_TYPE)0); \
}

#define _CLC_DEFINE_RELATIONAL_UNARY_VEC4(RET_TYPE, __CLC_FUNCTION, ARG_TYPE) \
_CLC_DEF _CLC_OVERLOAD RET_TYPE __CLC_FUNCTION(ARG_TYPE x) { \
return (RET_TYPE)((RET_TYPE){__CLC_FUNCTION(x.s0), __CLC_FUNCTION(x.s1), \
__CLC_FUNCTION(x.s2), \
__CLC_FUNCTION(x.s3)} != (RET_TYPE)0); \
}

#define _CLC_DEFINE_RELATIONAL_UNARY_VEC8(RET_TYPE, __CLC_FUNCTION, ARG_TYPE) \
_CLC_DEF _CLC_OVERLOAD RET_TYPE __CLC_FUNCTION(ARG_TYPE x) { \
return (RET_TYPE)((RET_TYPE){__CLC_FUNCTION(x.s0), __CLC_FUNCTION(x.s1), \
__CLC_FUNCTION(x.s2), __CLC_FUNCTION(x.s3), \
__CLC_FUNCTION(x.s4), __CLC_FUNCTION(x.s5), \
__CLC_FUNCTION(x.s6), \
__CLC_FUNCTION(x.s7)} != (RET_TYPE)0); \
}

#define _CLC_DEFINE_RELATIONAL_UNARY_VEC16(RET_TYPE, __CLC_FUNCTION, ARG_TYPE) \
_CLC_DEF _CLC_OVERLOAD RET_TYPE __CLC_FUNCTION(ARG_TYPE x) { \
return (RET_TYPE)((RET_TYPE){__CLC_FUNCTION(x.s0), __CLC_FUNCTION(x.s1), \
__CLC_FUNCTION(x.s2), __CLC_FUNCTION(x.s3), \
__CLC_FUNCTION(x.s4), __CLC_FUNCTION(x.s5), \
__CLC_FUNCTION(x.s6), __CLC_FUNCTION(x.s7), \
__CLC_FUNCTION(x.s8), __CLC_FUNCTION(x.s9), \
__CLC_FUNCTION(x.sa), __CLC_FUNCTION(x.sb), \
__CLC_FUNCTION(x.sc), __CLC_FUNCTION(x.sd), \
__CLC_FUNCTION(x.se), \
__CLC_FUNCTION(x.sf)} != (RET_TYPE)0); \
}

#define _CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(RET_TYPE, __CLC_FUNCTION, \
ARG_TYPE) \
_CLC_DEFINE_RELATIONAL_UNARY_VEC2(RET_TYPE##2, __CLC_FUNCTION, ARG_TYPE##2) \
_CLC_DEFINE_RELATIONAL_UNARY_VEC3(RET_TYPE##3, __CLC_FUNCTION, ARG_TYPE##3) \
_CLC_DEFINE_RELATIONAL_UNARY_VEC4(RET_TYPE##4, __CLC_FUNCTION, ARG_TYPE##4) \
_CLC_DEFINE_RELATIONAL_UNARY_VEC8(RET_TYPE##8, __CLC_FUNCTION, ARG_TYPE##8) \
_CLC_DEFINE_RELATIONAL_UNARY_VEC16(RET_TYPE##16, __CLC_FUNCTION, ARG_TYPE##16)

_CLC_DEF _CLC_OVERLOAD int __clc_signbit(float x) {
return __builtin_signbitf(x);
}

_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(int, __clc_signbit, float)

#ifdef cl_khr_fp64

#pragma OPENCL EXTENSION cl_khr_fp64 : enable

// The scalar version of __clc_signbit(double) returns an int, but the vector
// versions return long.

_CLC_DEF _CLC_OVERLOAD int __clc_signbit(double x) {
return __builtin_signbit(x);
}

_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(long, __clc_signbit, double)

#endif
#ifdef cl_khr_fp16

#pragma OPENCL EXTENSION cl_khr_fp16 : enable

// The scalar version of __clc_signbit(half) returns an int, but the vector
// versions return short.

_CLC_DEF _CLC_OVERLOAD int __clc_signbit(half x) {
return __builtin_signbit(x);
}

_CLC_DEFINE_RELATIONAL_UNARY_VEC_ALL(short, __clc_signbit, half)

#endif
#define __CLC_BODY "clc_signbit.inc"
#include "clc/math/gentype.inc"
23 changes: 23 additions & 0 deletions libclc/clc/lib/generic/relational/clc_signbit.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#if __CLC_VECSIZE_OR_1 == 1
#define __CLC_RETTYPE __CLC_INTN
#else
#define __CLC_RETTYPE __CLC_S_GENTYPE
#endif

_CLC_OVERLOAD _CLC_DEF __CLC_RETTYPE __clc_signbit(__CLC_GENTYPE x) {
#if __CLC_VECSIZE_OR_1 == 1
return (__CLC_INTN)(__CLC_AS_U_GENTYPE(x) >> (__CLC_FPSIZE - 1));
#else
return __CLC_AS_S_GENTYPE(x) >> (__CLC_FPSIZE - 1);
#endif
}

#undef __CLC_RETTYPE
30 changes: 0 additions & 30 deletions libclc/libspirv/lib/generic/relational/genunary.inc

This file was deleted.

11 changes: 6 additions & 5 deletions libclc/libspirv/lib/generic/relational/isfinite.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
//
//===----------------------------------------------------------------------===//

#include <libspirv/relational.h>
#include <libspirv/spirv.h>
#include "clc/clc_convert.h"
#include "clc/relational/clc_isfinite.h"

#define _CLC_SPIRV_BUILTIN __spirv_IsFinite
#define _CLC_BUILTIN_IMPL __builtin_isfinite
#include "genunary.inc"
#define __CLC_FUNCTION __spirv_IsFinite
#define __CLC_IMPL_FUNCTION(x) __clc_isfinite
#define __CLC_BODY "relational_unary_def.inc"
#include "clc/math/gentype.inc"
11 changes: 6 additions & 5 deletions libclc/libspirv/lib/generic/relational/isinf.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
//
//===----------------------------------------------------------------------===//

#include <libspirv/relational.h>
#include <libspirv/spirv.h>
#include "clc/clc_convert.h"
#include "clc/relational/clc_isinf.h"

#define _CLC_SPIRV_BUILTIN __spirv_IsInf
#define _CLC_BUILTIN_IMPL __builtin_isinf
#include "genunary.inc"
#define __CLC_FUNCTION __spirv_IsInf
#define __CLC_IMPL_FUNCTION(x) __clc_isinf
#define __CLC_BODY "relational_unary_def.inc"
#include "clc/math/gentype.inc"
11 changes: 6 additions & 5 deletions libclc/libspirv/lib/generic/relational/isnan.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
//
//===----------------------------------------------------------------------===//

#include <libspirv/relational.h>
#include <libspirv/spirv.h>
#include "clc/clc_convert.h"
#include "clc/relational/clc_isnan.h"

#define _CLC_SPIRV_BUILTIN __spirv_IsNan
#define _CLC_BUILTIN_IMPL __builtin_isnan
#include "genunary.inc"
#define __CLC_FUNCTION __spirv_IsNan
#define __CLC_IMPL_FUNCTION(x) __clc_isnan
#define __CLC_BODY "relational_unary_def.inc"
#include "clc/math/gentype.inc"
11 changes: 6 additions & 5 deletions libclc/libspirv/lib/generic/relational/isnormal.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
//
//===----------------------------------------------------------------------===//

#include <libspirv/relational.h>
#include <libspirv/spirv.h>
#include "clc/clc_convert.h"
#include "clc/relational/clc_isnormal.h"

#define _CLC_SPIRV_BUILTIN __spirv_IsNormal
#define _CLC_BUILTIN_IMPL __builtin_isnormal
#include "genunary.inc"
#define __CLC_FUNCTION __spirv_IsNormal
#define __CLC_IMPL_FUNCTION(x) __clc_isnormal
#define __CLC_BODY "relational_unary_def.inc"
#include "clc/math/gentype.inc"
21 changes: 21 additions & 0 deletions libclc/libspirv/lib/generic/relational/relational_unary_def.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "clc/utils.h"

#if __CLC_VECSIZE_OR_1 == 1
#define __CLC_RETTYPE bool
#else
#define __CLC_RETTYPE __CLC_CHARN
#endif

_CLC_OVERLOAD _CLC_DEF __CLC_RETTYPE __CLC_FUNCTION(__CLC_GENTYPE x) {
return __CLC_CONVERT_CHARN(__CLC_IMPL_FUNCTION(__CLC_FUNCTION)(x));
}

#undef __CLC_RETTYPE
13 changes: 6 additions & 7 deletions libclc/libspirv/lib/generic/relational/select.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
//
//===----------------------------------------------------------------------===//

#include <libspirv/spirv.h>
#include <clc/relational/clc_select.h>
#include <clc/utils.h>
#include "clc/relational/clc_select.h"
#include "clc/utils.h"

#define __CLC_SELECT_FN __spirv_ocl_select
#define __CLC_SELECT_DEF(x, y, z) return __clc_select(x, y, z)

#define __CLC_BODY <clc/relational/clc_select_impl.inc>
#include <clc/math/gentype.inc>
#define __CLC_BODY <clc/relational/clc_select_impl.inc>
#include <clc/integer/gentype.inc>
#define __CLC_BODY "clc/relational/clc_select_impl.inc"
#include "clc/math/gentype.inc"
#define __CLC_BODY "clc/relational/clc_select_impl.inc"
#include "clc/integer/gentype.inc"
11 changes: 6 additions & 5 deletions libclc/libspirv/lib/generic/relational/signbit.cl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
//
//===----------------------------------------------------------------------===//

#include <libspirv/relational.h>
#include <libspirv/spirv.h>
#include "clc/clc_convert.h"
#include "clc/relational/clc_signbit.h"

#define _CLC_SPIRV_BUILTIN __spirv_SignBitSet
#define _CLC_BUILTIN_IMPL __builtin_signbitf
#include "genunary.inc"
#define __CLC_FUNCTION __spirv_SignBitSet
#define __CLC_IMPL_FUNCTION(x) __clc_signbit
#define __CLC_BODY "relational_unary_def.inc"
#include "clc/math/gentype.inc"
Loading