1 /* 64-bit multiplication support for TILEPro.
2 Copyright (C) 2011, 2012
3 Free Software Foundation, Inc.
4 Contributed by Walter Lee (walt@tilera.com)
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 3, or (at your option) any
11 This file is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
25 /* 64-bit multiplication support. */
30 #define lo0 r9 /* low 32 bits of n0 */
31 #define hi0 r1 /* high 32 bits of n0 */
32 #define lo1 r2 /* low 32 bits of n1 */
33 #define hi1 r3 /* high 32 bits of n1 */
40 #define tmp0_left_16 r7
43 .section .text.__muldi3, "ax"
46 .type __muldi3, @function
49 move lo0, r0 /* so we can write "out r0" while "in r0" alive */
50 mulhl_uu tmp0, lo1, r0
53 mulll_uu result1_a, lo1, hi0
57 mulhla_uu tmp0, lo0, lo1
60 mulhlsa_uu result1_a, lo1, hi0
63 mulll_uu result1_b, lo0, hi1
64 slt_u tmp1, tmp0, tmp1
67 mulhlsa_uu result1_a, lo0, hi1
72 mulhha_uu result1_b, lo0, lo1
75 mullla_uu r0, lo1, lo0
79 mulhlsa_uu result1_b, hi0, lo1
80 inthh tmp1, tmp1, tmp0
83 mulhlsa_uu result1_a, hi1, lo0
84 slt_u tmp0, r0, tmp0_left_16
86 /* NOTE: this will stall for a cycle here. Oh well. */
89 add result1_a, result1_a, result1_b
95 .size __muldi3,.-__muldi3