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

Go to the source code of this file.

Functions

float128_t softfloat_addMagsF128 (uint_fast64_t uiA64, uint_fast64_t uiA0, uint_fast64_t uiB64, uint_fast64_t uiB0, bool signZ)
 

Function Documentation

◆ softfloat_addMagsF128()

float128_t softfloat_addMagsF128 ( uint_fast64_t uiA64,
uint_fast64_t uiA0,
uint_fast64_t uiB64,
uint_fast64_t uiB0,
bool signZ )

Definition at line 44 of file s_addMagsF128.c.

51{
52 int_fast32_t expA;
53 struct uint128 sigA;
54 int_fast32_t expB;
55 struct uint128 sigB;
56 int_fast32_t expDiff;
57 struct uint128 uiZ, sigZ;
58 int_fast32_t expZ;
59 uint_fast64_t sigZExtra;
60 struct uint128_extra sig128Extra;
61 union ui128_f128 uZ;
62
63 expA = expF128UI64( uiA64 );
64 sigA.v64 = fracF128UI64( uiA64 );
65 sigA.v0 = uiA0;
66 expB = expF128UI64( uiB64 );
67 sigB.v64 = fracF128UI64( uiB64 );
68 sigB.v0 = uiB0;
69 expDiff = expA - expB;
70 if ( ! expDiff ) {
71 if ( expA == 0x7FFF ) {
72 if ( sigA.v64 | sigA.v0 | sigB.v64 | sigB.v0 ) goto propagateNaN;
73 uiZ.v64 = uiA64;
74 uiZ.v0 = uiA0;
75 goto uiZ;
76 }
77 sigZ = softfloat_add128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 );
78 if ( ! expA ) {
79 uiZ.v64 = packToF128UI64( signZ, 0, sigZ.v64 );
80 uiZ.v0 = sigZ.v0;
81 goto uiZ;
82 }
83 expZ = expA;
84 sigZ.v64 |= UINT64_C( 0x0002000000000000 );
85 sigZExtra = 0;
86 goto shiftRight1;
87 }
88 if ( expDiff < 0 ) {
89 if ( expB == 0x7FFF ) {
90 if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
91 uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
92 uiZ.v0 = 0;
93 goto uiZ;
94 }
95 expZ = expB;
96 if ( expA ) {
97 sigA.v64 |= UINT64_C( 0x0001000000000000 );
98 } else {
99 ++expDiff;
100 sigZExtra = 0;
101 if ( ! expDiff ) goto newlyAligned;
102 }
103 sig128Extra =
104 softfloat_shiftRightJam128Extra( sigA.v64, sigA.v0, 0, -expDiff );
105 sigA = sig128Extra.v;
106 sigZExtra = sig128Extra.extra;
107 } else {
108 if ( expA == 0x7FFF ) {
109 if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
110 uiZ.v64 = uiA64;
111 uiZ.v0 = uiA0;
112 goto uiZ;
113 }
114 expZ = expA;
115 if ( expB ) {
116 sigB.v64 |= UINT64_C( 0x0001000000000000 );
117 } else {
118 --expDiff;
119 sigZExtra = 0;
120 if ( ! expDiff ) goto newlyAligned;
121 }
122 sig128Extra =
123 softfloat_shiftRightJam128Extra( sigB.v64, sigB.v0, 0, expDiff );
124 sigB = sig128Extra.v;
125 sigZExtra = sig128Extra.extra;
126 }
127 newlyAligned:
128 sigZ =
130 sigA.v64 | UINT64_C( 0x0001000000000000 ),
131 sigA.v0,
132 sigB.v64,
133 sigB.v0
134 );
135 --expZ;
136 if ( sigZ.v64 < UINT64_C( 0x0002000000000000 ) ) goto roundAndPack;
137 ++expZ;
138 shiftRight1:
139 sig128Extra =
141 sigZ.v64, sigZ.v0, sigZExtra, 1 );
142 sigZ = sig128Extra.v;
143 sigZExtra = sig128Extra.extra;
144 roundAndPack:
145 return
146 softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
147 propagateNaN:
148 uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
149 uiZ:
150 uZ.ui = uiZ;
151 return uZ.f;
152
153}
struct uint128 softfloat_propagateNaNF128UI(uint_fast64_t uiA64, uint_fast64_t uiA0, uint_fast64_t uiB64, uint_fast64_t uiB0)
struct uint128 softfloat_add128(uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0)
Definition s_add128.c:44
float128_t softfloat_roundPackToF128(bool sign, int_fast32_t exp, uint_fast64_t sig64, uint_fast64_t sig0, uint_fast64_t sigExtra)
struct uint128_extra softfloat_shiftRightJam128Extra(uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t dist)
struct uint128_extra softfloat_shortShiftRightJam128Extra(uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist)
uint64_t uint_fast64_t
Definition stdint.h:157
#define UINT64_C(val)
Definition stdint.h:284
int32_t int_fast32_t
Definition stdint.h:152
Here is the call graph for this function: