Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
f128M_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 f128M_div.c:

Go to the source code of this file.

Functions

void f128M_div (const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr)
 

Function Documentation

◆ f128M_div()

void f128M_div ( const float128_t * aPtr,
const float128_t * bPtr,
float128_t * zPtr )

Definition at line 57 of file f128M_div.c.

58{
59 const uint32_t *aWPtr, *bWPtr;
60 uint32_t *zWPtr, uiA96;
61 bool signA;
62 int32_t expA;
63 uint32_t uiB96;
64 bool signB;
65 int32_t expB;
66 bool signZ;
67 uint32_t y[5], sigB[4];
68 int32_t expZ;
69 uint32_t recip32;
70 int ix;
71 uint64_t q64;
72 uint32_t q, qs[3], uiZ96;
73
74 /*------------------------------------------------------------------------
75 *------------------------------------------------------------------------*/
76 aWPtr = (const uint32_t *) aPtr;
77 bWPtr = (const uint32_t *) bPtr;
78 zWPtr = (uint32_t *) zPtr;
79 /*------------------------------------------------------------------------
80 *------------------------------------------------------------------------*/
81 uiA96 = aWPtr[indexWordHi( 4 )];
82 signA = signF128UI96( uiA96 );
83 expA = expF128UI96( uiA96 );
84 uiB96 = bWPtr[indexWordHi( 4 )];
85 signB = signF128UI96( uiB96 );
86 expB = expF128UI96( uiB96 );
87 signZ = signA ^ signB;
88 /*------------------------------------------------------------------------
89 *------------------------------------------------------------------------*/
90 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
91 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
92 if ( expA == 0x7FFF ) {
93 if ( expB == 0x7FFF ) goto invalid;
94 goto infinity;
95 }
96 goto zero;
97 }
98 /*------------------------------------------------------------------------
99 *------------------------------------------------------------------------*/
100 expA = softfloat_shiftNormSigF128M( aWPtr, 13, y );
101 expB = softfloat_shiftNormSigF128M( bWPtr, 13, sigB );
102 if ( expA == -128 ) {
103 if ( expB == -128 ) goto invalid;
104 goto zero;
105 }
106 if ( expB == -128 ) {
108 goto infinity;
109 }
110 /*------------------------------------------------------------------------
111 *------------------------------------------------------------------------*/
112 expZ = expA - expB + 0x3FFE;
113 if ( softfloat_compare128M( y, sigB ) < 0 ) {
114 --expZ;
115 softfloat_add128M( y, y, y );
116 }
117 recip32 =
119 ((uint64_t) sigB[indexWord( 4, 3 )]<<32 | sigB[indexWord( 4, 2 )])
120 >>30
121 );
122 ix = 3;
123 for (;;) {
124 q64 = (uint64_t) y[indexWordHi( 4 )] * recip32;
125 q = (q64 + 0x80000000)>>32;
126 --ix;
127 if ( ix < 0 ) break;
128 softfloat_remStep128MBy32( y, 29, sigB, q, y );
129 if ( y[indexWordHi( 4 )] & 0x80000000 ) {
130 --q;
131 softfloat_add128M( y, sigB, y );
132 }
133 qs[ix] = q;
134 }
135 /*------------------------------------------------------------------------
136 *------------------------------------------------------------------------*/
137 if ( ((q + 1) & 7) < 2 ) {
138 softfloat_remStep128MBy32( y, 29, sigB, q, y );
139 if ( y[indexWordHi( 4 )] & 0x80000000 ) {
140 --q;
141 softfloat_add128M( y, sigB, y );
142 } else if ( softfloat_compare128M( sigB, y ) <= 0 ) {
143 ++q;
144 softfloat_sub128M( y, sigB, y );
145 }
146 if (
147 y[indexWordLo( 4 )] || y[indexWord( 4, 1 )]
148 || (y[indexWord( 4, 2 )] | y[indexWord( 4, 3 )])
149 ) {
150 q |= 1;
151 }
152 }
153 /*------------------------------------------------------------------------
154 *------------------------------------------------------------------------*/
155 q64 = (uint64_t) q<<28;
156 y[indexWord( 5, 0 )] = q64;
157 q64 = ((uint64_t) qs[0]<<25) + (q64>>32);
158 y[indexWord( 5, 1 )] = q64;
159 q64 = ((uint64_t) qs[1]<<22) + (q64>>32);
160 y[indexWord( 5, 2 )] = q64;
161 q64 = ((uint64_t) qs[2]<<19) + (q64>>32);
162 y[indexWord( 5, 3 )] = q64;
163 y[indexWord( 5, 4 )] = q64>>32;
164 softfloat_roundPackMToF128M( signZ, expZ, y, zWPtr );
165 return;
166 /*------------------------------------------------------------------------
167 *------------------------------------------------------------------------*/
168 invalid:
169 softfloat_invalidF128M( zWPtr );
170 return;
171 /*------------------------------------------------------------------------
172 *------------------------------------------------------------------------*/
173 infinity:
174 uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
175 goto uiZ96;
176 zero:
177 uiZ96 = packToF128UI96( signZ, 0, 0 );
178 uiZ96:
179 zWPtr[indexWordHi( 4 )] = uiZ96;
180 zWPtr[indexWord( 4, 2 )] = 0;
181 zWPtr[indexWord( 4, 1 )] = 0;
182 zWPtr[indexWord( 4, 0 )] = 0;
183
184}
uint64_t y
Definition sha3.cpp:34
void softfloat_raiseFlags(uint_fast8_t flags)
void softfloat_invalidF128M(uint32_t *)
void softfloat_roundPackMToF128M(bool, int32_t, uint32_t *, uint32_t *)
#define packToF128UI96(sign, exp, sig96)
Definition internals.h:250
int softfloat_shiftNormSigF128M(const uint32_t *, uint_fast8_t, uint32_t *)
bool softfloat_tryPropagateNaNF128M(const uint32_t *, const uint32_t *, uint32_t *)
#define signF128UI96(a96)
Definition internals.h:247
#define expF128UI96(a96)
Definition internals.h:248
#define indexWordLo(total)
#define indexWord(total, n)
#define indexWordHi(total)
#define softfloat_add128M(aPtr, bPtr, zPtr)
Definition primitives.h:923
int_fast8_t softfloat_compare128M(const uint32_t *aPtr, const uint32_t *bPtr)
#define softfloat_remStep128MBy32(remPtr, dist, bPtr, q, zPtr)
#define softfloat_sub128M(aPtr, bPtr, zPtr)
uint32_t softfloat_approxRecip32_1(uint32_t a)
@ softfloat_flag_infinite
Definition softfloat.h:88
unsigned int uint32_t
Definition stdint.h:126
signed int int32_t
Definition stdint.h:123
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the call graph for this function: