2 /*============================================================================
4 This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
5 Package, Release 3d, by John R. Hauser.
7 Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
8 California. All rights reserved.
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
13 1. Redistributions of source code must retain the above copyright notice,
14 this list of conditions, and the following disclaimer.
16 2. Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions, and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
20 3. Neither the name of the University nor the names of its contributors may
21 be used to endorse or promote products derived from this software without
22 specific prior written permission.
24 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
27 DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 =============================================================================*/
39 #include "primitiveTypes.h"
41 #ifndef softfloat_shiftRightJam256M
45 softfloat_shortShiftRightJamM(
46 uint_fast8_t size_words
,
52 uint_fast8_t uNegDist
;
53 unsigned int index
, lastIndex
;
54 uint64_t partWordZ
, wordA
;
57 index
= indexWordLo( size_words
);
58 lastIndex
= indexWordHi( size_words
);
60 partWordZ
= wordA
>>dist
;
61 if ( partWordZ
<<dist
!= wordA
) partWordZ
|= 1;
62 while ( index
!= lastIndex
) {
63 wordA
= aPtr
[index
+ wordIncr
];
64 zPtr
[index
] = wordA
<<(uNegDist
& 63) | partWordZ
;
66 partWordZ
= wordA
>>dist
;
68 zPtr
[index
] = partWordZ
;
73 softfloat_shiftRightJam256M(
74 const uint64_t *aPtr
, uint_fast32_t dist
, uint64_t *zPtr
)
77 uint_fast32_t wordDist
;
79 uint_fast8_t i
, innerDist
;
84 if ( 4 < wordDist
) wordDist
= 4;
85 ptr
= (uint64_t *) (aPtr
+ indexMultiwordLo( 4, wordDist
));
95 aPtr
+= indexMultiwordHiBut( 4, wordDist
);
96 innerDist
= dist
& 63;
98 softfloat_shortShiftRightJamM(
102 zPtr
+ indexMultiwordLoBut( 4, wordDist
)
104 if ( ! wordDist
) goto wordJam
;
106 aPtr
+= indexWordLo( 4 - wordDist
);
107 ptr
= zPtr
+ indexWordLo( 4 );
108 for ( i
= 4 - wordDist
; i
; --i
) {
114 ptr
= zPtr
+ indexMultiwordHi( 4, wordDist
);
119 } while ( wordDist
);
121 if ( wordJam
) zPtr
[indexWordLo( 4 )] |= 1;