18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci#include "libgcc.h" 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ciDWtype __ashrdi3(DWtype u, word_type b) 58c2ecf20Sopenharmony_ci{ 68c2ecf20Sopenharmony_ci const DWunion uu = {.ll = u}; 78c2ecf20Sopenharmony_ci const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b; 88c2ecf20Sopenharmony_ci DWunion w; 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci if (b == 0) 118c2ecf20Sopenharmony_ci return u; 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci if (bm <= 0) { 148c2ecf20Sopenharmony_ci /* w.s.high = 1..1 or 0..0 */ 158c2ecf20Sopenharmony_ci w.s.high = uu.s.high >> (sizeof (Wtype) * BITS_PER_UNIT - 1); 168c2ecf20Sopenharmony_ci w.s.low = uu.s.high >> -bm; 178c2ecf20Sopenharmony_ci } else { 188c2ecf20Sopenharmony_ci const UWtype carries = (UWtype) uu.s.high << bm; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci w.s.high = uu.s.high >> b; 218c2ecf20Sopenharmony_ci w.s.low = ((UWtype) uu.s.low >> b) | carries; 228c2ecf20Sopenharmony_ci } 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci return w.ll; 258c2ecf20Sopenharmony_ci} 26