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

📄 e_atan2.s

📁 glibc 2.9,最新版的C语言库函数
💻 S
📖 第 1 页 / 共 2 页
字号:
.file "atan2.s"// Copyright (c) 2000 - 2003, 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.// 08/17/00  Changed predicate register macro-usage to direct predicate//           names due to an assembler bug.// 09/28/00  Updated to set invalid on SNaN inputs// 01/19/01  Fixed flags for small results// 04/13/01  Rescheduled to make all paths faster// 05/20/02  Cleaned up namespace and sf0 syntax// 08/20/02  Corrected inexact flag and directed rounding symmetry bugs// 02/06/03  Reordered header: .section, .global, .proc, .align// 04/17/03  Added missing mutex directive// 12/23/03  atan2(NaN1,NaN2) now QNaN1, for consistency with atan2f, atan2l//// API//==============================================================// double atan2(double Y, double X)//// Overview of operation//==============================================================//// The atan2 function returns values in the interval [-pi,+pi].//// There are two basic paths: swap true and swap false.// atan2(Y,X) ==> atan2(V/U) where U >= V. If Y > X, we must swap.//// p6  swap True    |Y| > |X|// p7  swap False   |Y| <= |X|// p8  X+   (If swap=True p8=p9=0)// p9  X-//// all the other predicates p10 thru p15 are false for the main path//// Simple trigonometric identities show//   Region 1 (-45 to +45 degrees)://         X>0, |Y|<=X, V=Y, U=X     atan2(Y,X) = sgnY * (0 + atan(V/U))////   Region 2 (-90 to -45 degrees, and +45 to +90 degrees)://         X>0, |Y|>X, V=X, U=Y      atan2(Y,X) = sgnY * (pi/2 - atan(V/U))////   Region 3 (-135 to -90 degrees, and +90 to +135 degrees)://         X<0, |Y|>X, V=X, U=Y      atan2(Y,X) = sgnY * (pi/2 + atan(V/U))////   Region 4 (-180 to -135 degrees, and +135 to +180 degrees)://         X<0, |Y|<=X, V=Y, U=X      atan2(Y,X) = sgnY * (pi - atan(V/U))//// So the result is always of the form atan2(Y,X) = P + sgnXY * atan(V/U)//// We compute atan(V/U) from the identity//      atan(z) + atan([(V/U)-z] / [1+(V/U)z])//      where z is a limited precision approximation (16 bits) to V/U//// z is calculated with the assistance of the frcpa instruction.//// atan(z) is calculated by a polynomial z + z^3 * p(w),  w=z^2// where p(w) = P0+P1*w+...+P22*w^22//// Let d = [(V/U)-z] / [1+(V/U)z]) = (V-U*z)/(U+V*z)//// Approximate atan(d) by d + P0*d^3// Let F = 1/(U+V*z) * (1-a), where |a|< 2^-8.8.// Compute q(a) = 1 + a + ... + a^5.// Then F*q(a) approximates the reciprocal to more than 50 bits.// Special values//==============================================================//              Y                 x          Result//             +number           +inf        +0//             -number           +inf        -0//             +number           -inf        +pi//             -number           -inf        -pi////             +inf              +number     +pi/2//             -inf              +number     -pi/2//             +inf              -number     +pi/2//             -inf              -number     -pi/2////             +inf              +inf        +pi/4//             -inf              +inf        -pi/4//             +inf              -inf        +3pi/4//             -inf              -inf        -3pi/4////             +1                +1          +pi/4//             -1                +1          -pi/4//             +1                -1          +3pi/4//             -1                -1          -3pi/4////             +number           +0          +pi/2//             -number           +0          -pi/2//             +number           -0          +pi/2//             -number           -0          -pi/2////             +0                +number     +0//             -0                +number     -0//             +0                -number     +pi//             -0                -number     -pi////             +0                +0          +0//             -0                +0          -0//             +0                -0          +pi//             -0                -0          -pi////            Nan             anything      quiet Y//            Not NaN         NaN           quiet X// atan2(+-0/+-0) sets double error tag to 37// Registers used//==============================================================// predicate registers used:// p6 -> p15// floating-point registers used:// f8, f9 input// f32 -> f119// general registers used// r32 -> r41// Assembly macros//==============================================================EXP_AD_P1                    = r33EXP_AD_P2                    = r34rsig_near_one                = r35GR_SAVE_B0                   = r35GR_SAVE_GP                   = r36GR_SAVE_PFS                  = r37GR_Parameter_X               = r38GR_Parameter_Y               = r39GR_Parameter_RESULT          = r40atan2_GR_tag                 = r41atan2_Y                      = f8atan2_X                      = f9atan2_u1_X                   = f32atan2_u1_Y                   = f33atan2_z2_X                   = f34atan2_z2_Y                   = f35atan2_two                    = f36atan2_B1sq_Y                 = f37atan2_z1_X                   = f38atan2_z1_Y                   = f39atan2_B1X                    = f40atan2_B1Y                    = f41atan2_wp_X                   = f42atan2_B1sq_X                 = f43atan2_z                      = f44atan2_w                      = f45atan2_P0                     = f46atan2_P1                     = f47atan2_P2                     = f48atan2_P3                     = f49atan2_P4                     = f50atan2_P5                     = f51atan2_P6                     = f52atan2_P7                     = f53atan2_P8                     = f54atan2_P9                     = f55atan2_P10                    = f56atan2_P11                    = f57atan2_P12                    = f58atan2_P13                    = f59atan2_P14                    = f60atan2_P15                    = f61atan2_P16                    = f62atan2_P17                    = f63atan2_P18                    = f64atan2_P19                    = f65atan2_P20                    = f66atan2_P21                    = f67atan2_P22                    = f68atan2_tmp                    = f68atan2_pi_by_2                = f69atan2_sgn_pi_by_2            = f69atan2_V13                    = f70atan2_W11                    = f71atan2_E                      = f72atan2_wp_Y                   = f73atan2_V11                    = f74atan2_V12                    = f75atan2_V7                     = f76atan2_V8                     = f77atan2_W7                     = f78atan2_W8                     = f79atan2_W3                     = f80atan2_W4                     = f81atan2_V3                     = f82atan2_V4                     = f83atan2_F                      = f84atan2_gV                     = f85atan2_V10                    = f86atan2_zcub                   = f87atan2_V6                     = f88atan2_V9                     = f89atan2_W10                    = f90atan2_W6                     = f91atan2_W2                     = f92atan2_V2                     = f93atan2_alpha                  = f94atan2_alpha_1                = f95atan2_gVF                    = f96atan2_V5                     = f97atan2_W12                    = f98atan2_W5                     = f99atan2_alpha_sq               = f100atan2_Cp                     = f101atan2_V1                     = f102atan2_ysq                    = f103atan2_W1                     = f104atan2_alpha_cub              = f105atan2_C                      = f106atan2_xsq                    = f107atan2_d                      = f108atan2_A_hi                   = f109atan2_dsq                    = f110atan2_pd                     = f111atan2_A_lo                   = f112atan2_A                      = f113atan2_Pp                     = f114atan2_sgnY                   = f115atan2_sig_near_one           = f116atan2_near_one               = f116atan2_pi                     = f117atan2_sgn_pi                 = f117atan2_3pi_by_4               = f118atan2_pi_by_4                = f119/////////////////////////////////////////////////////////////RODATA.align 16LOCAL_OBJECT_START(atan2_tb1)data8 0xA21922DC45605EA1 ,  0x00003FFA // P11data8 0xB199DD6D2675C40F ,  0x0000BFFA // P10data8 0xC2F01E5DDD100DBE ,  0x00003FFA // P9data8 0xD78F28FC2A592781 ,  0x0000BFFA // P8data8 0xF0F03ADB3FC930D3 ,  0x00003FFA // P7data8 0x88887EBB209E3543 ,  0x0000BFFB // P6data8 0x9D89D7D55C3287A5 ,  0x00003FFB // P5data8 0xBA2E8B9793955C77 ,  0x0000BFFB // P4data8 0xE38E38E320A8A098 ,  0x00003FFB // P3data8 0x9249249247E37913 ,  0x0000BFFC // P2data8 0xCCCCCCCCCCC906CD ,  0x00003FFC // P1data8 0xAAAAAAAAAAAAA8A9 ,  0x0000BFFD // P0data8 0xC90FDAA22168C235 ,  0x00004000 // piLOCAL_OBJECT_END(atan2_tb1)LOCAL_OBJECT_START(atan2_tb2)data8 0xCE585A259BD8374C ,  0x00003FF0 // P21data8 0x9F90FB984D8E39D0 ,  0x0000BFF3 // P20data8 0x9D3436AABE218776 ,  0x00003FF5 // P19data8 0xDEC343E068A6D2A8 ,  0x0000BFF6 // P18data8 0xF396268151CFB11C ,  0x00003FF7 // P17data8 0xD818B4BB43D84BF2 ,  0x0000BFF8 // P16data8 0xA2270D30A90AA220 ,  0x00003FF9 // P15data8 0xD5F4F2182E7A8725 ,  0x0000BFF9 // P14data8 0x80D601879218B53A ,  0x00003FFA // P13data8 0x9297B23CCFFB291F ,  0x0000BFFA // P12data8 0xFE7E52D2A89995B3 ,  0x0000BFEC // P22data8 0xC90FDAA22168C235 ,  0x00003FFF // pi/2data8 0xC90FDAA22168C235 ,  0x00003FFE // pi/4data8 0x96cbe3f9990e91a8 ,  0x00004000 // 3pi/4LOCAL_OBJECT_END(atan2_tb2).section .textGLOBAL_IEEE754_ENTRY(atan2){ .mfi           alloc        r32           = ar.pfs,1,5,4,0           frcpa.s1     atan2_u1_X,p6 = f1,atan2_X           nop.i 999}{ .mfi           addl         EXP_AD_P1   = @ltoff(atan2_tb1), gp           fma.s1       atan2_two  = f1,f1,f1           nop.i 999;;}{ .mfi           ld8  EXP_AD_P1 = [EXP_AD_P1]           frcpa.s1     atan2_u1_Y,p7 = f1,atan2_Y           nop.i 999}{ .mfi           nop.m 999           fma.s1       atan2_xsq  = atan2_X,atan2_X,f0           nop.i 999;;}{ .mfi           nop.m 999           fclass.m p10,p0 = atan2_Y, 0xc3     // Test for y=nan           nop.i 999}{ .mfi           nop.m 999           fma.s1       atan2_ysq  = atan2_Y,atan2_Y,f0           nop.i 999};;{ .mfi           add  EXP_AD_P2 = 0xd0,EXP_AD_P1           fclass.m p12,p0 = atan2_X, 0xc3     // Test for x nan           nop.i 999};;// p10 Y NAN, quiet and return{ .mfi           ldfe         atan2_P11  = [EXP_AD_P1],16           fmerge.s     atan2_sgnY = atan2_Y,f1           nop.i 999}{ .mfb           ldfe         atan2_P21  = [EXP_AD_P2],16(p10)      fma.d.s0 f8 = atan2_X,atan2_Y,f0   // If y=nan, result quietized y(p10)      br.ret.spnt b0        // Exit if y=nan;;}{ .mfi           ldfe         atan2_P10  = [EXP_AD_P1],16           fma.s1       atan2_z1_X = atan2_u1_X, atan2_Y, f0           nop.i 999}{ .mfi           ldfe         atan2_P20  = [EXP_AD_P2],16           fnma.s1      atan2_B1X  = atan2_u1_X, atan2_X, atan2_two           nop.i 999;;}{ .mfi           ldfe         atan2_P9   = [EXP_AD_P1],16           fma.s1       atan2_z1_Y = atan2_u1_Y, atan2_X, f0           nop.i 999}{ .mfi           ldfe         atan2_P19  = [EXP_AD_P2],16           fnma.s1      atan2_B1Y  = atan2_u1_Y, atan2_Y, atan2_two           nop.i 999};;{ .mfi           ldfe         atan2_P8   = [EXP_AD_P1],16           fma.s1       atan2_z2_X = atan2_u1_X, atan2_ysq, f0           nop.i 999}{ .mfi           ldfe         atan2_P18  = [EXP_AD_P2],16           fma.s1       atan2_z2_Y = atan2_u1_Y, atan2_xsq, f0           nop.i 999};;// p10 ==> x  inf     y ?// p11 ==> x !inf     y ?{ .mfi           ldfe         atan2_P7   = [EXP_AD_P1],16           fclass.m p10,p11 = atan2_X, 0x23    // test for x inf           nop.i 999}{ .mfb           ldfe         atan2_P17  = [EXP_AD_P2],16(p12)      fma.d.s0        f8 = atan2_X,atan2_Y,f0     // If x nan, result quiet x(p12)      br.ret.spnt b0                 // Exit for x nan;;}// p6 true if swap,    means |y| >  |x|    or ysq > xsq// p7 true if no swap, means |x| >= |y|    or xsq >= ysq{ .mmf           ldfe         atan2_P6   = [EXP_AD_P1],16           ldfe         atan2_P16  = [EXP_AD_P2],16           fcmp.ge.s1 p7,p6    = atan2_xsq, atan2_ysq;;}{ .mfi           ldfe         atan2_P5   = [EXP_AD_P1],16           fma.s1       atan2_wp_X   = atan2_z1_X, atan2_z1_X, f0           nop.i 999}{ .mfi           ldfe         atan2_P15       = [EXP_AD_P2],16           fma.s1       atan2_B1sq_X = atan2_B1X, atan2_B1X, f0           nop.i 999;;}{ .mfi           ldfe         atan2_P4   = [EXP_AD_P1],16(p6)       fma.s1       atan2_wp_Y   = atan2_z1_Y, atan2_z1_Y, f0           nop.i 999}{ .mfi           ldfe         atan2_P14  = [EXP_AD_P2],16(p6)       fma.s1       atan2_B1sq_Y = atan2_B1Y, atan2_B1Y, f0           nop.i 999;;}{ .mfi           ldfe         atan2_P3        = [EXP_AD_P1],16(p6)       fma.s1       atan2_E         = atan2_z2_Y, atan2_B1Y, atan2_Y           nop.i 999}{ .mfi           ldfe         atan2_P13  = [EXP_AD_P2],16(p7)       fma.s1       atan2_E         = atan2_z2_X, atan2_B1X, atan2_X           nop.i 999;;}{ .mfi           ldfe         atan2_P2        = [EXP_AD_P1],16(p6)       fma.s1       atan2_z         = atan2_z1_Y, atan2_B1Y, f0           nop.i 999}{ .mfi           ldfe         atan2_P12  = [EXP_AD_P2],16(p7)       fma.s1       atan2_z         = atan2_z1_X, atan2_B1X, f0           nop.i 999;;}{ .mfi           ldfe         atan2_P1        = [EXP_AD_P1],16           fcmp.eq.s0  p14,p15=atan2_X,atan2_Y  // Dummy for denorm and invalid           nop.i 999}{ .mlx           ldfe         atan2_P22       = [EXP_AD_P2],16           movl         rsig_near_one = 0x8000000000000001 // signif near 1.0;;}// p12 ==> x  inf     y inf// p13 ==> x  inf     y !inf{ .mmf           ldfe         atan2_P0        = [EXP_AD_P1],16           ldfe         atan2_pi_by_2   = [EXP_AD_P2],16(p10)      fclass.m.unc p12,p13 = atan2_Y, 0x23  // x inf, test if y inf;;

⌨️ 快捷键说明

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