d07c13ec4fd4c1a54c522b4d5be4b77b201d7946
[linux-2.6-microblaze.git] / arch / c6x / lib / mpyll.S
1 ;; SPDX-License-Identifier: GPL-2.0-or-later
2 ;;  Copyright (C) 2010 Texas Instruments Incorporated
3 ;;  Contributed by Mark Salter <msalter@redhat.com>.
4 ;;
5
6 #include <linux/linkage.h>
7
8         ;; uint64_t __c6xabi_mpyll(uint64_t x, uint64_t y)
9         ;;
10         ;; 64x64 multiply
11         ;; First compute partial results using 32-bit parts of x and y:
12         ;;
13         ;;   b63         b32 b31          b0
14         ;;    -----------------------------
15         ;;    |      1      |      0      |
16         ;;    -----------------------------
17         ;;
18         ;;   P0 = X0*Y0
19         ;;   P1 = X0*Y1 + X1*Y0
20         ;;   P2 = X1*Y1
21         ;;
22         ;;   result = (P2 << 64) + (P1 << 32) + P0
23         ;;
24         ;; Since the result is also 64-bit, we can skip the P2 term.
25
26         .text
27 ENTRY(__c6xabi_mpyll)
28         mpy32u  .m1x    A4,B4,A1:A0     ; X0*Y0
29         b       .s2     B3
30  ||     mpy32u  .m2x    B5,A4,B1:B0     ; X0*Y1 (don't need upper 32-bits)
31  ||     mpy32u  .m1x    A5,B4,A3:A2     ; X1*Y0 (don't need upper 32-bits)
32         nop
33         nop
34         mv      .s1     A0,A4
35         add     .l1x    A2,B0,A5
36         add     .s1     A1,A5,A5
37 ENDPROC(__c6xabi_mpyll)