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_avx2(len, vec, *g_tbls, **buffs, *dest);
34 %include "reg_sizes.asm"
36 %ifidn __OUTPUT_FORMAT__, elf64
59 %ifidn __OUTPUT_FORMAT__, win64
65 %define arg4 r12 ; must be saved and loaded
70 %define tmp3 rdi ; must be saved and loaded
76 %define frame_size 2*8
77 %define arg(x) [rsp + frame_size + PS + PS*x]
79 %define func(x) proc_frame x
93 %ifidn __OUTPUT_FORMAT__, elf32
95 ;;;================== High Address;
102 ;;;<================= esp of caller
104 ;;;<================= ebp = esp
108 ;;;<================= esp of callee
110 ;;;================== Low Address;
115 %define arg(x) [ebp + PS*2 + PS*x]
117 %define trans ecx ;trans is for the variables in stack
119 %define arg0_m arg(0)
121 %define arg1_m arg(1)
123 %define arg2_m arg(2)
126 %define arg4_m arg(4)
133 %macro SLDR 2 ;stack load/restore
147 %macro FUNC_RESTORE 0
155 %endif ; output formats
159 %define mul_array arg2
167 %ifidn PS,4 ;32-bit code
170 %define dest_m arg4_m
173 %ifndef EC_ALIGNED_ADDR
174 ;;; Use Un-aligned load/store
178 ;;; Use Non-temporal load/stor
183 %define XLDR vmovntdqa
184 %define XSTR vmovntdq
188 %ifidn PS,8 ;64-bit code
196 %define xmask0fx xmm3
205 global gf_vect_dot_prod_avx2:function
206 func(gf_vect_dot_prod_avx2)
214 vpinsrb xmask0fx, xmask0fx, tmp.w, 0
215 vpbroadcastb xmask0f, xmask0fx ;Construct mask 0x0f0f0f...
224 mov ptr, [src+vec_i*PS]
226 vmovdqu xgft_lo, [tmp] ;Load array Cx{00}, Cx{01}, Cx{02}, ...
227 ; " Cx{00}, Cx{10}, Cx{20}, ... , Cx{f0}
228 vperm2i128 xgft_hi, xgft_lo, xgft_lo, 0x11 ; swapped to hi | hi
229 vperm2i128 xgft_lo, xgft_lo, xgft_lo, 0x00 ; swapped to lo | lo
231 XLDR x0, [ptr+pos] ;Get next source vector
236 vpand xtmpa, x0, xmask0f ;Mask low src nibble in bits 4-0
237 vpsraw x0, x0, 4 ;Shift to put high nibble into bits 4-0
238 vpand x0, x0, xmask0f ;Mask high src nibble in bits 4-0
240 vpshufb xgft_hi, xgft_hi, x0 ;Lookup mul table of high nibble
241 vpshufb xgft_lo, xgft_lo, xtmpa ;Lookup mul table of low nibble
242 vpxor xgft_hi, xgft_hi, xgft_lo ;GF add high and low partials
243 vpxor xp, xp, xgft_hi ;xp += partial
252 add pos, 32 ;Loop on 32 bytes at a time
262 mov pos, len ;Overlapped offset length-32
263 jmp .loop32 ;Do one more overlap pass
279 ;;; func core, ver, snum
280 slversion gf_vect_dot_prod_avx2, 04, 05, 0190