aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorStuart Henderson <shenders@gcc.gnu.org>2011-05-03 16:24:59 +0000
committerStuart Henderson <shenders@gcc.gnu.org>2011-05-03 16:24:59 +0000
commitf0b568f3c4108c65eeb0123e2d64988b172f9e75 (patch)
tree9d107555698857e6953f36513721495e8170bd62 /gcc
parent2f6c3c820613ea26afed8e6fabe10ac9a2298d3b (diff)
downloadgcc-f0b568f3c4108c65eeb0123e2d64988b172f9e75.zip
gcc-f0b568f3c4108c65eeb0123e2d64988b172f9e75.tar.gz
gcc-f0b568f3c4108c65eeb0123e2d64988b172f9e75.tar.bz2
2011-05-03 Stuart Henderson <shenders@gcc.gnu.org>
From Bernd Schmidt * config/bfin/t-bfin (LIB1ASMFUNCS): Add muldi3 and umulsi3_highpart. * config/bfin/t-bfin-elf (LIB1ASMFUNCS): Add muldi3. * config/bfin/t-bfin-linux (LIB1ASMFUNCS): Add muldi3. * config/bfin/t-bfin-uclinux (LIB1ASMFUNCS): Add muldi3. * config/bfin/lib1funcs.asm (___muldi3): New function. From-SVN: r173323
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/config/bfin/lib1funcs.asm65
-rw-r--r--gcc/config/bfin/t-bfin3
-rw-r--r--gcc/config/bfin/t-bfin-elf2
-rw-r--r--gcc/config/bfin/t-bfin-linux2
-rw-r--r--gcc/config/bfin/t-bfin-uclinux2
6 files changed, 79 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6817e7b..8124e22 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2011-05-03 Stuart Henderson <shenders@gcc.gnu.org>
+
+ From Bernd Schmidt
+ * config/bfin/t-bfin (LIB1ASMFUNCS): Add muldi3 and umulsi3_highpart.
+ * config/bfin/t-bfin-elf (LIB1ASMFUNCS): Add muldi3.
+ * config/bfin/t-bfin-linux (LIB1ASMFUNCS): Add muldi3.
+ * config/bfin/t-bfin-uclinux (LIB1ASMFUNCS): Add muldi3.
+ * config/bfin/lib1funcs.asm (___muldi3): New function.
+
2011-05-03 Nathan Froyd <froydnj@codesourcery.com>
* config/stormy16/stormy16 (xstormy16_init_builtins): Call
diff --git a/gcc/config/bfin/lib1funcs.asm b/gcc/config/bfin/lib1funcs.asm
index 4e15ad2..c7bf4f3 100644
--- a/gcc/config/bfin/lib1funcs.asm
+++ b/gcc/config/bfin/lib1funcs.asm
@@ -144,3 +144,68 @@ ___smulsi3_highpart:
R0 = (A0 += A1);
RTS;
#endif
+
+#ifdef L_muldi3
+.align 2
+.global ___muldi3;
+.type ___muldi3, STT_FUNC;
+
+/*
+ R1:R0 * R3:R2
+ = R1.h:R1.l:R0.h:R0.l * R3.h:R3.l:R2.h:R2.l
+[X] = (R1.h * R3.h) * 2^96
+[X] + (R1.h * R3.l + R1.l * R3.h) * 2^80
+[X] + (R1.h * R2.h + R1.l * R3.l + R3.h * R0.h) * 2^64
+[T1] + (R1.h * R2.l + R3.h * R0.l + R1.l * R2.h + R3.l * R0.h) * 2^48
+[T2] + (R1.l * R2.l + R3.l * R0.l + R0.h * R2.h) * 2^32
+[T3] + (R0.l * R2.h + R2.l * R0.h) * 2^16
+[T4] + (R0.l * R2.l)
+
+ We can discard the first three lines marked "X" since we produce
+ only a 64 bit result. So, we need ten 16-bit multiplies.
+
+ Individual mul-acc results:
+[E1] = R1.h * R2.l + R3.h * R0.l + R1.l * R2.h + R3.l * R0.h
+[E2] = R1.l * R2.l + R3.l * R0.l + R0.h * R2.h
+[E3] = R0.l * R2.h + R2.l * R0.h
+[E4] = R0.l * R2.l
+
+ We also need to add high parts from lower-level results to higher ones:
+ E[n]c = E[n] + (E[n+1]c >> 16), where E4c := E4
+
+ One interesting property is that all parts of the result that depend
+ on the sign of the multiplication are discarded. Those would be the
+ multiplications involving R1.h and R3.h, but only the top 16 bit of
+ the 32 bit result depend on the sign, and since R1.h and R3.h only
+ occur in E1, the top half of these results is cut off.
+ So, we can just use FU mode for all of the 16-bit multiplies, and
+ ignore questions of when to use mixed mode. */
+
+___muldi3:
+ /* [SP] technically is part of the caller's frame, but we can
+ use it as scratch space. */
+ A0 = R2.H * R1.L, A1 = R2.L * R1.H (FU) || R3 = [SP + 12]; /* E1 */
+ A0 += R3.H * R0.L, A1 += R3.L * R0.H (FU) || [SP] = R4; /* E1 */
+ A0 += A1; /* E1 */
+ R4 = A0.w;
+ A0 = R0.l * R3.l (FU); /* E2 */
+ A0 += R2.l * R1.l (FU); /* E2 */
+
+ A1 = R2.L * R0.L (FU); /* E4 */
+ R3 = A1.w;
+ A1 = A1 >> 16; /* E3c */
+ A0 += R2.H * R0.H, A1 += R2.L * R0.H (FU); /* E2, E3c */
+ A1 += R0.L * R2.H (FU); /* E3c */
+ R0 = A1.w;
+ A1 = A1 >> 16; /* E2c */
+ A0 += A1; /* E2c */
+ R1 = A0.w;
+
+ /* low(result) = low(E3c):low(E4) */
+ R0 = PACK (R0.l, R3.l);
+ /* high(result) = E2c + (E1 << 16) */
+ R1.h = R1.h + R4.l (NS) || R4 = [SP];
+ RTS;
+
+.size ___muldi3, .-___muldi3
+#endif
diff --git a/gcc/config/bfin/t-bfin b/gcc/config/bfin/t-bfin
index 37b6871..90ee8f2 100644
--- a/gcc/config/bfin/t-bfin
+++ b/gcc/config/bfin/t-bfin
@@ -19,7 +19,8 @@
## Target part of the Makefile
LIB1ASMSRC = bfin/lib1funcs.asm
-LIB1ASMFUNCS = _divsi3 _udivsi3 _umodsi3 _modsi3
+LIB1ASMFUNCS = _divsi3 _udivsi3 _umodsi3 _modsi3 _muldi3 _umulsi3_highpart
+LIB1ASMFUNCS += _smulsi3_highpart
EXTRA_PARTS = crtbegin.o crtend.o crti.o crtn.o
diff --git a/gcc/config/bfin/t-bfin-elf b/gcc/config/bfin/t-bfin-elf
index 39209f6..da242a0 100644
--- a/gcc/config/bfin/t-bfin-elf
+++ b/gcc/config/bfin/t-bfin-elf
@@ -19,7 +19,7 @@
## Target part of the Makefile
LIB1ASMSRC = bfin/lib1funcs.asm
-LIB1ASMFUNCS = _divsi3 _udivsi3 _umodsi3 _modsi3 _umulsi3_highpart
+LIB1ASMFUNCS = _divsi3 _udivsi3 _umodsi3 _modsi3 _muldi3 _umulsi3_highpart
LIB1ASMFUNCS += _smulsi3_highpart
FPBIT = fp-bit.c
diff --git a/gcc/config/bfin/t-bfin-linux b/gcc/config/bfin/t-bfin-linux
index f7ba955..daa1e05 100644
--- a/gcc/config/bfin/t-bfin-linux
+++ b/gcc/config/bfin/t-bfin-linux
@@ -19,7 +19,7 @@
## Target part of the Makefile
LIB1ASMSRC = bfin/lib1funcs.asm
-LIB1ASMFUNCS = _divsi3 _udivsi3 _umodsi3 _modsi3 _umulsi3_highpart
+LIB1ASMFUNCS = _divsi3 _udivsi3 _umodsi3 _modsi3 _muldi3 _umulsi3_highpart
LIB1ASMFUNCS += _smulsi3_highpart
FPBIT = fp-bit.c
diff --git a/gcc/config/bfin/t-bfin-uclinux b/gcc/config/bfin/t-bfin-uclinux
index eb6d225..0be258f 100644
--- a/gcc/config/bfin/t-bfin-uclinux
+++ b/gcc/config/bfin/t-bfin-uclinux
@@ -19,7 +19,7 @@
## Target part of the Makefile
LIB1ASMSRC = bfin/lib1funcs.asm
-LIB1ASMFUNCS = _divsi3 _udivsi3 _umodsi3 _modsi3 _umulsi3_highpart
+LIB1ASMFUNCS = _divsi3 _udivsi3 _umodsi3 _modsi3 _muldi3 _umulsi3_highpart
LIB1ASMFUNCS += _smulsi3_highpart
FPBIT = fp-bit.c