1 /* Copyright (C) 2005, 2007 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 3, 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 COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
34 #if !defined(L_mulsi3) && !defined(L_divsi3)
42 cache 0xe, [r8, 0] # write back invalid dcache
46 bittst! r8, 0x3 # if LDM is enable, write back LDM
51 bittst! r8, 0x2 # if LIM is enable, refill it
63 cache 0x2, [r8, 0] # invalid unlock icache
75 (U) INT32 v0 = __mulsi3 ((U) INT32 a0, (U) INT32 a1);
81 this seems to give better performance to just rotate and add. */
87 /* signed multiplication (32x32) */
93 andri.c t0, a1, 1 # t0 = multiplier[0]
94 srli a1, a1, 1 # a1 /= 2
95 beq __mulsi3_loop2 # skip if (t0 == 0)
96 add t1, t1, a0 # add multiplicand
98 slli a0, a0, 1 # multiplicand mul 2
104 #endif /* L_mulsi3 */
107 UINT32 (v0) = __udivsi3 (UINT32 (a0), UINT32 (a1));
108 INT32 (v0) = __divsi3 (INT32 (a0), INT32 (a1));
109 UINT32 (v0) = __umodsi3 (UINT32 (a0), UINT32 (a1));
110 INT32 (v0) = __modsi3 (INT32 (a0), INT32 (a1));
112 performs 32-bit division/modulo.
116 modify a0 becomes remainer */
124 /* unsigned division */
156 /* unsigned modulus */
175 b __udivsi3 # goto udivsi3
178 /* signed division */
202 #endif /* L_divsi3 */
204 #if !defined(L_mulsi3) && !defined(L_divsi3)
209 addi r0, -8 # pic used
210 .cpload r29 # pic used
215 cache 0xe, [r8, 0] # write back invalid dcache
219 bittst! r8, 0x3 # if LDM is enable, write back LDM
224 bittst! r8, 0x2 # if LIM is enable, refill it
236 cache 0x2, [r8, 0] # invalid unlock icache
244 .cprestore r0, 12 # pic used
245 addi r0, 8 # pic used
250 (U) INT32 v0 = __mulsi3 ((U) INT32 a0, (U) INT32 a1);
256 this seems to give better performance to just rotate and add. */
263 /* signed multiplication (32x32) */
267 addi r0, -8 # pic used
268 .cpload r29 # pic used
271 andri.c t0, a1, 1 # t0 = multiplier[0]
272 srli a1, a1, 1 # a1 /= 2
273 beq __mulsi3_loop2 # skip if (t0 == 0)
274 add t1, t1, a0 # add multiplicand
276 slli a0, a0, 1 # multiplicand mul 2
280 .cprestore r0, 12 # pic used
281 addi r0, 8 # pic used
284 #endif /* L_mulsi3 */
287 UINT32 (v0) = __udivsi3 (UINT32 (a0), UINT32 (a1));
288 INT32 (v0) = __divsi3 (INT32 (a0), INT32 (a1));
289 UINT32 (v0) = __umodsi3 (UINT32 (a0), UINT32 (a1));
290 INT32 (v0) = __modsi3 (INT32 (a0), INT32 (a1));
292 performs 32-bit division/modulo.
296 modify a0 becomes remainer */
305 /* unsigned division */
308 addi r0, -8 # pic used
309 .cpload r29 # pic used
336 .cprestore r0, 12 # pic used
337 addi r0, 8 # pic used
341 /* unsigned modulus */
344 addi r0, -8 # pic used
345 .cpload r29 # pic used
352 .cprestore r0, 12 # pic used
353 addi r0, 8 # pic used
367 b __udivsi3 # goto udivsi3
370 /* signed division */
373 addi r0, -8 # pic used
374 .cpload r29 # pic used
385 .cprestore r0, 12 # pic used
386 addi r0, 8 # pic used
393 addi r0, -8 # pic used
394 .cpload r29 # pic used