aboutsummaryrefslogtreecommitdiff
path: root/libgcc
diff options
context:
space:
mode:
Diffstat (limited to 'libgcc')
-rw-r--r--libgcc/ChangeLog5
-rw-r--r--libgcc/config.host4
-rw-r--r--libgcc/config/epiphany/crti.S34
-rw-r--r--libgcc/config/epiphany/crtint.S27
-rw-r--r--libgcc/config/epiphany/crtm1reg-r43.S26
-rw-r--r--libgcc/config/epiphany/crtm1reg-r63.S26
-rw-r--r--libgcc/config/epiphany/crtn.S32
-rw-r--r--libgcc/config/epiphany/crtrunc.S26
-rw-r--r--libgcc/config/epiphany/divsi3-float.S77
-rw-r--r--libgcc/config/epiphany/divsi3.S92
-rw-r--r--libgcc/config/epiphany/divsi3.c120
-rw-r--r--libgcc/config/epiphany/epiphany-asm.h53
-rw-r--r--libgcc/config/epiphany/ieee-754/eqsf2.S50
-rw-r--r--libgcc/config/epiphany/ieee-754/fast_div.S124
-rw-r--r--libgcc/config/epiphany/ieee-754/gtesf2.S66
-rw-r--r--libgcc/config/epiphany/ieee-754/ordsf2.S50
-rw-r--r--libgcc/config/epiphany/ieee-754/uneqsf2.S45
-rw-r--r--libgcc/config/epiphany/modsi3-float.S65
-rw-r--r--libgcc/config/epiphany/modsi3.S77
-rw-r--r--libgcc/config/epiphany/modsi3.c106
-rw-r--r--libgcc/config/epiphany/mulsi3.c39
-rw-r--r--libgcc/config/epiphany/t-custom-eqsf1
-rw-r--r--libgcc/config/epiphany/t-epiphany35
-rw-r--r--libgcc/config/epiphany/udivsi3-float.S83
-rw-r--r--libgcc/config/epiphany/udivsi3-float.c125
-rw-r--r--libgcc/config/epiphany/udivsi3.S85
-rw-r--r--libgcc/config/epiphany/udivsi3.c114
-rw-r--r--libgcc/config/epiphany/umodsi3-float.S63
-rw-r--r--libgcc/config/epiphany/umodsi3.S70
-rw-r--r--libgcc/config/epiphany/umodsi3.c101
30 files changed, 1821 insertions, 0 deletions
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 0a94c95..ae5e463 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,8 @@
+2011-11-05 Joern Rennecke <joern.rennecke@embecosm.com>
+
+ * config.host (epiphany-*-elf*): New configuration.
+ * config/epiphany: New Directory.
+
2011-11-05 Ralf Corsépius <ralf.corsepius@rtems.org>
* config.host (avr-*-rtems*): Add config/avr/t-rtems.
diff --git a/libgcc/config.host b/libgcc/config.host
index 1834179..36297fe 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -433,6 +433,10 @@ cris-*-elf)
cris-*-linux* | crisv32-*-linux*)
tmake_file="$tmake_file cris/t-cris t-fdpbit cris/t-linux"
;;
+epiphany-*-elf*)
+ tmake_file="epiphany/t-epiphany t-fdpbit epiphany/t-custom-eqsf"
+ extra_parts="$extra_parts crti.o crtint.o crtrunc.o crtm1reg-r43.o crtm1reg-r63.o crtn.o"
+ ;;
fr30-*-elf)
tmake_file="$tmake_file fr30/t-fr30 t-fdpbit"
extra_parts="$extra_parts crti.o crtn.o"
diff --git a/libgcc/config/epiphany/crti.S b/libgcc/config/epiphany/crti.S
new file mode 100644
index 0000000..527d926
--- /dev/null
+++ b/libgcc/config/epiphany/crti.S
@@ -0,0 +1,34 @@
+# Start .init and .fini sections.
+# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+# Contributed by Embecosm on behalf of Adapteva, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# Under Section 7 of GPL version 3, you are granted additional
+# permissions described in the GCC Runtime Library Exception, version
+# 3.1, as published by the Free Software Foundation.
+#
+# You should have received a copy of the GNU General Public License and
+# a copy of the GCC Runtime Library Exception along with this program;
+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+# <http://www.gnu.org/licenses/>.
+
+ .section .init
+ .global init
+ .balign 2
+init:
+ str lr,[sp],-4
+
+ .section .fini
+ .global fini
+ .balign 2
+fini:
+ str lr,[sp],-4
diff --git a/libgcc/config/epiphany/crtint.S b/libgcc/config/epiphany/crtint.S
new file mode 100644
index 0000000..e66b34e
--- /dev/null
+++ b/libgcc/config/epiphany/crtint.S
@@ -0,0 +1,27 @@
+# initialize config for -mfp-mode=int
+# Copyright (C) 2011 Free Software Foundation, Inc.
+# Contributed by Embecosm on behalf of Adapteva, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# Under Section 7 of GPL version 3, you are granted additional
+# permissions described in the GCC Runtime Library Exception, version
+# 3.1, as published by the Free Software Foundation.
+#
+# You should have received a copy of the GNU General Public License and
+# a copy of the GCC Runtime Library Exception along with this program;
+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+# <http://www.gnu.org/licenses/>.
+
+ .section .init
+ mov r0, %low(#524288)
+ movt r0, %high(#524288)
+ movts config,r0
diff --git a/libgcc/config/epiphany/crtm1reg-r43.S b/libgcc/config/epiphany/crtm1reg-r43.S
new file mode 100644
index 0000000..02ef9f2
--- /dev/null
+++ b/libgcc/config/epiphany/crtm1reg-r43.S
@@ -0,0 +1,26 @@
+# initialize config for -m1reg-r43
+# Copyright (C) 2011 Free Software Foundation, Inc.
+# Contributed by Embecosm on behalf of Adapteva, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# Under Section 7 of GPL version 3, you are granted additional
+# permissions described in the GCC Runtime Library Exception, version
+# 3.1, as published by the Free Software Foundation.
+#
+# You should have received a copy of the GNU General Public License and
+# a copy of the GCC Runtime Library Exception along with this program;
+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+# <http://www.gnu.org/licenses/>.
+
+ .section .init
+ mov r0, 0
+ sub r43,r0,1
diff --git a/libgcc/config/epiphany/crtm1reg-r63.S b/libgcc/config/epiphany/crtm1reg-r63.S
new file mode 100644
index 0000000..8bd9fb6
--- /dev/null
+++ b/libgcc/config/epiphany/crtm1reg-r63.S
@@ -0,0 +1,26 @@
+# initialize config for -m1reg-r63
+# Copyright (C) 2011 Free Software Foundation, Inc.
+# Contributed by Embecosm on behalf of Adapteva, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# Under Section 7 of GPL version 3, you are granted additional
+# permissions described in the GCC Runtime Library Exception, version
+# 3.1, as published by the Free Software Foundation.
+#
+# You should have received a copy of the GNU General Public License and
+# a copy of the GCC Runtime Library Exception along with this program;
+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+# <http://www.gnu.org/licenses/>.
+
+ .section .init
+ mov r0, 0
+ sub r63,r0,1
diff --git a/libgcc/config/epiphany/crtn.S b/libgcc/config/epiphany/crtn.S
new file mode 100644
index 0000000..2c326bf
--- /dev/null
+++ b/libgcc/config/epiphany/crtn.S
@@ -0,0 +1,32 @@
+# End .init and .fini sections.
+# Copyright (C) 2010, 2011 Free Software Foundation, Inc.
+# Contributed by Embecosm on behalf of Adapteva, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# Under Section 7 of GPL version 3, you are granted additional
+# permissions described in the GCC Runtime Library Exception, version
+# 3.1, as published by the Free Software Foundation.
+#
+# You should have received a copy of the GNU General Public License and
+# a copy of the GCC Runtime Library Exception along with this program;
+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+# <http://www.gnu.org/licenses/>.
+
+ .section .init
+ ldr lr,[sp,4]
+ add sp,sp,16
+ jr lr
+
+ .section .fini
+ ldr lr,[sp,4]
+ add sp,sp,16
+ jr lr
diff --git a/libgcc/config/epiphany/crtrunc.S b/libgcc/config/epiphany/crtrunc.S
new file mode 100644
index 0000000..37b0507
--- /dev/null
+++ b/libgcc/config/epiphany/crtrunc.S
@@ -0,0 +1,26 @@
+# initialize config for -mfp-mode=truncate
+# Copyright (C) 2011 Free Software Foundation, Inc.
+# Contributed by Embecosm on behalf of Adapteva, Inc.
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# Under Section 7 of GPL version 3, you are granted additional
+# permissions described in the GCC Runtime Library Exception, version
+# 3.1, as published by the Free Software Foundation.
+#
+# You should have received a copy of the GNU General Public License and
+# a copy of the GCC Runtime Library Exception along with this program;
+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+# <http://www.gnu.org/licenses/>.
+
+ .section .init
+ mov r0, 1
+ movts config,r0
diff --git a/libgcc/config/epiphany/divsi3-float.S b/libgcc/config/epiphany/divsi3-float.S
new file mode 100644
index 0000000..31a0506
--- /dev/null
+++ b/libgcc/config/epiphany/divsi3-float.S
@@ -0,0 +1,77 @@
+/* Signed 32 bit division optimized for Epiphany.
+ Copyright (C) 2009, 2011 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "epiphany-asm.h"
+
+ FSTAB (__divsi3,T_UINT)
+ .global SYM(__divsi3)
+ .balign 4
+ HIDDEN_FUNC(__divsi3)
+SYM(__divsi3):
+ float TMP2,r0
+ mov TMP4,0
+ float TMP1,r1
+ sub TMP0,TMP4,r0
+ beq .Lret_r0
+ movgt r0,TMP0
+ sub TMP0,TMP4,r1
+ movgt r1,TMP0
+ mov TMP0,1
+ sub TMP2,TMP2,TMP1
+ asr TMP3,TMP2,31 ; save sign
+ lsl TMP2,TMP2,1
+ blt .Lret0
+ sub TMP1,TMP2,1 ; rounding compensation, avoid overflow
+ movgte TMP2,TMP1
+ lsr TMP2,TMP2,24
+ lsl r1,r1,TMP2
+ lsl TMP0,TMP0,TMP2
+ sub TMP1,r0,r1
+ movgteu r0,TMP1
+ movgteu TMP4,TMP0
+ lsl TMP5,TMP0,1
+ sub TMP1,r0,r1
+ movgteu r0,TMP1
+ movgteu TMP4,TMP5
+ sub TMP1,r1,1
+ mov r1,%low(.L0step)
+ movt r1,%high(.L0step)
+ lsl TMP2,TMP2,3
+ sub r1,r1,TMP2
+ jr r1
+ .rep 30
+ lsl r0,r0,1
+ sub.l r1,r0,TMP1
+ movgteu r0,r1
+ .endr
+.L0step:sub r1,TMP0,1 ; mask result bits from steps ...
+ and r0,r0,r1
+ orr r0,r0,TMP4 ; ... and combine with first bit.
+ eor r0,r0,TMP3 ; restore sign
+ sub r0,r0,TMP3
+.Lret_r0:rts
+.Lret0: mov r0,0
+ rts
+ ENDFUNC(__divsi3)
diff --git a/libgcc/config/epiphany/divsi3.S b/libgcc/config/epiphany/divsi3.S
new file mode 100644
index 0000000..bdb2860
--- /dev/null
+++ b/libgcc/config/epiphany/divsi3.S
@@ -0,0 +1,92 @@
+/* Signed 32 bit division optimized for Epiphany.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "epiphany-asm.h"
+
+ FSTAB (__divsi3,T_INT)
+ .global SYM(__divsi3)
+ .balign 4
+ HIDDEN_FUNC(__divsi3)
+SYM(__divsi3):
+ mov r12,0
+ sub r2,r12,r0
+ movlt r2,r0
+ sub r3,r12,r1
+ movlt r3,r1
+ sub r19,r2,r3
+ bltu .Lret0
+ movt r12,0x4000
+ orr r16,r2,r12
+ orr r18,r3,r12
+ fsub r16,r16,r12
+ fsub r18,r18,r12
+ movt r12,0x4b80
+ lsr r19,r3,23
+ lsr r17,r2,23
+ movt r17,0x4b80
+ fsub r17,r17,r12
+ movt r19,0x4b80
+ fsub r19,r19,r12
+ mov r12,%low(.L0step)
+ movt r12,%high(.L0step)
+ mov r20,0
+ mov r21,1
+ movne r16,r17
+ lsr r17,r3,23
+ movne r18,r19
+ eor r1,r1,r0 ; save sign
+ asr r19,r1,31
+ lsr r1,r16,23
+ lsr r0,r18,23
+ sub r1,r1,r0 ; calculate bit number difference.
+ lsl r3,r3,r1
+ lsr r16,r3,1
+ lsl r0,r21,r1
+ lsl r1,r1,3
+ sub r12,r12,r1
+ sub r3,r2,r3
+ movgteu r2,r3
+ movgteu r20,r0
+ lsr r0,r0,1
+ add r17,r0,r20
+ sub r3,r2,r16
+ movgteu r2,r3
+ movgteu r20,r17
+ sub r16,r16,1
+ jr r12
+ .rep 30
+ lsl r2,r2,1
+ sub r3,r2,r16
+ movgteu r2,r3
+ .endr
+ sub r0,r0,1 ; mask result bits from steps ...
+ and r0,r0,r2
+ orr r20,r0,r20 ; ... and combine with first bit.
+.L0step:eor r0,r20,r19 ; restore sign
+ sub r0,r0,r19
+ rts
+.Lret0: mov r0,0
+ rts
+ ENDFUNC(__divsi3)
diff --git a/libgcc/config/epiphany/divsi3.c b/libgcc/config/epiphany/divsi3.c
new file mode 100644
index 0000000..c15aaf3
--- /dev/null
+++ b/libgcc/config/epiphany/divsi3.c
@@ -0,0 +1,120 @@
+/* Generic signed 32 bit division implementation.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+typedef union { unsigned int i; float f; } fu;
+
+/* Although the semantics of the function ask for signed / unsigned inputs,
+ for the actual implementation we use unsigned numbers. */
+unsigned int __divsi3 (unsigned int a, unsigned int b);
+
+unsigned int
+__divsi3 (unsigned int a, unsigned int b)
+{
+ unsigned int sign = (int) (a ^ b) >> 31;
+ unsigned int d, t, s0, s1, s2, r0, r1;
+ fu u0, u1, u2, u1b, u2b;
+
+ a = abs (a);
+ b = abs (b);
+
+ if (b > a)
+ return 0;
+
+ /* Compute difference in number of bits in S0. */
+ u0.i = 0x40000000;
+ u1b.i = u2b.i = u0.i;
+ u1.i = a;
+ u2.i = b;
+ u1.i = a | u0.i;
+ t = 0x4b800000 | ((a >> 23) & 0xffff);
+ if (a >> 23)
+ {
+ u1.i = t;
+ u1b.i = 0x4b800000;
+ }
+ u2.i = b | u0.i;
+ t = 0x4b800000 | ((b >> 23) & 0xffff);
+ if (b >> 23)
+ {
+ u2.i = t;
+ u2b.i = 0x4b800000;
+ }
+ u1.f = u1.f - u1b.f;
+ u2.f = u2.f - u2b.f;
+ s1 = u1.i >> 23;
+ s2 = u2.i >> 23;
+ s0 = s1 - s2;
+
+ b <<= s0;
+ d = b - 1;
+
+ r0 = 1 << s0;
+ r1 = 0;
+ t = a - b;
+ if (t <= a)
+ {
+ a = t;
+ r1 = r0;
+ }
+
+#define STEP(n) case n: a += a; t = a - d; if (t <= a) a = t;
+ switch (s0)
+ {
+ STEP (31)
+ STEP (30)
+ STEP (29)
+ STEP (28)
+ STEP (27)
+ STEP (26)
+ STEP (25)
+ STEP (24)
+ STEP (23)
+ STEP (22)
+ STEP (21)
+ STEP (20)
+ STEP (19)
+ STEP (18)
+ STEP (17)
+ STEP (16)
+ STEP (15)
+ STEP (14)
+ STEP (13)
+ STEP (12)
+ STEP (11)
+ STEP (10)
+ STEP (9)
+ STEP (8)
+ STEP (7)
+ STEP (6)
+ STEP (5)
+ STEP (4)
+ STEP (3)
+ STEP (2)
+ STEP (1)
+ case 0: ;
+ }
+ r0 = r1 | (r0-1 & a);
+ return (r0 ^ sign) - sign;
+}
diff --git a/libgcc/config/epiphany/epiphany-asm.h b/libgcc/config/epiphany/epiphany-asm.h
new file mode 100644
index 0000000..e86f7ef
--- /dev/null
+++ b/libgcc/config/epiphany/epiphany-asm.h
@@ -0,0 +1,53 @@
+/* Copyright (C) 1995, 1997, 2007, 2008, 2009, 2011
+ Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+/* ANSI concatenation macros. */
+
+#define CONCAT1(a, b) CONCAT2(a, b)
+#define CONCAT2(a, b) a ## b
+#define STRINGIFY2(a, b) STRINGIFY(a##b)
+#define STRINGIFY(a) #a
+
+/* Use the right prefix for global labels. */
+
+#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
+
+#define FSTAB(X,T) .stabs STRINGIFY2(X##:F,T),36,0,__LINE__,SYM(X)
+#define FUNC(X) .type SYM(X),@function
+#define HIDDEN_FUNC(X) FUNC(X)` .hidden SYM(X)
+#define ENDFUNC0(X) CONCAT1(.Lfe_,X): .size X,CONCAT1(.Lfe_,X)-X
+#define ENDFUNC(X) ENDFUNC0(SYM(X))
+
+#define TMP0 r12
+#define TMP1 r16
+#define TMP2 r17
+#define TMP3 r18
+#define TMP4 r19
+#define TMP5 r20
+
+#define T_INT (0,1)
+ .stabs "int:t(0,1)=r(0,1);-2147483648;2147483647;",128,0,1,0
+#define T_UINT (0,2)
+ .stabs "unsigned int:t(0,2)=r(0,2);0;037777777777;",128,0,1,0
diff --git a/libgcc/config/epiphany/ieee-754/eqsf2.S b/libgcc/config/epiphany/ieee-754/eqsf2.S
new file mode 100644
index 0000000..3c04e2a
--- /dev/null
+++ b/libgcc/config/epiphany/ieee-754/eqsf2.S
@@ -0,0 +1,50 @@
+/* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "../epiphany-asm.h"
+
+ /* Assumption: NaNs have all bits 10..30 and one of bit 0..9 set. */
+
+ FSTAB (__eqsf2,T_INT)
+ .global SYM(__eqsf2)
+ .balign 4
+ HIDDEN_FUNC(__eqsf2)
+SYM(__eqsf2):
+ sub TMP0,r0,r1
+ beq .Lno_bdiff
+ orr TMP0,r0,r1
+ add TMP0,TMP0,TMP0
+ rts
+.Lno_bdiff:
+#ifndef FLOAT_FORMAT_MOTOROLA
+ mov TMP0,0xffff
+ movt TMP0,0x7f
+ add TMP0,TMP0,r0
+#else
+ add TMP0,r0,0x3ff
+#endif
+ eor TMP0,TMP0,r0
+ lsr TMP0,TMP0,31
+ rts
+ ENDFUNC(__eqsf2)
diff --git a/libgcc/config/epiphany/ieee-754/fast_div.S b/libgcc/config/epiphany/ieee-754/fast_div.S
new file mode 100644
index 0000000..a6cf748
--- /dev/null
+++ b/libgcc/config/epiphany/ieee-754/fast_div.S
@@ -0,0 +1,124 @@
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "../epiphany-asm.h"
+
+.section _fast_div_text,"a",@progbits;
+ .balign 8;
+_fast_div_table:
+.word 0x007fffff// mantissa mask
+.word 0x40257ebb// hold constant a = 2.58586
+
+.word 0x3f000000// hold constant 126 shifted to bits [30:23]
+.word 0xc0ba2e88// hold constant b = -5.81818
+
+.word 0x4087c1e8// hold constant c = 4.24242
+.word 0x40000000// to hold constant 2 for Newton-Raphson iterations
+
+ .global SYM(__fast_recipsf2)
+ FUNC(__fast_recipsf2)
+SYM(__fast_recipsf2):
+
+//###################
+//# input operands:
+//###################
+// Divisor
+//R0
+// Function address (used with negative offsets to read _fast_div_table)
+//R1
+/* Scratch registers: two single (TMP0/TMP5) and two pairs. */
+#define P0L TMP1
+#define P0H TMP2
+#define P1L TMP3
+#define P1H TMP4
+
+//#########################################
+//# Constants to be used in the algorithm
+//#########################################
+ldrd P0L , [ R1 , -3 ]
+
+ldrd P1L , [ R1 , -2 ]
+
+
+
+//#############################################################################
+//# The Algorithm
+//#
+//# Operation: C=A/B
+//# stage 1 - find the reciprocal 1/B according to the following scheme:
+//# B = (2^E)*m (1<m<2, E=e-127)
+//# 1/B = 1/((2^E)*m) = 1/((2^(E+1))*m1) (0.5<m1<1)
+//# = (2^-(E+1))*(1/m1) = (2^E1)*(1/m1)
+//#
+//# Now we can find the new exponent:
+//# e1 = E1+127 = -E-1+127 = -e+127-1+127 = 253-e **
+//# 1/m1 alreadt has the exponent 127, so we have to add 126-e.
+//# the exponent might underflow, which we can detect as a sign change.
+//# Since the architeture uses flush-to-zero for subnormals, we can
+//# give the result 0. then.
+//#
+//# The 1/m1 term with 0.5<m1<1 is approximated with the Chebyshev polynomial
+//# 1/m1 = 2.58586*(m1^2) - 5.81818*m1 + 4.24242
+//#
+//# Next step is to use two iterations of Newton-Raphson algorithm to complete
+//# the reciprocal calculation.
+//#
+//# Final result is achieved by multiplying A with 1/B
+//#############################################################################
+
+
+
+// R0 exponent and sign "replacement" into TMP0
+AND TMP0,R0,P0L ;
+ORR TMP0,TMP0,P1L
+SUB TMP5,R0,TMP0 // R0 sign/exponent extraction into TMP5
+// Calculate new mantissa
+FMADD P1H,TMP0,P0H ;
+ // Calculate new exponent offset 126 - "old exponent"
+ SUB P1L,P1L,TMP5
+ ldrd P0L , [ R1 , -1 ]
+FMADD P0L,TMP0,P1H ;
+ eor P1H,r0,P1L // check for overflow (N-BIT).
+ blt .Lret_0
+// P0L exponent and sign "replacement"
+sub P0L,P0L,TMP5
+
+// Newton-Raphson iteration #1
+MOV TMP0,P0H ;
+FMSUB P0H,R0,P0L ;
+FMUL P0L,P0H,P0L ;
+// Newton-Raphson iteration #2
+FMSUB TMP0,R0,P0L ;
+FMUL R0,TMP0,P0L ;
+jr lr
+.Lret_0:ldrd P0L , [ R1 , -3 ]
+ lsr TMP0,r0,31 ; extract sign
+ lsl TMP0,TMP0,31
+ add P0L,P0L,r0 ; check for NaN input
+ eor P0L,P0L,r0
+ movgte r0,TMP0
+ jr lr
+// Quotient calculation is expected by the caller: FMUL quotient,divident,R0
+ ;
+ ENDFUNC(__fast_recipsf2)
diff --git a/libgcc/config/epiphany/ieee-754/gtesf2.S b/libgcc/config/epiphany/ieee-754/gtesf2.S
new file mode 100644
index 0000000..615dde4
--- /dev/null
+++ b/libgcc/config/epiphany/ieee-754/gtesf2.S
@@ -0,0 +1,66 @@
+/* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "../epiphany-asm.h"
+
+ /* Assumptions: NaNs have all bits 10..30 and one of bit 0..9 set.
+ after sub: AC = ~Borrow.
+ clobber: TMP0
+ output: gt / gte indicates greater / greater or equal. */
+
+ FSTAB (__gtesf2,T_INT)
+ .global SYM(__gtesf2)
+ .balign 4
+ HIDDEN_FUNC(__gtesf2)
+SYM(__gtesf2):
+#ifndef FLOAT_FORMAT_MOTOROLA
+ mov TMP0,0xffff
+ movt TMP0,0x7f
+ add TMP0,TMP0,r0
+ eor TMP0,TMP0,r0
+ blt .Lret
+ mov TMP0,0xffff
+ movt TMP0,0x7f
+ add TMP0,TMP0,r1
+#else
+ add TMP0,r0,0x3ff; check for r0 NaN
+ eor TMP0,TMP0,r0
+ blt .Lret
+ add TMP0,r1,0x3ff; check for r1 NaN
+#endif
+ eor TMP0,TMP0,r1
+ blt .Lret
+ and TMP0,r0,r1
+ blt .Lneg
+ orr TMP0,r0,r1
+ lsl TMP0,TMP0,1
+ beq .Lret
+ sub TMP0,r0,r1
+.Lret:
+ rts
+ .balign 4
+.Lneg:
+ sub TMP0,r1,r0
+ rts
+ ENDFUNC(__gtesf2)
diff --git a/libgcc/config/epiphany/ieee-754/ordsf2.S b/libgcc/config/epiphany/ieee-754/ordsf2.S
new file mode 100644
index 0000000..8493660
--- /dev/null
+++ b/libgcc/config/epiphany/ieee-754/ordsf2.S
@@ -0,0 +1,50 @@
+/* Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "../epiphany-asm.h"
+
+ FSTAB (__ordsf2,T_INT)
+ .global SYM(__ordsf2)
+ .balign 8,,2
+ HIDDEN_FUNC(__ordsf2)
+SYM(__ordsf2):
+#ifndef FLOAT_FORMAT_MOTOROLA
+ mov TMP0,0
+ movt TMP0,0xff00
+ lsl TMP1,r0,1
+ sub TMP1,TMP1,TMP0
+ bgtu .Lret
+ lsl TMP1,r1,1
+ sub TMP1,TMP1,TMP0
+.Lret: rts /* ordered: lteu */
+#else
+ /* Assumption: NaNs have all bits 9..30 and one of bit 0..8 set. */
+ lsl TMP0,r0,1
+ add TMP0,TMP0,0x3fe
+ bgteu .Lret
+ lsl TMP0,r1,1
+ add TMP0,TMP0,0x3fe
+.Lret: rts /* ordered: ltu */
+#endif
+ ENDFUNC(__ordsf2)
diff --git a/libgcc/config/epiphany/ieee-754/uneqsf2.S b/libgcc/config/epiphany/ieee-754/uneqsf2.S
new file mode 100644
index 0000000..cba04d3
--- /dev/null
+++ b/libgcc/config/epiphany/ieee-754/uneqsf2.S
@@ -0,0 +1,45 @@
+/* Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "../epiphany-asm.h"
+
+ FSTAB (__uneqsf2,T_INT)
+ .global SYM(__uneqsf2)
+ .balign 8,,2
+ HIDDEN_FUNC(__uneqsf2)
+SYM(__uneqsf2):
+ sub TMP0,r0,r1
+ beq .Lret
+ orr TMP0,r0,r1
+ add TMP0,TMP0,TMP0
+ beq .Lret
+ mov TMP0,1
+ movt TMP0,0xff00
+ lsl TMP1,r0,1
+ sub TMP1,TMP0,TMP1
+ blteu .Lret
+ lsl TMP1,r1,1
+ sub TMP1,TMP0,TMP1
+.Lret: rts /* uneq: lteu */
+ ENDFUNC(__uneqsf2)
diff --git a/libgcc/config/epiphany/modsi3-float.S b/libgcc/config/epiphany/modsi3-float.S
new file mode 100644
index 0000000..b789412
--- /dev/null
+++ b/libgcc/config/epiphany/modsi3-float.S
@@ -0,0 +1,65 @@
+/* Unsigned 32 bit division optimized for Epiphany.
+ Copyright (C) 2009, 2011 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "epiphany-asm.h"
+
+ FSTAB (__modsi3,T_UINT)
+ .global SYM(__modsi3)
+ .balign 4
+ HIDDEN_FUNC(__modsi3)
+SYM(__modsi3):
+ asr TMP3,r0,31 ; save sign
+ float TMP0,r0
+ float TMP1,r1
+ mov r2,0
+ sub TMP4,r2,r0
+ beq .Lret_r0
+ movgt r0,TMP4
+ sub TMP2,r2,r1
+ movlte TMP2,r1
+ sub r2,TMP0,TMP1
+ lsl r2,r2,1
+ blte .L0step
+ asr TMP4,r2,24
+ lsl r2,TMP4,3
+ mov TMP4,%low(.L0step)
+ movt TMP4,%high(.L0step)
+ sub r2,TMP4,r2
+ jr r2
+#define STEP(n) lsl.l r2,TMP2,n` sub r2,r0,r2` movgteu r0,r2
+ .balign 8,,2
+ STEP(31)` STEP(30)` STEP(29)` STEP(28)`
+ STEP(27)` STEP(26)` STEP(25)` STEP(24)`
+ STEP(23)` STEP(22)` STEP(21)` STEP(20)`
+ STEP(19)` STEP(18)` STEP(17)` STEP(16)`
+ STEP(15)` STEP(14)` STEP(13)` STEP(12)`
+ STEP(11)` STEP(10)` STEP(9)` STEP(8)`
+ STEP(7)` STEP(6)` STEP(5)` STEP(4)` STEP(3)` STEP(2)` STEP(1)
+.L0step:STEP(0)
+ eor r0,r0,TMP3 ; restore sign
+ sub r0,r0,TMP3
+.Lret_r0:
+ rts
+ ENDFUNC(__modsi3)
diff --git a/libgcc/config/epiphany/modsi3.S b/libgcc/config/epiphany/modsi3.S
new file mode 100644
index 0000000..d969b79
--- /dev/null
+++ b/libgcc/config/epiphany/modsi3.S
@@ -0,0 +1,77 @@
+/* Signed 32 bit modulo optimized for Epiphany.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "epiphany-asm.h"
+
+ FSTAB (__modsi3,T_INT)
+ .global SYM(__modsi3)
+ .balign 4
+ HIDDEN_FUNC(__modsi3)
+SYM(__modsi3):
+ asr r17,r0,31 ; save sign
+ mov r2,0
+ sub r3,r2,r0
+ movgt r0,r3
+ sub r3,r2,r1
+ movgt r1,r3
+ movt r2,0xa000 ; 0xa0000000
+ orr r3,r2,r0
+ lsr r15,r0,16
+ movt r15,0xa800
+ movne r3,r15
+ lsr r16,r2,2 ; 0x28000000
+ and r15,r3,r16
+ fadd r12,r3,r15
+ orr r3,r2,r1
+ lsr r2,r1,16
+ movt r2,0xa800
+ movne r3,r2
+ and r2,r16,r3
+ fadd r3,r3,r2
+ sub r2,r0,r1
+ bltu .Lret_a
+ lsr r12,r12,23
+ mov r2,%low(.L0step)
+ movt r2,%high(.L0step)
+ lsr r3,r3,23
+ sub r3,r12,r3 ; calculate bit number difference.
+ lsl r3,r3,3
+ sub r2,r2,r3
+ jr r2
+/* lsl_l r2,r1,n` sub r2,r0,r2` movgteu r0,r2 */
+#define STEP(n) .long 0x0006441f | (n) << 5` sub r2,r0,r2` movgteu r0,r2
+ .balign 8,,2
+ STEP(31)` STEP(30)` STEP(29)` STEP(28)`
+ STEP(27)` STEP(26)` STEP(25)` STEP(24)`
+ STEP(23)` STEP(22)` STEP(21)` STEP(20)`
+ STEP(19)` STEP(18)` STEP(17)` STEP(16)`
+ STEP(15)` STEP(14)` STEP(13)` STEP(12)`
+ STEP(11)` STEP(10)` STEP(9)` STEP(8)`
+ STEP(7)` STEP(6)` STEP(5)` STEP(4)` STEP(3)` STEP(2)` STEP(1)
+.L0step:STEP(0)
+.Lret_a:eor r0,r0,r17 ; restore sign
+ sub r0,r0,r17
+ rts
+ ENDFUNC(__modsi3)
diff --git a/libgcc/config/epiphany/modsi3.c b/libgcc/config/epiphany/modsi3.c
new file mode 100644
index 0000000..feee3d1
--- /dev/null
+++ b/libgcc/config/epiphany/modsi3.c
@@ -0,0 +1,106 @@
+/* Generic signed 32 bit modulo implementation.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+typedef union { unsigned int i; float f; } fu;
+
+unsigned int __modsi3 (unsigned int a, unsigned int b);
+
+unsigned int
+__modsi3 (unsigned int a, unsigned int b)
+{
+ unsigned int sign = (int) a >> 31;
+ unsigned int d, t, s0, s1, s2, r0, r1;
+ fu u0, u1, u2, u1b, u2b;
+
+ a = abs (a);
+ b = abs (b);
+
+ if (b > a)
+ goto ret_a;
+
+ /* Compute difference in number of bits in S0. */
+ u0.i = 0x40000000;
+ u1b.i = u2b.i = u0.i;
+ u1.i = a;
+ u2.i = b;
+ u1.i = a | u0.i;
+ t = 0x4b800000 | ((a >> 23) & 0xffff);
+ if (a >> 23)
+ {
+ u1.i = t;
+ u1b.i = 0x4b800000;
+ }
+ u2.i = b | u0.i;
+ t = 0x4b800000 | ((b >> 23) & 0xffff);
+ if (b >> 23)
+ {
+ u2.i = t;
+ u2b.i = 0x4b800000;
+ }
+ u1.f = u1.f - u1b.f;
+ u2.f = u2.f - u2b.f;
+ s1 = u1.i >> 23;
+ s2 = u2.i >> 23;
+ s0 = s1 - s2;
+
+#define STEP(n) case n: d = b << n; t = a - d; if (t <= a) a = t;
+ switch (s0)
+ {
+ STEP (31)
+ STEP (30)
+ STEP (29)
+ STEP (28)
+ STEP (27)
+ STEP (26)
+ STEP (25)
+ STEP (24)
+ STEP (23)
+ STEP (22)
+ STEP (21)
+ STEP (20)
+ STEP (19)
+ STEP (18)
+ STEP (17)
+ STEP (16)
+ STEP (15)
+ STEP (14)
+ STEP (13)
+ STEP (12)
+ STEP (11)
+ STEP (10)
+ STEP (9)
+ STEP (8)
+ STEP (7)
+ STEP (6)
+ STEP (5)
+ STEP (4)
+ STEP (3)
+ STEP (2)
+ STEP (1)
+ STEP (0)
+ }
+ ret_a:
+ return (a ^ sign) - sign;
+}
diff --git a/libgcc/config/epiphany/mulsi3.c b/libgcc/config/epiphany/mulsi3.c
new file mode 100644
index 0000000..148361d
--- /dev/null
+++ b/libgcc/config/epiphany/mulsi3.c
@@ -0,0 +1,39 @@
+/* Generic 32 bit multiply.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+unsigned int
+__mulsi3 (unsigned int a, unsigned int b)
+{
+ unsigned int r = 0;
+
+ while (a)
+ {
+ if (a & 1)
+ r += b;
+ a >>= 1;
+ b <<= 1;
+ }
+ return r;
+}
diff --git a/libgcc/config/epiphany/t-custom-eqsf b/libgcc/config/epiphany/t-custom-eqsf
new file mode 100644
index 0000000..3b5a54ac
--- /dev/null
+++ b/libgcc/config/epiphany/t-custom-eqsf
@@ -0,0 +1 @@
+FPBIT_FUNCS := $(filter-out _eq_sf,$(FPBIT_FUNCS))
diff --git a/libgcc/config/epiphany/t-epiphany b/libgcc/config/epiphany/t-epiphany
new file mode 100644
index 0000000..4b67f5d
--- /dev/null
+++ b/libgcc/config/epiphany/t-epiphany
@@ -0,0 +1,35 @@
+# Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003,
+# 2004, 2009, 2010, 2011 Free Software Foundation, Inc.
+# Contributed by Embecosm on behalf of Adapteva, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+LIB2ADD_ST = $(srcdir)/config/epiphany/modsi3-float.S \
+ $(srcdir)/config/epiphany/divsi3-float.S \
+ $(srcdir)/config/epiphany/udivsi3-float.S \
+ $(srcdir)/config/epiphany/umodsi3-float.S \
+ $(srcdir)/config/epiphany/ieee-754/eqsf2.S \
+ $(srcdir)/config/epiphany/ieee-754/gtesf2.S \
+ $(srcdir)/config/epiphany/ieee-754/ordsf2.S \
+ $(srcdir)/config/epiphany/ieee-754/uneqsf2.S \
+ $(srcdir)/config/epiphany/ieee-754/fast_div.S
+
+# .init/.fini section routines
+
+crtint.o crtrunc.o crtm1reg-r43.o crtm1reg-r63.o : \
+ %.o: $(srcdir)/config/epiphany/%.S $(GCC_PASSES) $(CONFIG_H)
+ $(crt_compile) -c -x assembler-with-cpp $<
diff --git a/libgcc/config/epiphany/udivsi3-float.S b/libgcc/config/epiphany/udivsi3-float.S
new file mode 100644
index 0000000..5c960dc
--- /dev/null
+++ b/libgcc/config/epiphany/udivsi3-float.S
@@ -0,0 +1,83 @@
+/* Unsigned 32 bit division optimized for Epiphany.
+ Copyright (C) 2009, 2011 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "epiphany-asm.h"
+
+ FSTAB (__udivsi3,T_UINT)
+ .global SYM(__udivsi3)
+ .balign 4
+ HIDDEN_FUNC(__udivsi3)
+SYM(__udivsi3):
+ sub TMP0,r0,r1
+ bltu .Lret0
+ float TMP2,r0
+ mov TMP1,%low(0xb0800000) ; ??? this would be faster with small data
+ float TMP3,r1
+ movt TMP1,%high(0xb0800000)
+ asr TMP0,r0,8
+ sub TMP0,TMP0,TMP1
+ movt TMP1,%high(0x00810000)
+ movgteu TMP2,TMP0
+ bblt .Lret1
+ sub TMP2,TMP2,TMP1
+ sub TMP2,TMP2,TMP3
+ mov TMP3,0
+ movltu TMP2,TMP3
+ lsr TMP2,TMP2,23
+ lsl r1,r1,TMP2
+ mov TMP0,1
+ lsl TMP0,TMP0,TMP2
+ sub r0,r0,r1
+ bltu .Ladd_back
+ add TMP3,TMP3,TMP0
+ sub r0,r0,r1
+ bltu .Ladd_back
+.Lsub_loop:; More than two iterations are rare, so it makes sense to leave
+ ; this label here to reduce average branch penalties.
+ add TMP3,TMP3,TMP0
+ sub r0,r0,r1
+ bgteu .Lsub_loop
+.Ladd_back:
+ add r0,r0,r1
+ sub TMP1,r1,1
+ mov r1,%low(.L0step)
+ movt r1,%high(.L0step)
+ lsl TMP2,TMP2,3
+ sub r1,r1,TMP2
+ jr r1
+ .rep 30
+ lsl r0,r0,1
+ sub.l r1,r0,TMP1
+ movgteu r0,r1
+ .endr
+.L0step:sub r1,TMP0,1 ; mask result bits from steps ...
+ and r0,r0,r1
+ orr r0,r0,TMP3 ; ... and combine with first bits.
+ rts
+.Lret0: mov r0,0
+ rts
+.Lret1: mov r0,1
+ rts
+ ENDFUNC(__udivsi3)
diff --git a/libgcc/config/epiphany/udivsi3-float.c b/libgcc/config/epiphany/udivsi3-float.c
new file mode 100644
index 0000000..c7f1059
--- /dev/null
+++ b/libgcc/config/epiphany/udivsi3-float.c
@@ -0,0 +1,125 @@
+/* Generic unsigned 32 bit division implementation.
+ Copyright (C) 2009, 2011 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+typedef union { unsigned int i; float f; } fu;
+
+unsigned int __udivsi3 (unsigned int a, unsigned int b);
+
+unsigned int
+__udivsi3 (unsigned int a, unsigned int b)
+{
+ unsigned int d, t, s0, s1, s2, r0, r1;
+ fu u0, u1, u2, u1b, u2b;
+
+ if (b > a)
+ return 0;
+ if ((int) b < 0)
+ return 1;
+
+ /* Assuming B is nonzero, compute S0 such that 0 <= S0,
+ (B << S0+1) does not overflow,
+ A < 4.01 * (B << S0), with S0 choosen as small as possible
+ without taking to much time calculating. */
+#ifdef CONVERT_UNSIGNED
+ u0.f = a;
+ u1.f = b;
+#else /* !CONVERT_UNSIGNED */
+ u0.f = (int) a;
+ u1.f = (int) b;
+#ifdef CONCISE
+ if (a < 0)
+ u0.i = (a >> 8) - 0x00800000 + 0x3f800000 + (31 << 23);
+#else /* To use flag seting / cmove, this can be written as: */
+ {
+ unsigned c = 0xff800000 - 0x4f000000;
+ t = (int)a >> 8;
+ if (t >= c)
+ u0.i = (t - c);
+ }
+#endif
+#endif /* !CONVERT_UNSIGNED */
+ s0 = u0.i + 1 /* Compensate for rounding errors. */
+ - 0x00800000 /* adjust by one */ ;
+ s0 = s0 - u1.i;
+ s0 = (int)s0 >= 0 ? s0 : 0;
+ s0 >>= 23;
+
+ b <<= s0;
+ r1 = 0;
+
+ r0 = 1 << s0;
+ a = ((t=a) - b);
+ if (a <= t)
+ {
+ r1 += r0;
+ a = ((t=a) - b);
+ if (a <= t)
+ do {
+ r1 += r0;
+ a = ((t=a) - b);
+ } while (a <= t);
+ }
+ a += b;
+ d = b - 1;
+
+#define STEP(n) case n: a += a; t = a - d; if (t <= a) a = t;
+ switch (s0)
+ {
+ STEP (31)
+ STEP (30)
+ STEP (29)
+ STEP (28)
+ STEP (27)
+ STEP (26)
+ STEP (25)
+ STEP (24)
+ STEP (23)
+ STEP (22)
+ STEP (21)
+ STEP (20)
+ STEP (19)
+ STEP (18)
+ STEP (17)
+ STEP (16)
+ STEP (15)
+ STEP (14)
+ STEP (13)
+ STEP (12)
+ STEP (11)
+ STEP (10)
+ STEP (9)
+ STEP (8)
+ STEP (7)
+ STEP (6)
+ STEP (5)
+ STEP (4)
+ STEP (3)
+ STEP (2)
+ STEP (1)
+ case 0: ;
+ }
+ r0 = r1 | (r0-1 & a);
+ return r0;
+}
diff --git a/libgcc/config/epiphany/udivsi3.S b/libgcc/config/epiphany/udivsi3.S
new file mode 100644
index 0000000..1396281
--- /dev/null
+++ b/libgcc/config/epiphany/udivsi3.S
@@ -0,0 +1,85 @@
+/* Unsigned 32 bit division optimized for Epiphany.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "epiphany-asm.h"
+
+ FSTAB (__udivsi3,T_UINT)
+ .global SYM(__udivsi3)
+ .balign 4
+ HIDDEN_FUNC(__udivsi3)
+SYM(__udivsi3):
+ sub r3,r0,r1
+ bltu .Lret0
+ mov r3,0x95
+ lsl r12,r3,23 ; 0x4a800000
+ lsl r3,r3,30 ; 0x40000000
+ orr r16,r0,r3
+ orr r2,r1,r3
+ fsub r16,r16,r3
+ fsub r2,r2,r3
+ lsr r3,r1,21
+ lsr r17,r0,21
+ movt r17,0x4a80
+ fsub r17,r17,r12
+ movt r3,0x4a80
+ fsub r3,r3,r12
+ mov r12,%low(.L0step)
+ movt r12,%high(.L0step)
+ mov r21,1
+ movne r16,r17
+ lsr r17,r1,21
+ movne r2,r3
+ lsr r3,r16,23 ; must mask lower bits of r2 in case op0 was ..
+ lsr r2,r2,23 ; .. shifted and op1 was not.
+ sub r3,r3,r2 ; calculate bit number difference.
+ lsl r1,r1,r3
+ lsr r16,r1,1
+ lsl r2,r21,r3
+ lsl r3,r3,3
+ sub r12,r12,r3
+ sub r3,r0,r1
+ movltu r3,r0
+ mov r0,0
+ movgteu r0,r2
+ lsr r2,r2,1
+ add r17,r2,r0
+ sub r1,r3,r16
+ movgteu r3,r1
+ movgteu r0,r17
+ sub r16,r16,1
+ jr r12
+ .rep 30
+ lsl r3,r3,1
+ sub r1,r3,r16
+ movgteu r3,r1
+ .endr
+ sub r2,r2,1 ; mask result bits from steps ...
+ and r3,r3,r2
+ orr r0,r0,r3 ; ... and combine with first bits.
+ nop
+.L0step:rts
+.Lret0: mov r0,0
+ rts
+ ENDFUNC(__udivsi3)
diff --git a/libgcc/config/epiphany/udivsi3.c b/libgcc/config/epiphany/udivsi3.c
new file mode 100644
index 0000000..cd34c6d
--- /dev/null
+++ b/libgcc/config/epiphany/udivsi3.c
@@ -0,0 +1,114 @@
+/* Generic unsigned 32 bit division implementation.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+typedef union { unsigned int i; float f; } fu;
+
+unsigned int __udivsi3 (unsigned int a, unsigned int b);
+
+unsigned int
+__udivsi3 (unsigned int a, unsigned int b)
+{
+ unsigned int d, t, s0, s1, s2, r0, r1;
+ fu u0, u1, u2, u1b, u2b;
+
+ if (b > a)
+ return 0;
+
+ /* Compute difference in number of bits in S0. */
+ u0.i = 0x40000000;
+ u1b.i = u2b.i = u0.i;
+ u1.i = a;
+ u2.i = b;
+ u1.i = a | u0.i;
+ t = 0x4b800000 | ((a >> 23) & 0xffff);
+ if (a >> 23)
+ {
+ u1.i = t;
+ u1b.i = 0x4b800000;
+ }
+ u2.i = b | u0.i;
+ t = 0x4b800000 | ((b >> 23) & 0xffff);
+ if (b >> 23)
+ {
+ u2.i = t;
+ u2b.i = 0x4b800000;
+ }
+ u1.f = u1.f - u1b.f;
+ u2.f = u2.f - u2b.f;
+ s1 = u1.i >> 23;
+ s2 = u2.i >> 23;
+ s0 = s1 - s2;
+
+ b <<= s0;
+ d = b - 1;
+
+ r0 = 1 << s0;
+ r1 = 0;
+ t = a - b;
+ if (t <= a)
+ {
+ a = t;
+ r1 = r0;
+ }
+
+#define STEP(n) case n: a += a; t = a - d; if (t <= a) a = t;
+ switch (s0)
+ {
+ STEP (31)
+ STEP (30)
+ STEP (29)
+ STEP (28)
+ STEP (27)
+ STEP (26)
+ STEP (25)
+ STEP (24)
+ STEP (23)
+ STEP (22)
+ STEP (21)
+ STEP (20)
+ STEP (19)
+ STEP (18)
+ STEP (17)
+ STEP (16)
+ STEP (15)
+ STEP (14)
+ STEP (13)
+ STEP (12)
+ STEP (11)
+ STEP (10)
+ STEP (9)
+ STEP (8)
+ STEP (7)
+ STEP (6)
+ STEP (5)
+ STEP (4)
+ STEP (3)
+ STEP (2)
+ STEP (1)
+ case 0: ;
+ }
+ r0 = r1 | (r0-1 & a);
+ return r0;
+}
diff --git a/libgcc/config/epiphany/umodsi3-float.S b/libgcc/config/epiphany/umodsi3-float.S
new file mode 100644
index 0000000..ca5db48
--- /dev/null
+++ b/libgcc/config/epiphany/umodsi3-float.S
@@ -0,0 +1,63 @@
+/* Unsigned 32 bit division optimized for Epiphany.
+ Copyright (C) 2009, 2011 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "epiphany-asm.h"
+
+/* Because we handle a divident with bit 31 set with truncating integer
+ arithmetic, there is no rounding-related overflow. */
+ FSTAB (__umodsi3,T_UINT)
+ .global SYM(__umodsi3)
+ .balign 4
+ HIDDEN_FUNC(__umodsi3)
+SYM(__umodsi3):
+ float r2,r0
+ mov TMP1,%low(0xb0800000) ; ??? this would be faster with small data
+ float TMP2,r1
+ movt TMP1,%high(0xb0800000)
+ asr TMP0,r0,8
+ sub TMP0,TMP0,TMP1
+ mov TMP1,%low(.L0step)
+ movgteu r2,TMP0
+ sub r2,r2,TMP2
+ blteu .L0step
+ asr r2,r2,23
+ movt TMP1,%high(.L0step)
+ lsl TMP2,r2,3
+ lsl r2,r1,r2` sub r2,r0,r2` movgteu r0,r2 ; STEP(r2)
+ sub r2,TMP1,TMP2
+ jr r2
+#define STEP(n) lsl.l r2,r1,n` sub r2,r0,r2` movgteu r0,r2
+ .balign 8,,2
+ STEP(31)` STEP(30)` STEP(29)` STEP(28)`
+ STEP(27)` STEP(26)` STEP(25)` STEP(24)`
+ STEP(23)` STEP(22)` STEP(21)` STEP(20)`
+ STEP(19)` STEP(18)` STEP(17)` STEP(16)`
+ STEP(15)` STEP(14)` STEP(13)` STEP(12)`
+ STEP(11)` STEP(10)` STEP(9)` STEP(8)`
+ STEP(7)` STEP(6)` STEP(5)` STEP(4)` STEP(3)` STEP(2)` STEP(1)
+.L0step:STEP(0)
+.Lret_r0:
+ rts
+ ENDFUNC(__umodsi3)
diff --git a/libgcc/config/epiphany/umodsi3.S b/libgcc/config/epiphany/umodsi3.S
new file mode 100644
index 0000000..6f808fd
--- /dev/null
+++ b/libgcc/config/epiphany/umodsi3.S
@@ -0,0 +1,70 @@
+/* Unsigned 32 bit modulo optimized for Epiphany.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#include "epiphany-asm.h"
+
+ FSTAB (__umodsi3,T_UINT)
+ .global SYM(__umodsi3)
+ .balign 4
+ HIDDEN_FUNC(__umodsi3)
+SYM(__umodsi3):
+ mov r2,5
+ lsl r2,r2,29 ; 0xa0000000
+ orr r3,r2,r0
+ lsr r15,r0,16
+ movt r15,0xa800
+ movne r3,r15
+ lsr r16,r2,2 ; 0x28000000
+ and r15,r3,r16
+ fadd r12,r3,r15
+ orr r3,r2,r1
+ lsr r2,r1,16
+ movt r2,0xa800
+ movne r3,r2
+ and r2,r16,r3
+ fadd r3,r3,r2
+ sub r2,r0,r1
+ bltu .Lret_a
+ lsr r12,r12,23
+ mov r2,%low(.L0step)
+ movt r2,%high(.L0step)
+ lsr r3,r3,23
+ sub r3,r12,r3 ; calculate bit number difference.
+ lsl r3,r3,3
+ sub r2,r2,r3
+ jr r2
+/* lsl_l r2,r1,n` sub r2,r0,r2` movgteu r0,r2 */
+#define STEP(n) .long 0x0006441f | (n) << 5` sub r2,r0,r2` movgteu r0,r2
+ .balign 8,,2
+ STEP(31)` STEP(30)` STEP(29)` STEP(28)`
+ STEP(27)` STEP(26)` STEP(25)` STEP(24)`
+ STEP(23)` STEP(22)` STEP(21)` STEP(20)`
+ STEP(19)` STEP(18)` STEP(17)` STEP(16)`
+ STEP(15)` STEP(14)` STEP(13)` STEP(12)`
+ STEP(11)` STEP(10)` STEP(9)` STEP(8)`
+ STEP(7)` STEP(6)` STEP(5)` STEP(4)` STEP(3)` STEP(2)` STEP(1)
+.L0step:STEP(0)
+.Lret_a:rts
+ ENDFUNC(__umodsi3)
diff --git a/libgcc/config/epiphany/umodsi3.c b/libgcc/config/epiphany/umodsi3.c
new file mode 100644
index 0000000..609a250
--- /dev/null
+++ b/libgcc/config/epiphany/umodsi3.c
@@ -0,0 +1,101 @@
+/* Generic unsigned 32 bit modulo implementation.
+ Copyright (C) 2009 Free Software Foundation, Inc.
+ Contributed by Embecosm on behalf of Adapteva, Inc.
+
+This file is part of GCC.
+
+This file is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 3, or (at your option) any
+later version.
+
+This file is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+typedef union { unsigned int i; float f; } fu;
+
+unsigned int __umodsi3 (unsigned int a, unsigned int b);
+
+unsigned int
+__umodsi3 (unsigned int a, unsigned int b)
+{
+ unsigned int d, t, s0, s1, s2, r0, r1;
+ fu u0, u1, u2, u1b, u2b;
+
+ if (b > a)
+ return a;
+
+ /* Compute difference in number of bits in S0. */
+ u0.i = 0x40000000;
+ u1b.i = u2b.i = u0.i;
+ u1.i = a;
+ u2.i = b;
+ u1.i = a | u0.i;
+ t = 0x4b800000 | ((a >> 23) & 0xffff);
+ if (a >> 23)
+ {
+ u1.i = t;
+ u1b.i = 0x4b800000;
+ }
+ u2.i = b | u0.i;
+ t = 0x4b800000 | ((b >> 23) & 0xffff);
+ if (b >> 23)
+ {
+ u2.i = t;
+ u2b.i = 0x4b800000;
+ }
+ u1.f = u1.f - u1b.f;
+ u2.f = u2.f - u2b.f;
+ s1 = u1.i >> 23;
+ s2 = u2.i >> 23;
+ s0 = s1 - s2;
+
+#define STEP(n) case n: d = b << n; t = a - d; if (t <= a) a = t;
+ switch (s0)
+ {
+ STEP (31)
+ STEP (30)
+ STEP (29)
+ STEP (28)
+ STEP (27)
+ STEP (26)
+ STEP (25)
+ STEP (24)
+ STEP (23)
+ STEP (22)
+ STEP (21)
+ STEP (20)
+ STEP (19)
+ STEP (18)
+ STEP (17)
+ STEP (16)
+ STEP (15)
+ STEP (14)
+ STEP (13)
+ STEP (12)
+ STEP (11)
+ STEP (10)
+ STEP (9)
+ STEP (8)
+ STEP (7)
+ STEP (6)
+ STEP (5)
+ STEP (4)
+ STEP (3)
+ STEP (2)
+ STEP (1)
+ STEP (0)
+ }
+ return a;
+}