Skip to content

Commit 1fa2b37

Browse files
author
matu3ba
authored
compiler_rt: document math functions (#14552)
This documents the currently implemented math functions in alphabetical order and sorts the remaining items.
1 parent d4bd1b1 commit 1fa2b37

File tree

1 file changed

+146
-10
lines changed

1 file changed

+146
-10
lines changed

lib/compiler_rt/README.md

Lines changed: 146 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -552,20 +552,156 @@ TODO brief explanation + implementation
552552
| ------ | ------------- | --------- | --------- | --------- | -------------------------- |
553553
| | | | | | **Fixed-Point Fractional** |
554554

555-
Further content:
555+
Math functions according to C99 with gnu extension sincos. f16, f80 and f128 functions
556+
are additionally supported by Zig, but not part of C standard. Alphabetically sorted.
557+
558+
| Done | Name | a | b | Out | Comment |
559+
| ---- | ------- | --------- | --------- | --------- | -------------------------- |
560+
|| __ceilh | f16 || f16 |smallest integer value not less than a|
561+
|| ceilf | f32 || f32 |If a is integer, +-0, +-NaN, or +-infinite, a itself is returned.|
562+
|| ceil | f64 || f64 | .. |
563+
|| __ceilx | f80 || f80 | |
564+
|| ceilf128 | f128 || f128 | .. PPC |
565+
|| ceilq | f128 || f128 | .. |
566+
|| ceill |long double||long double| .. |
567+
|| __cosh | f16 || f16 | `cos(a)=(e^(ia)+e^(-ia))/2`|
568+
|| cosf | f32 || f32 | .. |
569+
|| cos | f64 || f64 | .. |
570+
|| __cosx | f80 || f80 | .. |
571+
|| cosf128 | f128 || f128 | .. |
572+
|| cosq | f128 || f128 | .. PPC |
573+
|| cosl |long double||long double| .. |
574+
|| __exph | f16 || f16 | `e^a` with e base of natural logarithms|
575+
|| expf | f32 || f32 | .. |
576+
|| exp | f64 || f64 | .. |
577+
|| __expx | f80 || f80 | .. |
578+
|| expf128 | f128 || f128 | .. |
579+
|| expq | f128 || f128 | .. PPC |
580+
|| expl |long double||long double| .. |
581+
|| __exp2h | f16 || f16 | `2^a` |
582+
|| exp2f | f32 || f32 | .. |
583+
|| exp2 | f64 || f64 | .. |
584+
|| __exp2x | f80 || f80 | .. |
585+
|| exp2f128 | f128 || f128 | .. |
586+
|| exp2q | f128 || f128 | .. PPC |
587+
|| exp2l |long double||long double| .. |
588+
|| __fabsh | f16 || f16 | absolute value of a |
589+
|| fabsf | f32 || f32 | .. |
590+
|| fabs | f64 || f64 | .. |
591+
|| __fabsx | f80 || f80 | .. |
592+
|| fabsf128 | f128 || f128 | .. |
593+
|| fabsq | f128 || f128 | .. PPC |
594+
|| fabsl |long double||long double| .. |
595+
|| __floorh | f16 || f16 |largest integer value not greater than a|
596+
|| floorf | f32 || f32 |If a is integer, +-0, +-NaN, or +-infinite, a itself is returned.|
597+
|| floor | f64 || f64 | .. |
598+
|| __floorx | f80 || f80 | .. |
599+
|| floorf128 | f128 || f128 | .. |
600+
|| floorq | f128 || f128 | .. PPC |
601+
|| floorl |long double||long double| .. |
602+
|| __fmah | f16 | 2xf16 | f16 | args a,b,c result `(a*b)+c`|
603+
|| fmaf | f32 | 2xf32 | f32 |Fused multiply-add for hardware acceleration|
604+
|| fma | f64 | 2xf64 | f64 | .. |
605+
|| __fmax | f80 | 2xf80 | f80 | .. |
606+
|| fmaf128 | f128 | 2xf128 | f128 | .. |
607+
|| fmaq | f128 | 2xf128 | f128 | .. PPC |
608+
|| fmal |long double|2xlong double|long double| .. |
609+
|| __fmaxh | f16 | f16 | f16 | larger value of a,b |
610+
|| fmaxf | f32 | f32 | f32 | .. |
611+
|| fmax | f64 | f64 | f64 | .. |
612+
|| __fmaxx | f80 | f80 | f80 | .. |
613+
|| fmaxf128 | f128 | f128 | f128 | .. |
614+
|| fmaxq | f128 | f128 | f128 | .. PPC |
615+
|| fmaxl |long double|long double|long double| .. |
616+
|| __fminh | f16 | f16 | f16 | smaller value of a,b |
617+
|| fminf | f32 | f32 | f32 | .. |
618+
|| fmin | f64 | f64 | f64 | .. |
619+
|| __fminx | f80 | f80 | f80 | .. |
620+
|| fminf128 | f128 | f128 | f128 | .. |
621+
|| fminq | f128 | f128 | f128 | .. PPC |
622+
|| fminl |long double|long double|long double| .. |
623+
|| __fmodh | f16 | f16 | f16 |floating-point remainder of division a/b|
624+
|| fmodf | f32 | f32 | f32 | .. |
625+
|| fmod | f64 | f64 | f64 | .. |
626+
|| __fmodx | f80 | f80 | f80 | .. |
627+
|| fmodf128 | f128 | f128 | f128 | .. |
628+
|| fmodq | f128 | f128 | f128 | .. PPC |
629+
|| fmodl |long double|long double|long double| .. |
630+
|| __logh | f16 || f16 |natural (base-e) logarithm of a|
631+
|| logf | f32 || f32 | .. |
632+
|| log | f64 || f64 | .. |
633+
|| __logx | f80 || f80 | .. |
634+
|| logf128 | f128 || f128 | .. |
635+
|| logq | f128 || f128 | .. PPC |
636+
|| logl |long double||long double| .. |
637+
|| __log10h | f16 || f16 |common (base-10) logarithm of a|
638+
|| log10f | f32 || f32 | .. |
639+
|| log10 | f64 || f64 | .. |
640+
|| __log10x | f80 || f80 | .. |
641+
|| log10f128 | f128 || f128 | .. |
642+
|| log10q | f128 || f128 | .. PPC |
643+
|| log10l |long double||long double| .. |
644+
|| __log2h | f16 || f16 | base-2 logarithm of a |
645+
|| log2f | f32 || f32 | .. |
646+
|| log2 | f64 || f64 | .. |
647+
|| __log2x | f80 || f80 | .. |
648+
|| log2f128 | f128 || f128 | .. |
649+
|| log2q | f128 || f128 | .. PPC |
650+
|| log2l |long double||long double| .. |
651+
|| __roundh | f16 || f16 | a rounded to next int away from zero|
652+
|| roundf | f32 || f32 | .. |
653+
|| round | f64 || f64 | .. |
654+
|| __roundx | f80 || f80 | .. |
655+
|| roundf128 | f128 || f128 | .. |
656+
|| roundq | f128 || f128 | .. PPC |
657+
|| roundl |long double||long double| .. |
658+
|| __sinh | f16 || f16 | `sin(a)=(e^(ia)-e^(-ia))/2`|
659+
|| sinf | f32 || f32 | .. |
660+
|| sin | f64 || f64 | .. |
661+
|| __sinx | f80 || f80 | .. |
662+
|| sinf128 | f128 || f128 | .. |
663+
|| sinq | f128 || f128 | .. PPC |
664+
|| sinl |long double||long double| .. |
665+
|| __sincosh | f16 | 2x *f16 ||sin and cos of the same angle a|
666+
|| sincosf | f32 | 2x *f32 ||args a,*b,*c, `b.*=sin(x),c.*=cos(x)`|
667+
|| sincos | f64 | 2x *f64 || .. |
668+
|| __sincosx | f80 | 2x *f80 || .. |
669+
|| sincosf128 | f128 | 2x *f128 || .. |
670+
|| sincosq | f128 | 2x *f128 || .. PPC |
671+
|| sincosl |long double| 2x *long double|| .. |
672+
|| __sqrth | f16 || f16 | square root of a (find `r st. a=r^2`)|
673+
|| sqrtf | f32 || f32 | .. |
674+
|| sqrt | f64 || f64 | .. |
675+
|| __sqrtx | f80 || f80 | .. |
676+
|| sqrtf128 | f128 || f128 | .. |
677+
|| sqrtq | f128 || f128 | .. PPC |
678+
|| sqrtl |long double||long double| .. |
679+
|| __tanh | f16 || f16 | `tan(x)=sin(x)/cos(x) |
680+
|| tanf | f32 || f32 | .. |
681+
|| tan | f64 || f64 | .. |
682+
|| __tanx | f80 || f80 | .. |
683+
|| tanf128 | f128 || f128 | .. |
684+
|| tanq | f128 || f128 | .. PPC |
685+
|| tanl |long double||long double| .. |
686+
|| __trunch | f16 || f16 | a rounded to next int towards zero|
687+
|| truncf | f32 || f32 | .. |
688+
|| trunc | f64 || f64 | .. |
689+
|| __truncx | f80 || f80 | .. |
690+
|| truncf128 | f128 || f128 | .. |
691+
|| truncq | f128 || f128 | .. PPC |
692+
|| truncl |long double||long double| .. |
693+
694+
Further content (conditionally) exported with C abi:
556695
- aarch64 outline atomics
696+
- arm routines (memory routines + memclr [setting to 0], divmod routines and stubs for unwind_cpp)
557697
- atomics
558-
- msvc things like _alldiv, _aulldiv, _allrem
559-
- clear cache
560-
- tls emulation
561-
- math routines (cos, sin, tan, ceil, floor, exp, exp2, fabs, log, log10, log2, sincos, sqrt)
562698
- bcmp
563-
- ieee float routines (fma, fmax, fmin, fmod, fabs, float rounding, )
564-
- arm routines (memory routines + memclr [setting to 0], divmod routines and stubs for unwind_cpp)
699+
- clear cache
565700
- memory routines (memcmp, memcpy, memset, memmove)
701+
- msvc things like _alldiv, _aulldiv, _allrem
566702
- objective-c __isPlatformVersionAtLeast check
567703
- stack probe routines
704+
- tls emulation
568705

569-
Future work
570-
571-
Arbitrary length integer library routines
706+
Future work:
707+
- Arbitrary length integer library routines

0 commit comments

Comments
 (0)