blob: b5b351e82e10758da00dc714f800f17a729ab009 [file] [log] [blame]
Bryan Wu1394f032007-05-06 14:50:22 -07001/*
Robin Getz96f10502009-09-24 14:11:24 +00002 * Copyright 2004-2009 Analog Devices Inc.
Bryan Wu1394f032007-05-06 14:50:22 -07003 *
Robin Getz96f10502009-09-24 14:11:24 +00004 * Licensed under the GPL-2 or later.
Bryan Wu1394f032007-05-06 14:50:22 -07005 */
6
7#include "gcclib.h"
8
9#ifdef CONFIG_ARITHMETIC_OPS_L1
10DItype __ashrdi3(DItype u, word_type b)__attribute__((l1_text));
11#endif
12
13DItype __ashrdi3(DItype u, word_type b)
14{
15 DIunion w;
16 word_type bm;
17 DIunion uu;
18
19 if (b == 0)
20 return u;
21
22 uu.ll = u;
23
24 bm = (sizeof(SItype) * BITS_PER_UNIT) - b;
25 if (bm <= 0) {
26 /* w.s.high = 1..1 or 0..0 */
27 w.s.high = uu.s.high >> (sizeof(SItype) * BITS_PER_UNIT - 1);
28 w.s.low = uu.s.high >> -bm;
29 } else {
30 USItype carries = (USItype) uu.s.high << bm;
31 w.s.high = uu.s.high >> b;
32 w.s.low = ((USItype) uu.s.low >> b) | carries;
33 }
34
35 return w.ll;
36}