|
Packit Service |
82fcde |
.file "logbl.s"
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// Copyright (c) 2000 - 2003, Intel Corporation
|
|
Packit Service |
82fcde |
// All rights reserved.
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// Contributed 2000 by the Intel Numerics Group, Intel Corporation
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// Redistribution and use in source and binary forms, with or without
|
|
Packit Service |
82fcde |
// modification, are permitted provided that the following conditions are
|
|
Packit Service |
82fcde |
// met:
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// * Redistributions of source code must retain the above copyright
|
|
Packit Service |
82fcde |
// notice, this list of conditions and the following disclaimer.
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// * Redistributions in binary form must reproduce the above copyright
|
|
Packit Service |
82fcde |
// notice, this list of conditions and the following disclaimer in the
|
|
Packit Service |
82fcde |
// documentation and/or other materials provided with the distribution.
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// * The name of Intel Corporation may not be used to endorse or promote
|
|
Packit Service |
82fcde |
// products derived from this software without specific prior written
|
|
Packit Service |
82fcde |
// permission.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Packit Service |
82fcde |
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Packit Service |
82fcde |
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
Packit Service |
82fcde |
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
|
|
Packit Service |
82fcde |
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
Packit Service |
82fcde |
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
Packit Service |
82fcde |
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
Packit Service |
82fcde |
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
|
Packit Service |
82fcde |
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
|
|
Packit Service |
82fcde |
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
Packit Service |
82fcde |
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// Intel Corporation is the author of this code, and requests that all
|
|
Packit Service |
82fcde |
// problem reports or change requests be submitted to it directly at
|
|
Packit Service |
82fcde |
// http://www.intel.com/software/products/opensource/libraries/num.htm.
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// History
|
|
Packit Service |
82fcde |
//==============================================================
|
|
Packit Service |
82fcde |
// 02/02/00 Initial version
|
|
Packit Service |
82fcde |
// 02/16/00 Modified to conform to C9X
|
|
Packit Service |
82fcde |
// 03/16/00 Improved speed
|
|
Packit Service |
82fcde |
// 04/04/00 Unwind support added
|
|
Packit Service |
82fcde |
// 05/30/00 Fixed bug when x double-extended denormal
|
|
Packit Service |
82fcde |
// 08/15/00 Bundle added after call to __libm_error_support to properly
|
|
Packit Service |
82fcde |
// set [the previously overwritten] GR_Parameter_RESULT.
|
|
Packit Service |
82fcde |
// 05/20/02 Cleaned up namespace and sf0 syntax
|
|
Packit Service |
82fcde |
// 01/20/03 Improved performance
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// API
|
|
Packit Service |
82fcde |
//==============================================================
|
|
Packit Service |
82fcde |
// long double logbl( long double x );
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// Overview of operation
|
|
Packit Service |
82fcde |
//==============================================================
|
|
Packit Service |
82fcde |
// The logbl function extracts the exponent of x as an integer in
|
|
Packit Service |
82fcde |
// floating-point format.
|
|
Packit Service |
82fcde |
// logbl computes log2 of x as a long double
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// logbl is similar to ilogbl but differs in the following ways:
|
|
Packit Service |
82fcde |
// +-inf
|
|
Packit Service |
82fcde |
// ilogbl: returns INT_MAX
|
|
Packit Service |
82fcde |
// logbl: returns +inf
|
|
Packit Service |
82fcde |
// Nan returns FP_LOGBNAN (which is either INT_MAX or INT_MIN)
|
|
Packit Service |
82fcde |
// ilogbl: returns INT_MAX (7fffffff)
|
|
Packit Service |
82fcde |
// logbl: returns QNAN (quietized SNAN)
|
|
Packit Service |
82fcde |
// 0 returns FP_ILOGB0 (which is either INT_MIN or -INT_MAX)
|
|
Packit Service |
82fcde |
// ilogbl: returns -INT_MAX (80000001)
|
|
Packit Service |
82fcde |
// logbl: returns -inf, raises the divide-by-zero exception,
|
|
Packit Service |
82fcde |
// and calls libm_error_support to set domain error
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// Registers used
|
|
Packit Service |
82fcde |
//==============================================================
|
|
Packit Service |
82fcde |
// general registers used:
|
|
Packit Service |
82fcde |
// r26 -> r38
|
|
Packit Service |
82fcde |
// r35 -> r38 used as parameters to error path
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// predicate registers used:
|
|
Packit Service |
82fcde |
// p6, p7, p8
|
|
Packit Service |
82fcde |
// floating-point registers used:
|
|
Packit Service |
82fcde |
// f9, f10, f11
|
|
Packit Service |
82fcde |
// f8, input
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
rExpBias = r26
|
|
Packit Service |
82fcde |
rExpMask = r27
|
|
Packit Service |
82fcde |
rSignexp_x = r28
|
|
Packit Service |
82fcde |
rExp_x = r29
|
|
Packit Service |
82fcde |
rTrueExp_x = r30
|
|
Packit Service |
82fcde |
rExp_2to64 = r31
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
GR_SAVE_PFS = r32
|
|
Packit Service |
82fcde |
GR_SAVE_B0 = r33
|
|
Packit Service |
82fcde |
GR_SAVE_GP = r34
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
GR_Parameter_X = r35
|
|
Packit Service |
82fcde |
GR_Parameter_Y = r36
|
|
Packit Service |
82fcde |
GR_Parameter_RESULT = r37
|
|
Packit Service |
82fcde |
GR_Parameter_TAG = r38
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
fExp_in_signif = f9
|
|
Packit Service |
82fcde |
fNorm_x = f10
|
|
Packit Service |
82fcde |
fFloat_Exp = f10
|
|
Packit Service |
82fcde |
f2to64 = f11
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.section .text
|
|
Packit Service |
82fcde |
GLOBAL_LIBM_ENTRY(logbl)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// X NORMAL
|
|
Packit Service |
82fcde |
// TrueExp_x = exp(f8) - 0xffff
|
|
Packit Service |
82fcde |
// sig = TrueExp_x
|
|
Packit Service |
82fcde |
// f8 = convert_to_fp (sig))
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
getf.exp rSignexp_x = f8
|
|
Packit Service |
82fcde |
fclass.m p8,p0 = f8, 0x0b // Test for x unorm
|
|
Packit Service |
82fcde |
mov rExpBias = 0xffff // Exponent bias
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
nop.m 0
|
|
Packit Service |
82fcde |
fnorm.s1 fNorm_x = f8
|
|
Packit Service |
82fcde |
mov rExpMask = 0x1ffff // Exponent mask
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// Form signexp of 2^64 in case need to scale denormal
|
|
Packit Service |
82fcde |
{ .mfb
|
|
Packit Service |
82fcde |
mov rExp_2to64 = 0x1003f
|
|
Packit Service |
82fcde |
fclass.m p6,p0 = f8, 0x1e3 // Test x natval, nan, inf
|
|
Packit Service |
82fcde |
(p8) br.cond.spnt LOGB_DENORM // Branch if x unorm
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
LOGB_COMMON:
|
|
Packit Service |
82fcde |
// Return here from LOGB_DENORM
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
and rExp_x = rSignexp_x, rExpMask // Get biased exponent
|
|
Packit Service |
82fcde |
fclass.m p7,p0 = f8, 0x07 // Test x zero
|
|
Packit Service |
82fcde |
nop.i 0
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// X NAN or INFINITY, return f8 * f8
|
|
Packit Service |
82fcde |
{ .mfb
|
|
Packit Service |
82fcde |
sub rTrueExp_x = rExp_x, rExpBias // Get true exponent
|
|
Packit Service |
82fcde |
(p6) fma.s0 f8= f8,f8,f0 // Result if x natval, nan, inf
|
|
Packit Service |
82fcde |
(p6) br.ret.spnt b0 // Exit if x natval, nan, inf
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
{ .mib
|
|
Packit Service |
82fcde |
setf.sig fExp_in_signif = rTrueExp_x // Exponent as integer in fp
|
|
Packit Service |
82fcde |
nop.i 999
|
|
Packit Service |
82fcde |
(p7) br.cond.spnt LOGB_ZERO
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// Result can be represented in less than 24 bits, so no precision completer
|
|
Packit Service |
82fcde |
// is needed.
|
|
Packit Service |
82fcde |
{ .mfb
|
|
Packit Service |
82fcde |
nop.m 0
|
|
Packit Service |
82fcde |
fcvt.xf f8 = fExp_in_signif
|
|
Packit Service |
82fcde |
br.ret.sptk b0 // Exit main path, 0 < |x| < inf
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
LOGB_DENORM:
|
|
Packit Service |
82fcde |
// Form 2^64 in case need to scale denormal
|
|
Packit Service |
82fcde |
// Check to see if double-extended denormal
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
setf.exp f2to64 = rExp_2to64
|
|
Packit Service |
82fcde |
fclass.m p8,p0 = fNorm_x, 0x0b
|
|
Packit Service |
82fcde |
nop.i 0
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
nop.m 0
|
|
Packit Service |
82fcde |
fcmp.eq.s0 p7,p0 = f8, f0 // Dummy op to set denormal flag
|
|
Packit Service |
82fcde |
nop.i 0
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// If double-extended denormal add 64 to exponent bias for scaling
|
|
Packit Service |
82fcde |
// If double-extended denormal form x * 2^64 which is normal
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
(p8) add rExpBias = 64, rExpBias
|
|
Packit Service |
82fcde |
(p8) fmpy.s1 fNorm_x = fNorm_x, f2to64
|
|
Packit Service |
82fcde |
nop.i 0
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// Logic is the same as normal path but use normalized input
|
|
Packit Service |
82fcde |
{ .mib
|
|
Packit Service |
82fcde |
getf.exp rSignexp_x = fNorm_x
|
|
Packit Service |
82fcde |
nop.i 0
|
|
Packit Service |
82fcde |
br.cond.sptk LOGB_COMMON // Return to main path
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
LOGB_ZERO:
|
|
Packit Service |
82fcde |
// Here if x zero
|
|
Packit Service |
82fcde |
// f10 = -|f8|
|
|
Packit Service |
82fcde |
// f9 = 1.0/f10 = -1.0/|f8| = -inf
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
{ .mmf
|
|
Packit Service |
82fcde |
alloc r32=ar.pfs,1,2,4,0
|
|
Packit Service |
82fcde |
mov GR_Parameter_TAG = 150 // Error code
|
|
Packit Service |
82fcde |
fmerge.ns f10 = f0,f8
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
{ .mfb
|
|
Packit Service |
82fcde |
nop.m 0
|
|
Packit Service |
82fcde |
frcpa.s0 f9,p6 = f1,f10 // Produce -inf, Z flag
|
|
Packit Service |
82fcde |
br.cond.sptk __libm_error_region // Call error support
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
;;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
GLOBAL_LIBM_END(logbl)
|
|
Packit Service |
82fcde |
libm_alias_ldouble_other (logb, logb)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
LOCAL_LIBM_ENTRY(__libm_error_region)
|
|
Packit Service |
82fcde |
.prologue
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
add GR_Parameter_Y=-32,sp // Parameter 2 value
|
|
Packit Service |
82fcde |
nop.f 0
|
|
Packit Service |
82fcde |
.save ar.pfs,GR_SAVE_PFS
|
|
Packit Service |
82fcde |
mov GR_SAVE_PFS=ar.pfs // Save ar.pfs
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
.fframe 64
|
|
Packit Service |
82fcde |
add sp=-64,sp // Create new stack
|
|
Packit Service |
82fcde |
nop.f 0
|
|
Packit Service |
82fcde |
mov GR_SAVE_GP=gp // Save gp
|
|
Packit Service |
82fcde |
};;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
{ .mmi
|
|
Packit Service |
82fcde |
stfe [GR_Parameter_Y] = f0,16 // STORE Parameter 2 on stack
|
|
Packit Service |
82fcde |
add GR_Parameter_X = 16,sp // Parameter 1 address
|
|
Packit Service |
82fcde |
.save b0, GR_SAVE_B0
|
|
Packit Service |
82fcde |
mov GR_SAVE_B0=b0 // Save b0
|
|
Packit Service |
82fcde |
};;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.body
|
|
Packit Service |
82fcde |
{ .mib
|
|
Packit Service |
82fcde |
stfe [GR_Parameter_X] = f8 // STORE Parameter 1 on stack
|
|
Packit Service |
82fcde |
add GR_Parameter_RESULT = 0,GR_Parameter_Y // Parameter 3 address
|
|
Packit Service |
82fcde |
nop.b 0
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
{ .mib
|
|
Packit Service |
82fcde |
stfe [GR_Parameter_Y] = f9 // Store Parameter 3 on stack
|
|
Packit Service |
82fcde |
add GR_Parameter_Y = -16,GR_Parameter_Y
|
|
Packit Service |
82fcde |
br.call.sptk b0=__libm_error_support# // Call error handling function
|
|
Packit Service |
82fcde |
};;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
{ .mmi
|
|
Packit Service |
82fcde |
add GR_Parameter_RESULT = 48,sp
|
|
Packit Service |
82fcde |
nop.m 0
|
|
Packit Service |
82fcde |
nop.i 0
|
|
Packit Service |
82fcde |
};;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
{ .mmi
|
|
Packit Service |
82fcde |
ldfe f8 = [GR_Parameter_RESULT] // Get return result off stack
|
|
Packit Service |
82fcde |
.restore sp
|
|
Packit Service |
82fcde |
add sp = 64,sp // Restore stack pointer
|
|
Packit Service |
82fcde |
mov b0 = GR_SAVE_B0 // Restore return address
|
|
Packit Service |
82fcde |
};;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
{ .mib
|
|
Packit Service |
82fcde |
mov gp = GR_SAVE_GP // Restore gp
|
|
Packit Service |
82fcde |
mov ar.pfs = GR_SAVE_PFS // Restore ar.pfs
|
|
Packit Service |
82fcde |
br.ret.sptk b0
|
|
Packit Service |
82fcde |
};;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
LOCAL_LIBM_END(__libm_error_region)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.type __libm_error_support#,@function
|
|
Packit Service |
82fcde |
.global __libm_error_support#
|