Skip to content

Commit 1aad54a

Browse files
committed
sh: Migrate necessary libgcc bits in to arch/sh/lib for SUPERH32.
This moves in the necessary libgcc bits for SUPERH32 and drops the libgcc linking for the regular targets. This in turn allows us to rip out quite a few hacks both in sh_ksyms_32 and arch/sh/Makefile. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent e9bf51e commit 1aad54a

15 files changed

Lines changed: 1984 additions & 50 deletions

File tree

‎arch/sh/Makefile‎

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,6 @@ cflags-$(CONFIG_CPU_SH4A) += $(call cc-option,-m4a,) \
3434
$(call cc-option,-m4a-nofpu,)
3535
cflags-$(CONFIG_CPU_SH5) := $(call cc-option,-m5-32media-nofpu,)
3636

37-
ifeq ($(cflags-y),)
38-
#
39-
# In the case where we are stuck with a compiler that has been uselessly
40-
# restricted to a particular ISA, a favourite default of newer GCCs when
41-
# extensive multilib targets are not provided, ensure we get the best fit
42-
# regarding FP generation. This is necessary to avoid references to FP
43-
# variants in libgcc where integer variants exist, which otherwise result
44-
# in link errors. This is intentionally stupid (albeit many orders of
45-
# magnitude less than GCC's default behaviour), as anything with a large
46-
# number of multilib targets better have been built correctly for
47-
# the target in mind.
48-
#
49-
cflags-y += $(shell $(CC) $(KBUILD_CFLAGS) -print-multi-lib | \
50-
grep nofpu | sed q | sed -e 's/^/-/;s/;.*$$//')
51-
endif
52-
5337
cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mb
5438
cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml
5539

@@ -176,8 +160,7 @@ KBUILD_AFLAGS += $(cflags-y)
176160
LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
177161

178162
libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y)
179-
libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y)
180-
libs-y += $(LIBGCC)
163+
libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y) $(LIBGCC)
181164

182165
PHONY += maketools FORCE
183166

‎arch/sh/kernel/sh_ksyms_32.c‎

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,10 @@ EXPORT_SYMBOL(__const_udelay);
5252

5353
#define DECLARE_EXPORT(name) \
5454
extern void name(void);EXPORT_SYMBOL(name)
55-
#define MAYBE_DECLARE_EXPORT(name) \
56-
extern void name(void) __weak;EXPORT_SYMBOL(name)
5755

58-
/* These symbols are generated by the compiler itself */
59-
DECLARE_EXPORT(__udivsi3);
60-
DECLARE_EXPORT(__sdivsi3);
56+
DECLARE_EXPORT(__lshrsi3);
6157
DECLARE_EXPORT(__ashrsi3);
6258
DECLARE_EXPORT(__ashlsi3);
63-
DECLARE_EXPORT(__ashrdi3);
64-
DECLARE_EXPORT(__ashldi3);
6559
DECLARE_EXPORT(__ashiftrt_r4_6);
6660
DECLARE_EXPORT(__ashiftrt_r4_7);
6761
DECLARE_EXPORT(__ashiftrt_r4_8);
@@ -79,8 +73,7 @@ DECLARE_EXPORT(__ashiftrt_r4_23);
7973
DECLARE_EXPORT(__ashiftrt_r4_24);
8074
DECLARE_EXPORT(__ashiftrt_r4_27);
8175
DECLARE_EXPORT(__ashiftrt_r4_30);
82-
DECLARE_EXPORT(__lshrsi3);
83-
DECLARE_EXPORT(__lshrdi3);
76+
DECLARE_EXPORT(__movstr);
8477
DECLARE_EXPORT(__movstrSI8);
8578
DECLARE_EXPORT(__movstrSI12);
8679
DECLARE_EXPORT(__movstrSI16);
@@ -95,31 +88,12 @@ DECLARE_EXPORT(__movstrSI48);
9588
DECLARE_EXPORT(__movstrSI52);
9689
DECLARE_EXPORT(__movstrSI56);
9790
DECLARE_EXPORT(__movstrSI60);
98-
#if __GNUC__ == 4
99-
DECLARE_EXPORT(__movmem);
100-
#else
101-
DECLARE_EXPORT(__movstr);
102-
#endif
103-
104-
#if __GNUC__ == 4
105-
DECLARE_EXPORT(__movmem_i4_even);
106-
DECLARE_EXPORT(__movmem_i4_odd);
107-
DECLARE_EXPORT(__movmemSI12_i4);
108-
109-
#if (__GNUC_MINOR__ >= 2 || defined(__GNUC_STM_RELEASE__))
110-
/*
111-
* GCC >= 4.2 emits these for division, as do GCC 4.1.x versions of the ST
112-
* compiler which include backported patches.
113-
*/
114-
DECLARE_EXPORT(__udiv_qrnnd_16);
115-
MAYBE_DECLARE_EXPORT(__sdivsi3_i4i);
116-
MAYBE_DECLARE_EXPORT(__udivsi3_i4i);
117-
#endif
118-
#else /* GCC 3.x */
11991
DECLARE_EXPORT(__movstr_i4_even);
12092
DECLARE_EXPORT(__movstr_i4_odd);
12193
DECLARE_EXPORT(__movstrSI12_i4);
122-
#endif /* __GNUC__ == 4 */
94+
DECLARE_EXPORT(__udiv_qrnnd_16);
95+
DECLARE_EXPORT(__sdivsi3_i4i);
96+
DECLARE_EXPORT(__udivsi3_i4i);
12397

