OSDN Git Service

* config/arm/bpabi.c (__aeabi_ul2d): Give it default visibility.
[pf3gnuchains/gcc-fork.git] / gcc / config / arm / bpabi.c
1 /* Miscellaneous BPABI functions.
2
3    Copyright (C) 2003, 2004  Free Software Foundation, Inc.
4    Contributed by CodeSourcery, LLC.
5
6    This file is free software; you can redistribute it and/or modify it
7    under the terms of the GNU General Public License as published by the
8    Free Software Foundation; either version 2, or (at your option) any
9    later version.
10
11    In addition to the permissions in the GNU General Public License, the
12    Free Software Foundation gives you unlimited permission to link the
13    compiled version of this file into combinations with other programs,
14    and to distribute those combinations without any restriction coming
15    from the use of this file.  (The General Public License restrictions
16    do apply in other respects; for example, they cover modification of
17    the file, and distribution when not linked into a combine
18    executable.)
19
20    This file is distributed in the hope that it will be useful, but
21    WITHOUT ANY WARRANTY; without even the implied warranty of
22    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23    General Public License for more details.
24
25    You should have received a copy of the GNU General Public License
26    along with this program; see the file COPYING.  If not, write to
27    the Free Software Foundation, 59 Temple Place - Suite 330,
28    Boston, MA 02111-1307, USA.  */
29
30 #define VISIBLE __attribute__((visibility("default")))
31 extern VISIBLE double __aeabi_ul2d (unsigned long long);
32 extern VISIBLE float __aeabi_ul2f (unsigned long long);
33 extern long long __divdi3 (long long, long long);
34 extern unsigned long long __udivdi3 (unsigned long long, 
35                                      unsigned long long);
36 extern long long __gnu_ldivmod_helper (long long, long long, long long *);
37 extern unsigned long long __gnu_uldivmod_helper (unsigned long long, 
38                                                  unsigned long long, 
39                                                  unsigned long long *);
40
41 /* These functions are based on __floatdidf and __floatdisf, but
42    convert unsigned DImode values instead of signed DImode
43    values.  */
44
45 #define WORD_SIZE (sizeof (int) * 8)
46 #define HIGH_HALFWORD_COEFF (((unsigned long long) 1) << (WORD_SIZE / 2))
47 #define HIGH_WORD_COEFF (((unsigned long long) 1) << WORD_SIZE)
48
49 double
50 __aeabi_ul2d (unsigned long long u)
51 {
52   double d = (unsigned) (u >> WORD_SIZE);
53   d *= HIGH_HALFWORD_COEFF;
54   d *= HIGH_HALFWORD_COEFF;
55   d += (unsigned) (u & (HIGH_WORD_COEFF - 1));
56
57   return d;
58 }
59
60 float
61 __aeabi_ul2f (unsigned long long u)
62 {
63   /* Do the calculation in DFmode so that we don't lose any of the
64      precision of the high word while multiplying it.  */
65   double f = (unsigned) (u >> WORD_SIZE);
66   f *= HIGH_HALFWORD_COEFF;
67   f *= HIGH_HALFWORD_COEFF;
68   f += (unsigned) (u & (HIGH_WORD_COEFF - 1));
69
70   return (float) f;
71 }
72
73 long long
74 __gnu_ldivmod_helper (long long a, 
75                       long long b, 
76                       long long *remainder)
77 {
78   long long quotient;
79
80   quotient = __divdi3 (a, b);
81   *remainder = a - b * quotient;
82   return quotient;
83 }
84
85 unsigned long long
86 __gnu_uldivmod_helper (unsigned long long a, 
87                        unsigned long long b,
88                        unsigned long long *remainder)
89 {
90   unsigned long long quotient;
91
92   quotient = __udivdi3 (a, b);
93   *remainder = a - b * quotient;
94   return quotient;
95 }