3 picoChip GCC support for 32-bit shift left.
5 Copyright (C) 2003, 2004, 2005, 2008, 2009 Free Software Foundation, Inc.
6 Contributed by Picochip Ltd.
7 Maintained by Daniel Towner (daniel.towner@picochip.com)
9 This file is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 3, or (at your option) any
14 This file is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */
29 #error "Intended for compilation for PICOCHIP only."
32 typedef int HItype __attribute__ ((mode (HI)));
33 typedef unsigned int UHItype __attribute__ ((mode (HI)));
34 typedef unsigned int USItype __attribute__ ((mode (SI)));
36 typedef struct USIstruct {
40 typedef union USIunion {
45 USItype __ashlsi3(USIunion value, HItype count) {
49 /* Ignore a zero count until we get into the (count < 16)
50 clause. This is slightly slower when shifting by zero, but faster
51 and smaller in all other cases (due to the better scheduling
52 opportunities available by putting the test near computational
54 /* if (count == 0) return value.l; */
57 /* Shift low and high words by the count. */
58 result.s.low = value.s.low << count;
59 result.s.high = value.s.high << count;
61 /* There is now a hole in the lower `count' bits of the high
62 word. Shift the upper `count' bits of the low word into the
63 high word. This is only required when the count is non-zero. */
66 temp = value.s.low >> temp;
67 result.s.high |= temp;
71 /* Shift the lower word of the source into the upper word of the
72 result, and zero the result's lower word. */
74 result.s.high = value.s.low << count;