12498
#if !defined(CONFIG_CACHE_OFF) && (defined(CONFIG_CPU_SH4) || \
12599
defined(CONFIG_SH7705_CACHE_32KB))

‎arch/sh/lib/Makefile‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,25 @@
55
lib-y = delay.o memset.o memmove.o memchr.o \
66
checksum.o strlen.o div64.o div64-generic.o
77

8+
# Extracted from libgcc
9+
lib-y += movmem.o ashldi3.o ashrdi3.o lshrdi3.o \
10+
ashlsi3.o ashrsi3.o ashiftrt.o lshrsi3.o \
11+
udiv_qrnnd.o
12+
13+
udivsi3-y := udivsi3-Os.o
14+
15+
ifneq ($(CONFIG_CC_OPTIMIZE_FOR_SIZE),y)
16+
udivsi3-$(CONFIG_CPU_SH3) := udivsi3.o
17+
udivsi3-$(CONFIG_CPU_SH4) := udivsi3.o
18+
endif
19+
820
obj-y += io.o
921

1022
memcpy-y := memcpy.o
1123
memcpy-$(CONFIG_CPU_SH4) := memcpy-sh4.o
1224

1325
lib-$(CONFIG_MMU) += copy_page.o clear_page.o
1426
lib-$(CONFIG_FUNCTION_TRACER) += mcount.o
15-
lib-y += $(memcpy-y)
27+
lib-y += $(memcpy-y) $(udivsi3-y)
1628

1729
EXTRA_CFLAGS += -Werror

