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

Go to the source code of this file.

Functions

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

Function Documentation

◆ f128M_mul()

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

Definition at line 57 of file f128M_mul.c.

58{
59 const uint32_t *aWPtr, *bWPtr;
60 uint32_t *zWPtr;
61 uint32_t uiA96;
62 int32_t expA;
63 uint32_t uiB96;
64 int32_t expB;
65 bool signZ;
66 const uint32_t *ptr;
67 uint32_t uiZ96, sigA[4];
68 uint_fast8_t shiftDist;
69 uint32_t sigB[4];
70 int32_t expZ;
71 uint32_t sigProd[8], *extSigZPtr;
72
73 /*------------------------------------------------------------------------
74 *------------------------------------------------------------------------*/
75 aWPtr = (const uint32_t *) aPtr;
76 bWPtr = (const uint32_t *) bPtr;
77 zWPtr = (uint32_t *) zPtr;
78 /*------------------------------------------------------------------------
79 *------------------------------------------------------------------------*/
80 uiA96 = aWPtr[indexWordHi( 4 )];
81 expA = expF128UI96( uiA96 );
82 uiB96 = bWPtr[indexWordHi( 4 )];
83 expB = expF128UI96( uiB96 );
84 signZ = signF128UI96( uiA96 ) ^ signF128UI96( uiB96 );
85 /*------------------------------------------------------------------------
86 *------------------------------------------------------------------------*/
87 if ( (expA == 0x7FFF) || (expB == 0x7FFF) ) {
88 if ( softfloat_tryPropagateNaNF128M( aWPtr, bWPtr, zWPtr ) ) return;
89 ptr = aWPtr;
90 if ( ! expA ) goto possiblyInvalid;
91 if ( ! expB ) {
92 ptr = bWPtr;
93 possiblyInvalid:
94 if (
95 ! fracF128UI96( ptr[indexWordHi( 4 )] )
96 && ! (ptr[indexWord( 4, 2 )] | ptr[indexWord( 4, 1 )]
97 | ptr[indexWord( 4, 0 )])
98 ) {
100 return;
101 }
102 }
103 uiZ96 = packToF128UI96( signZ, 0x7FFF, 0 );
104 goto uiZ96;
105 }
106 /*------------------------------------------------------------------------
107 *------------------------------------------------------------------------*/
108 if ( expA ) {
109 sigA[indexWordHi( 4 )] = fracF128UI96( uiA96 ) | 0x00010000;
110 sigA[indexWord( 4, 2 )] = aWPtr[indexWord( 4, 2 )];
111 sigA[indexWord( 4, 1 )] = aWPtr[indexWord( 4, 1 )];
112 sigA[indexWord( 4, 0 )] = aWPtr[indexWord( 4, 0 )];
113 } else {
114 expA = softfloat_shiftNormSigF128M( aWPtr, 0, sigA );
115 if ( expA == -128 ) goto zero;
116 }
117 if ( expB ) {
118 sigB[indexWordHi( 4 )] = fracF128UI96( uiB96 ) | 0x00010000;
119 sigB[indexWord( 4, 2 )] = bWPtr[indexWord( 4, 2 )];
120 sigB[indexWord( 4, 1 )] = bWPtr[indexWord( 4, 1 )];
121 sigB[indexWord( 4, 0 )] = bWPtr[indexWord( 4, 0 )];
122 } else {
123 expB = softfloat_shiftNormSigF128M( bWPtr, 0, sigB );
124 if ( expB == -128 ) goto zero;
125 }
126 /*------------------------------------------------------------------------
127 *------------------------------------------------------------------------*/
128 expZ = expA + expB - 0x4000;
129 softfloat_mul128MTo256M( sigA, sigB, sigProd );
130 if (
131 sigProd[indexWord( 8, 2 )]
132 || (sigProd[indexWord( 8, 1 )] | sigProd[indexWord( 8, 0 )])
133 ) {
134 sigProd[indexWord( 8, 3 )] |= 1;
135 }
136 extSigZPtr = &sigProd[indexMultiwordHi( 8, 5 )];
137 shiftDist = 16;
138 if ( extSigZPtr[indexWordHi( 5 )] & 2 ) {
139 ++expZ;
140 shiftDist = 15;
141 }
142 softfloat_shortShiftLeft160M( extSigZPtr, shiftDist, extSigZPtr );
143 softfloat_roundPackMToF128M( signZ, expZ, extSigZPtr, zWPtr );
144 return;
145 /*------------------------------------------------------------------------
146 *------------------------------------------------------------------------*/
147 zero:
148 uiZ96 = packToF128UI96( signZ, 0, 0 );
149 uiZ96:
150 zWPtr[indexWordHi( 4 )] = uiZ96;
151 zWPtr[indexWord( 4, 2 )] = 0;
152 zWPtr[indexWord( 4, 1 )] = 0;
153 zWPtr[indexWord( 4, 0 )] = 0;
154
155}
void softfloat_invalidF128M(uint32_t *)
#define fracF128UI96(a96)
Definition internals.h:249
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 indexMultiwordHi(total, n)
#define indexWord(total, n)
#define indexWordHi(total)
void softfloat_mul128MTo256M(const uint32_t *aPtr, const uint32_t *bPtr, uint32_t *zPtr)
#define softfloat_shortShiftLeft160M(aPtr, dist, zPtr)
Definition primitives.h:711
unsigned int uint32_t
Definition stdint.h:126
signed int int32_t
Definition stdint.h:123
uint8_t uint_fast8_t
Definition stdint.h:154
Here is the call graph for this function: