⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 s_expm1.s

📁 glibc 2.9,最新版的C语言库函数
💻 S
📖 第 1 页 / 共 2 页
字号:
.file "exp_m1.s"// Copyright (c) 2000 - 2005, Intel Corporation// All rights reserved.//// Contributed 2000 by the Intel Numerics Group, Intel Corporation//// Redistribution and use in source and binary forms, with or without// modification, are permitted provided that the following conditions are// met://// * Redistributions of source code must retain the above copyright// notice, this list of conditions and the following disclaimer.//// * Redistributions in binary form must reproduce the above copyright// notice, this list of conditions and the following disclaimer in the// documentation and/or other materials provided with the distribution.//// * The name of Intel Corporation may not be used to endorse or promote// products derived from this software without specific prior written// permission.// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.//// Intel Corporation is the author of this code, and requests that all// problem reports or change requests be submitted to it directly at// http://www.intel.com/software/products/opensource/libraries/num.htm.//// History//==============================================================// 02/02/00 Initial Version// 04/04/00 Unwind support added// 08/15/00 Bundle added after call to __libm_error_support to properly//          set [the previously overwritten] GR_Parameter_RESULT.// 07/07/01 Improved speed of all paths// 05/20/02 Cleaned up namespace and sf0 syntax// 11/20/02 Improved speed, algorithm based on exp// 03/31/05 Reformatted delimiters between data tables// API//==============================================================// double expm1(double)// Overview of operation//==============================================================// 1. Inputs of Nan, Inf, Zero, NatVal handled with special paths//// 2. |x| < 2^-60//    Result = x, computed by x + x*x to handle appropriate flags and rounding//// 3. 2^-60 <= |x| < 2^-2//    Result determined by 13th order Taylor series polynomial//    expm1f(x) = x + Q2*x^2 + ... + Q13*x^13//// 4. x < -48.0//    Here we know result is essentially -1 + eps, where eps only affects//    rounded result.  Set I.//// 5. x >= 709.7827//    Result overflows.  Set I, O, and call error support//// 6. 2^-2 <= x < 709.7827  or  -48.0 <= x < -2^-2  //    This is the main path.  The algorithm is described below:// Take the input x. w is "how many log2/128 in x?"//  w = x * 128/log2//  n = int(w)//  x = n log2/128 + r + delta//  n = 128M + index_1 + 2^4 index_2//  x = M log2 + (log2/128) index_1 + (log2/8) index_2 + r + delta//  exp(x) = 2^M  2^(index_1/128)  2^(index_2/8) exp(r) exp(delta)//       Construct 2^M//       Get 2^(index_1/128) from table_1;//       Get 2^(index_2/8)   from table_2;//       Calculate exp(r) by series by 5th order polynomial//          r = x - n (log2/128)_high//          delta = - n (log2/128)_low//       Calculate exp(delta) as 1 + delta// Special values//==============================================================// expm1(+0)    = +0.0// expm1(-0)    = -0.0// expm1(+qnan) = +qnan// expm1(-qnan) = -qnan// expm1(+snan) = +qnan// expm1(-snan) = -qnan// expm1(-inf)  = -1.0// expm1(+inf)  = +inf// Overflow and Underflow//=======================// expm1(x) = largest double normal when//     x = 709.7827 = 40862e42fefa39ef//// Underflow is handled as described in case 2 above.// Registers used//==============================================================// Floating Point registers used:// f8, input// f9 -> f15,  f32 -> f75// General registers used:// r14 -> r40// Predicate registers used:// p6 -> p15// Assembly macros//==============================================================rRshf                  = r14rAD_TB1                = r15rAD_T1                 = r15rAD_TB2                = r16rAD_T2                 = r16rAD_Ln2_lo             = r17rAD_P                  = r17rN                     = r18rIndex_1               = r19rIndex_2_16            = r20rM                     = r21rBiased_M              = r21rIndex_1_16            = r22rSignexp_x             = r23rExp_x                 = r24rSig_inv_ln2           = r25rAD_Q1                 = r26rAD_Q2                 = r27rTmp                   = r27rExp_bias              = r28rExp_mask              = r29rRshf_2to56            = r30rGt_ln                 = r31rExp_2tom56            = r31GR_SAVE_B0             = r33GR_SAVE_PFS            = r34GR_SAVE_GP             = r35GR_SAVE_SP             = r36GR_Parameter_X         = r37GR_Parameter_Y         = r38GR_Parameter_RESULT    = r39GR_Parameter_TAG       = r40FR_X                   = f10FR_Y                   = f1FR_RESULT              = f8fRSHF_2TO56            = f6fINV_LN2_2TO63         = f7fW_2TO56_RSH           = f9f2TOM56                = f11fP5                    = f12fP54                   = f50fP5432                 = f50fP4                    = f13fP3                    = f14fP32                   = f14fP2                    = f15fLn2_by_128_hi         = f33fLn2_by_128_lo         = f34fRSHF                  = f35fNfloat                = f36fW                     = f37fR                     = f38fF                     = f39fRsq                   = f40fRcube                 = f41f2M                    = f42fS1                    = f43fT1                    = f44fMIN_DBL_OFLOW_ARG     = f45fMAX_DBL_MINUS_1_ARG   = f46fMAX_DBL_NORM_ARG      = f47fP_lo                  = f51fP_hi                  = f52fP                     = f53fS                     = f54fNormX                 = f56fWre_urm_f8            = f57fGt_pln                = f58fTmp                   = f58fS2                    = f59fT2                    = f60fSm1                   = f61fXsq                   = f62fX6                    = f63fX4                    = f63fQ7                    = f64fQ76                   = f64fQ7654                 = f64fQ765432               = f64fQ6                    = f65fQ5                    = f66fQ54                   = f66fQ4                    = f67fQ3                    = f68fQ32                   = f68fQ2                    = f69fQD                    = f70fQDC                   = f70fQDCBA                 = f70fQDCBA98               = f70fQDCBA98765432         = f70fQC                    = f71fQB                    = f72fQBA                   = f72fQA                    = f73fQ9                    = f74fQ98                   = f74fQ8                    = f75// Data tables//==============================================================RODATA.align 16// ************* DO NOT CHANGE ORDER OF THESE TABLES ********************// double-extended 1/ln(2)// 3fff b8aa 3b29 5c17 f0bb be87fed0691d3e88// 3fff b8aa 3b29 5c17 f0bc// For speed the significand will be loaded directly with a movl and setf.sig//   and the exponent will be bias+63 instead of bias+0.  Thus subsequent//   computations need to scale appropriately.// The constant 128/ln(2) is needed for the computation of w.  This is also//   obtained by scaling the computations.//// Two shifting constants are loaded directly with movl and setf.d.//   1. fRSHF_2TO56 = 1.1000..00 * 2^(63-7)//        This constant is added to x*1/ln2 to shift the integer part of//        x*128/ln2 into the rightmost bits of the significand.//        The result of this fma is fW_2TO56_RSH.//   2. fRSHF       = 1.1000..00 * 2^(63)//        This constant is subtracted from fW_2TO56_RSH * 2^(-56) to give//        the integer part of w, n, as a floating-point number.//        The result of this fms is fNfloat.LOCAL_OBJECT_START(exp_Table_1)data8 0x40862e42fefa39f0 // smallest dbl overflow argdata8 0xc048000000000000 // approx largest arg for minus one resultdata8 0x40862e42fefa39ef // largest dbl arg to give normal dbl resultdata8 0x0                // paddata8 0xb17217f7d1cf79ab , 0x00003ff7 // ln2/128 hidata8 0xc9e3b39803f2f6af , 0x00003fb7 // ln2/128 lo//// Table 1 is 2^(index_1/128) where// index_1 goes from 0 to 15//data8 0x8000000000000000 , 0x00003FFFdata8 0x80B1ED4FD999AB6C , 0x00003FFFdata8 0x8164D1F3BC030773 , 0x00003FFFdata8 0x8218AF4373FC25EC , 0x00003FFFdata8 0x82CD8698AC2BA1D7 , 0x00003FFFdata8 0x8383594EEFB6EE37 , 0x00003FFFdata8 0x843A28C3ACDE4046 , 0x00003FFFdata8 0x84F1F656379C1A29 , 0x00003FFFdata8 0x85AAC367CC487B15 , 0x00003FFFdata8 0x8664915B923FBA04 , 0x00003FFFdata8 0x871F61969E8D1010 , 0x00003FFFdata8 0x87DB357FF698D792 , 0x00003FFFdata8 0x88980E8092DA8527 , 0x00003FFFdata8 0x8955EE03618E5FDD , 0x00003FFFdata8 0x8A14D575496EFD9A , 0x00003FFFdata8 0x8AD4C6452C728924 , 0x00003FFFLOCAL_OBJECT_END(exp_Table_1)// Table 2 is 2^(index_1/8) where// index_2 goes from 0 to 7LOCAL_OBJECT_START(exp_Table_2)data8 0x8000000000000000 , 0x00003FFFdata8 0x8B95C1E3EA8BD6E7 , 0x00003FFFdata8 0x9837F0518DB8A96F , 0x00003FFFdata8 0xA5FED6A9B15138EA , 0x00003FFFdata8 0xB504F333F9DE6484 , 0x00003FFFdata8 0xC5672A115506DADD , 0x00003FFFdata8 0xD744FCCAD69D6AF4 , 0x00003FFFdata8 0xEAC0C6E7DD24392F , 0x00003FFFLOCAL_OBJECT_END(exp_Table_2)LOCAL_OBJECT_START(exp_p_table)data8 0x3f8111116da21757 //P5data8 0x3fa55555d787761c //P4data8 0x3fc5555555555414 //P3data8 0x3fdffffffffffd6a //P2LOCAL_OBJECT_END(exp_p_table)LOCAL_OBJECT_START(exp_Q1_table)data8 0x3de6124613a86d09 // QD = 1/13!data8 0x3e21eed8eff8d898 // QC = 1/12!data8 0x3ec71de3a556c734 // Q9 = 1/9!data8 0x3efa01a01a01a01a // Q8 = 1/8!data8 0x8888888888888889,0x3ff8 // Q5 = 1/5!data8 0xaaaaaaaaaaaaaaab,0x3ffc // Q3 = 1/3!data8 0x0,0x0            // Pad to avoid bank conflictsLOCAL_OBJECT_END(exp_Q1_table)LOCAL_OBJECT_START(exp_Q2_table)data8 0x3e5ae64567f544e4 // QB = 1/11!data8 0x3e927e4fb7789f5c // QA = 1/10!data8 0x3f2a01a01a01a01a // Q7 = 1/7!data8 0x3f56c16c16c16c17 // Q6 = 1/6!data8 0xaaaaaaaaaaaaaaab,0x3ffa // Q4 = 1/4!data8 0x8000000000000000,0x3ffe // Q2 = 1/2!LOCAL_OBJECT_END(exp_Q2_table).section .textGLOBAL_IEEE754_ENTRY(expm1){ .mlx      getf.exp        rSignexp_x = f8  // Must recompute if x unorm      movl            rSig_inv_ln2 = 0xb8aa3b295c17f0bc  // signif of 1/ln2}{ .mlx      addl            rAD_TB1    = @ltoff(exp_Table_1), gp      movl            rRshf_2to56 = 0x4768000000000000   // 1.10000 2^(63+56)};;// We do this fnorm right at the beginning to normalize// any input unnormals so that SWA is not taken.{ .mfi      ld8             rAD_TB1    = [rAD_TB1]      fclass.m        p6,p0 = f8,0x0b  // Test for x=unorm      mov             rExp_mask = 0x1ffff}{ .mfi      mov             rExp_bias = 0xffff      fnorm.s1        fNormX   = f8      mov             rExp_2tom56 = 0xffff-56};;// Form two constants we need//  1/ln2 * 2^63  to compute  w = x * 1/ln2 * 128//  1.1000..000 * 2^(63+63-7) to right shift int(w) into the significand{ .mfi      setf.sig        fINV_LN2_2TO63 = rSig_inv_ln2 // form 1/ln2 * 2^63      fclass.m        p8,p0 = f8,0x07  // Test for x=0      nop.i           0}{ .mlx      setf.d          fRSHF_2TO56 = rRshf_2to56 // Form 1.100 * 2^(63+56)      movl            rRshf = 0x43e8000000000000   // 1.10000 2^63 for rshift};;{ .mfi      setf.exp        f2TOM56 = rExp_2tom56 // form 2^-56 for scaling Nfloat      fclass.m        p9,p0 = f8,0x22  // Test for x=-inf      add             rAD_TB2 = 0x140, rAD_TB1 // Point to Table 2}{ .mib      add             rAD_Q1 = 0x1e0, rAD_TB1 // Point to Q table for small path      add             rAD_Ln2_lo = 0x30, rAD_TB1 // Point to ln2_by_128_lo(p6)  br.cond.spnt    EXPM1_UNORM // Branch if x unorm};;EXPM1_COMMON:{ .mfi      ldfpd           fMIN_DBL_OFLOW_ARG, fMAX_DBL_MINUS_1_ARG = [rAD_TB1],16      fclass.m        p10,p0 = f8,0x1e1  // Test for x=+inf, NaN, NaT      add             rAD_Q2 = 0x50, rAD_Q1   // Point to Q table for small path}{ .mfb      nop.m           0      nop.f           0(p8)  br.ret.spnt     b0                        // Exit for x=0, return x};;{ .mfi      ldfd            fMAX_DBL_NORM_ARG = [rAD_TB1],16      nop.f           0      and             rExp_x = rExp_mask, rSignexp_x // Biased exponent of x}{ .mfb      setf.d          fRSHF = rRshf // Form right shift const 1.100 * 2^63(p9)  fms.d.s0        f8 = f0,f0,f1            // quick exit for x=-inf(p9)  br.ret.spnt     b0};;{ .mfi      ldfpd           fQD, fQC = [rAD_Q1], 16  // Load coeff for small path      nop.f           0      sub             rExp_x = rExp_x, rExp_bias // True exponent of x}{ .mfb      ldfpd           fQB, fQA = [rAD_Q2], 16  // Load coeff for small path(p10) fma.d.s0        f8 = f8, f1, f0          // For x=+inf, NaN, NaT(p10) br.ret.spnt     b0                       // Exit for x=+inf, NaN, NaT};;{ .mfi      ldfpd           fQ9, fQ8 = [rAD_Q1], 16  // Load coeff for small path      fma.s1          fXsq = fNormX, fNormX, f0  // x*x for small path      cmp.gt          p7, p8 = -2, rExp_x      // Test |x| < 2^(-2)}{ .mfi      ldfpd           fQ7, fQ6 = [rAD_Q2], 16  // Load coeff for small path

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -