162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Linux/PA-RISC Project (http://www.parisc-linux.org/)
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Floating-point emulation code
662306a36Sopenharmony_ci *  Copyright (C) 2001 Hewlett-Packard (Paul Bame) <bame@debian.org>
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci#ifdef __NO_PA_HDRS
962306a36Sopenharmony_ci    PA header file -- do not include this header file for non-PA builds.
1062306a36Sopenharmony_ci#endif
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci/* 32-bit word grabbing functions */
1362306a36Sopenharmony_ci#define Dbl_firstword(value) Dallp1(value)
1462306a36Sopenharmony_ci#define Dbl_secondword(value) Dallp2(value)
1562306a36Sopenharmony_ci#define Dbl_thirdword(value) dummy_location
1662306a36Sopenharmony_ci#define Dbl_fourthword(value) dummy_location
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define Dbl_sign(object) Dsign(object)
1962306a36Sopenharmony_ci#define Dbl_exponent(object) Dexponent(object)
2062306a36Sopenharmony_ci#define Dbl_signexponent(object) Dsignexponent(object)
2162306a36Sopenharmony_ci#define Dbl_mantissap1(object) Dmantissap1(object)
2262306a36Sopenharmony_ci#define Dbl_mantissap2(object) Dmantissap2(object)
2362306a36Sopenharmony_ci#define Dbl_exponentmantissap1(object) Dexponentmantissap1(object)
2462306a36Sopenharmony_ci#define Dbl_allp1(object) Dallp1(object)
2562306a36Sopenharmony_ci#define Dbl_allp2(object) Dallp2(object)
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci/* dbl_and_signs ANDs the sign bits of each argument and puts the result
2862306a36Sopenharmony_ci * into the first argument. dbl_or_signs ors those same sign bits */
2962306a36Sopenharmony_ci#define Dbl_and_signs( src1dst, src2)		\
3062306a36Sopenharmony_ci    Dallp1(src1dst) = (Dallp1(src2)|~((unsigned int)1<<31)) & Dallp1(src1dst)
3162306a36Sopenharmony_ci#define Dbl_or_signs( src1dst, src2)		\
3262306a36Sopenharmony_ci    Dallp1(src1dst) = (Dallp1(src2)&((unsigned int)1<<31)) | Dallp1(src1dst)
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci/* The hidden bit is always the low bit of the exponent */
3562306a36Sopenharmony_ci#define Dbl_clear_exponent_set_hidden(srcdst) Deposit_dexponent(srcdst,1)
3662306a36Sopenharmony_ci#define Dbl_clear_signexponent_set_hidden(srcdst) \
3762306a36Sopenharmony_ci    Deposit_dsignexponent(srcdst,1)
3862306a36Sopenharmony_ci#define Dbl_clear_sign(srcdst) Dallp1(srcdst) &= ~((unsigned int)1<<31)
3962306a36Sopenharmony_ci#define Dbl_clear_signexponent(srcdst) \
4062306a36Sopenharmony_ci    Dallp1(srcdst) &= Dmantissap1((unsigned int)-1)
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci/* Exponent field for doubles has already been cleared and may be
4362306a36Sopenharmony_ci * included in the shift.  Here we need to generate two double width
4462306a36Sopenharmony_ci * variable shifts.  The insignificant bits can be ignored.
4562306a36Sopenharmony_ci *      MTSAR f(varamount)
4662306a36Sopenharmony_ci *      VSHD	srcdst.high,srcdst.low => srcdst.low
4762306a36Sopenharmony_ci *	VSHD	0,srcdst.high => srcdst.high
4862306a36Sopenharmony_ci * This is very difficult to model with C expressions since the shift amount
4962306a36Sopenharmony_ci * could exceed 32.  */
5062306a36Sopenharmony_ci/* varamount must be less than 64 */
5162306a36Sopenharmony_ci#define Dbl_rightshift(srcdstA, srcdstB, varamount)			\
5262306a36Sopenharmony_ci    {if((varamount) >= 32) {						\
5362306a36Sopenharmony_ci        Dallp2(srcdstB) = Dallp1(srcdstA) >> (varamount-32);		\
5462306a36Sopenharmony_ci        Dallp1(srcdstA)=0;						\
5562306a36Sopenharmony_ci    }									\
5662306a36Sopenharmony_ci    else if(varamount > 0) {						\
5762306a36Sopenharmony_ci	Variable_shift_double(Dallp1(srcdstA), Dallp2(srcdstB), 	\
5862306a36Sopenharmony_ci	  (varamount), Dallp2(srcdstB));				\
5962306a36Sopenharmony_ci	Dallp1(srcdstA) >>= varamount;					\
6062306a36Sopenharmony_ci    } }
6162306a36Sopenharmony_ci/* varamount must be less than 64 */
6262306a36Sopenharmony_ci#define Dbl_rightshift_exponentmantissa(srcdstA, srcdstB, varamount)	\
6362306a36Sopenharmony_ci    {if((varamount) >= 32) {						\
6462306a36Sopenharmony_ci        Dallp2(srcdstB) = Dexponentmantissap1(srcdstA) >> (varamount-32); \
6562306a36Sopenharmony_ci	Dallp1(srcdstA) &= ((unsigned int)1<<31);  /* clear expmant field */ \
6662306a36Sopenharmony_ci    }									\
6762306a36Sopenharmony_ci    else if(varamount > 0) {						\
6862306a36Sopenharmony_ci	Variable_shift_double(Dexponentmantissap1(srcdstA), Dallp2(srcdstB), \
6962306a36Sopenharmony_ci	(varamount), Dallp2(srcdstB));					\
7062306a36Sopenharmony_ci	Deposit_dexponentmantissap1(srcdstA,				\
7162306a36Sopenharmony_ci	    (Dexponentmantissap1(srcdstA)>>varamount));			\
7262306a36Sopenharmony_ci    } }
7362306a36Sopenharmony_ci/* varamount must be less than 64 */
7462306a36Sopenharmony_ci#define Dbl_leftshift(srcdstA, srcdstB, varamount)			\
7562306a36Sopenharmony_ci    {if((varamount) >= 32) {						\
7662306a36Sopenharmony_ci	Dallp1(srcdstA) = Dallp2(srcdstB) << (varamount-32);		\
7762306a36Sopenharmony_ci	Dallp2(srcdstB)=0;						\
7862306a36Sopenharmony_ci    }									\
7962306a36Sopenharmony_ci    else {								\
8062306a36Sopenharmony_ci	if ((varamount) > 0) {						\
8162306a36Sopenharmony_ci	    Dallp1(srcdstA) = (Dallp1(srcdstA) << (varamount)) |	\
8262306a36Sopenharmony_ci		(Dallp2(srcdstB) >> (32-(varamount)));			\
8362306a36Sopenharmony_ci	    Dallp2(srcdstB) <<= varamount;				\
8462306a36Sopenharmony_ci	}								\
8562306a36Sopenharmony_ci    } }
8662306a36Sopenharmony_ci#define Dbl_leftshiftby1_withextent(lefta,leftb,right,resulta,resultb)	\
8762306a36Sopenharmony_ci    Shiftdouble(Dallp1(lefta), Dallp2(leftb), 31, Dallp1(resulta));	\
8862306a36Sopenharmony_ci    Shiftdouble(Dallp2(leftb), Extall(right), 31, Dallp2(resultb))
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci#define Dbl_rightshiftby1_withextent(leftb,right,dst)		\
9162306a36Sopenharmony_ci    Extall(dst) = (Dallp2(leftb) << 31) | ((unsigned int)Extall(right) >> 1) | \
9262306a36Sopenharmony_ci		  Extlow(right)
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci#define Dbl_arithrightshiftby1(srcdstA,srcdstB)			\
9562306a36Sopenharmony_ci    Shiftdouble(Dallp1(srcdstA),Dallp2(srcdstB),1,Dallp2(srcdstB));\
9662306a36Sopenharmony_ci    Dallp1(srcdstA) = (int)Dallp1(srcdstA) >> 1
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci/* Sign extend the sign bit with an integer destination */
9962306a36Sopenharmony_ci#define Dbl_signextendedsign(value)  Dsignedsign(value)
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci#define Dbl_isone_hidden(dbl_value) (Is_dhidden(dbl_value)!=0)
10262306a36Sopenharmony_ci/* Singles and doubles may include the sign and exponent fields.  The
10362306a36Sopenharmony_ci * hidden bit and the hidden overflow must be included. */
10462306a36Sopenharmony_ci#define Dbl_increment(dbl_valueA,dbl_valueB) \
10562306a36Sopenharmony_ci    if( (Dallp2(dbl_valueB) += 1) == 0 )  Dallp1(dbl_valueA) += 1
10662306a36Sopenharmony_ci#define Dbl_increment_mantissa(dbl_valueA,dbl_valueB) \
10762306a36Sopenharmony_ci    if( (Dmantissap2(dbl_valueB) += 1) == 0 )  \
10862306a36Sopenharmony_ci    Deposit_dmantissap1(dbl_valueA,dbl_valueA+1)
10962306a36Sopenharmony_ci#define Dbl_decrement(dbl_valueA,dbl_valueB) \
11062306a36Sopenharmony_ci    if( Dallp2(dbl_valueB) == 0 )  Dallp1(dbl_valueA) -= 1; \
11162306a36Sopenharmony_ci    Dallp2(dbl_valueB) -= 1
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci#define Dbl_isone_sign(dbl_value) (Is_dsign(dbl_value)!=0)
11462306a36Sopenharmony_ci#define Dbl_isone_hiddenoverflow(dbl_value) (Is_dhiddenoverflow(dbl_value)!=0)
11562306a36Sopenharmony_ci#define Dbl_isone_lowmantissap1(dbl_valueA) (Is_dlowp1(dbl_valueA)!=0)
11662306a36Sopenharmony_ci#define Dbl_isone_lowmantissap2(dbl_valueB) (Is_dlowp2(dbl_valueB)!=0)
11762306a36Sopenharmony_ci#define Dbl_isone_signaling(dbl_value) (Is_dsignaling(dbl_value)!=0)
11862306a36Sopenharmony_ci#define Dbl_is_signalingnan(dbl_value) (Dsignalingnan(dbl_value)==0xfff)
11962306a36Sopenharmony_ci#define Dbl_isnotzero(dbl_valueA,dbl_valueB) \
12062306a36Sopenharmony_ci    (Dallp1(dbl_valueA) || Dallp2(dbl_valueB))
12162306a36Sopenharmony_ci#define Dbl_isnotzero_hiddenhigh7mantissa(dbl_value) \
12262306a36Sopenharmony_ci    (Dhiddenhigh7mantissa(dbl_value)!=0)
12362306a36Sopenharmony_ci#define Dbl_isnotzero_exponent(dbl_value) (Dexponent(dbl_value)!=0)
12462306a36Sopenharmony_ci#define Dbl_isnotzero_mantissa(dbl_valueA,dbl_valueB) \
12562306a36Sopenharmony_ci    (Dmantissap1(dbl_valueA) || Dmantissap2(dbl_valueB))
12662306a36Sopenharmony_ci#define Dbl_isnotzero_mantissap1(dbl_valueA) (Dmantissap1(dbl_valueA)!=0)
12762306a36Sopenharmony_ci#define Dbl_isnotzero_mantissap2(dbl_valueB) (Dmantissap2(dbl_valueB)!=0)
12862306a36Sopenharmony_ci#define Dbl_isnotzero_exponentmantissa(dbl_valueA,dbl_valueB) \
12962306a36Sopenharmony_ci    (Dexponentmantissap1(dbl_valueA) || Dmantissap2(dbl_valueB))
13062306a36Sopenharmony_ci#define Dbl_isnotzero_low4p2(dbl_value) (Dlow4p2(dbl_value)!=0)
13162306a36Sopenharmony_ci#define Dbl_iszero(dbl_valueA,dbl_valueB) (Dallp1(dbl_valueA)==0 && \
13262306a36Sopenharmony_ci    Dallp2(dbl_valueB)==0)
13362306a36Sopenharmony_ci#define Dbl_iszero_allp1(dbl_value) (Dallp1(dbl_value)==0)
13462306a36Sopenharmony_ci#define Dbl_iszero_allp2(dbl_value) (Dallp2(dbl_value)==0)
13562306a36Sopenharmony_ci#define Dbl_iszero_hidden(dbl_value) (Is_dhidden(dbl_value)==0)
13662306a36Sopenharmony_ci#define Dbl_iszero_hiddenoverflow(dbl_value) (Is_dhiddenoverflow(dbl_value)==0)
13762306a36Sopenharmony_ci#define Dbl_iszero_hiddenhigh3mantissa(dbl_value) \
13862306a36Sopenharmony_ci    (Dhiddenhigh3mantissa(dbl_value)==0)
13962306a36Sopenharmony_ci#define Dbl_iszero_hiddenhigh7mantissa(dbl_value) \
14062306a36Sopenharmony_ci    (Dhiddenhigh7mantissa(dbl_value)==0)
14162306a36Sopenharmony_ci#define Dbl_iszero_sign(dbl_value) (Is_dsign(dbl_value)==0)
14262306a36Sopenharmony_ci#define Dbl_iszero_exponent(dbl_value) (Dexponent(dbl_value)==0)
14362306a36Sopenharmony_ci#define Dbl_iszero_mantissa(dbl_valueA,dbl_valueB) \
14462306a36Sopenharmony_ci    (Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0)
14562306a36Sopenharmony_ci#define Dbl_iszero_exponentmantissa(dbl_valueA,dbl_valueB) \
14662306a36Sopenharmony_ci    (Dexponentmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0)
14762306a36Sopenharmony_ci#define Dbl_isinfinity_exponent(dbl_value)		\
14862306a36Sopenharmony_ci    (Dexponent(dbl_value)==DBL_INFINITY_EXPONENT)
14962306a36Sopenharmony_ci#define Dbl_isnotinfinity_exponent(dbl_value)		\
15062306a36Sopenharmony_ci    (Dexponent(dbl_value)!=DBL_INFINITY_EXPONENT)
15162306a36Sopenharmony_ci#define Dbl_isinfinity(dbl_valueA,dbl_valueB)			\
15262306a36Sopenharmony_ci    (Dexponent(dbl_valueA)==DBL_INFINITY_EXPONENT &&	\
15362306a36Sopenharmony_ci    Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0)
15462306a36Sopenharmony_ci#define Dbl_isnan(dbl_valueA,dbl_valueB)		\
15562306a36Sopenharmony_ci    (Dexponent(dbl_valueA)==DBL_INFINITY_EXPONENT &&	\
15662306a36Sopenharmony_ci    (Dmantissap1(dbl_valueA)!=0 || Dmantissap2(dbl_valueB)!=0))
15762306a36Sopenharmony_ci#define Dbl_isnotnan(dbl_valueA,dbl_valueB)		\
15862306a36Sopenharmony_ci    (Dexponent(dbl_valueA)!=DBL_INFINITY_EXPONENT ||	\
15962306a36Sopenharmony_ci    (Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0))
16062306a36Sopenharmony_ci
16162306a36Sopenharmony_ci#define Dbl_islessthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b)	\
16262306a36Sopenharmony_ci    (Dallp1(dbl_op1a) < Dallp1(dbl_op2a) ||			\
16362306a36Sopenharmony_ci     (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) &&			\
16462306a36Sopenharmony_ci      Dallp2(dbl_op1b) < Dallp2(dbl_op2b)))
16562306a36Sopenharmony_ci#define Dbl_isgreaterthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b)	\
16662306a36Sopenharmony_ci    (Dallp1(dbl_op1a) > Dallp1(dbl_op2a) ||			\
16762306a36Sopenharmony_ci     (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) &&			\
16862306a36Sopenharmony_ci      Dallp2(dbl_op1b) > Dallp2(dbl_op2b)))
16962306a36Sopenharmony_ci#define Dbl_isnotlessthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b)	\
17062306a36Sopenharmony_ci    (Dallp1(dbl_op1a) > Dallp1(dbl_op2a) ||			\
17162306a36Sopenharmony_ci     (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) &&			\
17262306a36Sopenharmony_ci      Dallp2(dbl_op1b) >= Dallp2(dbl_op2b)))
17362306a36Sopenharmony_ci#define Dbl_isnotgreaterthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \
17462306a36Sopenharmony_ci    (Dallp1(dbl_op1a) < Dallp1(dbl_op2a) ||			\
17562306a36Sopenharmony_ci     (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) &&			\
17662306a36Sopenharmony_ci      Dallp2(dbl_op1b) <= Dallp2(dbl_op2b)))
17762306a36Sopenharmony_ci#define Dbl_isequal(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b)	\
17862306a36Sopenharmony_ci     ((Dallp1(dbl_op1a) == Dallp1(dbl_op2a)) &&			\
17962306a36Sopenharmony_ci      (Dallp2(dbl_op1b) == Dallp2(dbl_op2b)))
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ci#define Dbl_leftshiftby8(dbl_valueA,dbl_valueB) \
18262306a36Sopenharmony_ci    Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),24,Dallp1(dbl_valueA)); \
18362306a36Sopenharmony_ci    Dallp2(dbl_valueB) <<= 8
18462306a36Sopenharmony_ci#define Dbl_leftshiftby7(dbl_valueA,dbl_valueB) \
18562306a36Sopenharmony_ci    Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),25,Dallp1(dbl_valueA)); \
18662306a36Sopenharmony_ci    Dallp2(dbl_valueB) <<= 7
18762306a36Sopenharmony_ci#define Dbl_leftshiftby4(dbl_valueA,dbl_valueB) \
18862306a36Sopenharmony_ci    Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),28,Dallp1(dbl_valueA)); \
18962306a36Sopenharmony_ci    Dallp2(dbl_valueB) <<= 4
19062306a36Sopenharmony_ci#define Dbl_leftshiftby3(dbl_valueA,dbl_valueB) \
19162306a36Sopenharmony_ci    Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),29,Dallp1(dbl_valueA)); \
19262306a36Sopenharmony_ci    Dallp2(dbl_valueB) <<= 3
19362306a36Sopenharmony_ci#define Dbl_leftshiftby2(dbl_valueA,dbl_valueB) \
19462306a36Sopenharmony_ci    Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),30,Dallp1(dbl_valueA)); \
19562306a36Sopenharmony_ci    Dallp2(dbl_valueB) <<= 2
19662306a36Sopenharmony_ci#define Dbl_leftshiftby1(dbl_valueA,dbl_valueB) \
19762306a36Sopenharmony_ci    Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),31,Dallp1(dbl_valueA)); \
19862306a36Sopenharmony_ci    Dallp2(dbl_valueB) <<= 1
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ci#define Dbl_rightshiftby8(dbl_valueA,dbl_valueB) \
20162306a36Sopenharmony_ci    Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),8,Dallp2(dbl_valueB)); \
20262306a36Sopenharmony_ci    Dallp1(dbl_valueA) >>= 8
20362306a36Sopenharmony_ci#define Dbl_rightshiftby4(dbl_valueA,dbl_valueB) \
20462306a36Sopenharmony_ci    Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),4,Dallp2(dbl_valueB)); \
20562306a36Sopenharmony_ci    Dallp1(dbl_valueA) >>= 4
20662306a36Sopenharmony_ci#define Dbl_rightshiftby2(dbl_valueA,dbl_valueB) \
20762306a36Sopenharmony_ci    Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),2,Dallp2(dbl_valueB)); \
20862306a36Sopenharmony_ci    Dallp1(dbl_valueA) >>= 2
20962306a36Sopenharmony_ci#define Dbl_rightshiftby1(dbl_valueA,dbl_valueB) \
21062306a36Sopenharmony_ci    Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),1,Dallp2(dbl_valueB)); \
21162306a36Sopenharmony_ci    Dallp1(dbl_valueA) >>= 1
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci/* This magnitude comparison uses the signless first words and
21462306a36Sopenharmony_ci * the regular part2 words.  The comparison is graphically:
21562306a36Sopenharmony_ci *
21662306a36Sopenharmony_ci *       1st greater?  -------------
21762306a36Sopenharmony_ci *                                 |
21862306a36Sopenharmony_ci *       1st less?-----------------+---------
21962306a36Sopenharmony_ci *                                 |        |
22062306a36Sopenharmony_ci *       2nd greater or equal----->|        |
22162306a36Sopenharmony_ci *                               False     True
22262306a36Sopenharmony_ci */
22362306a36Sopenharmony_ci#define Dbl_ismagnitudeless(leftB,rightB,signlessleft,signlessright)	\
22462306a36Sopenharmony_ci      ((signlessleft <= signlessright) &&				\
22562306a36Sopenharmony_ci       ( (signlessleft < signlessright) || (Dallp2(leftB)<Dallp2(rightB)) ))
22662306a36Sopenharmony_ci
22762306a36Sopenharmony_ci#define Dbl_copytoint_exponentmantissap1(src,dest) \
22862306a36Sopenharmony_ci    dest = Dexponentmantissap1(src)
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci/* A quiet NaN has the high mantissa bit clear and at least on other (in this
23162306a36Sopenharmony_ci * case the adjacent bit) bit set. */
23262306a36Sopenharmony_ci#define Dbl_set_quiet(dbl_value) Deposit_dhigh2mantissa(dbl_value,1)
23362306a36Sopenharmony_ci#define Dbl_set_exponent(dbl_value, exp) Deposit_dexponent(dbl_value,exp)
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ci#define Dbl_set_mantissa(desta,destb,valuea,valueb)	\
23662306a36Sopenharmony_ci    Deposit_dmantissap1(desta,valuea);			\
23762306a36Sopenharmony_ci    Dmantissap2(destb) = Dmantissap2(valueb)
23862306a36Sopenharmony_ci#define Dbl_set_mantissap1(desta,valuea)		\
23962306a36Sopenharmony_ci    Deposit_dmantissap1(desta,valuea)
24062306a36Sopenharmony_ci#define Dbl_set_mantissap2(destb,valueb)		\
24162306a36Sopenharmony_ci    Dmantissap2(destb) = Dmantissap2(valueb)
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci#define Dbl_set_exponentmantissa(desta,destb,valuea,valueb)	\
24462306a36Sopenharmony_ci    Deposit_dexponentmantissap1(desta,valuea);			\
24562306a36Sopenharmony_ci    Dmantissap2(destb) = Dmantissap2(valueb)
24662306a36Sopenharmony_ci#define Dbl_set_exponentmantissap1(dest,value)			\
24762306a36Sopenharmony_ci    Deposit_dexponentmantissap1(dest,value)
24862306a36Sopenharmony_ci
24962306a36Sopenharmony_ci#define Dbl_copyfromptr(src,desta,destb) \
25062306a36Sopenharmony_ci    Dallp1(desta) = src->wd0;		\
25162306a36Sopenharmony_ci    Dallp2(destb) = src->wd1
25262306a36Sopenharmony_ci#define Dbl_copytoptr(srca,srcb,dest)	\
25362306a36Sopenharmony_ci    dest->wd0 = Dallp1(srca);		\
25462306a36Sopenharmony_ci    dest->wd1 = Dallp2(srcb)
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_ci/*  An infinity is represented with the max exponent and a zero mantissa */
25762306a36Sopenharmony_ci#define Dbl_setinfinity_exponent(dbl_value) \
25862306a36Sopenharmony_ci    Deposit_dexponent(dbl_value,DBL_INFINITY_EXPONENT)
25962306a36Sopenharmony_ci#define Dbl_setinfinity_exponentmantissa(dbl_valueA,dbl_valueB)	\
26062306a36Sopenharmony_ci    Deposit_dexponentmantissap1(dbl_valueA, 			\
26162306a36Sopenharmony_ci    (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH))));	\
26262306a36Sopenharmony_ci    Dmantissap2(dbl_valueB) = 0
26362306a36Sopenharmony_ci#define Dbl_setinfinitypositive(dbl_valueA,dbl_valueB)		\
26462306a36Sopenharmony_ci    Dallp1(dbl_valueA) 						\
26562306a36Sopenharmony_ci        = (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH)));	\
26662306a36Sopenharmony_ci    Dmantissap2(dbl_valueB) = 0
26762306a36Sopenharmony_ci#define Dbl_setinfinitynegative(dbl_valueA,dbl_valueB)		\
26862306a36Sopenharmony_ci    Dallp1(dbl_valueA) = ((unsigned int)1<<31) |		\
26962306a36Sopenharmony_ci         (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH)));	\
27062306a36Sopenharmony_ci    Dmantissap2(dbl_valueB) = 0
27162306a36Sopenharmony_ci#define Dbl_setinfinity(dbl_valueA,dbl_valueB,sign)		\
27262306a36Sopenharmony_ci    Dallp1(dbl_valueA) = ((unsigned int)sign << 31) | 		\
27362306a36Sopenharmony_ci	(DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH)));	\
27462306a36Sopenharmony_ci    Dmantissap2(dbl_valueB) = 0
27562306a36Sopenharmony_ci
27662306a36Sopenharmony_ci#define Dbl_sethigh4bits(dbl_value, extsign) Deposit_dhigh4p1(dbl_value,extsign)
27762306a36Sopenharmony_ci#define Dbl_set_sign(dbl_value,sign) Deposit_dsign(dbl_value,sign)
27862306a36Sopenharmony_ci#define Dbl_invert_sign(dbl_value) Deposit_dsign(dbl_value,~Dsign(dbl_value))
27962306a36Sopenharmony_ci#define Dbl_setone_sign(dbl_value) Deposit_dsign(dbl_value,1)
28062306a36Sopenharmony_ci#define Dbl_setone_lowmantissap2(dbl_value) Deposit_dlowp2(dbl_value,1)
28162306a36Sopenharmony_ci#define Dbl_setzero_sign(dbl_value) Dallp1(dbl_value) &= 0x7fffffff
28262306a36Sopenharmony_ci#define Dbl_setzero_exponent(dbl_value) 		\
28362306a36Sopenharmony_ci    Dallp1(dbl_value) &= 0x800fffff
28462306a36Sopenharmony_ci#define Dbl_setzero_mantissa(dbl_valueA,dbl_valueB)	\
28562306a36Sopenharmony_ci    Dallp1(dbl_valueA) &= 0xfff00000; 			\
28662306a36Sopenharmony_ci    Dallp2(dbl_valueB) = 0
28762306a36Sopenharmony_ci#define Dbl_setzero_mantissap1(dbl_value) Dallp1(dbl_value) &= 0xfff00000
28862306a36Sopenharmony_ci#define Dbl_setzero_mantissap2(dbl_value) Dallp2(dbl_value) = 0
28962306a36Sopenharmony_ci#define Dbl_setzero_exponentmantissa(dbl_valueA,dbl_valueB)	\
29062306a36Sopenharmony_ci    Dallp1(dbl_valueA) &= 0x80000000;		\
29162306a36Sopenharmony_ci    Dallp2(dbl_valueB) = 0
29262306a36Sopenharmony_ci#define Dbl_setzero_exponentmantissap1(dbl_valueA)	\
29362306a36Sopenharmony_ci    Dallp1(dbl_valueA) &= 0x80000000
29462306a36Sopenharmony_ci#define Dbl_setzero(dbl_valueA,dbl_valueB) \
29562306a36Sopenharmony_ci    Dallp1(dbl_valueA) = 0; Dallp2(dbl_valueB) = 0
29662306a36Sopenharmony_ci#define Dbl_setzerop1(dbl_value) Dallp1(dbl_value) = 0
29762306a36Sopenharmony_ci#define Dbl_setzerop2(dbl_value) Dallp2(dbl_value) = 0
29862306a36Sopenharmony_ci#define Dbl_setnegativezero(dbl_value) \
29962306a36Sopenharmony_ci    Dallp1(dbl_value) = (unsigned int)1 << 31; Dallp2(dbl_value) = 0
30062306a36Sopenharmony_ci#define Dbl_setnegativezerop1(dbl_value) Dallp1(dbl_value) = (unsigned int)1<<31
30162306a36Sopenharmony_ci
30262306a36Sopenharmony_ci/* Use the following macro for both overflow & underflow conditions */
30362306a36Sopenharmony_ci#define ovfl -
30462306a36Sopenharmony_ci#define unfl +
30562306a36Sopenharmony_ci#define Dbl_setwrapped_exponent(dbl_value,exponent,op) \
30662306a36Sopenharmony_ci    Deposit_dexponent(dbl_value,(exponent op DBL_WRAP))
30762306a36Sopenharmony_ci
30862306a36Sopenharmony_ci#define Dbl_setlargestpositive(dbl_valueA,dbl_valueB) 			\
30962306a36Sopenharmony_ci    Dallp1(dbl_valueA) = ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \
31062306a36Sopenharmony_ci			| ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 );		\
31162306a36Sopenharmony_ci    Dallp2(dbl_valueB) = 0xFFFFFFFF
31262306a36Sopenharmony_ci#define Dbl_setlargestnegative(dbl_valueA,dbl_valueB) 			\
31362306a36Sopenharmony_ci    Dallp1(dbl_valueA) = ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \
31462306a36Sopenharmony_ci			| ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 )		\
31562306a36Sopenharmony_ci			| ((unsigned int)1<<31);			\
31662306a36Sopenharmony_ci    Dallp2(dbl_valueB) = 0xFFFFFFFF
31762306a36Sopenharmony_ci#define Dbl_setlargest_exponentmantissa(dbl_valueA,dbl_valueB)		\
31862306a36Sopenharmony_ci    Deposit_dexponentmantissap1(dbl_valueA,				\
31962306a36Sopenharmony_ci	(((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH)))		\
32062306a36Sopenharmony_ci			| ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 )));	\
32162306a36Sopenharmony_ci    Dallp2(dbl_valueB) = 0xFFFFFFFF
32262306a36Sopenharmony_ci
32362306a36Sopenharmony_ci#define Dbl_setnegativeinfinity(dbl_valueA,dbl_valueB) 			\
32462306a36Sopenharmony_ci    Dallp1(dbl_valueA) = ((1<<DBL_EXP_LENGTH) | DBL_INFINITY_EXPONENT) 	\
32562306a36Sopenharmony_ci			 << (32-(1+DBL_EXP_LENGTH)) ; 			\
32662306a36Sopenharmony_ci    Dallp2(dbl_valueB) = 0
32762306a36Sopenharmony_ci#define Dbl_setlargest(dbl_valueA,dbl_valueB,sign)			\
32862306a36Sopenharmony_ci    Dallp1(dbl_valueA) = ((unsigned int)sign << 31) |			\
32962306a36Sopenharmony_ci         ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) |	 	\
33062306a36Sopenharmony_ci	 ((1 << (32-(1+DBL_EXP_LENGTH))) - 1 );				\
33162306a36Sopenharmony_ci    Dallp2(dbl_valueB) = 0xFFFFFFFF
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_ci
33462306a36Sopenharmony_ci/* The high bit is always zero so arithmetic or logical shifts will work. */
33562306a36Sopenharmony_ci#define Dbl_right_align(srcdstA,srcdstB,shift,extent)			\
33662306a36Sopenharmony_ci    if( shift >= 32 ) 							\
33762306a36Sopenharmony_ci	{								\
33862306a36Sopenharmony_ci	/* Big shift requires examining the portion shift off 		\
33962306a36Sopenharmony_ci	the end to properly set inexact.  */				\
34062306a36Sopenharmony_ci	if(shift < 64)							\
34162306a36Sopenharmony_ci	    {								\
34262306a36Sopenharmony_ci	    if(shift > 32)						\
34362306a36Sopenharmony_ci		{							\
34462306a36Sopenharmony_ci	        Variable_shift_double(Dallp1(srcdstA),Dallp2(srcdstB),	\
34562306a36Sopenharmony_ci		 shift-32, Extall(extent));				\
34662306a36Sopenharmony_ci	        if(Dallp2(srcdstB) << 64 - (shift)) Ext_setone_low(extent); \
34762306a36Sopenharmony_ci	        }							\
34862306a36Sopenharmony_ci	    else Extall(extent) = Dallp2(srcdstB);			\
34962306a36Sopenharmony_ci	    Dallp2(srcdstB) = Dallp1(srcdstA) >> (shift - 32);		\
35062306a36Sopenharmony_ci	    }								\
35162306a36Sopenharmony_ci	else								\
35262306a36Sopenharmony_ci	    {								\
35362306a36Sopenharmony_ci	    Extall(extent) = Dallp1(srcdstA);				\
35462306a36Sopenharmony_ci	    if(Dallp2(srcdstB)) Ext_setone_low(extent);			\
35562306a36Sopenharmony_ci	    Dallp2(srcdstB) = 0;					\
35662306a36Sopenharmony_ci	    }								\
35762306a36Sopenharmony_ci	Dallp1(srcdstA) = 0;						\
35862306a36Sopenharmony_ci	}								\
35962306a36Sopenharmony_ci    else								\
36062306a36Sopenharmony_ci	{								\
36162306a36Sopenharmony_ci	/* Small alignment is simpler.  Extension is easily set. */	\
36262306a36Sopenharmony_ci	if (shift > 0)							\
36362306a36Sopenharmony_ci	    {								\
36462306a36Sopenharmony_ci	    Extall(extent) = Dallp2(srcdstB) << 32 - (shift);		\
36562306a36Sopenharmony_ci	    Variable_shift_double(Dallp1(srcdstA),Dallp2(srcdstB),shift, \
36662306a36Sopenharmony_ci	     Dallp2(srcdstB));						\
36762306a36Sopenharmony_ci	    Dallp1(srcdstA) >>= shift;					\
36862306a36Sopenharmony_ci	    }								\
36962306a36Sopenharmony_ci	else Extall(extent) = 0;					\
37062306a36Sopenharmony_ci	}
37162306a36Sopenharmony_ci
37262306a36Sopenharmony_ci/*
37362306a36Sopenharmony_ci * Here we need to shift the result right to correct for an overshift
37462306a36Sopenharmony_ci * (due to the exponent becoming negative) during normalization.
37562306a36Sopenharmony_ci */
37662306a36Sopenharmony_ci#define Dbl_fix_overshift(srcdstA,srcdstB,shift,extent)			\
37762306a36Sopenharmony_ci	    Extall(extent) = Dallp2(srcdstB) << 32 - (shift);		\
37862306a36Sopenharmony_ci	    Dallp2(srcdstB) = (Dallp1(srcdstA) << 32 - (shift)) |	\
37962306a36Sopenharmony_ci		(Dallp2(srcdstB) >> (shift));				\
38062306a36Sopenharmony_ci	    Dallp1(srcdstA) = Dallp1(srcdstA) >> shift
38162306a36Sopenharmony_ci
38262306a36Sopenharmony_ci#define Dbl_hiddenhigh3mantissa(dbl_value) Dhiddenhigh3mantissa(dbl_value)
38362306a36Sopenharmony_ci#define Dbl_hidden(dbl_value) Dhidden(dbl_value)
38462306a36Sopenharmony_ci#define Dbl_lowmantissap2(dbl_value) Dlowp2(dbl_value)
38562306a36Sopenharmony_ci
38662306a36Sopenharmony_ci/* The left argument is never smaller than the right argument */
38762306a36Sopenharmony_ci#define Dbl_subtract(lefta,leftb,righta,rightb,resulta,resultb)			\
38862306a36Sopenharmony_ci    if( Dallp2(rightb) > Dallp2(leftb) ) Dallp1(lefta)--;	\
38962306a36Sopenharmony_ci    Dallp2(resultb) = Dallp2(leftb) - Dallp2(rightb);		\
39062306a36Sopenharmony_ci    Dallp1(resulta) = Dallp1(lefta) - Dallp1(righta)
39162306a36Sopenharmony_ci
39262306a36Sopenharmony_ci/* Subtract right augmented with extension from left augmented with zeros and
39362306a36Sopenharmony_ci * store into result and extension. */
39462306a36Sopenharmony_ci#define Dbl_subtract_withextension(lefta,leftb,righta,rightb,extent,resulta,resultb)	\
39562306a36Sopenharmony_ci    Dbl_subtract(lefta,leftb,righta,rightb,resulta,resultb);		\
39662306a36Sopenharmony_ci    if( (Extall(extent) = 0-Extall(extent)) )				\
39762306a36Sopenharmony_ci        {								\
39862306a36Sopenharmony_ci        if((Dallp2(resultb)--) == 0) Dallp1(resulta)--;			\
39962306a36Sopenharmony_ci        }
40062306a36Sopenharmony_ci
40162306a36Sopenharmony_ci#define Dbl_addition(lefta,leftb,righta,rightb,resulta,resultb)		\
40262306a36Sopenharmony_ci    /* If the sum of the low words is less than either source, then	\
40362306a36Sopenharmony_ci     * an overflow into the next word occurred. */			\
40462306a36Sopenharmony_ci    Dallp1(resulta) = Dallp1(lefta) + Dallp1(righta);			\
40562306a36Sopenharmony_ci    if((Dallp2(resultb) = Dallp2(leftb) + Dallp2(rightb)) < Dallp2(rightb)) \
40662306a36Sopenharmony_ci	Dallp1(resulta)++
40762306a36Sopenharmony_ci
40862306a36Sopenharmony_ci#define Dbl_xortointp1(left,right,result)			\
40962306a36Sopenharmony_ci    result = Dallp1(left) XOR Dallp1(right)
41062306a36Sopenharmony_ci
41162306a36Sopenharmony_ci#define Dbl_xorfromintp1(left,right,result)			\
41262306a36Sopenharmony_ci    Dallp1(result) = left XOR Dallp1(right)
41362306a36Sopenharmony_ci
41462306a36Sopenharmony_ci#define Dbl_swap_lower(left,right)				\
41562306a36Sopenharmony_ci    Dallp2(left)  = Dallp2(left) XOR Dallp2(right);		\
41662306a36Sopenharmony_ci    Dallp2(right) = Dallp2(left) XOR Dallp2(right);		\
41762306a36Sopenharmony_ci    Dallp2(left)  = Dallp2(left) XOR Dallp2(right)
41862306a36Sopenharmony_ci
41962306a36Sopenharmony_ci/* Need to Initialize */
42062306a36Sopenharmony_ci#define Dbl_makequietnan(desta,destb)					\
42162306a36Sopenharmony_ci    Dallp1(desta) = ((DBL_EMAX+DBL_BIAS)+1)<< (32-(1+DBL_EXP_LENGTH))	\
42262306a36Sopenharmony_ci                 | (1<<(32-(1+DBL_EXP_LENGTH+2)));			\
42362306a36Sopenharmony_ci    Dallp2(destb) = 0
42462306a36Sopenharmony_ci#define Dbl_makesignalingnan(desta,destb)				\
42562306a36Sopenharmony_ci    Dallp1(desta) = ((DBL_EMAX+DBL_BIAS)+1)<< (32-(1+DBL_EXP_LENGTH))	\
42662306a36Sopenharmony_ci                 | (1<<(32-(1+DBL_EXP_LENGTH+1)));			\
42762306a36Sopenharmony_ci    Dallp2(destb) = 0
42862306a36Sopenharmony_ci
42962306a36Sopenharmony_ci#define Dbl_normalize(dbl_opndA,dbl_opndB,exponent)			\
43062306a36Sopenharmony_ci	while(Dbl_iszero_hiddenhigh7mantissa(dbl_opndA)) {		\
43162306a36Sopenharmony_ci		Dbl_leftshiftby8(dbl_opndA,dbl_opndB);			\
43262306a36Sopenharmony_ci		exponent -= 8;						\
43362306a36Sopenharmony_ci	}								\
43462306a36Sopenharmony_ci	if(Dbl_iszero_hiddenhigh3mantissa(dbl_opndA)) {			\
43562306a36Sopenharmony_ci		Dbl_leftshiftby4(dbl_opndA,dbl_opndB);			\
43662306a36Sopenharmony_ci		exponent -= 4;						\
43762306a36Sopenharmony_ci	}								\
43862306a36Sopenharmony_ci	while(Dbl_iszero_hidden(dbl_opndA)) {				\
43962306a36Sopenharmony_ci		Dbl_leftshiftby1(dbl_opndA,dbl_opndB);			\
44062306a36Sopenharmony_ci		exponent -= 1;						\
44162306a36Sopenharmony_ci	}
44262306a36Sopenharmony_ci
44362306a36Sopenharmony_ci#define Twoword_add(src1dstA,src1dstB,src2A,src2B)		\
44462306a36Sopenharmony_ci	/* 							\
44562306a36Sopenharmony_ci	 * want this macro to generate:				\
44662306a36Sopenharmony_ci	 *	ADD	src1dstB,src2B,src1dstB;		\
44762306a36Sopenharmony_ci	 *	ADDC	src1dstA,src2A,src1dstA;		\
44862306a36Sopenharmony_ci	 */							\
44962306a36Sopenharmony_ci	if ((src1dstB) + (src2B) < (src1dstB)) Dallp1(src1dstA)++; \
45062306a36Sopenharmony_ci	Dallp1(src1dstA) += (src2A);				\
45162306a36Sopenharmony_ci	Dallp2(src1dstB) += (src2B)
45262306a36Sopenharmony_ci
45362306a36Sopenharmony_ci#define Twoword_subtract(src1dstA,src1dstB,src2A,src2B)		\
45462306a36Sopenharmony_ci	/* 							\
45562306a36Sopenharmony_ci	 * want this macro to generate:				\
45662306a36Sopenharmony_ci	 *	SUB	src1dstB,src2B,src1dstB;		\
45762306a36Sopenharmony_ci	 *	SUBB	src1dstA,src2A,src1dstA;		\
45862306a36Sopenharmony_ci	 */							\
45962306a36Sopenharmony_ci	if ((src1dstB) < (src2B)) Dallp1(src1dstA)--;		\
46062306a36Sopenharmony_ci	Dallp1(src1dstA) -= (src2A);				\
46162306a36Sopenharmony_ci	Dallp2(src1dstB) -= (src2B)
46262306a36Sopenharmony_ci
46362306a36Sopenharmony_ci#define Dbl_setoverflow(resultA,resultB)				\
46462306a36Sopenharmony_ci	/* set result to infinity or largest number */			\
46562306a36Sopenharmony_ci	switch (Rounding_mode()) {					\
46662306a36Sopenharmony_ci		case ROUNDPLUS:						\
46762306a36Sopenharmony_ci			if (Dbl_isone_sign(resultA)) {			\
46862306a36Sopenharmony_ci				Dbl_setlargestnegative(resultA,resultB); \
46962306a36Sopenharmony_ci			}						\
47062306a36Sopenharmony_ci			else {						\
47162306a36Sopenharmony_ci				Dbl_setinfinitypositive(resultA,resultB); \
47262306a36Sopenharmony_ci			}						\
47362306a36Sopenharmony_ci			break;						\
47462306a36Sopenharmony_ci		case ROUNDMINUS:					\
47562306a36Sopenharmony_ci			if (Dbl_iszero_sign(resultA)) {			\
47662306a36Sopenharmony_ci				Dbl_setlargestpositive(resultA,resultB); \
47762306a36Sopenharmony_ci			}						\
47862306a36Sopenharmony_ci			else {						\
47962306a36Sopenharmony_ci				Dbl_setinfinitynegative(resultA,resultB); \
48062306a36Sopenharmony_ci			}						\
48162306a36Sopenharmony_ci			break;						\
48262306a36Sopenharmony_ci		case ROUNDNEAREST:					\
48362306a36Sopenharmony_ci			Dbl_setinfinity_exponentmantissa(resultA,resultB); \
48462306a36Sopenharmony_ci			break;						\
48562306a36Sopenharmony_ci		case ROUNDZERO:						\
48662306a36Sopenharmony_ci			Dbl_setlargest_exponentmantissa(resultA,resultB); \
48762306a36Sopenharmony_ci	}
48862306a36Sopenharmony_ci
48962306a36Sopenharmony_ci#define Dbl_denormalize(opndp1,opndp2,exponent,guard,sticky,inexact)	\
49062306a36Sopenharmony_ci    Dbl_clear_signexponent_set_hidden(opndp1);				\
49162306a36Sopenharmony_ci    if (exponent >= (1-DBL_P)) {					\
49262306a36Sopenharmony_ci	if (exponent >= -31) {						\
49362306a36Sopenharmony_ci	    guard = (Dallp2(opndp2) >> -exponent) & 1;			\
49462306a36Sopenharmony_ci	    if (exponent < 0) sticky |= Dallp2(opndp2) << (32+exponent); \
49562306a36Sopenharmony_ci	    if (exponent > -31) {					\
49662306a36Sopenharmony_ci		Variable_shift_double(opndp1,opndp2,1-exponent,opndp2);	\
49762306a36Sopenharmony_ci		Dallp1(opndp1) >>= 1-exponent;				\
49862306a36Sopenharmony_ci	    }								\
49962306a36Sopenharmony_ci	    else {							\
50062306a36Sopenharmony_ci		Dallp2(opndp2) = Dallp1(opndp1);			\
50162306a36Sopenharmony_ci		Dbl_setzerop1(opndp1);					\
50262306a36Sopenharmony_ci	    }								\
50362306a36Sopenharmony_ci	}								\
50462306a36Sopenharmony_ci	else {								\
50562306a36Sopenharmony_ci	    guard = (Dallp1(opndp1) >> -32-exponent) & 1;		\
50662306a36Sopenharmony_ci	    if (exponent == -32) sticky |= Dallp2(opndp2);		\
50762306a36Sopenharmony_ci	    else sticky |= (Dallp2(opndp2) | Dallp1(opndp1) << 64+exponent); \
50862306a36Sopenharmony_ci	    Dallp2(opndp2) = Dallp1(opndp1) >> -31-exponent;		\
50962306a36Sopenharmony_ci	    Dbl_setzerop1(opndp1);					\
51062306a36Sopenharmony_ci	}								\
51162306a36Sopenharmony_ci	inexact = guard | sticky;					\
51262306a36Sopenharmony_ci    }									\
51362306a36Sopenharmony_ci    else {								\
51462306a36Sopenharmony_ci	guard = 0;							\
51562306a36Sopenharmony_ci	sticky |= (Dallp1(opndp1) | Dallp2(opndp2));			\
51662306a36Sopenharmony_ci	Dbl_setzero(opndp1,opndp2);					\
51762306a36Sopenharmony_ci	inexact = sticky;						\
51862306a36Sopenharmony_ci    }
51962306a36Sopenharmony_ci
52062306a36Sopenharmony_ci/*
52162306a36Sopenharmony_ci * The fused multiply add instructions requires a double extended format,
52262306a36Sopenharmony_ci * with 106 bits of mantissa.
52362306a36Sopenharmony_ci */
52462306a36Sopenharmony_ci#define DBLEXT_THRESHOLD 106
52562306a36Sopenharmony_ci
52662306a36Sopenharmony_ci#define Dblext_setzero(valA,valB,valC,valD)	\
52762306a36Sopenharmony_ci    Dextallp1(valA) = 0; Dextallp2(valB) = 0;	\
52862306a36Sopenharmony_ci    Dextallp3(valC) = 0; Dextallp4(valD) = 0
52962306a36Sopenharmony_ci
53062306a36Sopenharmony_ci
53162306a36Sopenharmony_ci#define Dblext_isnotzero_mantissap3(valC) (Dextallp3(valC)!=0)
53262306a36Sopenharmony_ci#define Dblext_isnotzero_mantissap4(valD) (Dextallp3(valD)!=0)
53362306a36Sopenharmony_ci#define Dblext_isone_lowp2(val) (Dextlowp2(val)!=0)
53462306a36Sopenharmony_ci#define Dblext_isone_highp3(val) (Dexthighp3(val)!=0)
53562306a36Sopenharmony_ci#define Dblext_isnotzero_low31p3(val) (Dextlow31p3(val)!=0)
53662306a36Sopenharmony_ci#define Dblext_iszero(valA,valB,valC,valD) (Dextallp1(valA)==0 && \
53762306a36Sopenharmony_ci    Dextallp2(valB)==0 && Dextallp3(valC)==0 && Dextallp4(valD)==0)
53862306a36Sopenharmony_ci
53962306a36Sopenharmony_ci#define Dblext_copy(srca,srcb,srcc,srcd,desta,destb,destc,destd) \
54062306a36Sopenharmony_ci    Dextallp1(desta) = Dextallp4(srca);	\
54162306a36Sopenharmony_ci    Dextallp2(destb) = Dextallp4(srcb);	\
54262306a36Sopenharmony_ci    Dextallp3(destc) = Dextallp4(srcc);	\
54362306a36Sopenharmony_ci    Dextallp4(destd) = Dextallp4(srcd)
54462306a36Sopenharmony_ci
54562306a36Sopenharmony_ci#define Dblext_swap_lower(leftp2,leftp3,leftp4,rightp2,rightp3,rightp4)  \
54662306a36Sopenharmony_ci    Dextallp2(leftp2)  = Dextallp2(leftp2) XOR Dextallp2(rightp2);  \
54762306a36Sopenharmony_ci    Dextallp2(rightp2) = Dextallp2(leftp2) XOR Dextallp2(rightp2);  \
54862306a36Sopenharmony_ci    Dextallp2(leftp2)  = Dextallp2(leftp2) XOR Dextallp2(rightp2);  \
54962306a36Sopenharmony_ci    Dextallp3(leftp3)  = Dextallp3(leftp3) XOR Dextallp3(rightp3);  \
55062306a36Sopenharmony_ci    Dextallp3(rightp3) = Dextallp3(leftp3) XOR Dextallp3(rightp3);  \
55162306a36Sopenharmony_ci    Dextallp3(leftp3)  = Dextallp3(leftp3) XOR Dextallp3(rightp3);  \
55262306a36Sopenharmony_ci    Dextallp4(leftp4)  = Dextallp4(leftp4) XOR Dextallp4(rightp4);  \
55362306a36Sopenharmony_ci    Dextallp4(rightp4) = Dextallp4(leftp4) XOR Dextallp4(rightp4);  \
55462306a36Sopenharmony_ci    Dextallp4(leftp4)  = Dextallp4(leftp4) XOR Dextallp4(rightp4)
55562306a36Sopenharmony_ci
55662306a36Sopenharmony_ci#define Dblext_setone_lowmantissap4(dbl_value) Deposit_dextlowp4(dbl_value,1)
55762306a36Sopenharmony_ci
55862306a36Sopenharmony_ci/* The high bit is always zero so arithmetic or logical shifts will work. */
55962306a36Sopenharmony_ci#define Dblext_right_align(srcdstA,srcdstB,srcdstC,srcdstD,shift) \
56062306a36Sopenharmony_ci  {int shiftamt, sticky;						\
56162306a36Sopenharmony_ci    shiftamt = shift % 32;						\
56262306a36Sopenharmony_ci    sticky = 0;								\
56362306a36Sopenharmony_ci    switch (shift/32) {							\
56462306a36Sopenharmony_ci     case 0: if (shiftamt > 0) {					\
56562306a36Sopenharmony_ci	        sticky = Dextallp4(srcdstD) << 32 - (shiftamt); 	\
56662306a36Sopenharmony_ci                Variable_shift_double(Dextallp3(srcdstC),		\
56762306a36Sopenharmony_ci		 Dextallp4(srcdstD),shiftamt,Dextallp4(srcdstD));	\
56862306a36Sopenharmony_ci                Variable_shift_double(Dextallp2(srcdstB),		\
56962306a36Sopenharmony_ci		 Dextallp3(srcdstC),shiftamt,Dextallp3(srcdstC));	\
57062306a36Sopenharmony_ci                Variable_shift_double(Dextallp1(srcdstA),		\
57162306a36Sopenharmony_ci		 Dextallp2(srcdstB),shiftamt,Dextallp2(srcdstB));	\
57262306a36Sopenharmony_ci	        Dextallp1(srcdstA) >>= shiftamt;			\
57362306a36Sopenharmony_ci	     }								\
57462306a36Sopenharmony_ci	     break;							\
57562306a36Sopenharmony_ci     case 1: if (shiftamt > 0) {					\
57662306a36Sopenharmony_ci                sticky = (Dextallp3(srcdstC) << 31 - shiftamt) |	\
57762306a36Sopenharmony_ci			 Dextallp4(srcdstD);				\
57862306a36Sopenharmony_ci                Variable_shift_double(Dextallp2(srcdstB),		\
57962306a36Sopenharmony_ci		 Dextallp3(srcdstC),shiftamt,Dextallp4(srcdstD));	\
58062306a36Sopenharmony_ci                Variable_shift_double(Dextallp1(srcdstA),		\
58162306a36Sopenharmony_ci		 Dextallp2(srcdstB),shiftamt,Dextallp3(srcdstC));	\
58262306a36Sopenharmony_ci	     }								\
58362306a36Sopenharmony_ci	     else {							\
58462306a36Sopenharmony_ci		sticky = Dextallp4(srcdstD);				\
58562306a36Sopenharmony_ci		Dextallp4(srcdstD) = Dextallp3(srcdstC);		\
58662306a36Sopenharmony_ci		Dextallp3(srcdstC) = Dextallp2(srcdstB);		\
58762306a36Sopenharmony_ci	     }								\
58862306a36Sopenharmony_ci	     Dextallp2(srcdstB) = Dextallp1(srcdstA) >> shiftamt;	\
58962306a36Sopenharmony_ci	     Dextallp1(srcdstA) = 0;					\
59062306a36Sopenharmony_ci	     break;							\
59162306a36Sopenharmony_ci     case 2: if (shiftamt > 0) {					\
59262306a36Sopenharmony_ci                sticky = (Dextallp2(srcdstB) << 31 - shiftamt) |	\
59362306a36Sopenharmony_ci			 Dextallp3(srcdstC) | Dextallp4(srcdstD);	\
59462306a36Sopenharmony_ci                Variable_shift_double(Dextallp1(srcdstA),		\
59562306a36Sopenharmony_ci		 Dextallp2(srcdstB),shiftamt,Dextallp4(srcdstD));	\
59662306a36Sopenharmony_ci	     }								\
59762306a36Sopenharmony_ci	     else {							\
59862306a36Sopenharmony_ci		sticky = Dextallp3(srcdstC) | Dextallp4(srcdstD);	\
59962306a36Sopenharmony_ci		Dextallp4(srcdstD) = Dextallp2(srcdstB);		\
60062306a36Sopenharmony_ci	     }								\
60162306a36Sopenharmony_ci	     Dextallp3(srcdstC) = Dextallp1(srcdstA) >> shiftamt;	\
60262306a36Sopenharmony_ci	     Dextallp1(srcdstA) = Dextallp2(srcdstB) = 0;		\
60362306a36Sopenharmony_ci	     break;							\
60462306a36Sopenharmony_ci     case 3: if (shiftamt > 0) {					\
60562306a36Sopenharmony_ci                sticky = (Dextallp1(srcdstA) << 31 - shiftamt) |	\
60662306a36Sopenharmony_ci			 Dextallp2(srcdstB) | Dextallp3(srcdstC) |	\
60762306a36Sopenharmony_ci			 Dextallp4(srcdstD);				\
60862306a36Sopenharmony_ci	     }								\
60962306a36Sopenharmony_ci	     else {							\
61062306a36Sopenharmony_ci		sticky = Dextallp2(srcdstB) | Dextallp3(srcdstC) |	\
61162306a36Sopenharmony_ci		    Dextallp4(srcdstD);					\
61262306a36Sopenharmony_ci	     }								\
61362306a36Sopenharmony_ci	     Dextallp4(srcdstD) = Dextallp1(srcdstA) >> shiftamt;	\
61462306a36Sopenharmony_ci	     Dextallp1(srcdstA) = Dextallp2(srcdstB) = 0;		\
61562306a36Sopenharmony_ci	     Dextallp3(srcdstC) = 0;					\
61662306a36Sopenharmony_ci	     break;							\
61762306a36Sopenharmony_ci    }									\
61862306a36Sopenharmony_ci    if (sticky) Dblext_setone_lowmantissap4(srcdstD);			\
61962306a36Sopenharmony_ci  }
62062306a36Sopenharmony_ci
62162306a36Sopenharmony_ci/* The left argument is never smaller than the right argument */
62262306a36Sopenharmony_ci#define Dblext_subtract(lefta,leftb,leftc,leftd,righta,rightb,rightc,rightd,resulta,resultb,resultc,resultd) \
62362306a36Sopenharmony_ci    if( Dextallp4(rightd) > Dextallp4(leftd) ) 			\
62462306a36Sopenharmony_ci	if( (Dextallp3(leftc)--) == 0)				\
62562306a36Sopenharmony_ci	    if( (Dextallp2(leftb)--) == 0) Dextallp1(lefta)--;	\
62662306a36Sopenharmony_ci    Dextallp4(resultd) = Dextallp4(leftd) - Dextallp4(rightd);	\
62762306a36Sopenharmony_ci    if( Dextallp3(rightc) > Dextallp3(leftc) ) 			\
62862306a36Sopenharmony_ci        if( (Dextallp2(leftb)--) == 0) Dextallp1(lefta)--;	\
62962306a36Sopenharmony_ci    Dextallp3(resultc) = Dextallp3(leftc) - Dextallp3(rightc);	\
63062306a36Sopenharmony_ci    if( Dextallp2(rightb) > Dextallp2(leftb) ) Dextallp1(lefta)--; \
63162306a36Sopenharmony_ci    Dextallp2(resultb) = Dextallp2(leftb) - Dextallp2(rightb);	\
63262306a36Sopenharmony_ci    Dextallp1(resulta) = Dextallp1(lefta) - Dextallp1(righta)
63362306a36Sopenharmony_ci
63462306a36Sopenharmony_ci#define Dblext_addition(lefta,leftb,leftc,leftd,righta,rightb,rightc,rightd,resulta,resultb,resultc,resultd) \
63562306a36Sopenharmony_ci    /* If the sum of the low words is less than either source, then \
63662306a36Sopenharmony_ci     * an overflow into the next word occurred. */ \
63762306a36Sopenharmony_ci    if ((Dextallp4(resultd) = Dextallp4(leftd)+Dextallp4(rightd)) < \
63862306a36Sopenharmony_ci	Dextallp4(rightd)) \
63962306a36Sopenharmony_ci	if((Dextallp3(resultc) = Dextallp3(leftc)+Dextallp3(rightc)+1) <= \
64062306a36Sopenharmony_ci	    Dextallp3(rightc)) \
64162306a36Sopenharmony_ci	    if((Dextallp2(resultb) = Dextallp2(leftb)+Dextallp2(rightb)+1) \
64262306a36Sopenharmony_ci	        <= Dextallp2(rightb))  \
64362306a36Sopenharmony_ci		    Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)+1; \
64462306a36Sopenharmony_ci	    else Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta); \
64562306a36Sopenharmony_ci	else \
64662306a36Sopenharmony_ci	    if ((Dextallp2(resultb) = Dextallp2(leftb)+Dextallp2(rightb)) < \
64762306a36Sopenharmony_ci	        Dextallp2(rightb)) \
64862306a36Sopenharmony_ci		    Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)+1; \
64962306a36Sopenharmony_ci	    else Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta); \
65062306a36Sopenharmony_ci    else \
65162306a36Sopenharmony_ci	if ((Dextallp3(resultc) = Dextallp3(leftc)+Dextallp3(rightc)) < \
65262306a36Sopenharmony_ci	    Dextallp3(rightc))  \
65362306a36Sopenharmony_ci	    if ((Dextallp2(resultb) = Dextallp2(leftb)+Dextallp2(rightb)+1) \
65462306a36Sopenharmony_ci	        <= Dextallp2(rightb)) \
65562306a36Sopenharmony_ci		    Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)+1; \
65662306a36Sopenharmony_ci	    else Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta); \
65762306a36Sopenharmony_ci	else \
65862306a36Sopenharmony_ci	    if ((Dextallp2(resultb) = Dextallp2(leftb)+Dextallp2(rightb)) < \
65962306a36Sopenharmony_ci	        Dextallp2(rightb)) \
66062306a36Sopenharmony_ci		    Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)+1; \
66162306a36Sopenharmony_ci	    else Dextallp1(resulta) = Dextallp1(lefta)+Dextallp1(righta)
66262306a36Sopenharmony_ci
66362306a36Sopenharmony_ci
66462306a36Sopenharmony_ci#define Dblext_arithrightshiftby1(srcdstA,srcdstB,srcdstC,srcdstD)	\
66562306a36Sopenharmony_ci    Shiftdouble(Dextallp3(srcdstC),Dextallp4(srcdstD),1,Dextallp4(srcdstD)); \
66662306a36Sopenharmony_ci    Shiftdouble(Dextallp2(srcdstB),Dextallp3(srcdstC),1,Dextallp3(srcdstC)); \
66762306a36Sopenharmony_ci    Shiftdouble(Dextallp1(srcdstA),Dextallp2(srcdstB),1,Dextallp2(srcdstB)); \
66862306a36Sopenharmony_ci    Dextallp1(srcdstA) = (int)Dextallp1(srcdstA) >> 1
66962306a36Sopenharmony_ci
67062306a36Sopenharmony_ci#define Dblext_leftshiftby8(valA,valB,valC,valD) \
67162306a36Sopenharmony_ci    Shiftdouble(Dextallp1(valA),Dextallp2(valB),24,Dextallp1(valA)); \
67262306a36Sopenharmony_ci    Shiftdouble(Dextallp2(valB),Dextallp3(valC),24,Dextallp2(valB)); \
67362306a36Sopenharmony_ci    Shiftdouble(Dextallp3(valC),Dextallp4(valD),24,Dextallp3(valC)); \
67462306a36Sopenharmony_ci    Dextallp4(valD) <<= 8
67562306a36Sopenharmony_ci#define Dblext_leftshiftby4(valA,valB,valC,valD) \
67662306a36Sopenharmony_ci    Shiftdouble(Dextallp1(valA),Dextallp2(valB),28,Dextallp1(valA)); \
67762306a36Sopenharmony_ci    Shiftdouble(Dextallp2(valB),Dextallp3(valC),28,Dextallp2(valB)); \
67862306a36Sopenharmony_ci    Shiftdouble(Dextallp3(valC),Dextallp4(valD),28,Dextallp3(valC)); \
67962306a36Sopenharmony_ci    Dextallp4(valD) <<= 4
68062306a36Sopenharmony_ci#define Dblext_leftshiftby3(valA,valB,valC,valD) \
68162306a36Sopenharmony_ci    Shiftdouble(Dextallp1(valA),Dextallp2(valB),29,Dextallp1(valA)); \
68262306a36Sopenharmony_ci    Shiftdouble(Dextallp2(valB),Dextallp3(valC),29,Dextallp2(valB)); \
68362306a36Sopenharmony_ci    Shiftdouble(Dextallp3(valC),Dextallp4(valD),29,Dextallp3(valC)); \
68462306a36Sopenharmony_ci    Dextallp4(valD) <<= 3
68562306a36Sopenharmony_ci#define Dblext_leftshiftby2(valA,valB,valC,valD) \
68662306a36Sopenharmony_ci    Shiftdouble(Dextallp1(valA),Dextallp2(valB),30,Dextallp1(valA)); \
68762306a36Sopenharmony_ci    Shiftdouble(Dextallp2(valB),Dextallp3(valC),30,Dextallp2(valB)); \
68862306a36Sopenharmony_ci    Shiftdouble(Dextallp3(valC),Dextallp4(valD),30,Dextallp3(valC)); \
68962306a36Sopenharmony_ci    Dextallp4(valD) <<= 2
69062306a36Sopenharmony_ci#define Dblext_leftshiftby1(valA,valB,valC,valD) \
69162306a36Sopenharmony_ci    Shiftdouble(Dextallp1(valA),Dextallp2(valB),31,Dextallp1(valA)); \
69262306a36Sopenharmony_ci    Shiftdouble(Dextallp2(valB),Dextallp3(valC),31,Dextallp2(valB)); \
69362306a36Sopenharmony_ci    Shiftdouble(Dextallp3(valC),Dextallp4(valD),31,Dextallp3(valC)); \
69462306a36Sopenharmony_ci    Dextallp4(valD) <<= 1
69562306a36Sopenharmony_ci
69662306a36Sopenharmony_ci#define Dblext_rightshiftby4(valueA,valueB,valueC,valueD) \
69762306a36Sopenharmony_ci    Shiftdouble(Dextallp3(valueC),Dextallp4(valueD),4,Dextallp4(valueD)); \
69862306a36Sopenharmony_ci    Shiftdouble(Dextallp2(valueB),Dextallp3(valueC),4,Dextallp3(valueC)); \
69962306a36Sopenharmony_ci    Shiftdouble(Dextallp1(valueA),Dextallp2(valueB),4,Dextallp2(valueB)); \
70062306a36Sopenharmony_ci    Dextallp1(valueA) >>= 4
70162306a36Sopenharmony_ci#define Dblext_rightshiftby1(valueA,valueB,valueC,valueD) \
70262306a36Sopenharmony_ci    Shiftdouble(Dextallp3(valueC),Dextallp4(valueD),1,Dextallp4(valueD)); \
70362306a36Sopenharmony_ci    Shiftdouble(Dextallp2(valueB),Dextallp3(valueC),1,Dextallp3(valueC)); \
70462306a36Sopenharmony_ci    Shiftdouble(Dextallp1(valueA),Dextallp2(valueB),1,Dextallp2(valueB)); \
70562306a36Sopenharmony_ci    Dextallp1(valueA) >>= 1
70662306a36Sopenharmony_ci
70762306a36Sopenharmony_ci#define Dblext_xortointp1(left,right,result) Dbl_xortointp1(left,right,result)
70862306a36Sopenharmony_ci
70962306a36Sopenharmony_ci#define Dblext_xorfromintp1(left,right,result) \
71062306a36Sopenharmony_ci	Dbl_xorfromintp1(left,right,result)
71162306a36Sopenharmony_ci
71262306a36Sopenharmony_ci#define Dblext_copytoint_exponentmantissap1(src,dest) \
71362306a36Sopenharmony_ci	Dbl_copytoint_exponentmantissap1(src,dest)
71462306a36Sopenharmony_ci
71562306a36Sopenharmony_ci#define Dblext_ismagnitudeless(leftB,rightB,signlessleft,signlessright) \
71662306a36Sopenharmony_ci	Dbl_ismagnitudeless(leftB,rightB,signlessleft,signlessright)
71762306a36Sopenharmony_ci
71862306a36Sopenharmony_ci#define Dbl_copyto_dblext(src1,src2,dest1,dest2,dest3,dest4) \
71962306a36Sopenharmony_ci	Dextallp1(dest1) = Dallp1(src1); Dextallp2(dest2) = Dallp2(src2); \
72062306a36Sopenharmony_ci	Dextallp3(dest3) = 0; Dextallp4(dest4) = 0
72162306a36Sopenharmony_ci
72262306a36Sopenharmony_ci#define Dblext_set_sign(dbl_value,sign)  Dbl_set_sign(dbl_value,sign)
72362306a36Sopenharmony_ci#define Dblext_clear_signexponent_set_hidden(srcdst) \
72462306a36Sopenharmony_ci	Dbl_clear_signexponent_set_hidden(srcdst)
72562306a36Sopenharmony_ci#define Dblext_clear_signexponent(srcdst) Dbl_clear_signexponent(srcdst)
72662306a36Sopenharmony_ci#define Dblext_clear_sign(srcdst) Dbl_clear_sign(srcdst)
72762306a36Sopenharmony_ci#define Dblext_isone_hidden(dbl_value) Dbl_isone_hidden(dbl_value)
72862306a36Sopenharmony_ci
72962306a36Sopenharmony_ci/*
73062306a36Sopenharmony_ci * The Fourword_add() macro assumes that integers are 4 bytes in size.
73162306a36Sopenharmony_ci * It will break if this is not the case.
73262306a36Sopenharmony_ci */
73362306a36Sopenharmony_ci
73462306a36Sopenharmony_ci#define Fourword_add(src1dstA,src1dstB,src1dstC,src1dstD,src2A,src2B,src2C,src2D) \
73562306a36Sopenharmony_ci	/* 								\
73662306a36Sopenharmony_ci	 * want this macro to generate:					\
73762306a36Sopenharmony_ci	 *	ADD	src1dstD,src2D,src1dstD;			\
73862306a36Sopenharmony_ci	 *	ADDC	src1dstC,src2C,src1dstC;			\
73962306a36Sopenharmony_ci	 *	ADDC	src1dstB,src2B,src1dstB;			\
74062306a36Sopenharmony_ci	 *	ADDC	src1dstA,src2A,src1dstA;			\
74162306a36Sopenharmony_ci	 */								\
74262306a36Sopenharmony_ci	if ((unsigned int)(src1dstD += (src2D)) < (unsigned int)(src2D)) { \
74362306a36Sopenharmony_ci	   if ((unsigned int)(src1dstC += (src2C) + 1) <=		\
74462306a36Sopenharmony_ci	       (unsigned int)(src2C)) {					\
74562306a36Sopenharmony_ci	     if ((unsigned int)(src1dstB += (src2B) + 1) <=		\
74662306a36Sopenharmony_ci		 (unsigned int)(src2B)) src1dstA++;			\
74762306a36Sopenharmony_ci	   }								\
74862306a36Sopenharmony_ci	   else if ((unsigned int)(src1dstB += (src2B)) < 		\
74962306a36Sopenharmony_ci		    (unsigned int)(src2B)) src1dstA++;			\
75062306a36Sopenharmony_ci	}								\
75162306a36Sopenharmony_ci	else {								\
75262306a36Sopenharmony_ci	   if ((unsigned int)(src1dstC += (src2C)) <			\
75362306a36Sopenharmony_ci	       (unsigned int)(src2C)) {					\
75462306a36Sopenharmony_ci	      if ((unsigned int)(src1dstB += (src2B) + 1) <=		\
75562306a36Sopenharmony_ci		  (unsigned int)(src2B)) src1dstA++;			\
75662306a36Sopenharmony_ci	   }								\
75762306a36Sopenharmony_ci	   else if ((unsigned int)(src1dstB += (src2B)) <		\
75862306a36Sopenharmony_ci		    (unsigned int)(src2B)) src1dstA++;			\
75962306a36Sopenharmony_ci	}								\
76062306a36Sopenharmony_ci	src1dstA += (src2A)
76162306a36Sopenharmony_ci
76262306a36Sopenharmony_ci#define Dblext_denormalize(opndp1,opndp2,opndp3,opndp4,exponent,is_tiny) \
76362306a36Sopenharmony_ci  {int shiftamt, sticky;						\
76462306a36Sopenharmony_ci    is_tiny = TRUE;							\
76562306a36Sopenharmony_ci    if (exponent == 0 && (Dextallp3(opndp3) || Dextallp4(opndp4))) {	\
76662306a36Sopenharmony_ci	switch (Rounding_mode()) {					\
76762306a36Sopenharmony_ci	case ROUNDPLUS:							\
76862306a36Sopenharmony_ci		if (Dbl_iszero_sign(opndp1)) {				\
76962306a36Sopenharmony_ci			Dbl_increment(opndp1,opndp2);			\
77062306a36Sopenharmony_ci			if (Dbl_isone_hiddenoverflow(opndp1))		\
77162306a36Sopenharmony_ci				is_tiny = FALSE;			\
77262306a36Sopenharmony_ci			Dbl_decrement(opndp1,opndp2);			\
77362306a36Sopenharmony_ci		}							\
77462306a36Sopenharmony_ci		break;							\
77562306a36Sopenharmony_ci	case ROUNDMINUS:						\
77662306a36Sopenharmony_ci		if (Dbl_isone_sign(opndp1)) {				\
77762306a36Sopenharmony_ci			Dbl_increment(opndp1,opndp2);			\
77862306a36Sopenharmony_ci			if (Dbl_isone_hiddenoverflow(opndp1))		\
77962306a36Sopenharmony_ci				is_tiny = FALSE;			\
78062306a36Sopenharmony_ci			Dbl_decrement(opndp1,opndp2);			\
78162306a36Sopenharmony_ci		}							\
78262306a36Sopenharmony_ci		break;							\
78362306a36Sopenharmony_ci	case ROUNDNEAREST:						\
78462306a36Sopenharmony_ci		if (Dblext_isone_highp3(opndp3) &&			\
78562306a36Sopenharmony_ci		    (Dblext_isone_lowp2(opndp2) || 			\
78662306a36Sopenharmony_ci		     Dblext_isnotzero_low31p3(opndp3)))	{		\
78762306a36Sopenharmony_ci			Dbl_increment(opndp1,opndp2);			\
78862306a36Sopenharmony_ci			if (Dbl_isone_hiddenoverflow(opndp1))		\
78962306a36Sopenharmony_ci				is_tiny = FALSE;			\
79062306a36Sopenharmony_ci			Dbl_decrement(opndp1,opndp2);			\
79162306a36Sopenharmony_ci		}							\
79262306a36Sopenharmony_ci		break;							\
79362306a36Sopenharmony_ci	}								\
79462306a36Sopenharmony_ci    }									\
79562306a36Sopenharmony_ci    Dblext_clear_signexponent_set_hidden(opndp1);			\
79662306a36Sopenharmony_ci    if (exponent >= (1-QUAD_P)) {					\
79762306a36Sopenharmony_ci	shiftamt = (1-exponent) % 32;					\
79862306a36Sopenharmony_ci	switch((1-exponent)/32) {					\
79962306a36Sopenharmony_ci	  case 0: sticky = Dextallp4(opndp4) << 32-(shiftamt);		\
80062306a36Sopenharmony_ci		  Variableshiftdouble(opndp3,opndp4,shiftamt,opndp4);	\
80162306a36Sopenharmony_ci		  Variableshiftdouble(opndp2,opndp3,shiftamt,opndp3);	\
80262306a36Sopenharmony_ci		  Variableshiftdouble(opndp1,opndp2,shiftamt,opndp2);	\
80362306a36Sopenharmony_ci		  Dextallp1(opndp1) >>= shiftamt;			\
80462306a36Sopenharmony_ci		  break;						\
80562306a36Sopenharmony_ci	  case 1: sticky = (Dextallp3(opndp3) << 32-(shiftamt)) | 	\
80662306a36Sopenharmony_ci			   Dextallp4(opndp4);				\
80762306a36Sopenharmony_ci		  Variableshiftdouble(opndp2,opndp3,shiftamt,opndp4);	\
80862306a36Sopenharmony_ci		  Variableshiftdouble(opndp1,opndp2,shiftamt,opndp3);	\
80962306a36Sopenharmony_ci		  Dextallp2(opndp2) = Dextallp1(opndp1) >> shiftamt;	\
81062306a36Sopenharmony_ci		  Dextallp1(opndp1) = 0;				\
81162306a36Sopenharmony_ci		  break;						\
81262306a36Sopenharmony_ci	  case 2: sticky = (Dextallp2(opndp2) << 32-(shiftamt)) |	\
81362306a36Sopenharmony_ci			    Dextallp3(opndp3) | Dextallp4(opndp4);	\
81462306a36Sopenharmony_ci		  Variableshiftdouble(opndp1,opndp2,shiftamt,opndp4);	\
81562306a36Sopenharmony_ci		  Dextallp3(opndp3) = Dextallp1(opndp1) >> shiftamt;	\
81662306a36Sopenharmony_ci		  Dextallp1(opndp1) = Dextallp2(opndp2) = 0;		\
81762306a36Sopenharmony_ci		  break;						\
81862306a36Sopenharmony_ci	  case 3: sticky = (Dextallp1(opndp1) << 32-(shiftamt)) |	\
81962306a36Sopenharmony_ci		  	Dextallp2(opndp2) | Dextallp3(opndp3) | 	\
82062306a36Sopenharmony_ci			Dextallp4(opndp4);				\
82162306a36Sopenharmony_ci		  Dextallp4(opndp4) = Dextallp1(opndp1) >> shiftamt;	\
82262306a36Sopenharmony_ci		  Dextallp1(opndp1) = Dextallp2(opndp2) = 0;		\
82362306a36Sopenharmony_ci		  Dextallp3(opndp3) = 0;				\
82462306a36Sopenharmony_ci		  break;						\
82562306a36Sopenharmony_ci	}								\
82662306a36Sopenharmony_ci    }									\
82762306a36Sopenharmony_ci    else {								\
82862306a36Sopenharmony_ci	sticky = Dextallp1(opndp1) | Dextallp2(opndp2) |		\
82962306a36Sopenharmony_ci		 Dextallp3(opndp3) | Dextallp4(opndp4);			\
83062306a36Sopenharmony_ci	Dblext_setzero(opndp1,opndp2,opndp3,opndp4);			\
83162306a36Sopenharmony_ci    }									\
83262306a36Sopenharmony_ci    if (sticky) Dblext_setone_lowmantissap4(opndp4);			\
83362306a36Sopenharmony_ci    exponent = 0;							\
83462306a36Sopenharmony_ci  }
835