1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ; Copyright(c) 2011-2015 Intel Corporation All rights reserved.
4 ; Redistribution and use in source and binary forms, with or without
5 ; modification, are permitted provided that the following conditions
7 ; * Redistributions of source code must retain the above copyright
8 ; notice, this list of conditions and the following disclaimer.
9 ; * Redistributions in binary form must reproduce the above copyright
10 ; notice, this list of conditions and the following disclaimer in
11 ; the documentation and/or other materials provided with the
13 ; * Neither the name of Intel Corporation nor the names of its
14 ; contributors may be used to endorse or promote products derived
15 ; from this software without specific prior written permission.
17 ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
30 ;;; Optimized pq of N source vectors using SSE3
31 ;;; int pq_gen_sse(int vects, int len, void **array)
33 ;;; Generates P+Q parity vector from N (vects-2) sources in array of pointers
34 ;;; (**array). Last two pointers are the P and Q destinations respectively.
35 ;;; Vectors must be aligned to 16 bytes. Length must be 16 byte aligned.
37 %include "reg_sizes.asm"
39 %ifidn __OUTPUT_FORMAT__, elf64
54 %ifidn __OUTPUT_FORMAT__, win64
62 %define stack_size 7*16 + 8 ; must be an odd multiple of 8
63 %define func(x) proc_frame x
65 alloc_stack stack_size
66 save_xmm128 xmm6, 0*16
67 save_xmm128 xmm7, 1*16
68 save_xmm128 xmm8, 2*16
69 save_xmm128 xmm9, 3*16
70 save_xmm128 xmm10, 4*16
71 save_xmm128 xmm11, 5*16
72 save_xmm128 xmm15, 6*16
77 movdqa xmm6, [rsp + 0*16]
78 movdqa xmm7, [rsp + 1*16]
79 movdqa xmm8, [rsp + 2*16]
80 movdqa xmm9, [rsp + 3*16]
81 movdqa xmm10, [rsp + 4*16]
82 movdqa xmm11, [rsp + 5*16]
83 movdqa xmm15, [rsp + 6*16]
110 ;;; Use Non-temporal load/stor
115 %define XLDR movntdqa
125 global pq_gen_sse:function
128 sub vec, 3 ;Keep as offset to last source
129 jng return_fail ;Must have at least 2 sources
132 test len, (16-1) ;Check alignment of length
140 sub len, 48 ;Len points to last block
143 mov ptr, [arg2+vec*8] ;Fetch last source pointer
144 mov tmp, vec ;Set tmp to point back to last vector
145 XLDR xs1, [ptr+pos] ;Preload last vector (source)
146 XLDR xs2, [ptr+pos+16] ;Preload last vector (source)
147 XLDR xs3, [ptr+pos+32] ;Preload last vector (source)
148 pxor xp1, xp1 ;p1 = 0
149 pxor xp2, xp2 ;p2 = 0
150 pxor xp3, xp3 ;p3 = 0
151 pxor xq1, xq1 ;q1 = 0
152 pxor xq2, xq2 ;q2 = 0
153 pxor xq3, xq3 ;q3 = 0
156 sub tmp, 1 ;Inner loop for each source vector
157 mov ptr, [arg2+tmp*8] ; get pointer to next vect
158 pxor xq1, xs1 ; q1 ^= s1
159 pxor xq2, xs2 ; q2 ^= s2
160 pxor xq3, xs3 ; q3 ^= s3
161 pxor xp1, xs1 ; p1 ^= s1
162 pxor xp2, xs2 ; p2 ^= s2
163 pxor xp3, xs3 ; p3 ^= s2
164 pxor xtmp1, xtmp1 ; xtmp1 = 0 - for compare to 0
165 pxor xtmp2, xtmp2 ; xtmp2 = 0
166 pxor xtmp3, xtmp3 ; xtmp3 = 0
167 pcmpgtb xtmp1, xq1 ; xtmp1 = mask 0xff or 0x00 if bit7 set
168 pcmpgtb xtmp2, xq2 ; xtmp2 = mask 0xff or 0x00 if bit7 set
169 pcmpgtb xtmp3, xq3 ; xtmp3 = mask 0xff or 0x00 if bit7 set
170 pand xtmp1, xpoly ; xtmp1 = poly or 0x00
171 pand xtmp2, xpoly ; xtmp2 = poly or 0x00
172 pand xtmp3, xpoly ; xtmp3 = poly or 0x00
173 XLDR xs1, [ptr+pos] ; Get next vector (source data1)
174 XLDR xs2, [ptr+pos+16] ; Get next vector (source data2)
175 XLDR xs3, [ptr+pos+32] ; Get next vector (source data3)
176 paddb xq1, xq1 ; q1 = q1<<1
177 paddb xq2, xq2 ; q2 = q2<<1
178 paddb xq3, xq3 ; q3 = q3<<1
179 pxor xq1, xtmp1 ; q1 = q1<<1 ^ poly_masked
180 pxor xq2, xtmp2 ; q2 = q2<<1 ^ poly_masked
181 pxor xq3, xtmp3 ; q3 = q3<<1 ^ poly_masked
182 jg next_vect ; Loop for each vect except 0
184 mov ptr, [arg2+8+vec*8] ;Get address of P parity vector
185 mov tmp, [arg2+(2*8)+vec*8] ;Get address of Q parity vector
186 pxor xp1, xs1 ;p1 ^= s1[0] - last source is already loaded
187 pxor xq1, xs1 ;q1 ^= 1 * s1[0]
188 pxor xp2, xs2 ;p2 ^= s2[0]
189 pxor xq2, xs2 ;q2 ^= 1 * s2[0]
190 pxor xp3, xs3 ;p3 ^= s3[0]
191 pxor xq3, xs3 ;q3 ^= 1 * s3[0]
192 XSTR [ptr+pos], xp1 ;Write parity P1 vector
193 XSTR [ptr+pos+16], xp2 ;Write parity P2 vector
194 XSTR [ptr+pos+32], xp3 ;Write parity P3 vector
195 XSTR [tmp+pos], xq1 ;Write parity Q1 vector
196 XSTR [tmp+pos+16], xq2 ;Write parity Q2 vector
197 XSTR [tmp+pos+32], xq3 ;Write parity Q3 vector
202 ;; ------------------------------
203 ;; Do last 16 or 32 Bytes remaining
209 mov ptr, [arg2+vec*8] ;Fetch last source pointer
210 mov tmp, vec ;Set tmp to point back to last vector
211 XLDR xs1, [ptr+pos] ;Preload last vector (source)
216 sub tmp, 1 ;Inner loop for each source vector
217 mov ptr, [arg2+tmp*8] ; get pointer to next vect
218 pxor xq1, xs1 ; q1 ^= s1
219 pxor xtmp1, xtmp1 ; xtmp = 0
220 pcmpgtb xtmp1, xq1 ; xtmp = mask 0xff or 0x00 if bit7 set
221 pand xtmp1, xpoly ; xtmp = poly or 0x00
222 pxor xp1, xs1 ; p ^= s
223 paddb xq1, xq1 ; q = q<<1
224 pxor xq1, xtmp1 ; q = q<<1 ^ poly_masked
225 XLDR xs1, [ptr+pos] ; Get next vector (source data)
226 jg next_vect16 ; Loop for each vect except 0
228 mov ptr, [arg2+8+vec*8] ;Get address of P parity vector
229 mov tmp, [arg2+(2*8)+vec*8] ;Get address of Q parity vector
230 pxor xp1, xs1 ;p ^= s[0] - last source is already loaded
231 pxor xq1, xs1 ;q ^= 1 * s[0]
232 XSTR [ptr+pos], xp1 ;Write parity P vector
233 XSTR [tmp+pos], xq1 ;Write parity Q vector
255 dq 0x1d1d1d1d1d1d1d1d, 0x1d1d1d1d1d1d1d1d
257 ;;; func core, ver, snum
258 slversion pq_gen_sse, 00, 09, 0032