OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgcc/] [config/] [picochip/] [ashlsi3.c] - Blame information for rev 734

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 734 jeremybenn
/*
2
 
3
picoChip GCC support for 32-bit shift left.
4
 
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)
8
 
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
12
later version.
13
 
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.
18
 
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.
22
 
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/>.  */
27
 
28
#ifndef PICOCHIP
29
#error "Intended for compilation for PICOCHIP only."
30
#endif
31
 
32
typedef int HItype __attribute__ ((mode (HI)));
33
typedef unsigned int UHItype __attribute__ ((mode (HI)));
34
typedef unsigned int USItype __attribute__ ((mode (SI)));
35
 
36
typedef struct USIstruct {
37
  UHItype low, high;
38
} USIstruct;
39
 
40
typedef union USIunion {
41
  USItype l;
42
  USIstruct s;
43
} USIunion;
44
 
45
USItype __ashlsi3(USIunion value, HItype count) {
46
  USIunion result;
47
  int temp;
48
 
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
53
     instructions. */
54
  /* if (count == 0) return value.l; */
55
 
56
  if (count < 16) {
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;
60
 
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. */
64
    if (count != 0) {
65
      temp = 16 - count;
66
      temp = value.s.low >> temp;
67
      result.s.high |= temp;
68
    }
69
 
70
  } else {
71
    /* Shift the lower word of the source into the upper word of the
72
       result, and zero the result's lower word. */
73
    count -= 16;
74
    result.s.high = value.s.low << count;
75
    result.s.low = 0;
76
 
77
  }
78
 
79
  return result.l;
80
 
81
}
82
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.