about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTrevor Gross <tmgross@umich.edu>2025-02-11 15:40:17 +0000
committerTrevor Gross <t.gross35@gmail.com>2025-02-11 10:41:43 -0600
commitaa26cab257d34a8d8786f6c607b67fd70b467ce6 (patch)
treefcef85ba2aaa7162796caac39a607677feac06d5
parent7db47c741c173b94730b3017851924b1e7525dea (diff)
downloadrust-aa26cab257d34a8d8786f6c607b67fd70b467ce6.tar.gz
rust-aa26cab257d34a8d8786f6c607b67fd70b467ce6.zip
Rename `Float::exp` to `Float::ex`
Our function to get the exponent conflicts with the inherent `exp`
function for `e^x`. Rename `exp` to `ex` to avoid confusion and usage
problems.
-rw-r--r--library/compiler-builtins/libm/etc/function-definitions.json3
-rw-r--r--library/compiler-builtins/libm/src/math/generic/fma.rs6
-rw-r--r--library/compiler-builtins/libm/src/math/generic/fmod.rs4
-rw-r--r--library/compiler-builtins/libm/src/math/generic/rint.rs2
-rw-r--r--library/compiler-builtins/libm/src/math/generic/sqrt.rs2
-rw-r--r--library/compiler-builtins/libm/src/math/support/float_traits.rs4
6 files changed, 10 insertions, 11 deletions
diff --git a/library/compiler-builtins/libm/etc/function-definitions.json b/library/compiler-builtins/libm/etc/function-definitions.json
index a47aaad57c7..63d9927ad6f 100644
--- a/library/compiler-builtins/libm/etc/function-definitions.json
+++ b/library/compiler-builtins/libm/etc/function-definitions.json
@@ -206,8 +206,7 @@
     },
     "exp": {
         "sources": [
-            "src/math/exp.rs",
-            "src/math/support/float_traits.rs"
+            "src/math/exp.rs"
         ],
         "type": "f64"
     },
diff --git a/library/compiler-builtins/libm/src/math/generic/fma.rs b/library/compiler-builtins/libm/src/math/generic/fma.rs
index 821aee09028..cb1061cc38b 100644
--- a/library/compiler-builtins/libm/src/math/generic/fma.rs
+++ b/library/compiler-builtins/libm/src/math/generic/fma.rs
@@ -249,7 +249,7 @@ where
     let xy: B = x.widen() * y.widen();
     let mut result: B = xy + z.widen();
     let mut ui: B::Int = result.to_bits();
-    let re = result.exp();
+    let re = result.ex();
     let zb: B = z.widen();
 
     let prec_diff = B::SIG_BITS - F::SIG_BITS;
@@ -318,7 +318,7 @@ impl<F: Float> Norm<F> {
 
     fn from_float(x: F) -> Self {
         let mut ix = x.to_bits();
-        let mut e = x.exp() as i32;
+        let mut e = x.ex() as i32;
         let neg = x.is_sign_negative();
         if e == 0 {
             // Normalize subnormals by multiplication
@@ -326,7 +326,7 @@ impl<F: Float> Norm<F> {
             let scale_f = F::from_parts(false, scale_i + F::EXP_BIAS, F::Int::ZERO);
             let scaled = x * scale_f;
             ix = scaled.to_bits();
-            e = scaled.exp() as i32;
+            e = scaled.ex() as i32;
             e = if e == 0 {
                 // If the exponent is still zero, the input was zero. Artifically set this value
                 // such that the final `e` will exceed `ZERO_INF_NAN`.
diff --git a/library/compiler-builtins/libm/src/math/generic/fmod.rs b/library/compiler-builtins/libm/src/math/generic/fmod.rs
index ca1cda38323..c74b593d559 100644
--- a/library/compiler-builtins/libm/src/math/generic/fmod.rs
+++ b/library/compiler-builtins/libm/src/math/generic/fmod.rs
@@ -9,8 +9,8 @@ pub fn fmod<F: Float>(x: F, y: F) -> F {
     let one = F::Int::ONE;
     let mut ix = x.to_bits();
     let mut iy = y.to_bits();
-    let mut ex = x.exp().signed();
-    let mut ey = y.exp().signed();
+    let mut ex = x.ex().signed();
+    let mut ey = y.ex().signed();
     let sx = ix & F::SIGN_MASK;
 
     if iy << 1 == zero || y.is_nan() || ex == F::EXP_SAT as i32 {
diff --git a/library/compiler-builtins/libm/src/math/generic/rint.rs b/library/compiler-builtins/libm/src/math/generic/rint.rs
index 04e8f332f22..2f8b2b36591 100644
--- a/library/compiler-builtins/libm/src/math/generic/rint.rs
+++ b/library/compiler-builtins/libm/src/math/generic/rint.rs
@@ -8,7 +8,7 @@ use super::super::support::{FpResult, Round};
 /// applicable.
 pub fn rint_round<F: Float>(x: F, _round: Round) -> FpResult<F> {
     let toint = F::ONE / F::EPSILON;
-    let e = x.exp();
+    let e = x.ex();
     let positive = x.is_sign_positive();
 
     // On i386 `force_eval!` must be used to force rounding via storage to memory. Otherwise,
diff --git a/library/compiler-builtins/libm/src/math/generic/sqrt.rs b/library/compiler-builtins/libm/src/math/generic/sqrt.rs
index fdd612493b7..5918025bc67 100644
--- a/library/compiler-builtins/libm/src/math/generic/sqrt.rs
+++ b/library/compiler-builtins/libm/src/math/generic/sqrt.rs
@@ -109,7 +109,7 @@ where
         ix = scaled.to_bits();
         match top {
             Exp::Shifted(ref mut v) => {
-                *v = scaled.exp();
+                *v = scaled.ex();
                 *v = (*v).wrapping_sub(F::SIG_BITS);
             }
             Exp::NoShift(()) => {
diff --git a/library/compiler-builtins/libm/src/math/support/float_traits.rs b/library/compiler-builtins/libm/src/math/support/float_traits.rs
index 42ce3148464..534ca9a07fa 100644
--- a/library/compiler-builtins/libm/src/math/support/float_traits.rs
+++ b/library/compiler-builtins/libm/src/math/support/float_traits.rs
@@ -128,13 +128,13 @@ pub trait Float:
     }
 
     /// Returns the exponent, not adjusting for bias, not accounting for subnormals or zero.
-    fn exp(self) -> u32 {
+    fn ex(self) -> u32 {
         u32::cast_from(self.to_bits() >> Self::SIG_BITS) & Self::EXP_SAT
     }
 
     /// Extract the exponent and adjust it for bias, not accounting for subnormals or zero.
     fn exp_unbiased(self) -> i32 {
-        self.exp().signed() - (Self::EXP_BIAS as i32)
+        self.ex().signed() - (Self::EXP_BIAS as i32)
     }
 
     /// Returns the significand with no implicit bit (or the "fractional" part)