Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
extF80M_div.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include "platform.h"
#include "internals.h"
#include "specialize.h"
#include "softfloat.h"
Include dependency graph for extF80M_div.c:

Go to the source code of this file.

Functions

void extF80M_div (const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr)
 

Function Documentation

◆ extF80M_div()

void extF80M_div ( const extFloat80_t * aPtr,
const extFloat80_t * bPtr,
extFloat80_t * zPtr )

Definition at line 58 of file extF80M_div.c.

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 uint64_t sigA, x64;
69 int32_t expZ;
70 int shiftDist;
71 uint32_t y[3], recip32, sigB[3];
72 int ix;
73 uint32_t q, qs[2];
74 uint_fast16_t uiZ64;
75 uint64_t uiZ0;
76
77 /*------------------------------------------------------------------------
78 *------------------------------------------------------------------------*/
79 aSPtr = (const struct extFloat80M *) aPtr;
80 bSPtr = (const struct extFloat80M *) bPtr;
81 zSPtr = (struct extFloat80M *) zPtr;
82 /*------------------------------------------------------------------------
83 *------------------------------------------------------------------------*/
84 uiA64 = aSPtr->signExp;
85 expA = expExtF80UI64( uiA64 );
86 uiB64 = bSPtr->signExp;
87 expB = expExtF80UI64( uiB64 );
88 signZ = signExtF80UI64( uiA64 ) ^ signExtF80UI64( uiB64 );
89 /*------------------------------------------------------------------------
90 *------------------------------------------------------------------------*/
91 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
92 if ( softfloat_tryPropagateNaNExtF80M( aSPtr, bSPtr, zSPtr ) ) return;
93 if ( expA == 0x7FFF ) {
94 if ( expB == 0x7FFF ) goto invalid;
95 goto infinity;
96 }
97 goto zero;
98 }
99 /*------------------------------------------------------------------------
100 *------------------------------------------------------------------------*/
101 sigA = aSPtr->signif;
102 x64 = bSPtr->signif;
103 if ( ! expB ) expB = 1;
104 if ( ! (x64 & UINT64_C( 0x8000000000000000 )) ) {
105 if ( ! x64 ) {
106 if ( ! sigA ) goto invalid;
108 goto infinity;
109 }
110 expB += softfloat_normExtF80SigM( &x64 );
111 }
112 if ( ! expA ) expA = 1;
113 if ( ! (sigA & UINT64_C( 0x8000000000000000 )) ) {
114 if ( ! sigA ) goto zero;
115 expA += softfloat_normExtF80SigM( &sigA );
116 }
117 /*------------------------------------------------------------------------
118 *------------------------------------------------------------------------*/
119 expZ = expA - expB + 0x3FFF;
120 shiftDist = 29;
121 if ( sigA < x64 ) {
122 --expZ;
123 shiftDist = 30;
124 }
125 softfloat_shortShiftLeft64To96M( sigA, shiftDist, y );
126 recip32 = softfloat_approxRecip32_1( x64>>32 );
127 sigB[indexWord( 3, 0 )] = (uint32_t) x64<<30;
128 x64 >>= 2;
129 sigB[indexWord( 3, 2 )] = x64>>32;
130 sigB[indexWord( 3, 1 )] = x64;
131 ix = 2;
132 for (;;) {
133 x64 = (uint64_t) y[indexWordHi( 3 )] * recip32;
134 q = (x64 + 0x80000000)>>32;
135 --ix;
136 if ( ix < 0 ) break;
137 softfloat_remStep96MBy32( y, 29, sigB, q, y );
138 if ( y[indexWordHi( 3 )] & 0x80000000 ) {
139 --q;
140 softfloat_add96M( y, sigB, y );
141 }
142 qs[ix] = q;
143 }
144 /*------------------------------------------------------------------------
145 *------------------------------------------------------------------------*/
146 if ( ((q + 1) & 0x3FFFFF) < 2 ) {
147 softfloat_remStep96MBy32( y, 29, sigB, q, y );
148 if ( y[indexWordHi( 3 )] & 0x80000000 ) {
149 --q;
150 softfloat_add96M( y, sigB, y );
151 } else if ( softfloat_compare96M( sigB, y ) <= 0 ) {
152 ++q;
153 softfloat_sub96M( y, sigB, y );
154 }
155 if (
156 y[indexWordLo( 3 )] || y[indexWord( 3, 1 )] || y[indexWord( 3, 2 )]
157 ) {
158 q |= 1;
159 }
160 }
161 /*------------------------------------------------------------------------
162 *------------------------------------------------------------------------*/
163 x64 = (uint64_t) q<<9;
164 y[indexWord( 3, 0 )] = x64;
165 x64 = ((uint64_t) qs[0]<<6) + (x64>>32);
166 y[indexWord( 3, 1 )] = x64;
167 y[indexWord( 3, 2 )] = (qs[1]<<3) + (x64>>32);
169 signZ, expZ, y, extF80_roundingPrecision, zSPtr );
170 return;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 invalid:
175 return;
176 /*------------------------------------------------------------------------
177 *------------------------------------------------------------------------*/
178 infinity:
179 uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
180 uiZ0 = UINT64_C( 0x8000000000000000 );
181 goto uiZ;
182 /*------------------------------------------------------------------------
183 *------------------------------------------------------------------------*/
184 zero:
185 uiZ64 = packToExtF80UI64( signZ, 0 );
186 uiZ0 = 0;
187 uiZ:
188 zSPtr->signExp = uiZ64;
189 zSPtr->signif = uiZ0;
190
191}
uint64_t y
Definition sha3.cpp:34
void softfloat_raiseFlags(uint_fast8_t flags)
#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 indexWordLo(total)
#define indexWord(total, n)
#define indexWordHi(total)
int_fast8_t softfloat_compare96M(const uint32_t *aPtr, const uint32_t *bPtr)
#define softfloat_add96M(aPtr, bPtr, zPtr)
Definition primitives.h:915
#define softfloat_sub96M(aPtr, bPtr, zPtr)
#define softfloat_remStep96MBy32(remPtr, dist, bPtr, q, zPtr)
void softfloat_shortShiftLeft64To96M(uint64_t a, uint_fast8_t dist, uint32_t *zPtr)
uint32_t softfloat_approxRecip32_1(uint32_t a)
THREAD_LOCAL uint_fast8_t extF80_roundingPrecision
@ softfloat_flag_infinite
Definition softfloat.h:88
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
Here is the call graph for this function: