Skip to content

[libc][math][c23] Add ffma{,l,f128} and fdiv{,l,f128} C23 math functions #101089 #101253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1da499e
finishing fdiv
aaryanshukla Jul 29, 2024
4537494
added to spec file
aaryanshukla Jul 30, 2024
3318e96
opk
aaryanshukla Jul 30, 2024
dcf69a7
removed entrypoints in baremetal
aaryanshukla Jul 30, 2024
85e2cea
fixed wrong input value
aaryanshukla Jul 30, 2024
ffc5c28
Update libc/test/src/math/smoke/CMakeLists.txt
aaryanshukla Jul 31, 2024
8147210
Update libc/test/src/math/smoke/CMakeLists.txt
aaryanshukla Jul 31, 2024
6e87b0e
Update libc/test/src/math/CMakeLists.txt
aaryanshukla Jul 31, 2024
2c51661
Update libc/test/src/math/CMakeLists.txt
aaryanshukla Jul 31, 2024
12e35f4
Update libc/test/src/math/smoke/CMakeLists.txt
aaryanshukla Jul 31, 2024
4ae5bfe
changed dependencies in smoke cmake and f16div
aaryanshukla Jul 31, 2024
3c0fc85
added specific input/output to MPFR
aaryanshukla Aug 1, 2024
0244b28
added template void to MPFR
aaryanshukla Aug 1, 2024
1a069f1
Merge branch 'main' into f_basic_operations
aaryanshukla Aug 1, 2024
a38e676
Update CMakeLists.txt
aaryanshukla Aug 1, 2024
7cb17a6
added <long double> to <float>
aaryanshukla Aug 2, 2024
6e50699
updated index.rst
aaryanshukla Aug 2, 2024
2685839
updated rst
aaryanshukla Aug 2, 2024
66f4339
Update libc/test/src/math/CMakeLists.txt
aaryanshukla Aug 5, 2024
e48a6a9
Update libc/test/src/math/CMakeLists.txt
aaryanshukla Aug 5, 2024
1029578
Update libc/test/src/math/CMakeLists.txt
aaryanshukla Aug 5, 2024
86a3e9f
reordered MPFRwrapper and added headersa
aaryanshukla Aug 5, 2024
264beab
fixed ordering in MPFRWrapper
aaryanshukla Aug 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libc/config/darwin/arm/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fdim
libc.src.math.fdimf
libc.src.math.fdiml
libc.src.math.fdiv
libc.src.math.fdivl
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
libc.src.math.floorf
libc.src.math.floorl
Expand Down
4 changes: 4 additions & 0 deletions libc/config/darwin/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.fdim
#libc.src.math.fdimf
#libc.src.math.fdiml
#libc.src.math.fdiv
#libc.src.math.fdivl
#libc.src.math.ffma
#libc.src.math.ffmal
#libc.src.math.floor
#libc.src.math.floorf
#libc.src.math.floorl
Expand Down
6 changes: 6 additions & 0 deletions libc/config/linux/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,10 @@ if(LIBC_TYPES_HAS_FLOAT16)
libc.src.math.f16subf
libc.src.math.fabsf16
libc.src.math.fdimf16
libc.src.math.fdiv
libc.src.math.fdivl
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floorf16
libc.src.math.fmaxf16
libc.src.math.fmaximum_mag_numf16
Expand Down Expand Up @@ -626,6 +630,8 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.dsubf128
libc.src.math.fabsf128
libc.src.math.fdimf128
libc.src.math.fdivf128
libc.src.math.ffmaf128
libc.src.math.floorf128
libc.src.math.fmaxf128
libc.src.math.fmaximum_mag_numf128
Expand Down
4 changes: 4 additions & 0 deletions libc/config/linux/arm/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fdim
libc.src.math.fdimf
libc.src.math.fdiml
libc.src.math.fdiv
libc.src.math.fdivl
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
libc.src.math.floorf
libc.src.math.floorl
Expand Down
6 changes: 6 additions & 0 deletions libc/config/linux/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fdim
libc.src.math.fdimf
libc.src.math.fdiml
libc.src.math.fdiv
libc.src.math.fdivl
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
libc.src.math.floorf
libc.src.math.floorl
Expand Down Expand Up @@ -578,6 +582,8 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.dsqrtf128
libc.src.math.fabsf128
libc.src.math.fdimf128
libc.src.math.fdivf128
libc.src.math.ffmaf128
libc.src.math.floorf128
libc.src.math.fmaxf128
libc.src.math.fmaximum_mag_numf128
Expand Down
6 changes: 6 additions & 0 deletions libc/config/linux/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,10 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fdim
libc.src.math.fdimf
libc.src.math.fdiml
libc.src.math.fdiv
libc.src.math.fdivl
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
libc.src.math.floorf
libc.src.math.floorl
Expand Down Expand Up @@ -669,6 +673,8 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.dsubf128
libc.src.math.fabsf128
libc.src.math.fdimf128
libc.src.math.fdivf128
libc.src.math.ffmaf128
libc.src.math.floorf128
libc.src.math.fmaxf128
libc.src.math.fmaximum_mag_numf128
Expand Down
4 changes: 4 additions & 0 deletions libc/config/windows/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fdim
libc.src.math.fdimf
libc.src.math.fdiml
libc.src.math.fdiv
libc.src.math.fdivl
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
libc.src.math.floorf
libc.src.math.floorl
Expand Down
4 changes: 2 additions & 2 deletions libc/docs/math/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| fdim | |check| | |check| | |check| | |check| | |check| | 7.12.12.1 | F.10.9.1 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| fdiv | N/A | | | N/A | | 7.12.14.4 | F.10.11 |
| fdiv | N/A | |check| | |check| | N/A | |check|\* | 7.12.14.4 | F.10.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| ffma | N/A | | | N/A | | 7.12.14.5 | F.10.11 |
| ffma | N/A | |check| | |check| | N/A | |check|\* | 7.12.14.5 | F.10.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
| floor | |check| | |check| | |check| | |check| | |check| | 7.12.9.2 | F.10.6.2 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
Expand Down
47 changes: 47 additions & 0 deletions libc/newhdrgen/yaml/math.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,53 @@ functions:
- type: float128
- type: float128
guard: LIBC_TYPES_HAS_FLOAT128
- name: fdiv
standards:
- stdc
return_type: float
arguments:
- type: double
- type: double
- name: fdivl
standards:
- stdc
return_type: float
arguments:
- type: long double
- type: long double
- name: fdivf128
standards:
- llvm_libc_ext
return_type: float
arguments:
- type: float128
- type: float128
guard: LIBC_TYPES_HAS_FLOAT128
- name: ffma
standards:
- stdc
return_type: float
arguments:
- type: double
- type: double
- type: double
- name: ffmal
standards:
- stdc
return_type: float
arguments:
- type: long double
- type: long double
- type: long double
- name: ffmaf128
standards:
- llvm_libc_ext
return_type: float
arguments:
- type: float128
- type: float128
- type: float128
guards: LIBC_TYPES_HAS_FLOAT128
- name: floorf128
standards:
- stdc
Expand Down
4 changes: 4 additions & 0 deletions libc/spec/llvm_libc_ext.td
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ def LLVMLibcExt : StandardSpec<"llvm_libc_ext"> {
GuardedFunctionSpec<"f16sub", RetValSpec<Float16Type>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"f16subf", RetValSpec<Float16Type>, [ArgSpec<FloatType>, ArgSpec<FloatType>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"f16subl", RetValSpec<Float16Type>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>], "LIBC_TYPES_HAS_FLOAT16">,

GuardedFunctionSpec<"fdivf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,

GuardedFunctionSpec<"ffmaf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,

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

Expand Down
6 changes: 6 additions & 0 deletions libc/spec/stdc.td
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,12 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"fdiml", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
GuardedFunctionSpec<"fdimf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>, ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
GuardedFunctionSpec<"fdimf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,

FunctionSpec<"fdiv", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
FunctionSpec<"fdivl", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,

FunctionSpec<"ffma", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
FunctionSpec<"ffmal", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,

FunctionSpec<"floor", RetValSpec<DoubleType>, [ArgSpec<DoubleType>]>,
FunctionSpec<"floorf", RetValSpec<FloatType>, [ArgSpec<FloatType>]>,
Expand Down
8 changes: 8 additions & 0 deletions libc/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ add_math_entrypoint_object(fdiml)
add_math_entrypoint_object(fdimf16)
add_math_entrypoint_object(fdimf128)

add_math_entrypoint_object(fdiv)
add_math_entrypoint_object(fdivl)
add_math_entrypoint_object(fdivf128)

add_math_entrypoint_object(ffma)
add_math_entrypoint_object(ffmal)
add_math_entrypoint_object(ffmaf128)

add_math_entrypoint_object(floor)
add_math_entrypoint_object(floorf)
add_math_entrypoint_object(floorl)
Expand Down
20 changes: 20 additions & 0 deletions libc/src/math/fdiv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for fdiv --------------------------*- C++ -*-===//
//
// 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 LLVM_LIBC_SRC_MATH_FDIV_H
#define LLVM_LIBC_SRC_MATH_FDIV_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

float fdiv(double x, double y);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_FDIV_H
21 changes: 21 additions & 0 deletions libc/src/math/fdivf128.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation header for fdivf128 ----------------------*- C++ -*-===//
//
// 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 LLVM_LIBC_SRC_MATH_FDIVF128_H
#define LLVM_LIBC_SRC_MATH_FDIVF128_H

#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE_DECL {

float fdivf128(float128 x, float128 y);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_FDIVF128_H
20 changes: 20 additions & 0 deletions libc/src/math/fdivl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for fdivl -------------------------*- C++ -*-===//
//
// 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 LLVM_LIBC_SRC_MATH_FDIVL_H
#define LLVM_LIBC_SRC_MATH_FDIVL_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

float fdivl(long double x, long double y);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_FDIVL_H
20 changes: 20 additions & 0 deletions libc/src/math/ffma.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for ffma --------------------------*- C++ -*-===//
//
// 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 LLVM_LIBC_SRC_MATH_FFMA_H
#define LLVM_LIBC_SRC_MATH_FFMA_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

float ffma(double x, double y, double z);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_FFMA_H
21 changes: 21 additions & 0 deletions libc/src/math/ffmaf128.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//===-- Implementation header for ffmaf128 ----------------------*- C++ -*-===//
//
// 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 LLVM_LIBC_SRC_MATH_FFMAF128_H
#define LLVM_LIBC_SRC_MATH_FFMAF128_H

#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"

namespace LIBC_NAMESPACE_DECL {

float ffmaf128(float128 x, float128 y, float128 z);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_FFMAF128_H
20 changes: 20 additions & 0 deletions libc/src/math/ffmal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for ffmal -------------------------*- C++ -*-===//
//
// 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 LLVM_LIBC_SRC_MATH_FFMAL_H
#define LLVM_LIBC_SRC_MATH_FFMAL_H

#include "src/__support/macros/config.h"

namespace LIBC_NAMESPACE_DECL {

float ffmal(long double x, long double y, long double z);

} // namespace LIBC_NAMESPACE_DECL

#endif // LLVM_LIBC_SRC_MATH_FFMAL_H
Loading