File tree Expand file tree Collapse file tree 10 files changed +183
-36
lines changed Expand file tree Collapse file tree 10 files changed +183
-36
lines changed Original file line number Diff line number Diff line change
1
+ add_subdirectory (generic )
2
+ if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR} /${LIBC_TARGET_MACHINE} )
3
+ add_subdirectory (${LIBC_TARGET_MACHINE} )
4
+ endif ()
5
+
6
+ function (add_math_entrypoint_object name )
7
+ # We prefer machine specific implementation if available. Hence we check
8
+ # that first and retrun early if we are able to add an alias target for the
9
+ # machine specific implementation.
10
+ get_fq_target_name ("${LIBC_TARGET_MACHINE} .${name} " fq_machine_specific_target_name )
11
+ if (TARGET ${fq_machine_specific_target_name} )
12
+ add_entrypoint_object (
13
+ ${name}
14
+ ALIAS
15
+ DEPENDS
16
+ .${LIBC_TARGET_MACHINE}.${name}
17
+ )
18
+ return ()
19
+ endif ()
20
+
21
+ get_fq_target_name ("generic.${name} " fq_generic_target_name )
22
+ if (TARGET ${fq_generic_target_name} )
23
+ add_entrypoint_object (
24
+ ${name}
25
+ ALIAS
26
+ DEPENDS
27
+ .generic.${name}
28
+ )
29
+ return ()
30
+ endif ()
31
+
32
+ message (FATAL_ERROR "No machine specific or generic implementation found for ${name} ." )
33
+ endfunction ()
34
+
35
+ add_math_entrypoint_object (ceil )
36
+ add_math_entrypoint_object (ceilf )
37
+ add_math_entrypoint_object (ceill )
38
+
1
39
add_object_library (
2
40
math_utils
3
41
SRCS
@@ -128,42 +166,6 @@ add_entrypoint_object(
128
166
-O2
129
167
)
130
168
131
- add_entrypoint_object (
132
- ceil
133
- SRCS
134
- ceil.cpp
135
- HDRS
136
- ceil.h
137
- DEPENDS
138
- libc.utils.FPUtil.fputil
139
- COMPILE_OPTIONS
140
- -O2
141
- )
142
-
143
- add_entrypoint_object (
144
- ceilf
145
- SRCS
146
- ceilf.cpp
147
- HDRS
148
- ceilf.h
149
- DEPENDS
150
- libc.utils.FPUtil.fputil
151
- COMPILE_OPTIONS
152
- -O2
153
- )
154
-
155
- add_entrypoint_object (
156
- ceill
157
- SRCS
158
- ceill.cpp
159
- HDRS
160
- ceill.h
161
- DEPENDS
162
- libc.utils.FPUtil.fputil
163
- COMPILE_OPTIONS
164
- -O2
165
- )
166
-
167
169
add_entrypoint_object (
168
170
floor
169
171
SRCS
Original file line number Diff line number Diff line change
1
+ add_entrypoint_object (
2
+ ceil
3
+ SRCS
4
+ ceil.cpp
5
+ HDRS
6
+ ../ceil.h
7
+ COMPILE_OPTIONS
8
+ -O2
9
+ )
10
+
11
+ add_entrypoint_object (
12
+ ceilf
13
+ SRCS
14
+ ceilf.cpp
15
+ HDRS
16
+ ../ceilf.h
17
+ COMPILE_OPTIONS
18
+ -O2
19
+ )
Original file line number Diff line number Diff line change
1
+ // ===-- Implementation of the ceil function for aarch64 -------------------===//
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 " src/math/ceil.h"
10
+ #include " src/__support/common.h"
11
+
12
+ namespace __llvm_libc {
13
+
14
+ LLVM_LIBC_FUNCTION (double , ceil, (double x)) {
15
+ double y;
16
+ __asm__ __volatile__ (" ldr d0, %1\n "
17
+ " frintp d0, d0\n "
18
+ " str d0, %0\n "
19
+ : " =m" (y)
20
+ : " m" (x)
21
+ : " d0" );
22
+ return y;
23
+ }
24
+
25
+ } // namespace __llvm_libc
Original file line number Diff line number Diff line change
1
+ // ===-- Implementation of the ceilf function for aarch64 ------------------===//
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 " src/math/ceilf.h"
10
+ #include " src/__support/common.h"
11
+
12
+ namespace __llvm_libc {
13
+
14
+ LLVM_LIBC_FUNCTION (float , ceilf, (float x)) {
15
+ float y;
16
+ __asm__ __volatile__ (" ldr s0, %1\n "
17
+ " frintp s0, s0\n "
18
+ " str s0, %0\n "
19
+ : " =m" (y)
20
+ : " m" (x)
21
+ : " s0" );
22
+ return y;
23
+ }
24
+
25
+ } // namespace __llvm_libc
Original file line number Diff line number Diff line change
1
+ add_entrypoint_object (
2
+ ceil
3
+ SRCS
4
+ ceil.cpp
5
+ HDRS
6
+ ../ceil.h
7
+ DEPENDS
8
+ libc.utils.FPUtil.fputil
9
+ COMPILE_OPTIONS
10
+ -O2
11
+ )
12
+
13
+ add_entrypoint_object (
14
+ ceilf
15
+ SRCS
16
+ ceilf.cpp
17
+ HDRS
18
+ ../ceilf.h
19
+ DEPENDS
20
+ libc.utils.FPUtil.fputil
21
+ COMPILE_OPTIONS
22
+ -O2
23
+ )
24
+
25
+ add_entrypoint_object (
26
+ ceill
27
+ SRCS
28
+ ceill.cpp
29
+ HDRS
30
+ ../ceill.h
31
+ DEPENDS
32
+ libc.utils.FPUtil.fputil
33
+ COMPILE_OPTIONS
34
+ -O2
35
+ )
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change @@ -1070,3 +1070,5 @@ add_fp_unittest(
1070
1070
libc.src.math.fmaf
1071
1071
libc.utils.FPUtil.fputil
1072
1072
)
1073
+
1074
+ add_subdirectory (generic )
Original file line number Diff line number Diff line change
1
+ add_fp_unittest (
2
+ ceil_test
3
+ NEED_MPFR
4
+ SUITE
5
+ libc_math_unittests
6
+ SRCS
7
+ ../ceil_test.cpp
8
+ DEPENDS
9
+ libc.include.math
10
+ libc.src.math.generic.ceil
11
+ libc.utils.FPUtil.fputil
12
+ )
13
+
14
+ add_fp_unittest (
15
+ ceilf_test
16
+ NEED_MPFR
17
+ SUITE
18
+ libc_math_unittests
19
+ SRCS
20
+ ../ceilf_test.cpp
21
+ DEPENDS
22
+ libc.include.math
23
+ libc.src.math.generic.ceilf
24
+ libc.utils.FPUtil.fputil
25
+ )
26
+
27
+ add_fp_unittest (
28
+ ceill_test
29
+ NEED_MPFR
30
+ SUITE
31
+ libc_math_unittests
32
+ SRCS
33
+ ../ceill_test.cpp
34
+ DEPENDS
35
+ libc.include.math
36
+ libc.src.math.generic.ceill
37
+ libc.utils.FPUtil.fputil
38
+ )
39
+
You can’t perform that action at this time.
0 commit comments