xref: /openbmc/linux/arch/microblaze/lib/ashrdi3.c (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2d64af918SMichal Simek #include <linux/export.h>
34e07dba7SMichal Simek 
44e07dba7SMichal Simek #include "libgcc.h"
54e07dba7SMichal Simek 
__ashrdi3(long long u,word_type b)64e07dba7SMichal Simek long long __ashrdi3(long long u, word_type b)
74e07dba7SMichal Simek {
84e07dba7SMichal Simek 	DWunion uu, w;
94e07dba7SMichal Simek 	word_type bm;
104e07dba7SMichal Simek 
114e07dba7SMichal Simek 	if (b == 0)
124e07dba7SMichal Simek 		return u;
134e07dba7SMichal Simek 
144e07dba7SMichal Simek 	uu.ll = u;
154e07dba7SMichal Simek 	bm = 32 - b;
164e07dba7SMichal Simek 
174e07dba7SMichal Simek 	if (bm <= 0) {
184e07dba7SMichal Simek 		/* w.s.high = 1..1 or 0..0 */
194e07dba7SMichal Simek 		w.s.high =
204e07dba7SMichal Simek 		    uu.s.high >> 31;
214e07dba7SMichal Simek 		w.s.low = uu.s.high >> -bm;
224e07dba7SMichal Simek 	} else {
234e07dba7SMichal Simek 		const unsigned int carries = (unsigned int) uu.s.high << bm;
244e07dba7SMichal Simek 
254e07dba7SMichal Simek 		w.s.high = uu.s.high >> b;
264e07dba7SMichal Simek 		w.s.low = ((unsigned int) uu.s.low >> b) | carries;
274e07dba7SMichal Simek 	}
284e07dba7SMichal Simek 
294e07dba7SMichal Simek 	return w.ll;
304e07dba7SMichal Simek }
314e07dba7SMichal Simek EXPORT_SYMBOL(__ashrdi3);
32