Skip to content

Commit d10b37e

Browse files
authored
[libspirv][math] Implement OpFMod and OpFRem (#20644)
The previous commit 446a453 was reverted due to fail on Windows where file name is case-insensitive.
1 parent d67098c commit d10b37e

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

libclc/libspirv/lib/generic/SOURCES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ math/fmin.cl
9393
math/fmin_common.cl
9494
math/fmod.cl
9595
math/fract.cl
96+
math/frem.cl
9697
math/frexp.cl
9798
math/half_cos.cl
9899
math/half_divide.cl

libclc/libspirv/lib/generic/math/fmod.cl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include <libspirv/spirv.h>
9+
#include <clc/math/clc_copysign.h>
1010
#include <clc/math/clc_fmod.h>
11+
#include <libspirv/spirv.h>
1112

1213
#define __CLC_FUNCTION __spirv_ocl_fmod
1314
#define __CLC_IMPL_FUNCTION(x) __clc_fmod
1415
#define __CLC_BODY <clc/shared/binary_def.inc>
1516
#include <clc/math/gentype.inc>
17+
18+
#define __CLC_BODY <fmod.inc>
19+
#include <clc/math/gentype.inc>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 __spirv_FMod(__CLC_GENTYPE x,
10+
__CLC_GENTYPE y) {
11+
return __clc_copysign(__clc_fmod(x, y), y);
12+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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/math/clc_fmod.h>
10+
#include <libspirv/spirv.h>
11+
12+
#define __CLC_FUNCTION __spirv_FRem
13+
#define __CLC_IMPL_FUNCTION(x) __clc_fmod
14+
#define __CLC_BODY <clc/shared/binary_def.inc>
15+
16+
#include <clc/math/gentype.inc>

0 commit comments

Comments
 (0)