Merge branch 'for-v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm...
[linux-2.6-microblaze.git] / arch / h8300 / lib / ashldi3.c
1 // SPDX-License-Identifier: GPL-2.0
2 #include "libgcc.h"
3
4 DWtype
5 __ashldi3(DWtype u, word_type b)
6 {
7         const DWunion uu = {.ll = u};
8         const word_type bm = (sizeof (Wtype) * BITS_PER_UNIT) - b;
9         DWunion w;
10
11         if (b == 0)
12                 return u;
13
14         if (bm <= 0) {
15                 w.s.low = 0;
16                 w.s.high = (UWtype) uu.s.low << -bm;
17         } else {
18                 const UWtype carries = (UWtype) uu.s.low >> bm;
19
20                 w.s.low = (UWtype) uu.s.low << b;
21                 w.s.high = ((UWtype) uu.s.high << b) | carries;
22         }
23
24         return w.ll;
25 }