‎arch/sh/lib/ashiftrt.S‎

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/* Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
2+
2004, 2005, 2006
3+
Free Software Foundation, Inc.
4+
5+
This file is free software; you can redistribute it and/or modify it
6+
under the terms of the GNU General Public License as published by the
7+
Free Software Foundation; either version 2, or (at your option) any
8+
later version.
9+
10+
In addition to the permissions in the GNU General Public License, the
11+
Free Software Foundation gives you unlimited permission to link the
12+
compiled version of this file into combinations with other programs,
13+
and to distribute those combinations without any restriction coming
14+
from the use of this file. (The General Public License restrictions
15+
do apply in other respects; for example, they cover modification of
16+
the file, and distribution when not linked into a combine
17+
executable.)
18+
19+
This file is distributed in the hope that it will be useful, but
20+
WITHOUT ANY WARRANTY; without even the implied warranty of
21+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22+
General Public License for more details.
23+
24+
You should have received a copy of the GNU General Public License
25+
along with this program; see the file COPYING. If not, write to
26+
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
27+
Boston, MA 02110-1301, USA. */
28+
29+
!! libgcc routines for the Renesas / SuperH SH CPUs.
30+
!! Contributed by Steve Chamberlain.
31+
!! sac@cygnus.com
32+
33+
!! ashiftrt_r4_x, ___ashrsi3, ___ashlsi3, ___lshrsi3 routines
34+
!! recoded in assembly by Toshiyasu Morita
35+
!! tm@netcom.com
36+
37+
/* SH2 optimizations for ___ashrsi3, ___ashlsi3, ___lshrsi3 and
38+
ELF local label prefixes by J"orn Rennecke
39+
amylaar@cygnus.com */
40+
41+
.global __ashiftrt_r4_0
42+
.global __ashiftrt_r4_1
43+
.global __ashiftrt_r4_2
44+
.global __ashiftrt_r4_3
45+
.global __ashiftrt_r4_4
46+
.global __ashiftrt_r4_5
47+
.global __ashiftrt_r4_6
48+
.global __ashiftrt_r4_7
49+
.global __ashiftrt_r4_8
50+
.global __ashiftrt_r4_9
51+
.global __ashiftrt_r4_10
52+
.global __ashiftrt_r4_11
53+
.global __ashiftrt_r4_12
54+
.global __ashiftrt_r4_13
55+
.global __ashiftrt_r4_14
56+
.global __ashiftrt_r4_15
57+
.global __ashiftrt_r4_16
58+
.global __ashiftrt_r4_17
59+
.global __ashiftrt_r4_18
60+
.global __ashiftrt_r4_19
61+
.global __ashiftrt_r4_20
62+
.global __ashiftrt_r4_21
63+
.global __ashiftrt_r4_22
64+
.global __ashiftrt_r4_23
65+
.global __ashiftrt_r4_24
66+
.global __ashiftrt_r4_25
67+
.global __ashiftrt_r4_26
68+
.global __ashiftrt_r4_27
69+
.global __ashiftrt_r4_28
70+
.global __ashiftrt_r4_29
71+
.global __ashiftrt_r4_30
72+
.global __ashiftrt_r4_31
73+
.global __ashiftrt_r4_32
74+
75+
.align 1
76+
__ashiftrt_r4_32:
77+
__ashiftrt_r4_31:
78+
rotcl r4
79+
rts
80+
subc r4,r4
81+
__ashiftrt_r4_30:
82+
shar r4
83+
__ashiftrt_r4_29:
84+
shar r4
85+
__ashiftrt_r4_28:
86+
shar r4
87+
__ashiftrt_r4_27:
88+
shar r4
89+
__ashiftrt_r4_26:
90+
shar r4
91+
__ashiftrt_r4_25:
92+
shar r4
93+
__ashiftrt_r4_24:
94+
shlr16 r4
95+
shlr8 r4
96+
rts
97+
exts.b r4,r4
98+
__ashiftrt_r4_23:
99+
shar r4
100+
__ashiftrt_r4_22:
101+
shar r4
102+
__ashiftrt_r4_21:
103+
shar r4
104+
__ashiftrt_r4_20:
105+
shar r4
106+
__ashiftrt_r4_19:
107+
shar r4
108+
__ashiftrt_r4_18:
109+
shar r4
110+
__ashiftrt_r4_17:
111+
shar r4
112+
__ashiftrt_r4_16:
113+
shlr16 r4
114+
rts
115+
exts.w r4,r4
116+
__ashiftrt_r4_15:
117+
shar r4
118+
__ashiftrt_r4_14:
119+
shar r4
120+
__ashiftrt_r4_13:
121+
shar r4
122+
__ashiftrt_r4_12:
123+
shar r4
124+
__ashiftrt_r4_11:
125+
shar r4
126+
__ashiftrt_r4_10:
127+
shar r4
128+
__ashiftrt_r4_9:
129+
shar r4
130+
__ashiftrt_r4_8:
131+
shar r4
132+
__ashiftrt_r4_7:
133+
shar r4
134+
__ashiftrt_r4_6:
135+
shar r4
136+
__ashiftrt_r4_5:
137+
shar r4
138+
__ashiftrt_r4_4:
139+
shar r4
140+
__ashiftrt_r4_3:
141+
shar r4
142+
__ashiftrt_r4_2:
143+
shar r4
144+
__ashiftrt_r4_1:
145+
rts
146+
shar r4
147+
__ashiftrt_r4_0:
148+
rts
149+
nop

‎arch/sh/lib/ashldi3.c‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include <linux/module.h>
2+
3+
#include "libgcc.h"
4+
5+
long long __ashldi3(long long u, word_type b)
6+
{
7+
DWunion uu, w;
8+
word_type bm;
9+
10+
if (b == 0)
11+
return u;
12+
13+
uu.ll = u;
14+
bm = 32 - b;
15+
16+
if (bm <= 0) {
17+
w.s.low = 0;
18+
w.s.high = (unsigned int) uu.s.low << -bm;
19+
} else {
20+
const unsigned int carries = (unsigned int) uu.s.low >> bm;
21+
22+
w.s.low = (unsigned int) uu.s.low << b;
23+
w.s.high = ((unsigned int) uu.s.high << b) | carries;
24+
}
25+
26+
return w.ll;
27+
}
28+
29+
EXPORT_SYMBOL(__ashldi3);

0 commit comments

Comments
 (0)