7 #if __ARM_MAX_ARCH__>=7
10 .word OPENSSL_armcap_P-.Lbn_mul_mont
15 .type bn_mul_mont,%function
20 ldr ip,[sp,#4] @ load num
21 stmdb sp!,{r0,r2} @ sp points at argument block
22 #if __ARM_MAX_ARCH__>=7
26 ldr r2,.LOPENSSL_armcap
31 tst r0,#1 @ NEON available?
45 stmdb sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} @ save 10 registers
47 mov r0,r0,lsl#2 @ rescale r0 for byte count
48 sub sp,sp,r0 @ alloca(4*num)
49 sub sp,sp,#4 @ +extra dword
50 sub r0,r0,#4 @ "num=num-1"
51 add r4,r2,r0 @ &bp[num-1]
53 add r0,sp,r0 @ r0 to point at &tp[num-1]
54 ldr r8,[r0,#14*4] @ &n0
56 ldr r5,[r1],#4 @ ap[0],ap++
57 ldr r6,[r3],#4 @ np[0],np++
59 str r4,[r0,#15*4] @ save &bp[num]
61 umull r10,r11,r5,r2 @ ap[0]*bp[0]
62 str r8,[r0,#14*4] @ save n0 value
63 mul r8,r10,r8 @ "tp[0]"*n0
65 umlal r10,r12,r6,r8 @ np[0]*n0+"t[0]"
69 ldr r5,[r1],#4 @ ap[j],ap++
71 ldr r6,[r3],#4 @ np[j],np++
73 umlal r10,r11,r5,r2 @ ap[j]*bp[0]
75 umlal r12,r14,r6,r8 @ np[j]*n0
77 str r12,[r4],#4 @ tp[j-1]=,tp++
83 ldr r4,[r0,#13*4] @ restore bp
85 ldr r8,[r0,#14*4] @ restore n0
87 str r12,[r0] @ tp[num-1]=
88 str r14,[r0,#4] @ tp[num]=
91 sub r7,r0,sp @ "original" r0-1 value
92 sub r1,r1,r7 @ "rewind" ap to &ap[1]
93 ldr r2,[r4,#4]! @ *(++bp)
94 sub r3,r3,r7 @ "rewind" np to &np[1]
95 ldr r5,[r1,#-4] @ ap[0]
97 ldr r6,[r3,#-4] @ np[0]
98 ldr r7,[sp,#4] @ tp[1]
101 umlal r10,r11,r5,r2 @ ap[0]*bp[i]+tp[0]
102 str r4,[r0,#13*4] @ save bp
105 umlal r10,r12,r6,r8 @ np[0]*n0+"tp[0]"
109 ldr r5,[r1],#4 @ ap[j],ap++
110 adds r10,r11,r7 @ +=tp[j]
111 ldr r6,[r3],#4 @ np[j],np++
113 umlal r10,r11,r5,r2 @ ap[j]*bp[i]
115 umlal r12,r14,r6,r8 @ np[j]*n0
117 ldr r7,[r4,#8] @ tp[j+1]
119 str r12,[r4],#4 @ tp[j-1]=,tp++
126 ldr r4,[r0,#13*4] @ restore bp
128 ldr r8,[r0,#14*4] @ restore n0
130 ldr r7,[r0,#15*4] @ restore &bp[num]
132 str r12,[r0] @ tp[num-1]=
133 str r14,[r0,#4] @ tp[num]=
138 ldr r2,[r0,#12*4] @ pull rp
139 add r0,r0,#4 @ r0 to point at &tp[num]
140 sub r5,r0,sp @ "original" num value
141 mov r4,sp @ "rewind" r4
142 mov r1,r4 @ "borrow" r1
143 sub r3,r3,r5 @ "rewind" r3 to &np[0]
145 subs r7,r7,r7 @ "clear" carry flag
146 .Lsub: ldr r7,[r4],#4
148 sbcs r7,r7,r6 @ tp[j]-np[j]
149 str r7,[r2],#4 @ rp[j]=
150 teq r4,r0 @ preserve carry
152 sbcs r14,r14,#0 @ upmost carry
153 mov r4,sp @ "rewind" r4
154 sub r2,r2,r5 @ "rewind" r2
158 orr r1,r1,r3 @ ap=borrow?tp:rp
160 .Lcopy: ldr r7,[r1],#4 @ copy or in-place refresh
161 str sp,[r4],#4 @ zap tp
166 add sp,r0,#4 @ skip over tp[num+1]
167 ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} @ restore registers
168 add sp,sp,#2*4 @ skip over {r0,r2}
172 bx lr @ .word 0xe12fff1e
175 moveq pc,lr @ be binary compatible with V4, yet
176 .word 0xe12fff1e @ interoperable with Thumb ISA:-)
178 .size bn_mul_mont,.-bn_mul_mont
179 #if __ARM_MAX_ARCH__>=7
183 .type bn_mul8x_mont_neon,%function
187 stmdb sp!,{r4,r5,r6,r7,r8,r9,r10,r11}
188 vstmdb sp!,{d8,d9,d10,d11,d12,d13,d14,d15} @ ABI specification says so
189 ldmia ip,{r4,r5} @ load rest of parameter block
192 vld1.32 {d28[0]}, [r2,:32]!
194 vld1.32 {d0,d1,d2,d3}, [r1]! @ can't specify :32 :-(
196 vld1.32 {d30[0]}, [r4,:32]
202 vmull.u32 q6,d28,d0[0]
203 vmull.u32 q7,d28,d0[1]
204 vmull.u32 q8,d28,d1[0]
206 vmull.u32 q9,d28,d1[1]
212 vmull.u32 q10,d28,d2[0]
213 vld1.32 {d4,d5,d6,d7}, [r3]!
214 vmull.u32 q11,d28,d2[1]
215 vmull.u32 q12,d28,d3[0]
217 vmull.u32 q13,d28,d3[1]
221 @ special case for num=8, everything is in register bank...
223 vmlal.u32 q6,d29,d4[0]
225 vmlal.u32 q7,d29,d4[1]
226 vmlal.u32 q8,d29,d5[0]
227 vmlal.u32 q9,d29,d5[1]
229 vmlal.u32 q10,d29,d6[0]
231 vmlal.u32 q11,d29,d6[1]
233 vmlal.u32 q12,d29,d7[0]
235 vmlal.u32 q13,d29,d7[1]
250 vld1.32 {d28[0]}, [r2,:32]!
255 vmlal.u32 q6,d28,d0[0]
256 vmlal.u32 q7,d28,d0[1]
257 vmlal.u32 q8,d28,d1[0]
259 vmlal.u32 q9,d28,d1[1]
266 vmlal.u32 q10,d28,d2[0]
267 vmlal.u32 q11,d28,d2[1]
268 vmlal.u32 q12,d28,d3[0]
270 vmlal.u32 q13,d28,d3[1]
272 vmlal.u32 q6,d29,d4[0]
273 vmlal.u32 q7,d29,d4[1]
274 vmlal.u32 q8,d29,d5[0]
275 vmlal.u32 q9,d29,d5[1]
277 vmlal.u32 q10,d29,d6[0]
279 vmlal.u32 q11,d29,d6[1]
281 vmlal.u32 q12,d29,d7[0]
283 vmlal.u32 q13,d29,d7[1]
309 vmlal.u32 q6,d29,d4[0]
310 vld1.32 {d0,d1,d2,d3}, [r1]!
311 vmlal.u32 q7,d29,d4[1]
313 vmlal.u32 q8,d29,d5[0]
314 vmlal.u32 q9,d29,d5[1]
316 vmlal.u32 q10,d29,d6[0]
317 vld1.32 {d4,d5}, [r3]!
318 vmlal.u32 q11,d29,d6[1]
319 vst1.64 {q6,q7}, [r7,:256]!
320 vmlal.u32 q12,d29,d7[0]
321 vmlal.u32 q13,d29,d7[1]
322 vst1.64 {q8,q9}, [r7,:256]!
324 vmull.u32 q6,d28,d0[0]
325 vld1.32 {d6,d7}, [r3]!
326 vmull.u32 q7,d28,d0[1]
327 vst1.64 {q10,q11}, [r7,:256]!
328 vmull.u32 q8,d28,d1[0]
329 vmull.u32 q9,d28,d1[1]
330 vst1.64 {q12,q13}, [r7,:256]!
332 vmull.u32 q10,d28,d2[0]
333 vmull.u32 q11,d28,d2[1]
334 vmull.u32 q12,d28,d3[0]
335 vmull.u32 q13,d28,d3[1]
339 vmlal.u32 q6,d29,d4[0]
341 vmlal.u32 q7,d29,d4[1]
342 sub r1,r1,r5,lsl#2 @ rewind r1
343 vmlal.u32 q8,d29,d5[0]
344 vld1.64 {q5}, [sp,:128]
345 vmlal.u32 q9,d29,d5[1]
348 vmlal.u32 q10,d29,d6[0]
349 vst1.64 {q6,q7}, [r7,:256]!
350 vmlal.u32 q11,d29,d6[1]
352 vld1.64 {q6}, [r6, :128]!
353 vmlal.u32 q12,d29,d7[0]
354 vst1.64 {q8,q9}, [r7,:256]!
355 vmlal.u32 q13,d29,d7[1]
357 vst1.64 {q10,q11}, [r7,:256]!
360 vst1.64 {q12,q13}, [r7,:256]!
361 vld1.64 {q7,q8}, [r6, :256]!
362 vst1.64 {q4}, [r7,:128]
369 vld1.32 {d28[0]}, [r2,:32]!
370 sub r3,r3,r5,lsl#2 @ rewind r3
371 vld1.32 {d0,d1,d2,d3}, [r1]!
378 vmlal.u32 q6,d28,d0[0]
379 vld1.64 {q9,q10},[r6,:256]!
380 vmlal.u32 q7,d28,d0[1]
381 vmlal.u32 q8,d28,d1[0]
382 vld1.64 {q11,q12},[r6,:256]!
383 vmlal.u32 q9,d28,d1[1]
388 vld1.64 {q13},[r6,:128]!
391 vmlal.u32 q10,d28,d2[0]
392 vld1.32 {d4,d5,d6,d7}, [r3]!
393 vmlal.u32 q11,d28,d2[1]
394 vmlal.u32 q12,d28,d3[0]
396 vmlal.u32 q13,d28,d3[1]
399 vmlal.u32 q6,d29,d4[0]
400 vld1.32 {d0,d1,d2,d3}, [r1]!
401 vmlal.u32 q7,d29,d4[1]
403 vmlal.u32 q8,d29,d5[0]
404 vmlal.u32 q9,d29,d5[1]
405 vst1.64 {q6,q7}, [r7,:256]!
407 vmlal.u32 q10,d29,d6[0]
408 vld1.64 {q6}, [r6, :128]!
409 vmlal.u32 q11,d29,d6[1]
410 vst1.64 {q8,q9}, [r7,:256]!
411 vmlal.u32 q12,d29,d7[0]
412 vld1.64 {q7,q8}, [r6, :256]!
413 vmlal.u32 q13,d29,d7[1]
414 vst1.64 {q10,q11}, [r7,:256]!
416 vmlal.u32 q6,d28,d0[0]
417 vld1.64 {q9,q10}, [r6, :256]!
418 vmlal.u32 q7,d28,d0[1]
419 vst1.64 {q12,q13}, [r7,:256]!
420 vmlal.u32 q8,d28,d1[0]
421 vld1.64 {q11,q12}, [r6, :256]!
422 vmlal.u32 q9,d28,d1[1]
423 vld1.32 {d4,d5,d6,d7}, [r3]!
425 vmlal.u32 q10,d28,d2[0]
426 vld1.64 {q13}, [r6, :128]!
427 vmlal.u32 q11,d28,d2[1]
428 vmlal.u32 q12,d28,d3[0]
429 vmlal.u32 q13,d28,d3[1]
433 vmlal.u32 q6,d29,d4[0]
435 vmlal.u32 q7,d29,d4[1]
436 sub r1,r1,r5,lsl#2 @ rewind r1
437 vmlal.u32 q8,d29,d5[0]
438 vld1.64 {q5}, [sp,:128]
439 vmlal.u32 q9,d29,d5[1]
442 vmlal.u32 q10,d29,d6[0]
443 vst1.64 {q6,q7}, [r7,:256]!
444 vmlal.u32 q11,d29,d6[1]
445 vld1.64 {q6}, [r6, :128]!
447 vst1.64 {q8,q9}, [r7,:256]!
448 vmlal.u32 q12,d29,d7[0]
449 vld1.64 {q7,q8}, [r6, :256]!
450 vmlal.u32 q13,d29,d7[1]
452 vst1.64 {q10,q11}, [r7,:256]!
454 vst1.64 {q12,q13}, [r7,:256]!
464 vld1.64 {q9,q10}, [r6, :256]!
467 vld1.64 {q11,q12}, [r6, :256]!
469 vld1.64 {q13}, [r6, :128]!
474 vst1.32 {d12[0]}, [r7, :32]!
481 vst1.32 {d14[0]}, [r7, :32]!
488 vst1.32 {d16[0]}, [r7, :32]!
495 vst1.32 {d18[0]}, [r7, :32]!
502 vst1.32 {d20[0]}, [r7, :32]!
509 vst1.32 {d22[0]}, [r7, :32]!
512 vld1.64 {q6}, [r6, :128]!
517 vst1.32 {d24[0]}, [r7, :32]!
520 vld1.64 {q7,q8}, [r6, :256]!
524 vst1.32 {d26[0]}, [r7, :32]!
528 vst1.32 {d10[0]}, [r7, :32] @ top-most bit
529 sub r3,r3,r5,lsl#2 @ rewind r3
530 subs r1,sp,#0 @ clear carry flag
534 ldmia r1!, {r4,r5,r6,r7}
535 ldmia r3!, {r8,r9,r10,r11}
540 teq r1,r2 @ preserves carry
541 stmia r0!, {r8,r9,r10,r11}
544 ldr r10, [r1] @ load top-most bit
546 sub r11,r2,sp @ this is num*4
549 sub r0,r0,r11 @ rewind r0
550 mov r3,r2 @ second 3/4th of frame
551 sbcs r10,r10,#0 @ result is carry flag
554 ldmia r1!, {r4,r5,r6,r7}
555 ldmia r0, {r8,r9,r10,r11}
557 vst1.64 {q0,q1}, [r3,:256]! @ wipe
560 vst1.64 {q0,q1}, [r3,:256]! @ wipe
562 ldmia r1, {r4,r5,r6,r7}
563 stmia r0!, {r8,r9,r10,r11}
565 ldmia r0, {r8,r9,r10,r11}
567 vst1.64 {q0,q1}, [r1,:256]! @ wipe
570 vst1.64 {q0,q1}, [r3,:256]! @ wipe
572 teq r1,r2 @ preserves carry
573 stmia r0!, {r8,r9,r10,r11}
574 bne .LNEON_copy_n_zap
577 vldmia sp!,{d8,d9,d10,d11,d12,d13,d14,d15}
578 ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11}
579 bx lr @ .word 0xe12fff1e
580 .size bn_mul8x_mont_neon,.-bn_mul8x_mont_neon
582 .byte 77,111,110,116,103,111,109,101,114,121,32,109,117,108,116,105,112,108,105,99,97,116,105,111,110,32,102,111,114,32,65,82,77,118,52,47,78,69,79,78,44,32,67,82,89,80,84,79,71,65,77,83,32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115,115,108,46,111,114,103,62,0
585 #if __ARM_MAX_ARCH__>=7
586 .comm OPENSSL_armcap_P,4,4
587 .hidden OPENSSL_armcap_P