diff options
author | Tanner Gooding <tagoo@outlook.com> | 2018-11-05 15:37:36 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-05 15:37:36 -0800 |
commit | 28417584d8e98ae7eac22e92b952778f8ea94047 (patch) | |
tree | a6010a24228ca769fc7a6381cbd04b3a762e9219 /src/classlibnative | |
parent | d3a7c973723bf2610c7dcdcd00318c06a72a36f8 (diff) | |
download | coreclr-28417584d8e98ae7eac22e92b952778f8ea94047.tar.gz coreclr-28417584d8e98ae7eac22e92b952778f8ea94047.tar.bz2 coreclr-28417584d8e98ae7eac22e92b952778f8ea94047.zip |
Adding some new functions to System.Math and System.MathF (#20788)
* Adding BitIncrement, BitDecrement, CopySign, MaxMagnitude, and MinMagnitude to Math and MathF
* Adding FusedMultiplyAdd, IlogB, Log2, and ScaleB to Math and MathF
* Adding some basic PAL tests for fma, ilogb, log2, and scalbn
* Fixing a couple typos and adding clarifying comments
* Fixing the MSVC _VVV FCALL declarations
Diffstat (limited to 'src/classlibnative')
-rw-r--r-- | src/classlibnative/float/floatdouble.cpp | 36 | ||||
-rw-r--r-- | src/classlibnative/float/floatsingle.cpp | 36 | ||||
-rw-r--r-- | src/classlibnative/inc/floatdouble.h | 4 | ||||
-rw-r--r-- | src/classlibnative/inc/floatsingle.h | 4 |
4 files changed, 80 insertions, 0 deletions
diff --git a/src/classlibnative/float/floatdouble.cpp b/src/classlibnative/float/floatdouble.cpp index b27ef61416..2e4b382460 100644 --- a/src/classlibnative/float/floatdouble.cpp +++ b/src/classlibnative/float/floatdouble.cpp @@ -200,6 +200,24 @@ FCIMPL2_VV(double, COMDouble::FMod, double x, double y) return (double)fmod(x, y); FCIMPLEND +/*=====================================FusedMultiplyAdd========================== +** +==============================================================================*/ +FCIMPL3_VVV(double, COMDouble::FusedMultiplyAdd, double x, double y, double z) + FCALL_CONTRACT; + + return (double)fma(x, y, z); +FCIMPLEND + +/*=====================================Ilog2==================================== +** +==============================================================================*/ +FCIMPL1_V(int, COMDouble::IlogB, double x) + FCALL_CONTRACT; + + return (int)ilogb(x); +FCIMPLEND + /*=====================================Log====================================== ** ==============================================================================*/ @@ -209,6 +227,15 @@ FCIMPL1_V(double, COMDouble::Log, double x) return (double)log(x); FCIMPLEND +/*=====================================Log2===================================== +** +==============================================================================*/ +FCIMPL1_V(double, COMDouble::Log2, double x) + FCALL_CONTRACT; + + return (double)log2(x); +FCIMPLEND + /*====================================Log10===================================== ** ==============================================================================*/ @@ -236,6 +263,15 @@ FCIMPL2_VV(double, COMDouble::Pow, double x, double y) return (double)pow(x, y); FCIMPLEND +/*=====================================ScaleB=================================== +** +==============================================================================*/ +FCIMPL2_VI(double, COMDouble::ScaleB, double x, int n) + FCALL_CONTRACT; + + return (double)scalbn(x, n); +FCIMPLEND + /*=====================================Sin====================================== ** ==============================================================================*/ diff --git a/src/classlibnative/float/floatsingle.cpp b/src/classlibnative/float/floatsingle.cpp index 3903bc9cd3..23c1445e43 100644 --- a/src/classlibnative/float/floatsingle.cpp +++ b/src/classlibnative/float/floatsingle.cpp @@ -187,6 +187,24 @@ FCIMPL2_VV(float, COMSingle::FMod, float x, float y) return (float)fmodf(x, y); FCIMPLEND +/*=====================================FusedMultiplyAdd========================== +** +==============================================================================*/ +FCIMPL3_VVV(float, COMSingle::FusedMultiplyAdd, float x, float y, float z) + FCALL_CONTRACT; + + return (float)fmaf(x, y, z); +FCIMPLEND + +/*=====================================Ilog2==================================== +** +==============================================================================*/ +FCIMPL1_V(int, COMSingle::IlogB, float x) + FCALL_CONTRACT; + + return (int)ilogbf(x); +FCIMPLEND + /*=====================================Log====================================== ** ==============================================================================*/ @@ -196,6 +214,15 @@ FCIMPL1_V(float, COMSingle::Log, float x) return (float)logf(x); FCIMPLEND +/*=====================================Log2===================================== +** +==============================================================================*/ +FCIMPL1_V(float, COMSingle::Log2, float x) + FCALL_CONTRACT; + + return (float)log2f(x); +FCIMPLEND + /*====================================Log10===================================== ** ==============================================================================*/ @@ -223,6 +250,15 @@ FCIMPL2_VV(float, COMSingle::Pow, float x, float y) return (float)powf(x, y); FCIMPLEND +/*=====================================ScaleB=================================== +** +==============================================================================*/ +FCIMPL2_VI(float, COMSingle::ScaleB, float x, int n) + FCALL_CONTRACT; + + return (float)scalbnf(x, n); +FCIMPLEND + /*=====================================Sin====================================== ** ==============================================================================*/ diff --git a/src/classlibnative/inc/floatdouble.h b/src/classlibnative/inc/floatdouble.h index d2c819f544..602b45b2f8 100644 --- a/src/classlibnative/inc/floatdouble.h +++ b/src/classlibnative/inc/floatdouble.h @@ -25,10 +25,14 @@ public: FCDECL1_V(static double, Exp, double x); FCDECL1_V(static double, Floor, double x); FCDECL2_VV(static double, FMod, double x, double y); + FCDECL3_VVV(static double, FusedMultiplyAdd, double x, double y, double z); + FCDECL1_V(static int, IlogB, double x); FCDECL1_V(static double, Log, double x); + FCDECL1_V(static double, Log2, double x); FCDECL1_V(static double, Log10, double x); FCDECL2_VI(static double, ModF, double x, double* intptr); FCDECL2_VV(static double, Pow, double x, double y); + FCDECL2_VI(static double, ScaleB, double x, int n); FCDECL1_V(static double, Sin, double x); FCDECL1_V(static double, Sinh, double x); FCDECL1_V(static double, Sqrt, double x); diff --git a/src/classlibnative/inc/floatsingle.h b/src/classlibnative/inc/floatsingle.h index a4f9cb73df..f54a65028a 100644 --- a/src/classlibnative/inc/floatsingle.h +++ b/src/classlibnative/inc/floatsingle.h @@ -25,10 +25,14 @@ public: FCDECL1_V(static float, Exp, float x); FCDECL1_V(static float, Floor, float x); FCDECL2_VV(static float, FMod, float x, float y); + FCDECL3_VVV(static float, FusedMultiplyAdd, float x, float y, float z); + FCDECL1_V(static int, IlogB, float x); FCDECL1_V(static float, Log, float x); + FCDECL1_V(static float, Log2, float x); FCDECL1_V(static float, Log10, float x); FCDECL2_VI(static float, ModF, float x, float* intptr); FCDECL2_VV(static float, Pow, float x, float y); + FCDECL2_VI(static float, ScaleB, float x, int n); FCDECL1_V(static float, Sin, float x); FCDECL1_V(static float, Sinh, float x); FCDECL1_V(static float, Sqrt, float x); |