|
Packit Service |
82fcde |
.file "libm_frexp_4f.s"
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// Copyright (C) 2000, 2001, Intel Corporation
|
|
Packit Service |
82fcde |
// All rights reserved.
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// Contributed 2/2/2000 by John Harrison, Ted Kubaska, Bob Norin, Shane Story,
|
|
Packit Service |
82fcde |
// and Ping Tak Peter Tang of the Computational Software Lab, 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://developer.intel.com/opensource.
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// History
|
|
Packit Service |
82fcde |
//==============================================================
|
|
Packit Service |
82fcde |
// 2/02/00: Initial version
|
|
Packit Service |
82fcde |
// 3/20/00: Improved speed
|
|
Packit Service |
82fcde |
// 6/01/00: Fixed bug when x a double-extended denormal
|
|
Packit Service |
82fcde |
// 12/08/00 Corrected label on .endp
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// API
|
|
Packit Service |
82fcde |
//==============================================================
|
|
Packit Service |
82fcde |
// float frexp(float x, int* y)
|
|
Packit Service |
82fcde |
// float __libm_frexp_4f(float x, int* y)
|
|
Packit Service |
82fcde |
// where int* y is a 32-bit integer
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// Overview of operation
|
|
Packit Service |
82fcde |
//==============================================================
|
|
Packit Service |
82fcde |
// break a floating point x number into fraction and an exponent
|
|
Packit Service |
82fcde |
// The fraction is returned as a float
|
|
Packit Service |
82fcde |
// The exponent is returned as an integer pointed to by y
|
|
Packit Service |
82fcde |
// This is a true (not a biased exponent) but 0fffe is subtracted
|
|
Packit Service |
82fcde |
// as a bias instead of 0xffff. This is because the fraction returned
|
|
Packit Service |
82fcde |
// is between 0.5 and 1.0, not the expected IEEE range.
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// The fraction is 0.5 <= fraction < 1.0
|
|
Packit Service |
82fcde |
//
|
|
Packit Service |
82fcde |
// Registers used
|
|
Packit Service |
82fcde |
//==============================================================
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// general registers:
|
|
Packit Service |
82fcde |
// r14 exponent bias for x negative
|
|
Packit Service |
82fcde |
// r15 exponent bias for x positive
|
|
Packit Service |
82fcde |
// r16 signexp of x
|
|
Packit Service |
82fcde |
// r17 exponent mask
|
|
Packit Service |
82fcde |
// r18 exponent of x
|
|
Packit Service |
82fcde |
// r19 exponent result
|
|
Packit Service |
82fcde |
// r20 signexp of 2^64
|
|
Packit Service |
82fcde |
// r32 on input contains the 32-bit IEEE float that is in f8
|
|
Packit Service |
82fcde |
// r33 on input pointer to 32-bit integer for exponent
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// predicate registers:
|
|
Packit Service |
82fcde |
// p6 set if x is Nan, zero, or infinity
|
|
Packit Service |
82fcde |
// p7 set if x negative
|
|
Packit Service |
82fcde |
// p8 set if x positive
|
|
Packit Service |
82fcde |
// p9 set if x double-extended denormal
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// floating-point registers:
|
|
Packit Service |
82fcde |
// f8 input, output
|
|
Packit Service |
82fcde |
// f9 normalized x
|
|
Packit Service |
82fcde |
// f10 signexp for significand result for x positive
|
|
Packit Service |
82fcde |
// f11 signexp for significand result for x negative
|
|
Packit Service |
82fcde |
// f12 2^64
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include "libm_support.h"
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.align 32
|
|
Packit Service |
82fcde |
.global __libm_frexp_4f#
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.section .text
|
|
Packit Service |
82fcde |
.proc __libm_frexp_4f#
|
|
Packit Service |
82fcde |
.align 32
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
__libm_frexp_4f:
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// Set signexp for significand result for x>0
|
|
Packit Service |
82fcde |
// If x is a NaN, zero, or infinity, return it.
|
|
Packit Service |
82fcde |
// Put 0 in the int pointer.
|
|
Packit Service |
82fcde |
// x NAN, ZERO, INFINITY?
|
|
Packit Service |
82fcde |
// Set signexp for significand result for x<0
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
(p0) mov r15 = 0x0fffe
|
|
Packit Service |
82fcde |
(p0) fclass.m.unc p6,p0 = f8, 0xe7
|
|
Packit Service |
82fcde |
(p0) mov r14 = 0x2fffe
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
// Form signexp of 2^64 in case x double-extended denormal
|
|
Packit Service |
82fcde |
// Save the normalized value of input in f9
|
|
Packit Service |
82fcde |
// The normalization also sets fault flags and takes faults if necessary
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
(p0) mov r20 = 0x1003f
|
|
Packit Service |
82fcde |
(p0) fnorm f9 = f8
|
|
Packit Service |
82fcde |
nop.i 999 ;;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// Move signexp for significand result for x>0 to FP reg
|
|
Packit Service |
82fcde |
// Form 2^64 in case x double-extended denormal
|
|
Packit Service |
82fcde |
{ .mmi
|
|
Packit Service |
82fcde |
(p0) setf.exp f10 = r15
|
|
Packit Service |
82fcde |
(p0) setf.exp f12 = r20
|
|
Packit Service |
82fcde |
nop.i 999 ;;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// Move signexp for significand result for x<0 to FP reg
|
|
Packit Service |
82fcde |
// If x NAN, ZERO, INFINITY, set *y=0 as a 32-bit integer, and exit
|
|
Packit Service |
82fcde |
{ .mmb
|
|
Packit Service |
82fcde |
(p0) setf.exp f11 = r14
|
|
Packit Service |
82fcde |
(p6) st4 [r33] = r0
|
|
Packit Service |
82fcde |
(p6) br.ret.spnt b0 ;;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// Form exponent mask
|
|
Packit Service |
82fcde |
// p7 if x<0, else p8
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
(p0) mov r17 = 0x1ffff
|
|
Packit Service |
82fcde |
(p0) fcmp.lt.unc p7,p8 = f8,f0
|
|
Packit Service |
82fcde |
nop.i 999 ;;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// Test for fnorm(x) denormal, means x double-extended denormal
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
nop.m 999
|
|
Packit Service |
82fcde |
(p0) fclass.m.unc p9,p0 = f9, 0x0b
|
|
Packit Service |
82fcde |
nop.i 999 ;;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// If x double-extended denormal add 64 to exponent bias for scaling
|
|
Packit Service |
82fcde |
// If x double-extended denormal multiply x * 2^64 which is normal
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
(p9) add r15 = 64, r15
|
|
Packit Service |
82fcde |
(p9) fmpy f9 = f9, f12
|
|
Packit Service |
82fcde |
nop.i 999 ;;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// true exponent stored to int pointer
|
|
Packit Service |
82fcde |
// the bias is treated as 0xfffe instead of
|
|
Packit Service |
82fcde |
// normal 0xffff because we want the significand
|
|
Packit Service |
82fcde |
// to be in the range <=0.5 sig < 1.0
|
|
Packit Service |
82fcde |
// Store the value of the exponent at the pointer in r33
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// If x>0 form significand result
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
nop.m 999
|
|
Packit Service |
82fcde |
(p8) fmerge.se f8 = f10,f9
|
|
Packit Service |
82fcde |
nop.i 999 ;;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// Get signexp of normalized x
|
|
Packit Service |
82fcde |
// If x<0 form significand result
|
|
Packit Service |
82fcde |
{ .mfi
|
|
Packit Service |
82fcde |
(p0) getf.exp r16 = f9
|
|
Packit Service |
82fcde |
(p7) fmerge.se f8 = f11,f9
|
|
Packit Service |
82fcde |
nop.i 999 ;;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// Get exp of normalized x
|
|
Packit Service |
82fcde |
// Subtract off bias to get true exponent of x
|
|
Packit Service |
82fcde |
{ .mmi
|
|
Packit Service |
82fcde |
(p0) and r18 = r17,r16 ;;
|
|
Packit Service |
82fcde |
(p0) sub r19 = r18,r15
|
|
Packit Service |
82fcde |
nop.i 999 ;;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
// Store int y as a 32-bit integer
|
|
Packit Service |
82fcde |
// Make the value a float
|
|
Packit Service |
82fcde |
{ .mfb
|
|
Packit Service |
82fcde |
(p0) st4 [r33] = r19
|
|
Packit Service |
82fcde |
(p0) fnorm.s f8 = f8
|
|
Packit Service |
82fcde |
(p0) br.ret.sptk b0 ;;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.endp __libm_frexp_4f
|
|
Packit Service |
82fcde |
ASM_SIZE_DIRECTIVE(__libm_frexp_4f)
|
|
Packit Service |
82fcde |
strong_alias(__libm_frexp_4f, _GI___libm_frexp_4f)
|