[libclc] Move minmag & maxmag to the CLC library (#137982)
This commit is contained in:
19
libclc/clc/include/clc/math/clc_maxmag.h
Normal file
19
libclc/clc/include/clc/math/clc_maxmag.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef __CLC_MATH_CLC_MAXMAG_H__
|
||||
#define __CLC_MATH_CLC_MAXMAG_H__
|
||||
|
||||
#define __CLC_BODY <clc/shared/binary_decl.inc>
|
||||
#define __CLC_FUNCTION __clc_maxmag
|
||||
|
||||
#include <clc/math/gentype.inc>
|
||||
|
||||
#undef __CLC_FUNCTION
|
||||
|
||||
#endif // __CLC_MATH_CLC_MAXMAG_H__
|
||||
19
libclc/clc/include/clc/math/clc_minmag.h
Normal file
19
libclc/clc/include/clc/math/clc_minmag.h
Normal file
@@ -0,0 +1,19 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef __CLC_MATH_CLC_MINMAG_H__
|
||||
#define __CLC_MATH_CLC_MINMAG_H__
|
||||
|
||||
#define __CLC_BODY <clc/shared/binary_decl.inc>
|
||||
#define __CLC_FUNCTION __clc_minmag
|
||||
|
||||
#include <clc/math/gentype.inc>
|
||||
|
||||
#undef __CLC_FUNCTION
|
||||
|
||||
#endif // __CLC_MATH_CLC_MINMAG_H__
|
||||
@@ -58,6 +58,8 @@ math/clc_log10.cl
|
||||
math/clc_log1p.cl
|
||||
math/clc_log2.cl
|
||||
math/clc_mad.cl
|
||||
math/clc_maxmag.cl
|
||||
math/clc_minmag.cl
|
||||
math/clc_modf.cl
|
||||
math/clc_nan.cl
|
||||
math/clc_native_cos.cl
|
||||
|
||||
19
libclc/clc/lib/generic/math/clc_maxmag.cl
Normal file
19
libclc/clc/lib/generic/math/clc_maxmag.cl
Normal file
@@ -0,0 +1,19 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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/clc_convert.h>
|
||||
#include <clc/internal/clc.h>
|
||||
#include <clc/math/clc_fabs.h>
|
||||
#include <clc/math/clc_fmax.h>
|
||||
#include <clc/relational/clc_isequal.h>
|
||||
#include <clc/relational/clc_isgreater.h>
|
||||
#include <clc/relational/clc_isnan.h>
|
||||
#include <clc/relational/clc_select.h>
|
||||
|
||||
#define __CLC_BODY <clc_maxmag.inc>
|
||||
#include <clc/math/gentype.inc>
|
||||
18
libclc/clc/lib/generic/math/clc_maxmag.inc
Normal file
18
libclc/clc/lib/generic/math/clc_maxmag.inc
Normal file
@@ -0,0 +1,18 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_maxmag(__CLC_GENTYPE x,
|
||||
__CLC_GENTYPE y) {
|
||||
const __CLC_GENTYPE res = __clc_select(
|
||||
y, x,
|
||||
__CLC_CONVERT_BIT_INTN(__clc_isgreater(__clc_fabs(x), __clc_fabs(y))));
|
||||
return __clc_select(
|
||||
res, __clc_fmax(x, y),
|
||||
__CLC_CONVERT_BIT_INTN(__clc_isnan(x) || __clc_isnan(y) ||
|
||||
__clc_isequal(__clc_fabs(x), __clc_fabs(y))));
|
||||
}
|
||||
19
libclc/clc/lib/generic/math/clc_minmag.cl
Normal file
19
libclc/clc/lib/generic/math/clc_minmag.cl
Normal file
@@ -0,0 +1,19 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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/clc_convert.h>
|
||||
#include <clc/internal/clc.h>
|
||||
#include <clc/math/clc_fabs.h>
|
||||
#include <clc/math/clc_fmin.h>
|
||||
#include <clc/relational/clc_isequal.h>
|
||||
#include <clc/relational/clc_isless.h>
|
||||
#include <clc/relational/clc_isnan.h>
|
||||
#include <clc/relational/clc_select.h>
|
||||
|
||||
#define __CLC_BODY <clc_minmag.inc>
|
||||
#include <clc/math/gentype.inc>
|
||||
17
libclc/clc/lib/generic/math/clc_minmag.inc
Normal file
17
libclc/clc/lib/generic/math/clc_minmag.inc
Normal file
@@ -0,0 +1,17 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_minmag(__CLC_GENTYPE x,
|
||||
__CLC_GENTYPE y) {
|
||||
const __CLC_GENTYPE res = __clc_select(
|
||||
y, x, __CLC_CONVERT_BIT_INTN(__clc_isless(__clc_fabs(x), __clc_fabs(y))));
|
||||
return __clc_select(
|
||||
res, __clc_fmin(x, y),
|
||||
__CLC_CONVERT_BIT_INTN(__clc_isnan(x) || __clc_isnan(y) ||
|
||||
__clc_isequal(__clc_fabs(x), __clc_fabs(y))));
|
||||
}
|
||||
@@ -7,7 +7,8 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <clc/clc.h>
|
||||
#include <clc/utils.h>
|
||||
#include <clc/math/clc_maxmag.h>
|
||||
|
||||
#define __CLC_BODY <maxmag.inc>
|
||||
#define FUNCTION maxmag
|
||||
#define __CLC_BODY <clc/shared/binary_def.inc>
|
||||
#include <clc/math/gentype.inc>
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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_FPSIZE == 64
|
||||
#define __CLC_CONVERT_NATN __CLC_XCONCAT(convert_long, __CLC_VECSIZE)
|
||||
#elif __CLC_FPSIZE == 32
|
||||
#define __CLC_CONVERT_NATN __CLC_XCONCAT(convert_int, __CLC_VECSIZE)
|
||||
#elif __CLC_FPSIZE == 16
|
||||
#define __CLC_CONVERT_NATN __CLC_XCONCAT(convert_short, __CLC_VECSIZE)
|
||||
#endif
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE maxmag(__CLC_GENTYPE x, __CLC_GENTYPE y) {
|
||||
const __CLC_GENTYPE res = select(y, x, __CLC_CONVERT_NATN(isgreater(fabs(x), fabs(y))));
|
||||
return select(res, fmax(x, y), __CLC_CONVERT_NATN(isnan(x) | isnan(y) | isequal(fabs(x), fabs(y))));
|
||||
}
|
||||
|
||||
#undef __CLC_CONVERT_NATN
|
||||
@@ -7,7 +7,8 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <clc/clc.h>
|
||||
#include <clc/utils.h>
|
||||
#include <clc/math/clc_minmag.h>
|
||||
|
||||
#define __CLC_BODY <minmag.inc>
|
||||
#define FUNCTION minmag
|
||||
#define __CLC_BODY <clc/shared/binary_def.inc>
|
||||
#include <clc/math/gentype.inc>
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifdef __CLC_SCALAR
|
||||
#define __CLC_VECSIZE
|
||||
#endif
|
||||
|
||||
#if __CLC_FPSIZE == 64
|
||||
#define __CLC_CONVERT_NATN __CLC_XCONCAT(convert_long, __CLC_VECSIZE)
|
||||
#elif __CLC_FPSIZE == 32
|
||||
#define __CLC_CONVERT_NATN __CLC_XCONCAT(convert_int, __CLC_VECSIZE)
|
||||
#elif __CLC_FPSIZE == 16
|
||||
#define __CLC_CONVERT_NATN __CLC_XCONCAT(convert_short, __CLC_VECSIZE)
|
||||
#endif
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE minmag(__CLC_GENTYPE x, __CLC_GENTYPE y) {
|
||||
const __CLC_GENTYPE res = select(y, x, __CLC_CONVERT_NATN(isless(fabs(x), fabs(y))));
|
||||
return select(res, fmin(x, y), __CLC_CONVERT_NATN(isnan(x) | isnan(y) | isequal(fabs(x), fabs(y))));
|
||||
}
|
||||
|
||||
#undef __CLC_CONVERT_NATN
|
||||
|
||||
#ifdef __CLC_SCALAR
|
||||
#undef __CLC_VECSIZE
|
||||
#endif
|
||||
Reference in New Issue
Block a user