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

Go to the source code of this file.

Functions

void softfloat_roundPackMToF128M (bool sign, int32_t exp, uint32_t *extSigPtr, uint32_t *zWPtr)
 

Function Documentation

◆ softfloat_roundPackMToF128M()

void softfloat_roundPackMToF128M ( bool sign,
int32_t exp,
uint32_t * extSigPtr,
uint32_t * zWPtr )

Definition at line 44 of file s_roundPackMToF128M.c.

46{
47 uint_fast8_t roundingMode;
48 bool roundNearEven;
49 uint32_t sigExtra;
50 bool doIncrement, isTiny;
51 static const uint32_t maxSig[4] =
52 INIT_UINTM4( 0x0001FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF );
53 uint32_t ui, uj;
54
55 /*------------------------------------------------------------------------
56 *------------------------------------------------------------------------*/
57 roundingMode = softfloat_roundingMode;
58 roundNearEven = (roundingMode == softfloat_round_near_even);
59 sigExtra = extSigPtr[indexWordLo( 5 )];
60 doIncrement = (0x80000000 <= sigExtra);
61 if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
62 doIncrement =
63 (roundingMode
65 && sigExtra;
66 }
67 /*------------------------------------------------------------------------
68 *------------------------------------------------------------------------*/
69 if ( 0x7FFD <= (uint32_t) exp ) {
70 if ( exp < 0 ) {
71 /*----------------------------------------------------------------
72 *----------------------------------------------------------------*/
73 isTiny =
76 || (exp < -1)
77 || ! doIncrement
79 extSigPtr + indexMultiwordHi( 5, 4 ), maxSig )
80 < 0);
81 softfloat_shiftRightJam160M( extSigPtr, -exp, extSigPtr );
82 exp = 0;
83 sigExtra = extSigPtr[indexWordLo( 5 )];
84 if ( isTiny && sigExtra ) {
86 }
87 doIncrement = (0x80000000 <= sigExtra);
88 if (
89 ! roundNearEven
90 && (roundingMode != softfloat_round_near_maxMag)
91 ) {
92 doIncrement =
93 (roundingMode
95 && sigExtra;
96 }
97 } else if (
98 (0x7FFD < exp)
99 || ((exp == 0x7FFD) && doIncrement
101 extSigPtr + indexMultiwordHi( 5, 4 ), maxSig )
102 == 0))
103 ) {
104 /*----------------------------------------------------------------
105 *----------------------------------------------------------------*/
108 if (
109 roundNearEven
110 || (roundingMode == softfloat_round_near_maxMag)
111 || (roundingMode
113 ) {
114 ui = packToF128UI96( sign, 0x7FFF, 0 );
115 uj = 0;
116 } else {
117 ui = packToF128UI96( sign, 0x7FFE, 0x0000FFFF );
118 uj = 0xFFFFFFFF;
119 }
120 zWPtr[indexWordHi( 4 )] = ui;
121 zWPtr[indexWord( 4, 2 )] = uj;
122 zWPtr[indexWord( 4, 1 )] = uj;
123 zWPtr[indexWord( 4, 0 )] = uj;
124 return;
125 }
126 }
127 /*------------------------------------------------------------------------
128 *------------------------------------------------------------------------*/
129 uj = extSigPtr[indexWord( 5, 1 )];
130 if ( sigExtra ) {
132#ifdef SOFTFLOAT_ROUND_ODD
133 if ( roundingMode == softfloat_round_odd ) {
134 uj |= 1;
135 goto noIncrementPackReturn;
136 }
137#endif
138 }
139 if ( doIncrement ) {
140 ++uj;
141 if ( uj ) {
142 if ( ! (sigExtra & 0x7FFFFFFF) && roundNearEven ) uj &= ~1;
143 zWPtr[indexWord( 4, 2 )] = extSigPtr[indexWord( 5, 3 )];
144 zWPtr[indexWord( 4, 1 )] = extSigPtr[indexWord( 5, 2 )];
145 zWPtr[indexWord( 4, 0 )] = uj;
146 ui = extSigPtr[indexWordHi( 5 )];
147 } else {
148 zWPtr[indexWord( 4, 0 )] = uj;
149 ui = extSigPtr[indexWord( 5, 2 )] + 1;
150 zWPtr[indexWord( 4, 1 )] = ui;
151 uj = extSigPtr[indexWord( 5, 3 )];
152 if ( ui ) {
153 zWPtr[indexWord( 4, 2 )] = uj;
154 ui = extSigPtr[indexWordHi( 5 )];
155 } else {
156 ++uj;
157 zWPtr[indexWord( 4, 2 )] = uj;
158 ui = extSigPtr[indexWordHi( 5 )];
159 if ( ! uj ) ++ui;
160 }
161 }
162 } else {
163 noIncrementPackReturn:
164 zWPtr[indexWord( 4, 0 )] = uj;
165 ui = extSigPtr[indexWord( 5, 2 )];
166 zWPtr[indexWord( 4, 1 )] = ui;
167 uj |= ui;
168 ui = extSigPtr[indexWord( 5, 3 )];
169 zWPtr[indexWord( 4, 2 )] = ui;
170 uj |= ui;
171 ui = extSigPtr[indexWordHi( 5 )];
172 uj |= ui;
173 if ( ! uj ) exp = 0;
174 }
175 zWPtr[indexWordHi( 4 )] = packToF128UI96( sign, exp, ui );
176
177}
void softfloat_raiseFlags(uint_fast8_t flags)
#define packToF128UI96(sign, exp, sig96)
Definition internals.h:250
#define indexMultiwordHi(total, n)
#define INIT_UINTM4(v3, v2, v1, v0)
#define indexWordLo(total)
#define indexWord(total, n)
#define indexWordHi(total)
int_fast8_t softfloat_compare128M(const uint32_t *aPtr, const uint32_t *bPtr)
#define softfloat_shiftRightJam160M(aPtr, dist, zPtr)
Definition primitives.h:889
THREAD_LOCAL uint_fast8_t softfloat_roundingMode
@ softfloat_flag_inexact
Definition softfloat.h:85
@ softfloat_flag_underflow
Definition softfloat.h:86
@ softfloat_flag_overflow
Definition softfloat.h:87
THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags
THREAD_LOCAL uint_fast8_t softfloat_detectTininess
@ softfloat_round_odd
Definition softfloat.h:77
@ softfloat_round_max
Definition softfloat.h:75
@ softfloat_round_min
Definition softfloat.h:74
@ softfloat_round_near_even
Definition softfloat.h:72
@ softfloat_round_near_maxMag
Definition softfloat.h:76
@ softfloat_tininess_beforeRounding
Definition softfloat.h:62
unsigned int uint32_t
Definition stdint.h:126
uint8_t uint_fast8_t
Definition stdint.h:154