Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Yoshinori Sato | a71a29d | 2015-01-28 02:48:15 +0900 | [diff] [blame] | 2 | #include "libgcc.h" |
| 3 | |
| 4 | DWtype __lshrdi3(DWtype u, word_type b) |
| 5 | { |
| 6 | const DWunion uu = {.ll = u}; |
| 7 | const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b; |
| 8 | DWunion w; |
| 9 | |
| 10 | if (b == 0) |
| 11 | return u; |
| 12 | |
| 13 | if (bm <= 0) { |
| 14 | w.s.high = 0; |
| 15 | w.s.low = (UWtype) uu.s.high >> -bm; |
| 16 | } else { |
| 17 | const UWtype carries = (UWtype) uu.s.high << bm; |
| 18 | |
| 19 | w.s.high = (UWtype) uu.s.high >> b; |
| 20 | w.s.low = ((UWtype) uu.s.low >> b) | carries; |
| 21 | } |
| 22 | |
| 23 | return w.ll; |
| 24 | } |