Debian Codegraph @

mpi/power/mpih-mul2.S

raw
1 /* IBM POWER addmul_1 -- Multiply a limb vector with a limb and add
2 * the result to a second limb vector.
3 *
4 * Copyright (C) 1992, 1994, 1999, 2002 Free Software Foundation, Inc.
5 *
6 * This file is part of Libgcrypt.
7 *
8 * Libgcrypt is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as
10 * published by the Free Software Foundation; either version 2.1 of
11 * the License, or (at your option) any later version.
12 *
13 * Libgcrypt is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program; if not, see <https://www.gnu.org/licenses/>.
20 * SPDX-License-Identifier: LGPL-2.1-or-later
21 */
22
23 #include "sysdep.h"
24 #include "asm-syntax.h"
25
26
27
28 /*
29 # INPUT PARAMETERS
30 # res_ptr r3
31 # s1_ptr r4
32 # size r5
33 # s2_limb r6
34
35 # The RS/6000 has no unsigned 32x32->64 bit multiplication instruction. To
36 # obtain that operation, we have to use the 32x32->64 signed multiplication
37 # instruction, and add the appropriate compensation to the high limb of the
38 # result. We add the multiplicand if the multiplier has its most significant
39 # bit set, and we add the multiplier if the multiplicand has its most
40 # significant bit set. We need to preserve the carry flag between each
41 # iteration, so we have to compute the compensation carefully (the natural,
42 # srai+and doesn't work). Since the POWER architecture has a branch unit
43 # we can branch in zero cycles, so that's how we perform the additions.
44 */
45
46 .toc
47 .csect ._gcry_mpih_addmul_1[PR]
48 .align 2
49 .globl _gcry_mpih_addmul_1
50 .globl ._gcry_mpih_addmul_1
51 .csect _gcry_mpih_addmul_1[DS]
52 _gcry_mpih_addmul_1:
53 .long ._gcry_mpih_addmul_1[PR], TOC[tc0], 0
54 .csect ._gcry_mpih_addmul_1[PR]
55 ._gcry_mpih_addmul_1:
56
57 cal 3,-4(3)
58 l 0,0(4)
59 cmpi 0,6,0
60 mtctr 5
61 mul 9,0,6
62 srai 7,0,31
63 and 7,7,6
64 mfmq 8
65 cax 9,9,7
66 l 7,4(3)
67 a 8,8,7 # add res_limb
68 blt Lneg
69 Lpos: bdz Lend
70
71 Lploop: lu 0,4(4)
72 stu 8,4(3)
73 cmpi 0,0,0
74 mul 10,0,6
75 mfmq 0
76 ae 8,0,9 # low limb + old_cy_limb + old cy
77 l 7,4(3)
78 aze 10,10 # propagate cy to new cy_limb
79 a 8,8,7 # add res_limb
80 bge Lp0
81 cax 10,10,6 # adjust high limb for negative limb from s1
82 Lp0: bdz Lend0
83 lu 0,4(4)
84 stu 8,4(3)
85 cmpi 0,0,0
86 mul 9,0,6
87 mfmq 0
88 ae 8,0,10
89 l 7,4(3)
90 aze 9,9
91 a 8,8,7
92 bge Lp1
93 cax 9,9,6 # adjust high limb for negative limb from s1
94 Lp1: bdn Lploop
95
96 b Lend
97
98 Lneg: cax 9,9,0
99 bdz Lend
100 Lnloop: lu 0,4(4)
101 stu 8,4(3)
102 cmpi 0,0,0
103 mul 10,0,6
104 mfmq 7
105 ae 8,7,9
106 l 7,4(3)
107 ae 10,10,0 # propagate cy to new cy_limb
108 a 8,8,7 # add res_limb
109 bge Ln0
110 cax 10,10,6 # adjust high limb for negative limb from s1
111 Ln0: bdz Lend0
112 lu 0,4(4)
113 stu 8,4(3)
114 cmpi 0,0,0
115 mul 9,0,6
116 mfmq 7
117 ae 8,7,10
118 l 7,4(3)
119 ae 9,9,0 # propagate cy to new cy_limb
120 a 8,8,7 # add res_limb
121 bge Ln1
122 cax 9,9,6 # adjust high limb for negative limb from s1
123 Ln1: bdn Lnloop
124 b Lend
125
126 Lend0: cal 9,0(10)
127 Lend: st 8,4(3)
128 aze 3,9
129 br
130