1239310Sdim
2239310Sdim/*============================================================================
3239310Sdim
4239310SdimThis C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5239310SdimPackage, Release 3e, by John R. Hauser.
6239310Sdim
7239310SdimCopyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8239310SdimAll rights reserved.
9239310Sdim
10239310SdimRedistribution and use in source and binary forms, with or without
11239310Sdimmodification, are permitted provided that the following conditions are met:
12239310Sdim
13239310Sdim 1. Redistributions of source code must retain the above copyright notice,
14239310Sdim    this list of conditions, and the following disclaimer.
15239310Sdim
16239310Sdim 2. Redistributions in binary form must reproduce the above copyright notice,
17239310Sdim    this list of conditions, and the following disclaimer in the documentation
18249423Sdim    and/or other materials provided with the distribution.
19251662Sdim
20249423Sdim 3. Neither the name of the University nor the names of its contributors may
21249423Sdim    be used to endorse or promote products derived from this software without
22239310Sdim    specific prior written permission.
23239310Sdim
24239310SdimTHIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25239310SdimEXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26239310SdimWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27239310SdimDISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28239310SdimDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29239310Sdim(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30263508SdimLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31239310SdimON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32239310Sdim(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33239310SdimSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34239310Sdim
35239310Sdim=============================================================================*/
36239310Sdim
37239310Sdim#include <stdbool.h>
38239310Sdim#include <stdint.h>
39239310Sdim#include "platform.h"
40239310Sdim#include "internals.h"
41239310Sdim#include "specialize.h"
42239310Sdim#include "softfloat.h"
43239310Sdim
44239310Sdim#ifdef SOFTFLOAT_FAST_INT64
45239310Sdim
46249423Sdimbool extF80M_lt_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
47249423Sdim{
48249423Sdim
49249423Sdim    return extF80_lt_quiet( *aPtr, *bPtr );
50249423Sdim
51249423Sdim}
52249423Sdim
53249423Sdim#else
54249423Sdim
55249423Sdimbool extF80M_lt_quiet( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
56249423Sdim{
57249423Sdim    const struct extFloat80M *aSPtr, *bSPtr;
58239310Sdim    uint_fast16_t uiA64;
59239310Sdim    uint64_t uiA0;
60239310Sdim    uint_fast16_t uiB64;
61239310Sdim    uint64_t uiB0;
62249423Sdim    bool signA, ltMags;
63249423Sdim
64251662Sdim    /*------------------------------------------------------------------------
65251662Sdim    *------------------------------------------------------------------------*/
66251662Sdim    aSPtr = (const struct extFloat80M *) aPtr;
67263508Sdim    bSPtr = (const struct extFloat80M *) bPtr;
68239310Sdim    /*------------------------------------------------------------------------
69239310Sdim    *------------------------------------------------------------------------*/
70239310Sdim    uiA64 = aSPtr->signExp;
71239310Sdim    uiA0  = aSPtr->signif;
72239310Sdim    uiB64 = bSPtr->signExp;
73239310Sdim    uiB0  = bSPtr->signif;
74249423Sdim    /*------------------------------------------------------------------------
75239310Sdim    *------------------------------------------------------------------------*/
76239310Sdim    if ( isNaNExtF80UI( uiA64, uiA0 ) || isNaNExtF80UI( uiB64, uiB0 ) ) {
77263508Sdim        if (
78239310Sdim               softfloat_isSigNaNExtF80UI( uiA64, uiA0 )
79239310Sdim            || softfloat_isSigNaNExtF80UI( uiB64, uiB0 )
80239310Sdim        ) {
81239310Sdim            softfloat_raiseFlags( softfloat_flag_invalid );
82239310Sdim        }
83239310Sdim        return false;
84239310Sdim    }
85239310Sdim    /*------------------------------------------------------------------------
86239310Sdim    *------------------------------------------------------------------------*/
87239310Sdim    signA = signExtF80UI64( uiA64 );
88239310Sdim    if ( (uiA64 ^ uiB64) & 0x8000 ) {
89239310Sdim        /*--------------------------------------------------------------------
90239310Sdim        | Signs are different.
91239310Sdim        *--------------------------------------------------------------------*/
92239310Sdim        return signA && ((uiA0 | uiB0) != 0);
93239310Sdim    } else {
94239310Sdim        /*--------------------------------------------------------------------
95239310Sdim        | Signs are the same.
96239310Sdim        *--------------------------------------------------------------------*/
97239310Sdim        if ( ! ((uiA0 & uiB0) & UINT64_C( 0x8000000000000000 )) ) {
98239310Sdim            return (softfloat_compareNonnormExtF80M( aSPtr, bSPtr ) < 0);
99239310Sdim        }
100239310Sdim        if ( uiA64 == uiB64 ) {
101239310Sdim            if ( uiA0 == uiB0 ) return false;
102239310Sdim            ltMags = (uiA0 < uiB0);
103239310Sdim        } else {
104239310Sdim            ltMags = (uiA64 < uiB64);
105239310Sdim        }
106239310Sdim        return signA ^ ltMags;
107239310Sdim    }
108239310Sdim
109239310Sdim}
110239310Sdim
111239310Sdim#endif
112249423Sdim
113239310Sdim