Skip to content

Commit 0395bf7

Browse files
[libc][math][c23] Add ffma{,l,f128} and fdiv{,l,f128} C23 math functions #101089 (#101253)
- added all variations of ffma and fdiv - will add all new headers into yaml for next patch - only fsub is left then all basic operations for float is complete --------- Co-authored-by: OverMighty <[email protected]>
1 parent 3e3ea54 commit 0395bf7

39 files changed

+701
-11
lines changed

libc/config/darwin/arm/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ set(TARGET_LIBM_ENTRYPOINTS
165165
libc.src.math.fdim
166166
libc.src.math.fdimf
167167
libc.src.math.fdiml
168+
libc.src.math.fdiv
169+
libc.src.math.fdivl
170+
libc.src.math.ffma
171+
libc.src.math.ffmal
168172
libc.src.math.floor
169173
libc.src.math.floorf
170174
libc.src.math.floorl

libc/config/darwin/x86_64/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ set(TARGET_LIBM_ENTRYPOINTS
132132
#libc.src.math.fdim
133133
#libc.src.math.fdimf
134134
#libc.src.math.fdiml
135+
#libc.src.math.fdiv
136+
#libc.src.math.fdivl
137+
#libc.src.math.ffma
138+
#libc.src.math.ffmal
135139
#libc.src.math.floor
136140
#libc.src.math.floorf
137141
#libc.src.math.floorl

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,10 @@ if(LIBC_TYPES_HAS_FLOAT16)
600600
# libc.src.math.f16subl
601601
libc.src.math.fabsf16
602602
libc.src.math.fdimf16
603+
libc.src.math.fdiv
604+
libc.src.math.fdivl
605+
libc.src.math.ffma
606+
libc.src.math.ffmal
603607
libc.src.math.floorf16
604608
libc.src.math.fmaxf16
605609
libc.src.math.fmaximum_mag_numf16
@@ -677,6 +681,8 @@ if(LIBC_TYPES_HAS_FLOAT128)
677681
libc.src.math.dsubf128
678682
libc.src.math.fabsf128
679683
libc.src.math.fdimf128
684+
libc.src.math.fdivf128
685+
libc.src.math.ffmaf128
680686
libc.src.math.floorf128
681687
libc.src.math.fmaxf128
682688
libc.src.math.fmaximum_mag_numf128

libc/config/linux/arm/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ set(TARGET_LIBM_ENTRYPOINTS
246246
libc.src.math.fdim
247247
libc.src.math.fdimf
248248
libc.src.math.fdiml
249+
libc.src.math.fdiv
250+
libc.src.math.fdivl
251+
libc.src.math.ffma
252+
libc.src.math.ffmal
249253
libc.src.math.floor
250254
libc.src.math.floorf
251255
libc.src.math.floorl

libc/config/linux/riscv/entrypoints.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ set(TARGET_LIBM_ENTRYPOINTS
409409
libc.src.math.fdim
410410
libc.src.math.fdimf
411411
libc.src.math.fdiml
412+
libc.src.math.fdiv
413+
libc.src.math.fdivl
414+
libc.src.math.ffma
415+
libc.src.math.ffmal
412416
libc.src.math.floor
413417
libc.src.math.floorf
414418
libc.src.math.floorl
@@ -584,6 +588,8 @@ if(LIBC_TYPES_HAS_FLOAT128)
584588
libc.src.math.dsubf128
585589
libc.src.math.fabsf128
586590
libc.src.math.fdimf128
591+
libc.src.math.fdivf128
592+
libc.src.math.ffmaf128
587593
libc.src.math.floorf128
588594
libc.src.math.fmaxf128
589595
libc.src.math.fmaximum_mag_numf128

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ set(TARGET_LIBM_ENTRYPOINTS
409409
libc.src.math.fdim
410410
libc.src.math.fdimf
411411
libc.src.math.fdiml
412+
libc.src.math.fdiv
413+
libc.src.math.fdivl
414+
libc.src.math.ffma
415+
libc.src.math.ffmal
412416
libc.src.math.floor
413417
libc.src.math.floorf
414418
libc.src.math.floorl
@@ -672,6 +676,8 @@ if(LIBC_TYPES_HAS_FLOAT128)
672676
libc.src.math.dsubf128
673677
libc.src.math.fabsf128
674678
libc.src.math.fdimf128
679+
libc.src.math.fdivf128
680+
libc.src.math.ffmaf128
675681
libc.src.math.floorf128
676682
libc.src.math.fmaxf128
677683
libc.src.math.fmaximum_mag_numf128

libc/config/windows/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ set(TARGET_LIBM_ENTRYPOINTS
155155
libc.src.math.fdim
156156
libc.src.math.fdimf
157157
libc.src.math.fdiml
158+
libc.src.math.fdiv
159+
libc.src.math.fdivl
160+
libc.src.math.ffma
161+
libc.src.math.ffmal
158162
libc.src.math.floor
159163
libc.src.math.floorf
160164
libc.src.math.floorl

libc/docs/math/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ Basic Operations
140140
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
141141
| fdim | |check| | |check| | |check| | |check| | |check| | 7.12.12.1 | F.10.9.1 |
142142
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
143-
| fdiv | N/A | | | N/A | | 7.12.14.4 | F.10.11 |
143+
| fdiv | N/A | |check| | |check| | N/A | |check|\* | 7.12.14.4 | F.10.11 |
144144
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
145-
| ffma | N/A | | | N/A | | 7.12.14.5 | F.10.11 |
145+
| ffma | N/A | |check| | |check| | N/A | |check|\* | 7.12.14.5 | F.10.11 |
146146
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
147147
| floor | |check| | |check| | |check| | |check| | |check| | 7.12.9.2 | F.10.6.2 |
148148
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+

libc/newhdrgen/yaml/math.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,6 +1845,53 @@ functions:
18451845
- type: float128
18461846
- type: float128
18471847
guard: LIBC_TYPES_HAS_FLOAT128
1848+
- name: fdiv
1849+
standards:
1850+
- stdc
1851+
return_type: float
1852+
arguments:
1853+
- type: double
1854+
- type: double
1855+
- name: fdivl
1856+
standards:
1857+
- stdc
1858+
return_type: float
1859+
arguments:
1860+
- type: long double
1861+
- type: long double
1862+
- name: fdivf128
1863+
standards:
1864+
- llvm_libc_ext
1865+
return_type: float
1866+
arguments:
1867+
- type: float128
1868+
- type: float128
1869+
guard: LIBC_TYPES_HAS_FLOAT128
1870+
- name: ffma
1871+
standards:
1872+
- stdc
1873+
return_type: float
1874+
arguments:
1875+
- type: double
1876+
- type: double
1877+
- type: double
1878+
- name: ffmal
1879+
standards:
1880+
- stdc
1881+
return_type: float
1882+
arguments:
1883+
- type: long double
1884+
- type: long double
1885+
- type: long double
1886+
- name: ffmaf128
1887+
standards:
1888+
- llvm_libc_ext
1889+
return_type: float
1890+
arguments:
1891+
- type: float128
1892+
- type: float128
1893+
- type: float128
1894+
guards: LIBC_TYPES_HAS_FLOAT128
18481895
- name: floorf128
18491896
standards:
18501897
- stdc

libc/spec/llvm_libc_ext.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ def LLVMLibcExt : StandardSpec<"llvm_libc_ext"> {
7171
GuardedFunctionSpec<"f16sub", RetValSpec<Float16Type>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>], "LIBC_TYPES_HAS_FLOAT16">,
7272
GuardedFunctionSpec<"f16subf", RetValSpec<Float16Type>, [ArgSpec<FloatType>, ArgSpec<FloatType>], "LIBC_TYPES_HAS_FLOAT16">,
7373
GuardedFunctionSpec<"f16subl", RetValSpec<Float16Type>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>], "LIBC_TYPES_HAS_FLOAT16">,
74+
75+
GuardedFunctionSpec<"fdivf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
76+
77+
GuardedFunctionSpec<"ffmaf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
7478

7579
GuardedFunctionSpec<"fmulf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
7680

libc/spec/stdc.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,12 @@ def StdC : StandardSpec<"stdc"> {
414414
FunctionSpec<"fdiml", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
415415
GuardedFunctionSpec<"fdimf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>, ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
416416
GuardedFunctionSpec<"fdimf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
417+
418+
FunctionSpec<"fdiv", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
419+
FunctionSpec<"fdivl", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
420+
421+
FunctionSpec<"ffma", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
422+
FunctionSpec<"ffmal", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
417423

418424
FunctionSpec<"floor", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
419425
FunctionSpec<"floorf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,

libc/src/math/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,14 @@ add_math_entrypoint_object(fdiml)
167167
add_math_entrypoint_object(fdimf16)
168168
add_math_entrypoint_object(fdimf128)
169169

170+
add_math_entrypoint_object(fdiv)
171+
add_math_entrypoint_object(fdivl)
172+
add_math_entrypoint_object(fdivf128)
173+
174+
add_math_entrypoint_object(ffma)
175+
add_math_entrypoint_object(ffmal)
176+
add_math_entrypoint_object(ffmaf128)
177+
170178
add_math_entrypoint_object(floor)
171179
add_math_entrypoint_object(floorf)
172180
add_math_entrypoint_object(floorl)

libc/src/math/fdiv.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header for fdiv --------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC_MATH_FDIV_H
10+
#define LLVM_LIBC_SRC_MATH_FDIV_H
11+
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
float fdiv(double x, double y);
17+
18+
} // namespace LIBC_NAMESPACE_DECL
19+
20+
#endif // LLVM_LIBC_SRC_MATH_FDIV_H

libc/src/math/fdivf128.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Implementation header for fdivf128 ----------------------*- C++ -*-===//
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 LLVM_LIBC_SRC_MATH_FDIVF128_H
10+
#define LLVM_LIBC_SRC_MATH_FDIVF128_H
11+
12+
#include "src/__support/macros/config.h"
13+
#include "src/__support/macros/properties/types.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
17+
float fdivf128(float128 x, float128 y);
18+
19+
} // namespace LIBC_NAMESPACE_DECL
20+
21+
#endif // LLVM_LIBC_SRC_MATH_FDIVF128_H

libc/src/math/fdivl.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header for fdivl -------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC_MATH_FDIVL_H
10+
#define LLVM_LIBC_SRC_MATH_FDIVL_H
11+
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
float fdivl(long double x, long double y);
17+
18+
} // namespace LIBC_NAMESPACE_DECL
19+
20+
#endif // LLVM_LIBC_SRC_MATH_FDIVL_H

libc/src/math/ffma.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header for ffma --------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC_MATH_FFMA_H
10+
#define LLVM_LIBC_SRC_MATH_FFMA_H
11+
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
float ffma(double x, double y, double z);
17+
18+
} // namespace LIBC_NAMESPACE_DECL
19+
20+
#endif // LLVM_LIBC_SRC_MATH_FFMA_H

libc/src/math/ffmaf128.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Implementation header for ffmaf128 ----------------------*- C++ -*-===//
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 LLVM_LIBC_SRC_MATH_FFMAF128_H
10+
#define LLVM_LIBC_SRC_MATH_FFMAF128_H
11+
12+
#include "src/__support/macros/config.h"
13+
#include "src/__support/macros/properties/types.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
17+
float ffmaf128(float128 x, float128 y, float128 z);
18+
19+
} // namespace LIBC_NAMESPACE_DECL
20+
21+
#endif // LLVM_LIBC_SRC_MATH_FFMAF128_H

libc/src/math/ffmal.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//===-- Implementation header for ffmal -------------------------*- C++ -*-===//
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 LLVM_LIBC_SRC_MATH_FFMAL_H
10+
#define LLVM_LIBC_SRC_MATH_FFMAL_H
11+
12+
#include "src/__support/macros/config.h"
13+
14+
namespace LIBC_NAMESPACE_DECL {
15+
16+
float ffmal(long double x, long double y, long double z);
17+
18+
} // namespace LIBC_NAMESPACE_DECL
19+
20+
#endif // LLVM_LIBC_SRC_MATH_FFMAL_H

0 commit comments

Comments
 (0)