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