Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Side by Side Diff: nss/mozilla/security/nss/lib/freebl/mpi/mpi_arm.c

Issue 10828060: Use the ARM assembly code in mpi_arm.c for iOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Add mpi_mac.c for including the appropriate assembly code file for Mac/iOS Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is the Netscape security libraries.
15 *
16 * The Initial Developer of the Original Code is Mozilla Japan.
17 * Portions created by the Initial Developer are Copyright (C) 2010
18 * the Initial Developer. All Rights Reserved.
19 *
20 * Contributor(s):
21 * Makoto Kato <m_kato@ga2.so-net.ne.jp> (Original Author)
22 *
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
34 *
35 * ***** END LICENSE BLOCK ***** */
36
37 /* This inlined version is for 32-bit ARM platform only */
38
39 #if !defined(__arm__)
40 #error "This is for ARM only"
41 #endif
42
43 /* 16-bit thumb doesn't work inlined assember version */
Mark Mentovai 2012/08/02 14:50:34 This doesn’t quite seem like a sentence.
wtc 2012/11/26 22:22:44 This file was contributed by someone else. I'll a
44 #if (!defined(__thumb__) || defined(__thumb2__)) && !defined(__ARM_ARCH_3__)
45
46 #include "mpi-priv.h"
47
48 #ifdef MP_ASSEMBLY_MULTIPLY
49 void s_mpv_mul_d(const mp_digit *a, mp_size a_len, mp_digit b, mp_digit *c)
50 {
51 __asm__ __volatile__(
52 "mov r5, #0\n"
53 #ifdef __thumb2__
54 "cbz %1, 2f\n"
55 #else
56 "cmp %1, r5\n" /* r5 is 0 now */
57 "beq 2f\n"
58 #endif
59
60 "1:\n"
61 "mov r4, #0\n"
62 "ldr r6, [%0], #4\n"
63 "umlal r5, r4, r6, %2\n"
64 "str r5, [%3], #4\n"
65 "mov r5, r4\n"
66
67 "subs %1, #1\n"
68 "bne 1b\n"
69
70 "2:\n"
71 "str r5, [%3]\n"
72 :
73 : "r"(a), "r"(a_len), "r"(b), "r"(c)
74 : "memory", "cc", "%r4", "%r5", "%r6");
75 }
76
77 void s_mpv_mul_d_add(const mp_digit *a, mp_size a_len, mp_digit b, mp_digit *c)
78 {
79 __asm__ __volatile__(
80 "mov r5, #0\n"
81 #ifdef __thumb2__
82 "cbz %1, 2f\n"
83 #else
84 "cmp %1, r5\n" /* r5 is 0 now */
85 "beq 2f\n"
86 #endif
87
88 "1:\n"
89 "mov r4, #0\n"
90 "ldr r6, [%3]\n"
91 "adds r5, r6\n"
92 "adc r4, #0\n"
droger 2012/10/29 14:38:54 When we tried building this on trunk we had a synt
93
94 "ldr r6, [%0], #4\n"
95 "umlal r5, r4, r6, %2\n"
96 "str r5, [%3], #4\n"
97 "mov r5, r4\n"
98
99 "subs %1, #1\n"
100 "bne 1b\n"
101
102 "2:\n"
103 "str r5, [%3]\n"
104 :
105 : "r"(a), "r"(a_len), "r"(b), "r"(c)
106 : "memory", "cc", "%r4", "%r5", "%r6");
107 }
108
109 void s_mpv_mul_d_add_prop(const mp_digit *a, mp_size a_len, mp_digit b, mp_digit *c)
110 {
111 if (!a_len)
Mark Mentovai 2012/08/02 14:50:34 Just curious why you’re handling this in C code he
112 return;
113
114 __asm__ __volatile__(
115 "mov r5, #0\n"
116
117 "1:\n"
118 "mov r4, #0\n"
119 "ldr r6, [%3]\n"
120 "adds r5, r6\n"
121 "adc r4, #0\n"
122 "ldr r6, [%0], #4\n"
123 "umlal r5, r4, r6, %2\n"
124 "str r5, [%3], #4\n"
125 "mov r5, r4\n"
126
127 "subs %1, #1\n"
128 "bne 1b\n"
129
130 #ifdef __thumb2__
131 "cbz r4, 3f\n"
132 #else
133 "cmp r4, #0\n"
134 "beq 3f\n"
135 #endif
136
137 "2:\n"
138 "mov r4, #0\n"
139 "ldr r6, [%3]\n"
140 "adds r5, r6\n"
141 "adc r4, #0\n"
142 "str r5, [%3], #4\n"
143 "movs r5, r4\n"
144 "bne 2b\n"
145
146 "3:\n"
147 :
148 : "r"(a), "r"(a_len), "r"(b), "r"(c)
149 : "memory", "cc", "%r4", "%r5", "%r6");
150 }
151 #endif
152
153 #ifdef MP_ASSEMBLY_SQUARE
154 void s_mpv_sqr_add_prop(const mp_digit *pa, mp_size a_len, mp_digit *ps)
155 {
156 if (!a_len)
157 return;
158
159 __asm__ __volatile__(
160 "mov r3, #0\n"
161
162 "1:\n"
163 "mov r4, #0\n"
164 "ldr r6, [%0], #4\n"
165 "ldr r5, [%2]\n"
166 "adds r3, r5\n"
167 "adc r4, #0\n"
168 "umlal r3, r4, r6, r6\n" /* w = r3:r4 */
169 "str r3, [%2], #4\n"
170
171 "ldr r5, [%2]\n"
172 "adds r3, r4, r5\n"
173 "mov r4, #0\n"
174 "adc r4, #0\n"
175 "str r3, [%2], #4\n"
176 "mov r3, r4\n"
177
178 "subs %1, #1\n"
179 "bne 1b\n"
180
181 #ifdef __thumb2__
182 "cbz r3, 3f\n"
183 #else
184 "cmp r3, #0\n"
185 "beq 3f\n"
186 #endif
187
188 "2:\n"
189 "mov r4, #0\n"
190 "ldr r5, [%2]\n"
191 "adds r3, r5\n"
192 "adc r4, #0\n"
193 "str r3, [%2], #4\n"
194 "movs r3, r4\n"
195 "bne 2b\n"
196
197 "3:"
198 :
199 : "r"(pa), "r"(a_len), "r"(ps)
200 : "memory", "cc", "%r3", "%r4", "%r5", "%r6");
201 }
202 #endif
203 #endif
OLDNEW
« no previous file with comments | « no previous file | nss/mozilla/security/nss/lib/freebl/mpi/mpi_mac.c » ('j') | nss/mozilla/security/nss/lib/freebl/mpi/mpi_mac.c » ('J')

Powered by Google App Engine
This is Rietveld 408576698