Skip to content

Commit 8c81fb6

Browse files
[libc][math][c23] Add fadd{l,f128} C23 math functions (#102531)
Co-authored-by: OverMighty <[email protected]>
1 parent 95820ca commit 8c81fb6

File tree

21 files changed

+239
-10
lines changed

21 files changed

+239
-10
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ set(TARGET_LIBM_ENTRYPOINTS
407407
libc.src.math.fabs
408408
libc.src.math.fabsf
409409
libc.src.math.fabsl
410+
libc.src.math.fadd
411+
libc.src.math.faddl
410412
libc.src.math.fadd
411413
libc.src.math.fdim
412414
libc.src.math.fdimf
@@ -692,6 +694,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
692694
libc.src.math.dsqrtf128
693695
libc.src.math.dsubf128
694696
libc.src.math.fabsf128
697+
libc.src.math.faddf128
695698
libc.src.math.fdimf128
696699
libc.src.math.fdivf128
697700
libc.src.math.ffmaf128

libc/config/linux/arm/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ set(TARGET_LIBM_ENTRYPOINTS
242242
libc.src.math.fabs
243243
libc.src.math.fabsf
244244
libc.src.math.fabsl
245+
libc.src.math.fadd
246+
libc.src.math.faddl
245247
libc.src.math.fadd
246248
libc.src.math.fdim
247249
libc.src.math.fdimf

libc/config/linux/riscv/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ set(TARGET_LIBM_ENTRYPOINTS
406406
libc.src.math.fabs
407407
libc.src.math.fabsf
408408
libc.src.math.fabsl
409+
libc.src.math.fadd
410+
libc.src.math.faddl
409411
libc.src.math.fadd
410412
libc.src.math.fdim
411413
libc.src.math.fdimf
@@ -599,6 +601,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
599601
libc.src.math.dsqrtf128
600602
libc.src.math.dsubf128
601603
libc.src.math.fabsf128
604+
libc.src.math.faddf128
602605
libc.src.math.fdimf128
603606
libc.src.math.fdivf128
604607
libc.src.math.ffmaf128

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ set(TARGET_LIBM_ENTRYPOINTS
406406
libc.src.math.fabs
407407
libc.src.math.fabsf
408408
libc.src.math.fabsl
409+
libc.src.math.fadd
410+
libc.src.math.faddl
409411
libc.src.math.fadd
410412
libc.src.math.fdim
411413
libc.src.math.fdimf
@@ -688,6 +690,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
688690
libc.src.math.dsqrtf128
689691
libc.src.math.dsubf128
690692
libc.src.math.fabsf128
693+
libc.src.math.faddf128
691694
libc.src.math.fdimf128
692695
libc.src.math.fdivf128
693696
libc.src.math.ffmaf128

libc/config/windows/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ set(TARGET_LIBM_ENTRYPOINTS
153153
libc.src.math.fabsf
154154
libc.src.math.fabsl
155155
libc.src.math.fadd
156+
libc.src.math.faddl
156157
libc.src.math.fdim
157158
libc.src.math.fdimf
158159
libc.src.math.fdiml

libc/newhdrgen/yaml/math.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ functions:
7676
return_type: long double
7777
arguments:
7878
- type: long double
79+
- name: fadd
80+
standards:
81+
- stdc
82+
return_type: float
83+
arguments:
84+
- type: double
85+
- type: double
86+
- name: faddl
87+
standards:
88+
- faddl
89+
return_type: float
90+
arguments:
91+
- type: long double
92+
- type: long double
93+
- name: faddf128
94+
standards:
95+
- llvm_libc_ext
96+
return_type: float
97+
arguments:
98+
- type: float128
99+
- type: float128
100+
guard: LIBC_TYPES_HAS_FLOAT128
79101
- name: fdim
80102
standards:
81103
- stdc

libc/spec/llvm_libc_ext.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ 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<"faddf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
7476

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

libc/spec/stdc.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,9 @@ def StdC : StandardSpec<"stdc"> {
407407
FunctionSpec<"fabsl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>]>,
408408
GuardedFunctionSpec<"fabsf16", RetValSpec<Float16Type>, [ArgSpec<Float16Type>], "LIBC_TYPES_HAS_FLOAT16">,
409409
GuardedFunctionSpec<"fabsf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
410+
410411
FunctionSpec<"fadd", RetValSpec<FloatType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
412+
FunctionSpec<"faddl", RetValSpec<FloatType>, [ArgSpec<LongDoubleType>, ArgSpec<LongDoubleType>]>,
411413

412414
FunctionSpec<"fdim", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
413415
FunctionSpec<"fdimf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>]>,

libc/src/math/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,10 @@ add_math_entrypoint_object(fabsf)
161161
add_math_entrypoint_object(fabsl)
162162
add_math_entrypoint_object(fabsf16)
163163
add_math_entrypoint_object(fabsf128)
164+
164165
add_math_entrypoint_object(fadd)
166+
add_math_entrypoint_object(faddl)
167+
add_math_entrypoint_object(faddf128)
165168

166169
add_math_entrypoint_object(fdim)
167170
add_math_entrypoint_object(fdimf)

libc/src/math/fadd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
//===-- Implementation of fadd function ----------------------------------===//
1+
//===-- Implementation of fadd function -----------------------------------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "src/__support/macros/config.h"
10-
119
#ifndef LLVM_LIBC_SRC_MATH_FADD_H
1210
#define LLVM_LIBC_SRC_MATH_FADD_H
1311

12+
#include "src/__support/macros/config.h"
13+
1414
namespace LIBC_NAMESPACE_DECL {
1515

1616
float fadd(double x, double y);

0 commit comments

Comments
 (0)