blob: 2c6cd424eb3e33d25506f4766d9f49e003ef3250 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Yoshinori Satoa71a29d2015-01-28 02:48:15 +09002#include "libgcc.h"
3
4DWtype __ashrdi3(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 = 1..1 or 0..0 */
15 w.s.high = uu.s.high >> (sizeof (Wtype) * BITS_PER_UNIT - 1);
16 w.s.low = uu.s.high >> -bm;
17 } else {
18 const UWtype carries = (UWtype) uu.s.high << bm;
19
20 w.s.high = uu.s.high >> b;
21 w.s.low = ((UWtype) uu.s.low >> b) | carries;
22 }
23
24 return w.ll;
25}