Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
extF80M_mul.c
Go to the documentation of this file.
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5Package, Release 3e, by John R. Hauser.
6
7Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
8All rights reserved.
9
10Redistribution and use in source and binary forms, with or without
11modification, are permitted provided that the following conditions are met:
12
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
15
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
23
24THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35=============================================================================*/
36
37#include <stdbool.h>
38#include <stdint.h>
39#include "platform.h"
40#include "internals.h"
41#include "specialize.h"
42#include "softfloat.h"
43
44#ifdef SOFTFLOAT_FAST_INT64
45
46void
48 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
49{
50
51 *zPtr = extF80_mul( *aPtr, *bPtr );
52
53}
54
55#else
56
57void
59 const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
60{
61 const struct extFloat80M *aSPtr, *bSPtr;
62 struct extFloat80M *zSPtr;
63 uint_fast16_t uiA64;
64 int32_t expA;
65 uint_fast16_t uiB64;
66 int32_t expB;
67 bool signZ;
68 uint_fast16_t exp, uiZ64;
69 uint64_t uiZ0, sigA, sigB;
70 int32_t expZ;
71 uint32_t sigProd[4], *extSigZPtr;
72
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 aSPtr = (const struct extFloat80M *) aPtr;
76 bSPtr = (const struct extFloat80M *) bPtr;
77 zSPtr = (struct extFloat80M *) zPtr;
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 uiA64 = aSPtr->signExp;
81 expA = expExtF80UI64( uiA64 );
82 uiB64 = bSPtr->signExp;
83 expB = expExtF80UI64( uiB64 );
84 signZ = signExtF80UI64( uiA64 ) ^ signExtF80UI64( uiB64 );
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
88 if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
89 if (
90 (! aSPtr->signif && (expA != 0x7FFF))
91 || (! bSPtr->signif && (expB != 0x7FFF))
92 ) {
94 return;
95 }
96 uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
97 uiZ0 = UINT64_C( 0x8000000000000000 );
98 goto uiZ;
99 }
100 /*------------------------------------------------------------------------
101 *------------------------------------------------------------------------*/
102 if ( ! expA ) expA = 1;
103 sigA = aSPtr->signif;
104 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
105 if ( ! sigA ) goto zero;
106 expA += softfloat_normExtF80SigM( &sigA );
107 }
108 if ( ! expB ) expB = 1;
109 sigB = bSPtr->signif;
110 if ( ! (sigB & UINT64_C( 0x8000000000000000 )) ) {
111 if ( ! sigB ) goto zero;
112 expB += softfloat_normExtF80SigM( &sigB );
113 }
114 /*------------------------------------------------------------------------
115 *------------------------------------------------------------------------*/
116 expZ = expA + expB - 0x3FFE;
117 softfloat_mul64To128M( sigA, sigB, sigProd );
118 if ( sigProd[indexWordLo( 4 )] ) sigProd[indexWord( 4, 1 )] |= 1;
119 extSigZPtr = &sigProd[indexMultiwordHi( 4, 3 )];
120 if ( sigProd[indexWordHi( 4 )] < 0x80000000 ) {
121 --expZ;
122 softfloat_add96M( extSigZPtr, extSigZPtr, extSigZPtr );
123 }
125 signZ, expZ, extSigZPtr, extF80_roundingPrecision, zSPtr );
126 return;
127 /*------------------------------------------------------------------------
128 *------------------------------------------------------------------------*/
129 zero:
130 uiZ64 = packToExtF80UI64( signZ, 0 );
131 uiZ0 = 0;
132 uiZ:
133 zSPtr->signExp = uiZ64;
134 zSPtr->signif = uiZ0;
135
136}
137
138#endif
139
extFloat80_t extF80_mul(extFloat80_t a, extFloat80_t b)
Definition extF80_mul.c:44
void extF80M_mul(const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr)
Definition extF80M_mul.c:58
#define packToExtF80UI64(sign, exp)
Definition internals.h:148
#define expExtF80UI64(a64)
Definition internals.h:147
void softfloat_invalidExtF80M(struct extFloat80M *)
void softfloat_roundPackMToExtF80M(bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M *)
#define signExtF80UI64(a64)
Definition internals.h:146
bool softfloat_tryPropagateNaNExtF80M(const struct extFloat80M *, const struct extFloat80M *, struct extFloat80M *)
int softfloat_normExtF80SigM(uint64_t *)
#define indexMultiwordHi(total, n)
#define indexWordLo(total)
#define indexWord(total, n)
#define indexWordHi(total)
#define softfloat_add96M(aPtr, bPtr, zPtr)
Definition primitives.h:915
void softfloat_mul64To128M(uint64_t a, uint64_t b, uint32_t *zPtr)
THREAD_LOCAL uint_fast8_t extF80_roundingPrecision
unsigned int uint32_t
Definition stdint.h:126
uint16_t uint_fast16_t
Definition stdint.h:155
#define UINT64_C(val)
Definition stdint.h:284
signed int int32_t
Definition stdint.h:123
unsigned __int64 uint64_t
Definition stdint.h:136
uint64_t signif
uint16_t signExp