1 /* Copyright (C) 2005 Free Software Foundation, Inc.
2 Contributed by Sunnorth
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 2, or (at your
9 option) any later version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to
18 the Free Software Foundation, 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
35 #if !defined(L_mulsi3) && !defined(L_divsi3)
43 cache 0xe, [r8, 0] # write back invalid dcache
47 bittst! r8, 0x3 # if LDM is enable, write back LDM
52 bittst! r8, 0x2 # if LIM is enable, refill it
64 cache 0x2, [r8, 0] # invalid unlock icache
76 (U) INT32 v0 = __mulsi3 ((U) INT32 a0, (U) INT32 a1);
82 this seems to give better performance to just rotate and add. */
88 /* signed multiplication (32x32) */
94 andri.c t0, a1, 1 # t0 = multiplier[0]
95 srli a1, a1, 1 # a1 /= 2
96 beq __mulsi3_loop2 # skip if (t0 == 0)
97 add t1, t1, a0 # add multiplicand
99 slli a0, a0, 1 # multiplicand mul 2
105 #endif /* L_mulsi3 */
108 UINT32 (v0) = __udivsi3 (UINT32 (a0), UINT32 (a1));
109 INT32 (v0) = __divsi3 (INT32 (a0), INT32 (a1));
110 UINT32 (v0) = __umodsi3 (UINT32 (a0), UINT32 (a1));
111 INT32 (v0) = __modsi3 (INT32 (a0), INT32 (a1));
113 performs 32-bit division/modulo.
117 modify a0 becomes remainer */
125 /* unsigned division */
157 /* unsigned modulus */
176 b __udivsi3 # goto udivsi3
179 /* signed division */
203 #endif /* L_divsi3 */
205 #if !defined(L_mulsi3) && !defined(L_divsi3)
210 addi r0, -8 # pic used
211 .cpload r29 # pic used
216 cache 0xe, [r8, 0] # write back invalid dcache
220 bittst! r8, 0x3 # if LDM is enable, write back LDM
225 bittst! r8, 0x2 # if LIM is enable, refill it
237 cache 0x2, [r8, 0] # invalid unlock icache
245 .cprestore 12 # pic used
246 addi r0, 8 # pic used
251 (U) INT32 v0 = __mulsi3 ((U) INT32 a0, (U) INT32 a1);
257 this seems to give better performance to just rotate and add. */
264 /* signed multiplication (32x32) */
268 addi r0, -8 # pic used
269 .cpload r29 # pic used
272 andri.c t0, a1, 1 # t0 = multiplier[0]
273 srli a1, a1, 1 # a1 /= 2
274 beq __mulsi3_loop2 # skip if (t0 == 0)
275 add t1, t1, a0 # add multiplicand
277 slli a0, a0, 1 # multiplicand mul 2
281 .cprestore 12 # pic used
282 addi r0, 8 # pic used
285 #endif /* L_mulsi3 */
288 UINT32 (v0) = __udivsi3 (UINT32 (a0), UINT32 (a1));
289 INT32 (v0) = __divsi3 (INT32 (a0), INT32 (a1));
290 UINT32 (v0) = __umodsi3 (UINT32 (a0), UINT32 (a1));
291 INT32 (v0) = __modsi3 (INT32 (a0), INT32 (a1));
293 performs 32-bit division/modulo.
297 modify a0 becomes remainer */
306 /* unsigned division */
309 addi r0, -8 # pic used
310 .cpload r29 # pic used
337 .cprestore 12 # pic used
338 addi r0, 8 # pic used
342 /* unsigned modulus */
345 addi r0, -8 # pic used
346 .cpload r29 # pic used
353 .cprestore 12 # pic used
354 addi r0, 8 # pic used
368 b __udivsi3 # goto udivsi3
371 /* signed division */
374 addi r0, -8 # pic used
375 .cpload r29 # pic used
386 .cprestore 12 # pic used
387 addi r0, 8 # pic used
394 addi r0, -8 # pic used
395 .cpload r29 # pic used