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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
31 ;;; gf_vect_mul_avx(len, mul_array, src, dest)
34 %include "reg_sizes.asm"
36 %ifidn __OUTPUT_FORMAT__, elf64
45 %define func(x) x: endbranch
49 %elifidn __OUTPUT_FORMAT__, win64
55 %define stack_size 5*16 + 8 ; must be an odd multiple of 8
56 %define func(x) proc_frame x
58 alloc_stack stack_size
59 vmovdqa [rsp + 0*16], xmm6
60 vmovdqa [rsp + 1*16], xmm7
61 vmovdqa [rsp + 2*16], xmm13
62 vmovdqa [rsp + 3*16], xmm14
63 vmovdqa [rsp + 4*16], xmm15
68 vmovdqa xmm6, [rsp + 0*16]
69 vmovdqa xmm7, [rsp + 1*16]
70 vmovdqa xmm13, [rsp + 2*16]
71 vmovdqa xmm14, [rsp + 3*16]
72 vmovdqa xmm15, [rsp + 4*16]
80 %define mul_array arg1
86 ;;; Use Non-temporal load/stor
91 %define XLDR vmovntdqa
100 %define xmask0f xmm15
101 %define xgft_lo xmm14
102 %define xgft_hi xmm13
114 mk_global gf_vect_mul_avx, function
115 func(gf_vect_mul_avx)
118 vmovdqa xmask0f, [mask0f] ;Load mask of lower nibble in each byte
119 vmovdqu xgft_lo, [mul_array] ;Load array Cx{00}, Cx{01}, Cx{02}, ...
120 vmovdqu xgft_hi, [mul_array+16] ; " Cx{00}, Cx{10}, Cx{20}, ... , Cx{f0}
123 XLDR x0, [src+pos] ;Get next source vector
124 XLDR x1, [src+pos+16] ;Get next source vector + 16B ahead
125 add pos, 32 ;Loop on 16 bytes at a time
127 vpand xtmp1a, x0, xmask0f ;Mask low src nibble in bits 4-0
128 vpand xtmp2a, x1, xmask0f
129 vpsraw x0, x0, 4 ;Shift to put high nibble into bits 4-0
131 vpand x0, x0, xmask0f ;Mask high src nibble in bits 4-0
132 vpand x1, x1, xmask0f
133 vpshufb xtmp1b, xgft_hi, x0 ;Lookup mul table of high nibble
134 vpshufb xtmp1c, xgft_lo, xtmp1a ;Lookup mul table of low nibble
135 vpshufb xtmp2b, xgft_hi, x1 ;Lookup mul table of high nibble
136 vpshufb xtmp2c, xgft_lo, xtmp2a ;Lookup mul table of low nibble
137 vpxor xtmp1b, xtmp1b, xtmp1c ;GF add high and low partials
138 vpxor xtmp2b, xtmp2b, xtmp2c
139 XSTR [dest+pos-32], xtmp1b ;Store result
140 XSTR [dest+pos-16], xtmp2b ;Store +16B result
161 dq 0x0f0f0f0f0f0f0f0f, 0x0f0f0f0f0f0f0f0f
163 ;;; func core, ver, snum
164 slversion gf_vect_mul_avx, 01, 03, 0036