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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [config/] [m32c/] [m32c-lib2.c] - Blame information for rev 38

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 38 julius
/* libgcc routines for R8C/M16C/M32C
2
   Copyright (C) 2005
3
   Free Software Foundation, Inc.
4
   Contributed by Red Hat.
5
 
6
   This file is part of GCC.
7
 
8
   GCC is free software; you can redistribute it and/or modify it
9
   under the terms of the GNU General Public License as published
10
   by the Free Software Foundation; either version 2, or (at your
11
   option) any later version.
12
 
13
   In addition to the permissions in the GNU General Public License,
14
   the Free Software Foundation gives you unlimited permission to link
15
   the compiled version of this file into combinations with other
16
   programs, and to distribute those combinations without any
17
   restriction coming from the use of this file.  (The General Public
18
   License restrictions do apply in other respects; for example, they
19
   cover modification of the file, and distribution when not linked
20
   into a combine executable.)
21
 
22
   GCC is distributed in the hope that it will be useful, but WITHOUT
23
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
25
   License for more details.
26
 
27
   You should have received a copy of the GNU General Public License
28
   along with GCC; see the file COPYING.  If not, write to the Free
29
   Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
30
   02110-1301, USA.  */
31
 
32
typedef          int  HItype __attribute__ ((mode (HI)));
33
typedef unsigned int UHItype __attribute__ ((mode (HI)));
34
typedef          int  SItype __attribute__ ((mode (SI)));
35
typedef unsigned int USItype __attribute__ ((mode (SI)));
36
 
37
typedef int word_type __attribute__ ((mode (__word__)));
38
 
39
USItype udivmodsi4 (USItype num, USItype den, word_type modwanted);
40
SItype __divsi3 (SItype a, SItype b);
41
SItype __modsi3 (SItype a, SItype b);
42
SItype __udivsi3 (SItype a, SItype b);
43
SItype __umodsi3 (SItype a, SItype b);
44
 
45
USItype
46
udivmodsi4 (USItype num, USItype den, word_type modwanted)
47
{
48
  USItype bit = 1;
49
  USItype res = 0;
50
 
51
  while (den < num && bit && !(den & (1L << 31)))
52
    {
53
      den <<= 1;
54
      bit <<= 1;
55
    }
56
  while (bit)
57
    {
58
      if (num >= den)
59
        {
60
          num -= den;
61
          res |= bit;
62
        }
63
      bit >>= 1;
64
      den >>= 1;
65
    }
66
  if (modwanted)
67
    return num;
68
  return res;
69
}
70
 
71
 
72
 
73
SItype
74
__divsi3 (SItype a, SItype b)
75
{
76
  word_type neg = 0;
77
  SItype res;
78
 
79
  if (a < 0)
80
    {
81
      a = -a;
82
      neg = !neg;
83
    }
84
 
85
  if (b < 0)
86
    {
87
      b = -b;
88
      neg = !neg;
89
    }
90
 
91
  res = udivmodsi4 (a, b, 0);
92
 
93
  if (neg)
94
    res = -res;
95
 
96
  return res;
97
}
98
 
99
 
100
 
101
SItype
102
__modsi3 (SItype a, SItype b)
103
{
104
  word_type neg = 0;
105
  SItype res;
106
 
107
  if (a < 0)
108
    {
109
      a = -a;
110
      neg = 1;
111
    }
112
 
113
  if (b < 0)
114
    b = -b;
115
 
116
  res = udivmodsi4 (a, b, 1);
117
 
118
  if (neg)
119
    res = -res;
120
 
121
  return res;
122
}
123
 
124
 
125
 
126
 
127
SItype
128
__udivsi3 (SItype a, SItype b)
129
{
130
  return udivmodsi4 (a, b, 0);
131
}
132
 
133
 
134
 
135
SItype
136
__umodsi3 (SItype a, SItype b)
137
{
138
  return udivmodsi4 (a, b, 1);
139
}

powered by: WebSVN 2.1.0

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