^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include "libgcc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) DWtype __ashrdi3(DWtype u, word_type b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) const DWunion uu = {.ll = u};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) DWunion w;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) if (b == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) return u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) if (bm <= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) /* w.s.high = 1..1 or 0..0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) w.s.high = uu.s.high >> (sizeof (Wtype) * BITS_PER_UNIT - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) w.s.low = uu.s.high >> -bm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) const UWtype carries = (UWtype) uu.s.high << bm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) w.s.high = uu.s.high >> b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) w.s.low = ((UWtype) uu.s.low >> b) | carries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) return w.ll;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) }