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_dot_prod_avx(len, vec, *g_tbls, **buffs, *dest);
34 %include "reg_sizes.asm"
36 %ifidn __OUTPUT_FORMAT__, elf64
56 %ifidn __OUTPUT_FORMAT__, win64
62 %define arg4 r12 ; must be saved and loaded
65 %define tmp3 rdi ; must be saved and loaded
71 %define frame_size 2*8
72 %define arg(x) [rsp + frame_size + PS + PS*x]
74 %define func(x) proc_frame x
88 %ifidn __OUTPUT_FORMAT__, elf32
90 ;;;================== High Address;
97 ;;;<================= esp of caller
99 ;;;<================= ebp = esp
103 ;;;<================= esp of callee
105 ;;;================== Low Address;
110 %define arg(x) [ebp + PS*2 + PS*x]
112 %define trans ecx ;trans is for the variables in stack
114 %define arg0_m arg(0)
116 %define arg1_m arg(1)
118 %define arg2_m arg(2)
121 %define arg4_m arg(4)
126 %macro SLDR 2 ;; stack load/restore
140 %macro FUNC_RESTORE 0
148 %endif ; output formats
152 %define mul_array arg2
160 %ifidn PS,4 ;32-bit code
163 %define dest_m arg4_m
166 %ifndef EC_ALIGNED_ADDR
167 ;;; Use Un-aligned load/store
171 ;;; Use Non-temporal load/stor
176 %define XLDR vmovntdqa
177 %define XSTR vmovntdq
181 %ifidn PS,8 ; 64-bit code
197 global gf_vect_dot_prod_avx:function
198 func(gf_vect_dot_prod_avx)
205 vmovdqa xmask0f, [mask0f] ;Load mask of lower nibble in each byte
214 mov ptr, [src+vec_i*PS]
215 vmovdqu xgft_lo, [tmp] ;Load array Cx{00}, Cx{01}, ..., Cx{0f}
216 vmovdqu xgft_hi, [tmp+16] ; " Cx{00}, Cx{10}, ..., Cx{f0}
217 XLDR x0, [ptr+pos] ;Get next source vector
222 vpand xtmpa, x0, xmask0f ;Mask low src nibble in bits 4-0
223 vpsraw x0, x0, 4 ;Shift to put high nibble into bits 4-0
224 vpand x0, x0, xmask0f ;Mask high src nibble in bits 4-0
226 vpshufb xgft_hi, xgft_hi, x0 ;Lookup mul table of high nibble
227 vpshufb xgft_lo, xgft_lo, xtmpa ;Lookup mul table of low nibble
228 vpxor xgft_hi, xgft_hi, xgft_lo ;GF add high and low partials
229 vpxor xp, xp, xgft_hi ;xp += partial
238 add pos, 16 ;Loop on 16 bytes at a time
248 mov pos, len ;Overlapped offset length-16
249 jmp .loop16 ;Do one more overlap pass
268 ddq 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f
270 ;;; func core, ver, snum
271 slversion gf_vect_dot_prod_avx, 02, 05, 0061