Skip to content

Commit 6c4dd8d

Browse files
authored
[libclc] Move minmag & maxmag to the CLC library (#137982)
1 parent 9b10512 commit 6c4dd8d

File tree

11 files changed

+119
-56
lines changed

11 files changed

+119
-56
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef __CLC_MATH_CLC_MAXMAG_H__
10+
#define __CLC_MATH_CLC_MAXMAG_H__
11+
12+
#define __CLC_BODY <clc/shared/binary_decl.inc>
13+
#define __CLC_FUNCTION __clc_maxmag
14+
15+
#include <clc/math/gentype.inc>
16+
17+
#undef __CLC_FUNCTION
18+
19+
#endif // __CLC_MATH_CLC_MAXMAG_H__
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef __CLC_MATH_CLC_MINMAG_H__
10+
#define __CLC_MATH_CLC_MINMAG_H__
11+
12+
#define __CLC_BODY <clc/shared/binary_decl.inc>
13+
#define __CLC_FUNCTION __clc_minmag
14+
15+
#include <clc/math/gentype.inc>
16+
17+
#undef __CLC_FUNCTION
18+
19+
#endif // __CLC_MATH_CLC_MINMAG_H__

libclc/clc/lib/generic/SOURCES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ math/clc_log10.cl
5858
math/clc_log1p.cl
5959
math/clc_log2.cl
6060
math/clc_mad.cl
61+
math/clc_maxmag.cl
62+
math/clc_minmag.cl
6163
math/clc_modf.cl
6264
math/clc_nan.cl
6365
math/clc_native_cos.cl
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include <clc/clc_convert.h>
10+
#include <clc/internal/clc.h>
11+
#include <clc/math/clc_fabs.h>
12+
#include <clc/math/clc_fmax.h>
13+
#include <clc/relational/clc_isequal.h>
14+
#include <clc/relational/clc_isgreater.h>
15+
#include <clc/relational/clc_isnan.h>
16+
#include <clc/relational/clc_select.h>
17+
18+
#define __CLC_BODY <clc_maxmag.inc>
19+
#include <clc/math/gentype.inc>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_maxmag(__CLC_GENTYPE x,
10+
__CLC_GENTYPE y) {
11+
const __CLC_GENTYPE res = __clc_select(
12+
y, x,
13+
__CLC_CONVERT_BIT_INTN(__clc_isgreater(__clc_fabs(x), __clc_fabs(y))));
14+
return __clc_select(
15+
res, __clc_fmax(x, y),
16+
__CLC_CONVERT_BIT_INTN(__clc_isnan(x) || __clc_isnan(y) ||
17+
__clc_isequal(__clc_fabs(x), __clc_fabs(y))));
18+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include <clc/clc_convert.h>
10+
#include <clc/internal/clc.h>
11+
#include <clc/math/clc_fabs.h>
12+
#include <clc/math/clc_fmin.h>
13+
#include <clc/relational/clc_isequal.h>
14+
#include <clc/relational/clc_isless.h>
15+
#include <clc/relational/clc_isnan.h>
16+
#include <clc/relational/clc_select.h>
17+
18+
#define __CLC_BODY <clc_minmag.inc>
19+
#include <clc/math/gentype.inc>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
_CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_minmag(__CLC_GENTYPE x,
10+
__CLC_GENTYPE y) {
11+
const __CLC_GENTYPE res = __clc_select(
12+
y, x, __CLC_CONVERT_BIT_INTN(__clc_isless(__clc_fabs(x), __clc_fabs(y))));
13+
return __clc_select(
14+
res, __clc_fmin(x, y),
15+
__CLC_CONVERT_BIT_INTN(__clc_isnan(x) || __clc_isnan(y) ||
16+
__clc_isequal(__clc_fabs(x), __clc_fabs(y))));
17+
}

libclc/generic/lib/math/maxmag.cl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include <clc/clc.h>
10-
#include <clc/utils.h>
10+
#include <clc/math/clc_maxmag.h>
1111

12-
#define __CLC_BODY <maxmag.inc>
12+
#define FUNCTION maxmag
13+
#define __CLC_BODY <clc/shared/binary_def.inc>
1314
#include <clc/math/gentype.inc>

libclc/generic/lib/math/maxmag.inc

Lines changed: 0 additions & 22 deletions
This file was deleted.

libclc/generic/lib/math/minmag.cl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include <clc/clc.h>
10-
#include <clc/utils.h>
10+
#include <clc/math/clc_minmag.h>
1111

12-
#define __CLC_BODY <minmag.inc>
12+
#define FUNCTION minmag
13+
#define __CLC_BODY <clc/shared/binary_def.inc>
1314
#include <clc/math/gentype.inc>

libclc/generic/lib/math/minmag.inc

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)