Skip to content

Commit 2c74237

Browse files
[libc][math][c23] Add fsub{,l,f128} and remainderf128 C23 math functions (#101576)
Co-authored-by: OverMighty <[email protected]>
1 parent 07ddf19 commit 2c74237

28 files changed

+413
-6
lines changed

libc/config/darwin/arm/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ set(TARGET_LIBM_ENTRYPOINTS
185185
libc.src.math.frexp
186186
libc.src.math.frexpf
187187
libc.src.math.frexpl
188+
libc.src.math.fsub
189+
libc.src.math.fsubl
188190
libc.src.math.hypot
189191
libc.src.math.hypotf
190192
libc.src.math.ilogb

libc/config/darwin/x86_64/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ set(TARGET_LIBM_ENTRYPOINTS
152152
#libc.src.math.frexp
153153
#libc.src.math.frexpf
154154
#libc.src.math.frexpl
155+
#libc.src.math.fsub
156+
#libc.src.math.fsubl
155157
#libc.src.math.hypot
156158
#libc.src.math.hypotf
157159
#libc.src.math.ilogb

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ set(TARGET_LIBM_ENTRYPOINTS
461461
libc.src.math.fromfpxl
462462
libc.src.math.fsqrt
463463
libc.src.math.fsqrtl
464+
libc.src.math.fsub
465+
libc.src.math.fsubl
464466
libc.src.math.getpayload
465467
libc.src.math.getpayloadf
466468
libc.src.math.getpayloadl
@@ -701,6 +703,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
701703
libc.src.math.fromfpf128
702704
libc.src.math.fromfpxf128
703705
libc.src.math.fsqrtf128
706+
libc.src.math.fsubf128
704707
libc.src.math.getpayloadf128
705708
libc.src.math.ilogbf128
706709
libc.src.math.ldexpf128
@@ -716,6 +719,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
716719
libc.src.math.nextafterf128
717720
libc.src.math.nextdownf128
718721
libc.src.math.nextupf128
722+
libc.src.math.remainderf128
719723
libc.src.math.remquof128
720724
libc.src.math.rintf128
721725
libc.src.math.roundevenf128

libc/config/linux/arm/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ set(TARGET_LIBM_ENTRYPOINTS
297297
libc.src.math.fromfpx
298298
libc.src.math.fromfpxf
299299
libc.src.math.fromfpxl
300+
libc.src.math.fsub
301+
libc.src.math.fsubl
300302
libc.src.math.getpayload
301303
libc.src.math.getpayloadf
302304
libc.src.math.getpayloadl

libc/config/linux/riscv/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ set(TARGET_LIBM_ENTRYPOINTS
464464
libc.src.math.fromfpxl
465465
libc.src.math.fsqrt
466466
libc.src.math.fsqrtl
467+
libc.src.math.fsub
468+
libc.src.math.fsubl
467469
libc.src.math.getpayload
468470
libc.src.math.getpayloadf
469471
libc.src.math.getpayloadl
@@ -608,6 +610,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
608610
libc.src.math.fromfpf128
609611
libc.src.math.fromfpxf128
610612
libc.src.math.fsqrtf128
613+
libc.src.math.fsubf128
611614
libc.src.math.getpayloadf128
612615
libc.src.math.ilogbf128
613616
libc.src.math.ldexpf128
@@ -623,6 +626,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
623626
libc.src.math.nextafterf128
624627
libc.src.math.nextdownf128
625628
libc.src.math.nextupf128
629+
libc.src.math.remainderf128
626630
libc.src.math.remquof128
627631
libc.src.math.rintf128
628632
libc.src.math.roundevenf128

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,8 @@ set(TARGET_LIBM_ENTRYPOINTS
464464
libc.src.math.fromfpxl
465465
libc.src.math.fsqrt
466466
libc.src.math.fsqrtl
467+
libc.src.math.fsub
468+
libc.src.math.fsubl
467469
libc.src.math.getpayload
468470
libc.src.math.getpayloadf
469471
libc.src.math.getpayloadl
@@ -697,6 +699,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
697699
libc.src.math.fromfpf128
698700
libc.src.math.fromfpxf128
699701
libc.src.math.fsqrtf128
702+
libc.src.math.fsubf128
700703
libc.src.math.getpayloadf128
701704
libc.src.math.ilogbf128
702705
libc.src.math.ldexpf128
@@ -712,6 +715,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
712715
libc.src.math.nextafterf128
713716
libc.src.math.nextdownf128
714717
libc.src.math.nextupf128
718+
libc.src.math.remainderf128
715719
libc.src.math.remquof128
716720
libc.src.math.rintf128
717721
libc.src.math.roundevenf128

libc/config/windows/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ set(TARGET_LIBM_ENTRYPOINTS
201201
libc.src.math.frexp
202202
libc.src.math.frexpf
203203
libc.src.math.frexpl
204+
libc.src.math.fsub
205+
libc.src.math.fsubl
204206
libc.src.math.hypot
205207
libc.src.math.hypotf
206208
libc.src.math.ilogb

libc/docs/math/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Basic Operations
118118
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
119119
| ddiv | N/A | N/A | | N/A | |check|\* | 7.12.14.4 | F.10.11 |
120120
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
121-
| dfma | N/A | N/A | |check| | N/A | |check|\* | 7.12.14.5 | F.10.11 |
121+
| dfma | N/A | N/A | |check| | N/A | |check|\* | 7.12.14.5 | F.10.11 |
122122
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
123123
| dmul | N/A | N/A | |check| | N/A | |check|\* | 7.12.14.3 | F.10.11 |
124124
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
@@ -176,7 +176,7 @@ Basic Operations
176176
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
177177
| fromfpx | |check| | |check| | |check| | |check| | |check| | 7.12.9.11 | F.10.6.11 |
178178
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
179-
| fsub | N/A | | | N/A | | 7.12.14.2 | F.10.11 |
179+
| fsub | N/A | |check| | |check| | N/A | |check|\* | 7.12.14.2 | F.10.11 |
180180
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
181181
| getpayload | |check| | |check| | |check| | |check| | |check| | F.10.13.1 | N/A |
182182
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
@@ -210,7 +210,7 @@ Basic Operations
210210
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
211211
| nextup | |check| | |check| | |check| | |check| | |check| | 7.12.11.5 | F.10.8.5 |
212212
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
213-
| remainder | |check| | |check| | |check| | |check| | | 7.12.10.2 | F.10.7.2 |
213+
| remainder | |check| | |check| | |check| | |check| | |check| | 7.12.10.2 | F.10.7.2 |
214214
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
215215
| remquo | |check| | |check| | |check| | |check| | |check| | 7.12.10.3 | F.10.7.3 |
216216
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+

libc/newhdrgen/yaml/math.yaml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,14 @@ functions:
794794
arguments:
795795
- type: long double
796796
- type: long double
797+
- name: remainderf128
798+
standards:
799+
- stdc
800+
return_type: float128
801+
arguments:
802+
- type: float128
803+
- type: float128
804+
guard: LIBC_TYPES_HAS_FLOAT128
797805
- name: remquo
798806
standards:
799807
- stdc
@@ -1540,6 +1548,28 @@ functions:
15401548
- type: int
15411549
- type: unsigned int
15421550
guard: LIBC_TYPES_HAS_FLOAT16
1551+
- name: fsub
1552+
standards:
1553+
- stdc
1554+
return_type: float
1555+
arguments:
1556+
- type: double
1557+
- type: double
1558+
- name: fsubl
1559+
standards:
1560+
- stdc
1561+
return_type: float
1562+
arguments:
1563+
- type: long double
1564+
- type: long double
1565+
- name: fsubf128
1566+
standards:
1567+
- llvm_libc_ext
1568+
return_type: float
1569+
arguments:
1570+
- type: float128
1571+
- type: float128
1572+
guard: LIBC_TYPES_HAS_FLOAT128
15431573
- name: getpayload
15441574
standards:
15451575
- stdc
@@ -1557,7 +1587,7 @@ functions:
15571587
- stdc
15581588
return_type: float
15591589
arguments:
1560-
- type: float *
1590+
- type: float *
15611591
- name: getpayloadf16
15621592
standards:
15631593
- stdc

libc/spec/llvm_libc_ext.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ def LLVMLibcExt : StandardSpec<"llvm_libc_ext"> {
9898

9999
GuardedFunctionSpec<"fsqrtf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
100100

101+
FunctionSpec<"fsubf128", RetValSpec<FloatType>, [ArgSpec<Float128Type>, ArgSpec<Float128Type>], "LIBC_TYPES_HAS_FLOAT128">,
102+
101103
FunctionSpec<"powi", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<IntType>]>,
102-
FunctionSpec<"powif", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<IntType>]>,
104+
FunctionSpec<"powif", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<IntType>]>,
103105
]
104106
>;
105107

0 commit comments

Comments
 (0)