Blame sysdeps/ia64/fpu/e_sqrtl.S

Packit 6c4009
.file "sqrtl.s"
Packit 6c4009
Packit 6c4009
Packit 6c4009
// Copyright (c) 2000 - 2003, Intel Corporation
Packit 6c4009
// All rights reserved.
Packit 6c4009
//
Packit 6c4009
// Contributed 2000 by the Intel Numerics Group, Intel Corporation
Packit 6c4009
//
Packit 6c4009
// Redistribution and use in source and binary forms, with or without
Packit 6c4009
// modification, are permitted provided that the following conditions are
Packit 6c4009
// met:
Packit 6c4009
//
Packit 6c4009
// * Redistributions of source code must retain the above copyright
Packit 6c4009
// notice, this list of conditions and the following disclaimer.
Packit 6c4009
//
Packit 6c4009
// * Redistributions in binary form must reproduce the above copyright
Packit 6c4009
// notice, this list of conditions and the following disclaimer in the
Packit 6c4009
// documentation and/or other materials provided with the distribution.
Packit 6c4009
//
Packit 6c4009
// * The name of Intel Corporation may not be used to endorse or promote
Packit 6c4009
// products derived from this software without specific prior written
Packit 6c4009
// permission.
Packit 6c4009
Packit 6c4009
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
Packit 6c4009
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
Packit 6c4009
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Packit 6c4009
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
Packit 6c4009
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
Packit 6c4009
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
Packit 6c4009
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Packit 6c4009
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
Packit 6c4009
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
Packit 6c4009
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
Packit 6c4009
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 6c4009
//
Packit 6c4009
// Intel Corporation is the author of this code, and requests that all
Packit 6c4009
// problem reports or change requests be submitted to it directly at
Packit 6c4009
// http://www.intel.com/software/products/opensource/libraries/num.htm.
Packit 6c4009
//
Packit 6c4009
//********************************************************************
Packit 6c4009
//
Packit 6c4009
// History:
Packit 6c4009
// 02/02/00 (hand-optimized)
Packit 6c4009
// 04/04/00 Unwind support added
Packit 6c4009
// 08/15/00 Bundle added after call to __libm_error_support to properly
Packit 6c4009
//          set [the previously overwritten] GR_Parameter_RESULT.
Packit 6c4009
// 05/20/02 Cleaned up namespace and sf0 syntax
Packit 6c4009
// 02/10/03 Reordered header: .section, .global, .proc, .align
Packit 6c4009
//
Packit 6c4009
//********************************************************************
Packit 6c4009
//
Packit 6c4009
// Function:   Combined sqrtl(x), where
Packit 6c4009
//                         _
Packit 6c4009
//             sqrtl(x) = |x, for double-extended precision x values
Packit 6c4009
//
Packit 6c4009
//********************************************************************
Packit 6c4009
//
Packit 6c4009
// Resources Used:
Packit 6c4009
//
Packit 6c4009
//    Floating-Point Registers: f8  (Input and Return Value)
Packit 6c4009
//                              f7 -f14
Packit 6c4009
//
Packit 6c4009
//    General Purpose Registers:
Packit 6c4009
//      r32-r36 (Locals)
Packit 6c4009
//      r37-r40 (Used to pass arguments to error handling routine)
Packit 6c4009
//
Packit 6c4009
//    Predicate Registers:      p6, p7, p8
Packit 6c4009
//
Packit 6c4009
//********************************************************************
Packit 6c4009
//
Packit 6c4009
// IEEE Special Conditions:
Packit 6c4009
//
Packit 6c4009
//    All faults and exceptions should be raised correctly.
Packit 6c4009
//    sqrtl(QNaN) = QNaN
Packit 6c4009
//    sqrtl(SNaN) = QNaN
Packit 6c4009
//    sqrtl(+/-0) = +/-0
Packit 6c4009
//    sqrtl(negative) = QNaN and error handling is called
Packit 6c4009
//
Packit 6c4009
//********************************************************************
Packit 6c4009
//
Packit 6c4009
// Implementation:
Packit 6c4009
//
Packit 6c4009
//  Modified Newton-Raphson Algorithm
Packit 6c4009
//
Packit 6c4009
//********************************************************************
Packit 6c4009
Packit 6c4009
GR_SAVE_PFS         = r33
Packit 6c4009
GR_SAVE_B0          = r34
Packit 6c4009
GR_SAVE_GP          = r35
Packit 6c4009
GR_Parameter_X      = r37
Packit 6c4009
GR_Parameter_Y      = r38
Packit 6c4009
GR_Parameter_RESULT = r39
Packit 6c4009
GR_Parameter_TAG    = r40
Packit 6c4009
Packit 6c4009
FR_X                = f15
Packit 6c4009
FR_Y                = f0
Packit 6c4009
FR_RESULT           = f8
Packit 6c4009
Packit 6c4009
.section .text
Packit 6c4009
GLOBAL_IEEE754_ENTRY(sqrtl)
Packit 6c4009
{ .mlx
Packit 6c4009
alloc r32= ar.pfs,0,5,4,0
Packit 6c4009
  // exponent of +1/2 in r2
Packit 6c4009
  movl r2 = 0x0fffe;;
Packit 6c4009
} { .mfi
Packit 6c4009
  // +1/2 in f10
Packit 6c4009
  setf.exp f12 = r2
Packit 6c4009
  // Step (1)
Packit 6c4009
  // y0 = 1/sqrt(a) in f7
Packit 6c4009
  frsqrta.s0 f7,p6=f8
Packit 6c4009
  nop.i 0;;
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (2)
Packit 6c4009
  // H0 = +1/2 * y0 in f9
Packit 6c4009
  (p6) fma.s1 f9=f12,f7,f0
Packit 6c4009
  nop.i 0
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (3)
Packit 6c4009
  // S0 = a * y0 in f7
Packit 6c4009
  (p6) fma.s1 f7=f8,f7,f0
Packit 6c4009
  nop.i 0;;
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Make copy input x
Packit 6c4009
  mov f13=f8
Packit 6c4009
  nop.i 0
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  fclass.m.unc p7,p8 = f8,0x3A
Packit 6c4009
  nop.i 0;;
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (4)
Packit 6c4009
  // d0 = 1/2 - S0 * H0 in f10
Packit 6c4009
  (p6) fnma.s1 f10=f7,f9,f12
Packit 6c4009
  nop.i 0;;
Packit 6c4009
}
Packit 6c4009
{ .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
       mov f15=f8
Packit 6c4009
  nop.i 0;;
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (5)
Packit 6c4009
  // H1 = H0 + d0 * H0 in f9
Packit 6c4009
  (p6) fma.s1 f9=f10,f9,f9
Packit 6c4009
  nop.i 0
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (6)
Packit 6c4009
  // S1 = S0 + d0 * S0 in f7
Packit 6c4009
  (p6) fma.s1 f7=f10,f7,f7
Packit 6c4009
  nop.i 0;;
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (7)
Packit 6c4009
  // d1 = 1/2 - S1 * H1 in f10
Packit 6c4009
  (p6) fnma.s1 f10=f7,f9,f12
Packit 6c4009
  nop.i 0;;
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (8)
Packit 6c4009
  // H2 = H1 + d1 * H1 in f9
Packit 6c4009
  (p6) fma.s1 f9=f10,f9,f9
Packit 6c4009
  nop.i 0
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (9)
Packit 6c4009
  // S2 = S1 + d1 * S1 in f7
Packit 6c4009
  (p6) fma.s1 f7=f10,f7,f7
Packit 6c4009
  nop.i 0;;
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (10)
Packit 6c4009
  // d2 = 1/2 - S2 * H2 in f10
Packit 6c4009
  (p6) fnma.s1 f10=f7,f9,f12
Packit 6c4009
  nop.i 0
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (11)
Packit 6c4009
  // e2 = a - S2 * S2 in f12
Packit 6c4009
  (p6) fnma.s1 f12=f7,f7,f8
Packit 6c4009
  nop.i 0;;
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (12)
Packit 6c4009
  // S3 = S2 + d2 * S2 in f7
Packit 6c4009
  (p6) fma.s1 f7=f12,f9,f7
Packit 6c4009
  nop.i 0
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (13)
Packit 6c4009
  // H3 = H2 + d2 * H2 in f9
Packit 6c4009
  (p6) fma.s1 f9=f10,f9,f9
Packit 6c4009
  nop.i 0;;
Packit 6c4009
} { .mfi
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (14)
Packit 6c4009
  // e3 = a - S3 * S3 in f12
Packit 6c4009
  (p6) fnma.s1 f12=f7,f7,f8
Packit 6c4009
  nop.i 0;;
Packit 6c4009
} { .mfb
Packit 6c4009
  nop.m 0
Packit 6c4009
  // Step (15)
Packit 6c4009
  // S = S3 + e3 * H3 in f7
Packit 6c4009
  (p6) fma.s0 f8=f12,f9,f7
Packit 6c4009
  (p6) br.ret.sptk b0 ;;
Packit 6c4009
}
Packit 6c4009
{ .mfb
Packit 6c4009
       mov GR_Parameter_TAG    = 48
Packit 6c4009
       mov   f8 = f7
Packit 6c4009
  (p8) br.ret.sptk b0 ;;
Packit 6c4009
}
Packit 6c4009
//
Packit 6c4009
// This branch includes all those special values that are not negative,
Packit 6c4009
// with the result equal to frcpa(x)
Packit 6c4009
//
Packit 6c4009
Packit 6c4009
Packit 6c4009
// END DOUBLE EXTENDED PRECISION MINIMUM LATENCY SQUARE ROOT ALGORITHM
Packit 6c4009
GLOBAL_IEEE754_END(sqrtl)
Packit 6c4009
libm_alias_ldouble_other (__sqrt, sqrt)
Packit 6c4009
Packit 6c4009
LOCAL_LIBM_ENTRY(__libm_error_region)
Packit 6c4009
.prologue
Packit 6c4009
{ .mfi
Packit 6c4009
        add   GR_Parameter_Y=-32,sp             // Parameter 2 value
Packit 6c4009
        nop.f 0
Packit 6c4009
.save   ar.pfs,GR_SAVE_PFS
Packit 6c4009
        mov  GR_SAVE_PFS=ar.pfs                 // Save ar.pfs
Packit 6c4009
}
Packit 6c4009
{ .mfi
Packit 6c4009
.fframe 64
Packit 6c4009
        add sp=-64,sp                           // Create new stack
Packit 6c4009
        nop.f 0
Packit 6c4009
        mov GR_SAVE_GP=gp                       // Save gp
Packit 6c4009
};;
Packit 6c4009
{ .mmi
Packit 6c4009
        stfe [GR_Parameter_Y] = FR_Y,16         // Save Parameter 2 on stack
Packit 6c4009
        add GR_Parameter_X = 16,sp              // Parameter 1 address
Packit 6c4009
.save   b0, GR_SAVE_B0
Packit 6c4009
        mov GR_SAVE_B0=b0                       // Save b0
Packit 6c4009
};;
Packit 6c4009
.body
Packit 6c4009
{ .mib
Packit 6c4009
        stfe [GR_Parameter_X] = FR_X            // Store Parameter 1 on stack
Packit 6c4009
        add   GR_Parameter_RESULT = 0,GR_Parameter_Y
Packit 6c4009
        nop.b 0                                 // Parameter 3 address
Packit 6c4009
}
Packit 6c4009
{ .mib
Packit 6c4009
        stfe [GR_Parameter_Y] = FR_RESULT      // Store Parameter 3 on stack
Packit 6c4009
        add   GR_Parameter_Y = -16,GR_Parameter_Y
Packit 6c4009
        br.call.sptk b0=__libm_error_support#  // Call error handling function
Packit 6c4009
};;
Packit 6c4009
{ .mmi
Packit 6c4009
        nop.m 0
Packit 6c4009
        nop.m 0
Packit 6c4009
        add   GR_Parameter_RESULT = 48,sp
Packit 6c4009
};;
Packit 6c4009
{ .mmi
Packit 6c4009
        ldfe  f8 = [GR_Parameter_RESULT]       // Get return result off stack
Packit 6c4009
.restore sp
Packit 6c4009
        add   sp = 64,sp                       // Restore stack pointer
Packit 6c4009
        mov   b0 = GR_SAVE_B0                  // Restore return address
Packit 6c4009
};;
Packit 6c4009
{ .mib
Packit 6c4009
        mov   gp = GR_SAVE_GP                  // Restore gp
Packit 6c4009
        mov   ar.pfs = GR_SAVE_PFS             // Restore ar.pfs
Packit 6c4009
        br.ret.sptk     b0                     // Return
Packit 6c4009
};;
Packit 6c4009
Packit 6c4009
LOCAL_LIBM_END(__libm_error_region#)
Packit 6c4009
.type   __libm_error_support#,@function
Packit 6c4009
.global __libm_error_support#