diff options
Diffstat (limited to 'sysdeps/ia64/fpu/s_tanf.S')
-rw-r--r-- | sysdeps/ia64/fpu/s_tanf.S | 1004 |
1 files changed, 541 insertions, 463 deletions
diff --git a/sysdeps/ia64/fpu/s_tanf.S b/sysdeps/ia64/fpu/s_tanf.S index 193d7568a5..a84009e2fe 100644 --- a/sysdeps/ia64/fpu/s_tanf.S +++ b/sysdeps/ia64/fpu/s_tanf.S @@ -1,10 +1,10 @@ -.file "tancotf.s" +.file "tanf.s" - -// Copyright (c) 2000 - 2005, Intel Corporation +// Copyright (C) 2000, 2001, Intel Corporation // All rights reserved. -// -// Contributed 2000 by the Intel Numerics Group, Intel Corporation +// +// Contributed 2/2/2000 by John Harrison, Ted Kubaska, Bob Norin, Shane Story, +// and Ping Tak Peter Tang of the Computational Software Lab, Intel Corporation. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are @@ -20,7 +20,7 @@ // * 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 @@ -32,661 +32,739 @@ // 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. +// http://developer.intel.com/opensource. // // History //============================================================== -// 02/02/00 Initial version -// 04/04/00 Unwind support added +// 2/02/00: Initial version +// 4/04/00 Unwind support added // 12/27/00 Improved speed -// 02/21/01 Updated to call tanl -// 05/30/02 Improved speed, added cotf. -// 11/25/02 Added explicit completer on fnorm -// 02/10/03 Reordered header: .section, .global, .proc, .align -// 04/17/03 Eliminated redundant stop bits -// 03/31/05 Reformatted delimiters between data tables // -// APIs +// API //============================================================== -// float tanf(float) -// float cotf(float) +// float tan( float x); // -// Algorithm Description for tanf +// Overview of operation //============================================================== -// The tanf function computes the principle value of the tangent of x, -// where x is radian argument. -// -// There are 5 paths: -// 1. x = +/-0.0 -// Return tanf(x) = +/-0.0 +// If the input value in radians is |x| >= 1.xxxxx 2^10 call the +// older slower version. // -// 2. x = [S,Q]NaN -// Return tanf(x) = QNaN +// The new algorithm is used when |x| <= 1.xxxxx 2^9. // -// 3. x = +/-Inf -// Return tanf(x) = QNaN +// Represent the input X as Nfloat * pi/2 + r +// where r can be negative and |r| <= pi/4 // -// 4. x = r + (Pi/2)*N, N = RoundInt(x*(2/Pi)), N is even, |r|<Pi/4 -// Return tanf(x) = P19(r) = A1*r + A3*r^3 + A5*r^5 + ... + A19*r^19 = -// = r*(A1 + A3*t + A5*t^2 + ... + A19*t^9) = r*P9(t), where t = r^2 +// tan_W = x * 2/pi +// Nfloat = round_int(tan_W) // -// 5. x = r + (Pi/2)*N, N = RoundInt(x*(2/Pi)), N is odd, |r|<Pi/4 -// Return tanf(x) = -1/r + P11(r) = -1/r + B1*r + B3*r^3 + ... + B11*r^11 = -// = -1/r + r*(B1 + B3*t + B5*t^2 + ... + B11*t^5) = -1/r + r*P11(t), -// where t = r^2 -// -// Algorithm Description for cotf -//============================================================== -// The cotf function computes the principle value of the cotangent of x, -// where x is radian argument. +// tan_r = x - Nfloat * (pi/2)_hi +// tan_r = tan_r - Nfloat * (pi/2)_lo // -// There are 5 paths: -// 1. x = +/-0.0 -// Return cotf(x) = +/-Inf and error handling is called +// We have two paths: p8, when Nfloat is even and p9. when Nfloat is odd. +// p8: tan(X) = tan(r) +// p9: tan(X) = -cot(r) // -// 2. x = [S,Q]NaN -// Return cotf(x) = QNaN -// -// 3. x = +/-Inf -// Return cotf(x) = QNaN -// -// 4. x = r + (Pi/2)*N, N = RoundInt(x*(2/Pi)), N is odd, |r|<Pi/4 -// Return cotf(x) = P19(-r) = A1*(-r) + A3*(-r^3) + ... + A19*(-r^19) = -// = -r*(A1 + A3*t + A5*t^2 + ... + A19*t^9) = -r*P9(t), where t = r^2 -// -// 5. x = r + (Pi/2)*N, N = RoundInt(x*(2/Pi)), N is even, |r|<Pi/4 -// Return cotf(x) = 1/r + P11(-r) = 1/r + B1*(-r) + ... + B11*(-r^11) = -// = 1/r - r*(B1 + B3*t + B5*t^2 + ... + B11*t^5) = 1/r - r*P11(t), -// where t = r^2 -// -// We set p10 and clear p11 if computing tanf, vice versa for cotf. +// Each is evaluated as a series. The p9 path requires 1/r. // +// The coefficients used in the series are stored in a table as +// are the pi constants. // // Registers used //============================================================== -// Floating Point registers used: -// f8, input -// f32 -> f80 // -// General registers used: -// r14 -> r23, r32 -> r39 +// predicate registers used: +// p6-10 // -// Predicate registers used: -// p6 -> p13 +// floating-point registers used: +// f10-15, f32-105 +// f8, input +// +// general registers used +// r14-18, r32-43 // -// Assembly macros -//============================================================== -// integer registers -rExp = r14 -rSignMask = r15 -rRshf = r16 -rScFctrExp = r17 -rIntN = r18 -rSigRcpPiby2 = r19 -rScRshf = r20 -rCoeffA = r21 -rCoeffB = r22 -rExpCut = r23 - -GR_SAVE_B0 = r33 -GR_SAVE_PFS = r34 -GR_SAVE_GP = r35 -GR_Parameter_X = r36 -GR_Parameter_Y = r37 -GR_Parameter_RESULT = r38 -GR_Parameter_Tag = r39 -//============================================================== -// floating point registers -fScRcpPiby2 = f32 -fScRshf = f33 -fNormArg = f34 -fScFctr = f35 -fRshf = f36 -fShiftedN = f37 -fN = f38 -fR = f39 -fA01 = f40 -fA03 = f41 -fA05 = f42 -fA07 = f43 -fA09 = f44 -fA11 = f45 -fA13 = f46 -fA15 = f47 -fA17 = f48 -fA19 = f49 -fB01 = f50 -fB03 = f51 -fB05 = f52 -fB07 = f53 -fB09 = f54 -fB11 = f55 -fA03_01 = f56 -fA07_05 = f57 -fA11_09 = f58 -fA15_13 = f59 -fA19_17 = f60 -fA11_05 = f61 -fA19_13 = f62 -fA19_05 = f63 -fRbyA03_01 = f64 -fB03_01 = f65 -fB07_05 = f66 -fB11_09 = f67 -fB11_05 = f68 -fRbyB03_01 = f69 -fRbyB11_01 = f70 -fRp2 = f71 -fRp4 = f72 -fRp8 = f73 -fRp5 = f74 -fY0 = f75 -fY1 = f76 -fD = f77 -fDp2 = f78 -fInvR = f79 -fPiby2 = f80 -//============================================================== +#include "libm_support.h" +// Assembly macros +//============================================================== +TAN_INV_PI_BY_2_2TO64 = f10 +TAN_RSHF_2TO64 = f11 +TAN_2TOM64 = f12 +TAN_RSHF = f13 +TAN_W_2TO64_RSH = f14 +TAN_NFLOAT = f15 + +tan_Inv_Pi_by_2 = f32 +tan_Pi_by_2_hi = f33 +tan_Pi_by_2_lo = f34 + + +tan_P0 = f35 +tan_P1 = f36 +tan_P2 = f37 +tan_P3 = f38 +tan_P4 = f39 +tan_P5 = f40 +tan_P6 = f41 +tan_P7 = f42 +tan_P8 = f43 +tan_P9 = f44 +tan_P10 = f45 +tan_P11 = f46 +tan_P12 = f47 +tan_P13 = f48 +tan_P14 = f49 +tan_P15 = f50 + +tan_Q0 = f51 +tan_Q1 = f52 +tan_Q2 = f53 +tan_Q3 = f54 +tan_Q4 = f55 +tan_Q5 = f56 +tan_Q6 = f57 +tan_Q7 = f58 +tan_Q8 = f59 +tan_Q9 = f60 +tan_Q10 = f61 + +tan_r = f62 +tan_rsq = f63 +tan_rcube = f64 + +tan_v18 = f65 +tan_v16 = f66 +tan_v17 = f67 +tan_v12 = f68 +tan_v13 = f69 +tan_v7 = f70 +tan_v8 = f71 +tan_v4 = f72 +tan_v5 = f73 +tan_v15 = f74 +tan_v11 = f75 +tan_v14 = f76 +tan_v3 = f77 +tan_v6 = f78 +tan_v10 = f79 +tan_v2 = f80 +tan_v9 = f81 +tan_v1 = f82 +tan_int_Nfloat = f83 +tan_Nfloat = f84 + +tan_NORM_f8 = f85 +tan_W = f86 + +tan_y0 = f87 +tan_d = f88 +tan_y1 = f89 +tan_dsq = f90 +tan_y2 = f91 +tan_d4 = f92 +tan_inv_r = f93 + +tan_z1 = f94 +tan_z2 = f95 +tan_z3 = f96 +tan_z4 = f97 +tan_z5 = f98 +tan_z6 = f99 +tan_z7 = f100 +tan_z8 = f101 +tan_z9 = f102 +tan_z10 = f103 +tan_z11 = f104 +tan_z12 = f105 + + +///////////////////////////////////////////////////////////// + +tan_GR_sig_inv_pi_by_2 = r14 +tan_GR_rshf_2to64 = r15 +tan_GR_exp_2tom64 = r16 +tan_GR_n = r17 +tan_GR_rshf = r18 + +tan_AD = r33 +tan_GR_10009 = r34 +tan_GR_17_ones = r35 +tan_GR_N_odd_even = r36 +tan_GR_N = r37 +tan_signexp = r38 +tan_exp = r39 +tan_ADQ = r40 + +GR_SAVE_PFS = r41 +GR_SAVE_B0 = r42 +GR_SAVE_GP = r43 + + +#ifdef _LIBC +.rodata +#else +.data +#endif -RODATA .align 16 -LOCAL_OBJECT_START(coeff_A) -data8 0x3FF0000000000000 // A1 = 1.00000000000000000000e+00 -data8 0x3FD5555556BCE758 // A3 = 3.33333334641442641606e-01 -data8 0x3FC111105C2DAE48 // A5 = 1.33333249100689099175e-01 -data8 0x3FABA1F876341060 // A7 = 5.39701122561673229739e-02 -data8 0x3F965FB86D12A38D // A9 = 2.18495194027670719750e-02 -data8 0x3F8265F62415F9D6 // A11 = 8.98353860497717439465e-03 -data8 0x3F69E3AE64CCF58D // A13 = 3.16032468108912746342e-03 -data8 0x3F63920D09D0E6F6 // A15 = 2.38897844840557235331e-03 -LOCAL_OBJECT_END(coeff_A) - -LOCAL_OBJECT_START(coeff_B) -data8 0xC90FDAA22168C235, 0x3FFF // pi/2 -data8 0x3FD55555555358DB // B1 = 3.33333333326107426583e-01 -data8 0x3F96C16C252F643F // B3 = 2.22222230621336129239e-02 -data8 0x3F61566243AB3C60 // B5 = 2.11638633968606896785e-03 -data8 0x3F2BC1169BD4438B // B7 = 2.11748132564551094391e-04 -data8 0x3EF611B4CEA056A1 // B9 = 2.10467959860990200942e-05 -data8 0x3EC600F9E32194BF // B11 = 2.62305891234274186608e-06 -data8 0xBF42BA7BCC177616 // A17 =-5.71546981685324877205e-04 -data8 0x3F4F2614BC6D3BB8 // A19 = 9.50584530849832782542e-04 -LOCAL_OBJECT_END(coeff_B) +double_tan_constants: +ASM_TYPE_DIRECTIVE(double_tan_constants,@object) +// data8 0xA2F9836E4E44152A, 0x00003FFE // 2/pi + data8 0xC90FDAA22168C234, 0x00003FFF // pi/2 hi + + data8 0xBEEA54580DDEA0E1 // P14 + data8 0x3ED3021ACE749A59 // P15 + data8 0xBEF312BD91DC8DA1 // P12 + data8 0x3EFAE9AFC14C5119 // P13 + data8 0x3F2F342BF411E769 // P8 + data8 0x3F1A60FC9F3B0227 // P9 + data8 0x3EFF246E78E5E45B // P10 + data8 0x3F01D9D2E782875C // P11 + data8 0x3F8226E34C4499B6 // P4 + data8 0x3F6D6D3F12C236AC // P5 + data8 0x3F57DA1146DCFD8B // P6 + data8 0x3F43576410FE3D75 // P7 + data8 0x3FD5555555555555 // P0 + data8 0x3FC11111111111C2 // P1 + data8 0x3FABA1BA1BA0E850 // P2 + data8 0x3F9664F4886725A7 // P3 +ASM_SIZE_DIRECTIVE(double_tan_constants) + +double_Q_tan_constants: +ASM_TYPE_DIRECTIVE(double_Q_tan_constants,@object) + data8 0xC4C6628B80DC1CD1, 0x00003FBF // pi/2 lo + data8 0x3E223A73BA576E48 // Q8 + data8 0x3DF54AD8D1F2CA43 // Q9 + data8 0x3EF66A8EE529A6AA // Q4 + data8 0x3EC2281050410EE6 // Q5 + data8 0x3E8D6BB992CC3CF5 // Q6 + data8 0x3E57F88DE34832E4 // Q7 + data8 0x3FD5555555555555 // Q0 + data8 0x3F96C16C16C16DB8 // Q1 + data8 0x3F61566ABBFFB489 // Q2 + data8 0x3F2BBD77945C1733 // Q3 + data8 0x3D927FB33E2B0E04 // Q10 +ASM_SIZE_DIRECTIVE(double_Q_tan_constants) + + + +.align 32 +.global tanf# +#ifdef _LIBC +.global __tanf# +#endif + +//////////////////////////////////////////////////////// -.section .text -LOCAL_LIBM_ENTRY(cotf) +.section .text +.proc tanf# +#ifdef _LIBC +.proc __tanf# +#endif +.align 32 +tanf: +#ifdef _LIBC +__tanf: +#endif +// The initial fnorm will take any unmasked faults and +// normalize any single/double unorms { .mlx - getf.exp rExp = f8 // ***** Get 2ˆ17 * s + E - movl rSigRcpPiby2= 0xA2F9836E4E44152A // significand of 2/Pi + alloc r32=ar.pfs,1,11,0,0 + movl tan_GR_sig_inv_pi_by_2 = 0xA2F9836E4E44152A // significand of 2/pi } { .mlx - addl rCoeffA = @ltoff(coeff_A), gp - movl rScRshf = 0x47e8000000000000 // 1.5*2^(63+63+1) + addl tan_AD = @ltoff(double_tan_constants), gp + movl tan_GR_rshf_2to64 = 0x47e8000000000000 // 1.1000 2^(63+63+1) } ;; { .mfi - alloc r32 = ar.pfs, 0, 4, 4, 0 - fclass.m p9, p0 = f8, 0xc3 // Test for x=nan - cmp.eq p11, p10 = r0, r0 // if p11=1 we compute cotf + ld8 tan_AD = [tan_AD] + fnorm tan_NORM_f8 = f8 + mov tan_GR_exp_2tom64 = 0xffff-64 // exponent of scaling factor 2^-64 } -{ .mib - ld8 rCoeffA = [rCoeffA] - mov rExpCut = 0x10009 // cutoff for exponent - br.cond.sptk Common_Path +{ .mlx + nop.m 999 + movl tan_GR_rshf = 0x43e8000000000000 // 1.1000 2^63 for right shift } ;; -LOCAL_LIBM_END(cotf) +// Form two constants we need +// 2/pi * 2^1 * 2^63, scaled by 2^64 since we just loaded the significand +// 1.1000...000 * 2^(63+63+1) to right shift int(W) into the significand +{ .mmi + setf.sig TAN_INV_PI_BY_2_2TO64 = tan_GR_sig_inv_pi_by_2 + setf.d TAN_RSHF_2TO64 = tan_GR_rshf_2to64 + mov tan_GR_17_ones = 0x1ffff ;; +} -GLOBAL_IEEE754_ENTRY(tanf) -{ .mlx - getf.exp rExp = f8 // ***** Get 2ˆ17 * s + E - movl rSigRcpPiby2= 0xA2F9836E4E44152A // significand of 2/Pi -} -{ .mlx - addl rCoeffA = @ltoff(coeff_A), gp - movl rScRshf = 0x47e8000000000000 // 1.5*2^(63+63+1) +// Form another constant +// 2^-64 for scaling Nfloat +// 1.1000...000 * 2^63, the right shift constant +{ .mmf + setf.exp TAN_2TOM64 = tan_GR_exp_2tom64 + adds tan_ADQ = double_Q_tan_constants - double_tan_constants, tan_AD + fclass.m.unc p6,p0 = f8, 0x07 // Test for x=0 } ;; -{ .mfi - alloc r32 = ar.pfs, 0, 4, 4, 0 - fclass.m p9, p0 = f8, 0xc3 // Test for x=nan - cmp.eq p10, p11 = r0, r0 // if p10=1 we compute tandf -} -{ .mib - ld8 rCoeffA = [rCoeffA] - mov rExpCut = 0x10009 // cutoff for exponent - nop.b 0 + +// Form another constant +// 2^-64 for scaling Nfloat +// 1.1000...000 * 2^63, the right shift constant +{ .mmf + setf.d TAN_RSHF = tan_GR_rshf + ldfe tan_Pi_by_2_hi = [tan_AD],16 + fclass.m.unc p7,p0 = f8, 0x23 // Test for x=inf } ;; -// Below is common path for both tandf and cotdf -Common_Path: -{ .mfi - setf.sig fScRcpPiby2 = rSigRcpPiby2 // 2^(63+1)*(2/Pi) - fclass.m p8, p0 = f8, 0x23 // Test for x=inf - mov rSignMask = 0x1ffff // mask for sign bit -} -{ .mlx - setf.d fScRshf = rScRshf // 1.5*2^(63+63+1) - movl rRshf = 0x43e8000000000000 // 1.5 2^63 for right shift +{ .mfb + ldfe tan_Pi_by_2_lo = [tan_ADQ],16 + fclass.m.unc p8,p0 = f8, 0xc3 // Test for x=nan +(p6) br.ret.spnt b0 ;; // Exit for x=0 } -;; { .mfi - and rSignMask = rSignMask, rExp // clear sign bit -(p10) fclass.m.unc p7, p0 = f8, 0x07 // Test for x=0 (for tanf) - mov rScFctrExp = 0xffff-64 // exp of scaling factor + ldfpd tan_P14,tan_P15 = [tan_AD],16 +(p7) frcpa.s0 f8,p9=f0,f0 // Set qnan indef if x=inf + mov tan_GR_10009 = 0x10009 } -{ .mfb - adds rCoeffB = coeff_B - coeff_A, rCoeffA -(p9) fma.s.s0 f8 = f8, f1, f8 // Set qnan if x=nan -(p9) br.ret.spnt b0 // Exit for x=nan +{ .mib + ldfpd tan_Q8,tan_Q9 = [tan_ADQ],16 + nop.i 999 +(p7) br.ret.spnt b0 ;; // Exit for x=inf } -;; { .mfi - cmp.ge p6, p0 = rSignMask, rExpCut // p6 = (E => 0x10009) -(p8) frcpa.s0 f8, p0 = f0, f0 // Set qnan indef if x=inf - mov GR_Parameter_Tag = 227 // (cotf) + ldfpd tan_P12,tan_P13 = [tan_AD],16 +(p8) fma.s f8=f8,f1,f8 // Set qnan if x=nan + nop.i 999 } -{ .mbb - ldfe fPiby2 = [rCoeffB], 16 -(p8) br.ret.spnt b0 // Exit for x=inf -(p6) br.cond.spnt Huge_Argument // Branch if |x|>=2^10 +{ .mib + ldfpd tan_Q4,tan_Q5 = [tan_ADQ],16 + nop.i 999 +(p8) br.ret.spnt b0 ;; // Exit for x=nan } -;; -{ .mfi - nop.m 0 -(p11) fclass.m.unc p6, p0 = f8, 0x07 // Test for x=0 (for cotf) - nop.i 0 +{ .mmi + getf.exp tan_signexp = tan_NORM_f8 + ldfpd tan_P8,tan_P9 = [tan_AD],16 + nop.i 999 ;; } -{ .mfb - nop.m 0 - fnorm.s0 fNormArg = f8 -(p7) br.ret.spnt b0 // Exit for x=0 (for tanf) + +// Multiply x by scaled 2/pi and add large const to shift integer part of W to +// rightmost bits of significand +{ .mfi + ldfpd tan_Q6,tan_Q7 = [tan_ADQ],16 + fma.s1 TAN_W_2TO64_RSH = tan_NORM_f8,TAN_INV_PI_BY_2_2TO64,TAN_RSHF_2TO64 + nop.i 999 ;; } -;; -{ .mmf - ldfpd fA01, fA03 = [rCoeffA], 16 - ldfpd fB01, fB03 = [rCoeffB], 16 - fmerge.s f10 = f8, f8 // Save input for error call +{ .mmi + ldfpd tan_P10,tan_P11 = [tan_AD],16 + nop.m 999 + and tan_exp = tan_GR_17_ones, tan_signexp ;; } -;; -{ .mmf - setf.exp fScFctr = rScFctrExp // get as real - setf.d fRshf = rRshf // get right shifter as real -(p6) frcpa.s0 f8, p0 = f1, f8 // cotf(+-0) = +-Inf + +// p7 is true if we must call DBX TAN +// p7 is true if f8 exp is > 0x10009 (which includes all ones +// NAN or inf) +{ .mmi + ldfpd tan_Q0,tan_Q1 = [tan_ADQ],16 + cmp.ge.unc p7,p0 = tan_exp,tan_GR_10009 + nop.i 999 ;; } -;; + { .mmb - ldfpd fA05, fA07 = [rCoeffA], 16 - ldfpd fB05, fB07 = [rCoeffB], 16 -(p6) br.cond.spnt __libm_error_region // call error support if cotf(+-0) + ldfpd tan_P4,tan_P5 = [tan_AD],16 + nop.m 999 +(p7) br.cond.spnt L(TAN_DBX) ;; } -;; + { .mmi - ldfpd fA09, fA11 = [rCoeffA], 16 - ldfpd fB09, fB11 = [rCoeffB], 16 - nop.i 0 + ldfpd tan_Q2,tan_Q3 = [tan_ADQ],16 + nop.m 999 + nop.i 999 ;; } -;; + + +// TAN_NFLOAT = Round_Int_Nearest(tan_W) { .mfi - nop.m 0 - fma.s1 fShiftedN = fNormArg,fScRcpPiby2,fScRshf // x*2^70*(2/Pi)+ScRshf - nop.i 0 + ldfpd tan_P6,tan_P7 = [tan_AD],16 + fms.s1 TAN_NFLOAT = TAN_W_2TO64_RSH,TAN_2TOM64,TAN_RSHF + nop.i 999 ;; } -;; + { .mfi - nop.m 0 - fms.s1 fN = fShiftedN, fScFctr, fRshf // N = Y*2^(-70) - Rshf - nop.i 0 + ldfd tan_Q10 = [tan_ADQ] + nop.f 999 + nop.i 999 ;; } -;; -.pred.rel "mutex", p10, p11 + { .mfi - getf.sig rIntN = fShiftedN // get N as integer -(p10) fnma.s1 fR = fN, fPiby2, fNormArg // R = x - (Pi/2)*N (tanf) - nop.i 0 + ldfpd tan_P0,tan_P1 = [tan_AD],16 + nop.f 999 + nop.i 999 ;; } + + { .mfi - nop.m 0 -(p11) fms.s1 fR = fN, fPiby2, fNormArg // R = (Pi/2)*N - x (cotf) - nop.i 0 + getf.sig tan_GR_n = TAN_W_2TO64_RSH + nop.f 999 + nop.i 999 ;; } -;; -{ .mmi - ldfpd fA13, fA15 = [rCoeffA], 16 - ldfpd fA17, fA19 = [rCoeffB], 16 - nop.i 0 +// tan_r = -tan_Nfloat * tan_Pi_by_2_hi + x +{ .mfi + ldfpd tan_P2,tan_P3 = [tan_AD] + fnma.s1 tan_r = TAN_NFLOAT, tan_Pi_by_2_hi, tan_NORM_f8 + nop.i 999 ;; } -;; -Return_From_Huges: -{ .mfi - nop.m 0 - fma.s1 fRp2 = fR, fR, f0 // R^2 -(p11) add rIntN = 0x1, rIntN // N = N + 1 (cotf) + +// p8 ==> even +// p9 ==> odd +{ .mmi + and tan_GR_N_odd_even = 0x1, tan_GR_n ;; + nop.m 999 + cmp.eq.unc p8,p9 = tan_GR_N_odd_even, r0 ;; } -;; + +// tan_r = tan_r -tan_Nfloat * tan_Pi_by_2_lo { .mfi - nop.m 0 - frcpa.s1 fY0, p0 = f1, fR // Y0 ~ 1/R - tbit.z p8, p9 = rIntN, 0 // p8=1 if N is even + nop.m 999 + fnma.s1 tan_r = TAN_NFLOAT, tan_Pi_by_2_lo, tan_r + nop.i 999 ;; } -;; -// Below are mixed polynomial calculations (mixed for even and odd N) + { .mfi - nop.m 0 -(p9) fma.s1 fB03_01 = fRp2, fB03, fB01 // R^2*B3 + B1 - nop.i 0 + nop.m 999 + fma.s1 tan_rsq = tan_r, tan_r, f0 + nop.i 999 ;; } + + { .mfi - nop.m 0 - fma.s1 fRp4 = fRp2, fRp2, f0 // R^4 - nop.i 0 + nop.m 999 +(p9) frcpa.s1 tan_y0, p10 = f1,tan_r + nop.i 999 ;; } -;; + { .mfi - nop.m 0 -(p8) fma.s1 fA15_13 = fRp2, fA15, fA13 // R^2*A15 + A13 - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v18 = tan_rsq, tan_P15, tan_P14 + nop.i 999 } { .mfi - nop.m 0 -(p8) fma.s1 fA19_17 = fRp2, fA19, fA17 // R^2*A19 + A17 - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v4 = tan_rsq, tan_P1, tan_P0 + nop.i 999 ;; } -;; + + { .mfi - nop.m 0 -(p8) fma.s1 fA07_05 = fRp2, fA07, fA05 // R^2*A7 + A5 - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v16 = tan_rsq, tan_P13, tan_P12 + nop.i 999 } { .mfi - nop.m 0 -(p8) fma.s1 fA11_09 = fRp2, fA11, fA09 // R^2*A11 + A9 - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v17 = tan_rsq, tan_rsq, f0 + nop.i 999 ;; } -;; + + { .mfi - nop.m 0 -(p9) fma.s1 fB07_05 = fRp2, fB07, fB05 // R^2*B7 + B5 - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v12 = tan_rsq, tan_P9, tan_P8 + nop.i 999 } { .mfi - nop.m 0 -(p9) fma.s1 fB11_09 = fRp2, fB11, fB09 // R^2*B11 + B9 - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v13 = tan_rsq, tan_P11, tan_P10 + nop.i 999 ;; } -;; + + { .mfi - nop.m 0 -(p9) fnma.s1 fD = fR, fY0, f1 // D = 1 - R*Y0 - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v7 = tan_rsq, tan_P5, tan_P4 + nop.i 999 } { .mfi - nop.m 0 -(p8) fma.s1 fA03_01 = fRp2, fA03, fA01 // R^2*A3 + A1 - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v8 = tan_rsq, tan_P7, tan_P6 + nop.i 999 ;; } -;; + + { .mfi - nop.m 0 - fma.s1 fRp8 = fRp4, fRp4, f0 // R^8 - nop.i 0 + nop.m 999 +(p9) fnma.s1 tan_d = tan_r, tan_y0, f1 + nop.i 999 } { .mfi - nop.m 0 - fma.s1 fRp5 = fR, fRp4, f0 // R^5 - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v5 = tan_rsq, tan_P3, tan_P2 + nop.i 999 ;; } -;; + + { .mfi - nop.m 0 -(p8) fma.s1 fA11_05 = fRp4, fA11_09, fA07_05 // R^4*(R^2*A11 + A9) + ... - nop.i 0 + nop.m 999 +(p9) fma.s1 tan_z11 = tan_rsq, tan_Q9, tan_Q8 + nop.i 999 } { .mfi - nop.m 0 -(p8) fma.s1 fA19_13 = fRp4, fA19_17, fA15_13 // R^4*(R^2*A19 + A17) + .. - nop.i 0 + nop.m 999 +(p9) fma.s1 tan_z12 = tan_rsq, tan_rsq, f0 + nop.i 999 ;; } -;; + { .mfi - nop.m 0 -(p9) fma.s1 fB11_05 = fRp4, fB11_09, fB07_05 // R^4*(R^2*B11 + B9) + ... - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v15 = tan_v17, tan_v18, tan_v16 + nop.i 999 } { .mfi - nop.m 0 -(p9) fma.s1 fRbyB03_01 = fR, fB03_01, f0 // R*(R^2*B3 + B1) - nop.i 0 + nop.m 999 +(p9) fma.s1 tan_z7 = tan_rsq, tan_Q5, tan_Q4 + nop.i 999 ;; } -;; + { .mfi - nop.m 0 -(p9) fma.s1 fY1 = fY0, fD, fY0 // Y1 = Y0*D + Y0 - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v11 = tan_v17, tan_v13, tan_v12 + nop.i 999 } { .mfi - nop.m 0 -(p9) fma.s1 fDp2 = fD, fD, f0 // D^2 - nop.i 0 + nop.m 999 +(p9) fma.s1 tan_z8 = tan_rsq, tan_Q7, tan_Q6 + nop.i 999 ;; } -;; + + { .mfi - nop.m 0 - // R^8*(R^6*A19 + R^4*A17 + R^2*A15 + A13) + R^6*A11 + R^4*A9 + R^2*A7 + A5 -(p8) fma.d.s1 fA19_05 = fRp8, fA19_13, fA11_05 - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v14 = tan_v17, tan_v17, f0 + nop.i 999 } { .mfi - nop.m 0 -(p8) fma.d.s1 fRbyA03_01 = fR, fA03_01, f0 // R*(R^2*A3 + A1) - nop.i 0 + nop.m 999 +(p9) fma.s1 tan_z3 = tan_rsq, tan_Q1, tan_Q0 + nop.i 999 ;; } -;; + + + { .mfi - nop.m 0 -(p9) fma.d.s1 fInvR = fY1, fDp2, fY1 // 1/R = Y1*D^2 + Y1 - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v3 = tan_v17, tan_v5, tan_v4 + nop.i 999 } { .mfi - nop.m 0 - // R^5*(R^6*B11 + R^4*B9 + R^2*B7 + B5) + R^3*B3 + R*B1 -(p9) fma.d.s1 fRbyB11_01 = fRp5, fB11_05, fRbyB03_01 - nop.i 0 + nop.m 999 +(p8) fma.s1 tan_v6 = tan_v17, tan_v8, tan_v7 + nop.i 999 ;; } -;; -.pred.rel "mutex", p8, p9 + + { .mfi - nop.m 0 - // Result = R^5*(R^14*A19 + R^12*A17 + R^10*A15 + ...) + R^3*A3 + R*A1 -(p8) fma.s.s0 f8 = fRp5, fA19_05, fRbyA03_01 - nop.i 0 + nop.m 999 +(p9) fma.s1 tan_y1 = tan_y0, tan_d, tan_y0 + nop.i 999 } -{ .mfb - nop.m 0 - // Result = -1/R + R^11*B11 + R^9*B9 + R^7*B7 + R^5*B5 + R^3*B3 + R*B1 -(p9) fnma.s.s0 f8 = f1, fInvR, fRbyB11_01 - br.ret.sptk b0 // exit for main path +{ .mfi + nop.m 999 +(p9) fma.s1 tan_dsq = tan_d, tan_d, f0 + nop.i 999 ;; } -;; -GLOBAL_IEEE754_END(tanf) +{ .mfi + nop.m 999 +(p9) fma.s1 tan_z10 = tan_z12, tan_Q10, tan_z11 + nop.i 999 +} +{ .mfi + nop.m 999 +(p9) fma.s1 tan_z9 = tan_z12, tan_z12,f0 + nop.i 999 ;; +} -LOCAL_LIBM_ENTRY(__libm_callout) -Huge_Argument: -.prologue { .mfi - nop.m 0 - fmerge.s f9 = f0,f0 -.save ar.pfs,GR_SAVE_PFS - mov GR_SAVE_PFS=ar.pfs + nop.m 999 +(p9) fma.s1 tan_z4 = tan_rsq, tan_Q3, tan_Q2 + nop.i 999 } -;; +{ .mfi + nop.m 999 +(p9) fma.s1 tan_z6 = tan_z12, tan_z8, tan_z7 + nop.i 999 ;; +} + + { .mfi - mov GR_SAVE_GP=gp - nop.f 0 -.save b0, GR_SAVE_B0 - mov GR_SAVE_B0=b0 + nop.m 999 +(p8) fma.s1 tan_v10 = tan_v14, tan_v15, tan_v11 + nop.i 999 ;; } -.body -{ .mmb + + +{ .mfi nop.m 999 +(p9) fma.s1 tan_y2 = tan_y1, tan_d, tan_y0 + nop.i 999 +} +{ .mfi nop.m 999 -(p10) br.cond.sptk.many call_tanl ;; +(p9) fma.s1 tan_d4 = tan_dsq, tan_dsq, tan_d + nop.i 999 ;; } -// Here if we should call cotl (p10=0, p11=1) -{ .mmb + +{ .mfi nop.m 999 +(p8) fma.s1 tan_v2 = tan_v14, tan_v6, tan_v3 + nop.i 999 +} +{ .mfi nop.m 999 - br.call.sptk.many b0=__libm_cotl# ;; +(p8) fma.s1 tan_v9 = tan_v14, tan_v14, f0 + nop.i 999 ;; } + { .mfi - mov gp = GR_SAVE_GP - fnorm.s.s0 f8 = f8 - mov b0 = GR_SAVE_B0 + nop.m 999 +(p9) fma.s1 tan_z2 = tan_z12, tan_z4, tan_z3 + nop.i 999 } -;; - -{ .mib +{ .mfi nop.m 999 - mov ar.pfs = GR_SAVE_PFS - br.ret.sptk b0 -;; +(p9) fma.s1 tan_z5 = tan_z9, tan_z10, tan_z6 + nop.i 999 ;; } -// Here if we should call tanl (p10=1, p11=0) -call_tanl: -{ .mmb + +{ .mfi nop.m 999 +(p9) fma.s1 tan_inv_r = tan_d4, tan_y2, tan_y0 + nop.i 999 +} +{ .mfi nop.m 999 - br.call.sptk.many b0=__libm_tanl# ;; +(p8) fma.s1 tan_rcube = tan_rsq, tan_r, f0 + nop.i 999 ;; } + + { .mfi - mov gp = GR_SAVE_GP - fnorm.s.s0 f8 = f8 - mov b0 = GR_SAVE_B0 + nop.m 999 +(p8) fma.s1 tan_v1 = tan_v9, tan_v10, tan_v2 + nop.i 999 } -;; - -{ .mib +{ .mfi nop.m 999 - mov ar.pfs = GR_SAVE_PFS - br.ret.sptk b0 -;; +(p9) fma.s1 tan_z1 = tan_z9, tan_z5, tan_z2 + nop.i 999 ;; } -LOCAL_LIBM_END(__libm_callout) -.type __libm_tanl#,@function -.global __libm_tanl# -.type __libm_cotl#,@function -.global __libm_cotl# + +{ .mfi + nop.m 999 +(p8) fma.s.s0 f8 = tan_v1, tan_rcube, tan_r + nop.i 999 +} +{ .mfb + nop.m 999 +(p9) fms.s.s0 f8 = tan_r, tan_z1, tan_inv_r + br.ret.sptk b0 ;; +} +.endp tanf# +ASM_SIZE_DIRECTIVE(tanf#) -LOCAL_LIBM_ENTRY(__libm_error_region) +.proc __libm_callout +__libm_callout: +L(TAN_DBX): .prologue -// (1) { .mfi - add GR_Parameter_Y=-32,sp // Parameter 2 value - nop.f 0 + nop.m 0 + fmerge.s f9 = f0,f0 .save ar.pfs,GR_SAVE_PFS - mov GR_SAVE_PFS=ar.pfs // Save ar.pfs + mov GR_SAVE_PFS=ar.pfs } -{ .mfi -.fframe 64 - add sp=-64,sp // Create new stack - nop.f 0 - mov GR_SAVE_GP=gp // Save gp -};; +;; -// (2) -{ .mmi - stfs [GR_Parameter_Y] = f1,16 // STORE Parameter 2 on stack - add GR_Parameter_X = 16,sp // Parameter 1 address +{ .mfi + mov GR_SAVE_GP=gp + nop.f 0 .save b0, GR_SAVE_B0 - mov GR_SAVE_B0=b0 // Save b0 -};; + mov GR_SAVE_B0=b0 +} .body -// (3) -{ .mib - stfs [GR_Parameter_X] = f10 // STORE Parameter 1 on stack - add GR_Parameter_RESULT = 0,GR_Parameter_Y // Parameter 3 address - nop.b 0 +{ .mfb + nop.m 999 + nop.f 999 + br.call.sptk.many b0=__libm_tan# ;; } -{ .mib - stfs [GR_Parameter_Y] = f8 // STORE Parameter 3 on stack - add GR_Parameter_Y = -16,GR_Parameter_Y - br.call.sptk b0=__libm_error_support# // Call error handling function -};; -{ .mmi - nop.m 0 - nop.m 0 - add GR_Parameter_RESULT = 48,sp -};; -// (4) -{ .mmi - ldfs f8 = [GR_Parameter_RESULT] // Get return result off stack -.restore sp - add sp = 64,sp // Restore stack pointer - mov b0 = GR_SAVE_B0 // Restore return address -};; + +{ .mfi + mov gp = GR_SAVE_GP + fnorm.s f8 = f8 + mov b0 = GR_SAVE_B0 +} +;; + + { .mib - mov gp = GR_SAVE_GP // Restore gp - mov ar.pfs = GR_SAVE_PFS // Restore ar.pfs - br.ret.sptk b0 // Return -};; + nop.m 999 + mov ar.pfs = GR_SAVE_PFS + br.ret.sptk b0 +;; +} -LOCAL_LIBM_END(__libm_error_region) -.type __libm_error_support#,@function -.global __libm_error_support# +.endp __libm_callout +ASM_SIZE_DIRECTIVE(__libm_callout) +.type __libm_tan#,@function +.global __libm_tan# |