| 1 |
/* keccak-amd64-avx512.S - x86-64 AVX512 implementation of Keccak |
| 2 |
* |
| 3 |
* Copyright (C) 2022 Jussi Kivilinna <[email protected]> |
| 4 |
* |
| 5 |
* This file is part of Libgcrypt. |
| 6 |
* |
| 7 |
* Libgcrypt is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU Lesser General Public License as |
| 9 |
* published by the Free Software Foundation; either version 2.1 of |
| 10 |
* the License, or (at your option) any later version. |
| 11 |
* |
| 12 |
* Libgcrypt is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU Lesser General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Lesser General Public |
| 18 |
* License along with this program; if not, see <http://www.gnu.org/licenses/>. |
| 19 |
* |
| 20 |
* --- |
| 21 |
* |
| 22 |
* Core function `KeccakF1600_ce` based on ARMv8-CE KeccakF1600 implementation |
| 23 |
* by Andy Polyakov from CRYPTOGAMS distribution `arm/keccak1600-armv8.pl`. |
| 24 |
* `KeccakF1600_ce` was ported to x86-64 AVX512 and converted to use GCC |
| 25 |
* preprocessed assembly and fitted with new absorb function optimized for |
| 26 |
* x86-64. SHA3-256 performance on Intel tigerlake, 5.72 cpB. |
| 27 |
* |
| 28 |
* Original copyright license follows: |
| 29 |
* |
| 30 |
* Copyright (c) 2006, CRYPTOGAMS by <[email protected]> |
| 31 |
* All rights reserved. |
| 32 |
* |
| 33 |
* Redistribution and use in source and binary forms, with or without |
| 34 |
* modification, are permitted provided that the following conditions |
| 35 |
* are met: |
| 36 |
* |
| 37 |
* * Redistributions of source code must retain copyright notices, |
| 38 |
* this list of conditions and the following disclaimer. |
| 39 |
* |
| 40 |
* * Redistributions in binary form must reproduce the above |
| 41 |
* copyright notice, this list of conditions and the following |
| 42 |
* disclaimer in the documentation and/or other materials |
| 43 |
* provided with the distribution. |
| 44 |
* |
| 45 |
* * Neither the name of the CRYPTOGAMS nor the names of its |
| 46 |
* copyright holder and contributors may be used to endorse or |
| 47 |
* promote products derived from this software without specific |
| 48 |
* prior written permission. |
| 49 |
* |
| 50 |
* ALTERNATIVELY, provided that this notice is retained in full, this |
| 51 |
* product may be distributed under the terms of the GNU General Public |
| 52 |
* License (GPL), in which case the provisions of the GPL apply INSTEAD OF |
| 53 |
* those given above. |
| 54 |
* |
| 55 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS |
| 56 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 57 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 58 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 59 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 60 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 61 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 62 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 63 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 64 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 65 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 66 |
*/ |
| 67 |
|
| 68 |
#ifdef __x86_64 |
| 69 |
#include <config.h> |
| 70 |
#if defined(HAVE_GCC_INLINE_ASM_AVX512) && \ |
| 71 |
(defined(HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS) || \ |
| 72 |
defined(HAVE_COMPATIBLE_GCC_WIN64_PLATFORM_AS)) |
| 73 |
|
| 74 |
#include "asm-common-amd64.h" |
| 75 |
|
| 76 |
.text |
| 77 |
|
| 78 |
/* Register macros. */ |
| 79 |
#define A_0_0 %xmm31 |
| 80 |
#define A_0_1 %xmm30 |
| 81 |
#define A_0_2 %xmm29 |
| 82 |
#define A_0_3 %xmm28 |
| 83 |
#define A_0_4 %xmm27 |
| 84 |
#define A_1_0 %xmm26 |
| 85 |
#define A_1_1 %xmm25 |
| 86 |
#define A_1_2 %xmm24 |
| 87 |
#define A_1_3 %xmm23 |
| 88 |
#define A_1_4 %xmm22 |
| 89 |
#define A_2_0 %xmm21 |
| 90 |
#define A_2_1 %xmm20 |
| 91 |
#define A_2_2 %xmm19 |
| 92 |
#define A_2_3 %xmm18 |
| 93 |
#define A_2_4 %xmm17 |
| 94 |
#define A_3_0 %xmm16 |
| 95 |
#define A_3_1 %xmm15 |
| 96 |
#define A_3_2 %xmm14 |
| 97 |
#define A_3_3 %xmm13 |
| 98 |
#define A_3_4 %xmm12 |
| 99 |
#define A_4_0 %xmm11 |
| 100 |
#define A_4_1 %xmm10 |
| 101 |
#define A_4_2 %xmm9 |
| 102 |
#define A_4_3 %xmm8 |
| 103 |
#define A_4_4 %xmm7 |
| 104 |
|
| 105 |
#define C_0 %xmm6 |
| 106 |
#define C_1 %xmm5 |
| 107 |
#define C_2 %xmm4 |
| 108 |
#define C_3 %xmm3 |
| 109 |
#define C_4 %xmm2 |
| 110 |
#define C_5 %xmm1 |
| 111 |
#define C_6 %xmm0 |
| 112 |
|
| 113 |
#define D_0 C_4 |
| 114 |
#define D_1 C_5 |
| 115 |
#define D_2 C_6 |
| 116 |
#define D_3 C_2 |
| 117 |
#define D_4 C_3 |
| 118 |
|
| 119 |
/* Helper macros for ARMv8-CE to x86-64/AVX512 conversion. */ |
| 120 |
#define eor3_d(dst_s1, s2, s3) \ |
| 121 |
vpternlogq $0x96, s3, s2, dst_s1; |
| 122 |
|
| 123 |
#define eor3(dst, s1, s2, s3) \ |
| 124 |
vmovdqa s1, dst; \ |
| 125 |
eor3_d(dst, s2, s3); |
| 126 |
|
| 127 |
#define rax1_c(dst, s1, s2_rol1) \ |
| 128 |
vprolq $1, s2_rol1, dst; \ |
| 129 |
vpxor s1, dst, dst; |
| 130 |
|
| 131 |
#define rax1_t(dst_s1, s2_rol1, tmp) \ |
| 132 |
vprolq $1, s2_rol1, tmp; \ |
| 133 |
vpxor tmp, dst_s1, dst_s1; |
| 134 |
|
| 135 |
#define rax1_s(dst_s1, s2_rol1) \ |
| 136 |
vprolq $1, s2_rol1, s2_rol1; \ |
| 137 |
vpxor s2_rol1, dst_s1, dst_s1; |
| 138 |
|
| 139 |
#define xar(dst, s1, s2, rol) \ |
| 140 |
vpxorq s2, s1, dst; \ |
| 141 |
vprolq $(rol), dst, dst; |
| 142 |
|
| 143 |
#define xar_x(dst, s1, s2, rol) \ |
| 144 |
vpxor s2, s1, dst; \ |
| 145 |
vprolq $(rol), dst, dst; |
| 146 |
|
| 147 |
#define bcax_d(dst_s1, s2, s3) \ |
| 148 |
vpternlogq $0xb4, s3, s2, dst_s1; |
| 149 |
|
| 150 |
#define bcax(dst, s1, s2, s3) \ |
| 151 |
vmovdqa64 s1, dst; \ |
| 152 |
bcax_d(dst, s2, s3); |
| 153 |
|
| 154 |
#define bcax_x(dst, s1, s2, s3) \ |
| 155 |
vmovdqa s1, dst; \ |
| 156 |
bcax_d(dst, s2, s3); |
| 157 |
|
| 158 |
#define eor(dst, s1, s2) \ |
| 159 |
vpxorq s2, s1, dst; |
| 160 |
|
| 161 |
/* Misc helper macros. */ |
| 162 |
#define clear_avx512_4regs(a, b, c, d) \ |
| 163 |
eor(a, a, a); eor(b, b, b); eor(c, c, c); eor(d, d, d); |
| 164 |
|
| 165 |
#define clear_regs() \ |
| 166 |
vzeroall; /* xmm0-xmm15 */ \ |
| 167 |
clear_avx512_4regs(%ymm16, %ymm17, %ymm18, %ymm19); \ |
| 168 |
clear_avx512_4regs(%ymm20, %ymm21, %ymm22, %ymm23); \ |
| 169 |
clear_avx512_4regs(%ymm24, %ymm25, %ymm26, %ymm27); \ |
| 170 |
clear_avx512_4regs(%ymm28, %ymm29, %ymm30, %ymm31); |
| 171 |
|
| 172 |
ELF(.type KeccakF1600_ce,@function) |
| 173 |
.align 64, 0xcc |
| 174 |
KeccakF1600_ce: |
| 175 |
.Loop_ce: |
| 176 |
CFI_STARTPROC() |
| 177 |
|
| 178 |
////////////////////////////////////////////////// Theta |
| 179 |
eor3( C_0, A_4_0, A_3_0, A_2_0) |
| 180 |
eor3( C_1, A_4_1, A_3_1, A_2_1) |
| 181 |
eor3( C_3, A_4_3, A_3_3, A_2_3) |
| 182 |
eor3( C_2, A_4_2, A_3_2, A_2_2) |
| 183 |
eor3( C_4, A_4_4, A_3_4, A_2_4) |
| 184 |
eor3_d( C_0, A_1_0, A_0_0) |
| 185 |
eor3_d( C_1, A_1_1, A_0_1) |
| 186 |
eor3_d( C_3, A_1_3, A_0_3) |
| 187 |
eor3_d( C_2, A_1_2, A_0_2) |
| 188 |
eor3_d( C_4, A_1_4, A_0_4) |
| 189 |
|
| 190 |
rax1_c( C_5, C_0, C_2) // D[1] |
| 191 |
rax1_t( C_2, C_4, C_6) // D[3] |
| 192 |
rax1_c( C_6, C_1, C_3) // D[2] |
| 193 |
rax1_s( C_3, C_0) // D[4] |
| 194 |
rax1_s( C_4, C_1) // D[0] |
| 195 |
|
| 196 |
////////////////////////////////////////////////// Theta+Rho+Pi |
| 197 |
xar( C_0, A_0_1, D_1, 1) // C[0]=A[2][0] |
| 198 |
|
| 199 |
xar( A_0_1, A_1_1, D_1, 44) |
| 200 |
xar( A_1_1, A_1_4, D_4, 20) |
| 201 |
xar( A_1_4, A_4_2, D_2, 61) |
| 202 |
xar( A_4_2, A_2_4, D_4, 39) |
| 203 |
xar( A_2_4, A_4_0, D_0, 18) |
| 204 |
|
| 205 |
xar( C_1, A_0_2, D_2, 62) // C[1]=A[4][0] |
| 206 |
|
| 207 |
xar( A_0_2, A_2_2, D_2, 43) |
| 208 |
xar( A_2_2, A_2_3, D_3, 25) |
| 209 |
xar( A_2_3, A_3_4, D_4, 8) |
| 210 |
xar_x( A_3_4, A_4_3, D_3, 56) |
| 211 |
xar( A_4_3, A_3_0, D_0, 41) |
| 212 |
|
| 213 |
xar( A_3_0, A_0_4, D_4, 27) |
| 214 |
|
| 215 |
xar_x( D_4, A_4_4, D_4, 14) // D[4]=A[0][4] |
| 216 |
xar_x( A_4_4, A_4_1, D_1, 2) |
| 217 |
xar( A_1_3, A_1_3, D_3, 55) // A[1][3]=A[4][1] |
| 218 |
xar( A_0_4, A_3_1, D_1, 45) // A[0][4]=A[1][3] |
| 219 |
xar( A_3_1, A_1_0, D_0, 36) |
| 220 |
|
| 221 |
xar( A_1_0, A_0_3, D_3, 28) |
| 222 |
|
| 223 |
eor( A_0_0, A_0_0, D_0) |
| 224 |
|
| 225 |
xar_x( D_3, A_3_3, D_3, 21) // D[3]=A[0][3] |
| 226 |
xar( A_0_3, A_3_2, D_2, 15) // A[0][3]=A[3][3] |
| 227 |
xar( D_1, A_2_1, D_1, 10) // D[1]=A[3][2] |
| 228 |
xar( D_2, A_1_2, D_2, 6) // D[2]=A[2][1] |
| 229 |
xar( D_0, A_2_0, D_0, 3) // D[0]=A[1][2] |
| 230 |
|
| 231 |
////////////////////////////////////////////////// Chi+Iota |
| 232 |
bcax_x( A_4_0, C_1, A_4_2, A_1_3) // A[1][3]=A[4][1] |
| 233 |
bcax( A_4_1, A_1_3, A_4_3, A_4_2) // A[1][3]=A[4][1] |
| 234 |
bcax_d( A_4_2, A_4_4, A_4_3) |
| 235 |
bcax_d( A_4_3, C_1, A_4_4) |
| 236 |
bcax_d( A_4_4, A_1_3, C_1) // A[1][3]=A[4][1] |
| 237 |
|
| 238 |
bcax_x( A_3_2, D_1, A_3_4, A_0_3) // A[0][3]=A[3][3] |
| 239 |
bcax( A_3_3, A_0_3, A_3_0, A_3_4) // A[0][3]=A[3][3] |
| 240 |
bcax_d( A_3_4, A_3_1, A_3_0) |
| 241 |
bcax_d( A_3_0, D_1, A_3_1) |
| 242 |
bcax_d( A_3_1, A_0_3, D_1) // A[0][3]=A[3][3] |
| 243 |
|
| 244 |
bcax( A_2_0, C_0, A_2_2, D_2) |
| 245 |
bcax( A_2_1, D_2, A_2_3, A_2_2) |
| 246 |
bcax_d( A_2_2, A_2_4, A_2_3) |
| 247 |
bcax_d( A_2_3, C_0, A_2_4) |
| 248 |
bcax_d( A_2_4, D_2, C_0) |
| 249 |
|
| 250 |
bcax( A_1_2, D_0, A_1_4, A_0_4) // A[0][4]=A[1][3] |
| 251 |
bcax( A_1_3, A_0_4, A_1_0, A_1_4) // A[0][4]=A[1][3] |
| 252 |
bcax_d( A_1_4, A_1_1, A_1_0) |
| 253 |
bcax_d( A_1_0, D_0, A_1_1) |
| 254 |
bcax_d( A_1_1, A_0_4, D_0) // A[0][4]=A[1][3] |
| 255 |
|
| 256 |
bcax( A_0_3, D_3, A_0_0, D_4) |
| 257 |
bcax( A_0_4, D_4, A_0_1, A_0_0) |
| 258 |
bcax_d( A_0_0, A_0_2, A_0_1) |
| 259 |
bcax_d( A_0_1, D_3, A_0_2) |
| 260 |
bcax_d( A_0_2, D_4, D_3) |
| 261 |
eor( A_0_0, A_0_0, (%r10)) |
| 262 |
|
| 263 |
cmpq %r10, %r11 |
| 264 |
je .Lend_ce |
| 265 |
|
| 266 |
addq $8, %r10 |
| 267 |
jmp .Loop_ce |
| 268 |
|
| 269 |
.align 64, 0xcc |
| 270 |
.Lend_ce: |
| 271 |
ret_spec_stop |
| 272 |
CFI_ENDPROC() |
| 273 |
ELF(.size KeccakF1600_ce,.-KeccakF1600_ce) |
| 274 |
|
| 275 |
.globl _gcry_keccak_f1600_state_permute64_avx512 |
| 276 |
ELF(.type _gcry_keccak_f1600_state_permute64_avx512,@function) |
| 277 |
.align 64, 0xcc |
| 278 |
_gcry_keccak_f1600_state_permute64_avx512: |
| 279 |
/* input: |
| 280 |
* %rdi: state |
| 281 |
* %rsi: round constants |
| 282 |
*/ |
| 283 |
CFI_STARTPROC() |
| 284 |
|
| 285 |
spec_stop_avx512; |
| 286 |
|
| 287 |
leaq 12*8(%rdi), %rax |
| 288 |
leaq (24-1)*8(%rsi), %r11 |
| 289 |
|
| 290 |
vmovdqu64 0*8(%rdi), A_0_0 |
| 291 |
vmovdqu64 1*8(%rdi), A_0_1 |
| 292 |
vmovdqu64 2*8(%rdi), A_0_2 |
| 293 |
vmovdqu64 3*8(%rdi), A_0_3 |
| 294 |
vmovdqu64 4*8(%rdi), A_0_4 |
| 295 |
vmovdqu64 5*8(%rdi), A_1_0 |
| 296 |
vmovdqu64 6*8(%rdi), A_1_1 |
| 297 |
vmovdqu64 7*8(%rdi), A_1_2 |
| 298 |
vmovdqu64 8*8(%rdi), A_1_3 |
| 299 |
vmovdqu64 9*8(%rdi), A_1_4 |
| 300 |
vmovdqu64 10*8(%rdi), A_2_0 |
| 301 |
vmovdqu64 11*8(%rdi), A_2_1 |
| 302 |
vmovdqu64 0*8(%rax), A_2_2 |
| 303 |
vmovdqu64 1*8(%rax), A_2_3 |
| 304 |
vmovdqu64 2*8(%rax), A_2_4 |
| 305 |
vmovdqu64 3*8(%rax), A_3_0 |
| 306 |
vmovdqu 4*8(%rax), A_3_1 |
| 307 |
vmovdqu 5*8(%rax), A_3_2 |
| 308 |
vmovdqu 6*8(%rax), A_3_3 |
| 309 |
vmovdqu 7*8(%rax), A_3_4 |
| 310 |
vmovdqu 8*8(%rax), A_4_0 |
| 311 |
vmovdqu 9*8(%rax), A_4_1 |
| 312 |
vmovdqu 10*8(%rax), A_4_2 |
| 313 |
vmovdqu 11*8(%rax), A_4_3 |
| 314 |
vmovq 12*8(%rax), A_4_4 |
| 315 |
|
| 316 |
movq %rsi, %r10 |
| 317 |
call KeccakF1600_ce |
| 318 |
|
| 319 |
vpunpcklqdq A_0_1, A_0_0, A_0_0 |
| 320 |
vpunpcklqdq A_0_3, A_0_2, A_0_2 |
| 321 |
vpunpcklqdq A_1_0, A_0_4, A_0_4 |
| 322 |
vpunpcklqdq A_1_2, A_1_1, A_1_1 |
| 323 |
vpunpcklqdq A_1_4, A_1_3, A_1_3 |
| 324 |
vpunpcklqdq A_2_1, A_2_0, A_2_0 |
| 325 |
vpunpcklqdq A_2_3, A_2_2, A_2_2 |
| 326 |
vpunpcklqdq A_3_0, A_2_4, A_2_4 |
| 327 |
vpunpcklqdq A_3_2, A_3_1, A_3_1 |
| 328 |
vpunpcklqdq A_3_4, A_3_3, A_3_3 |
| 329 |
vpunpcklqdq A_4_1, A_4_0, A_4_0 |
| 330 |
vpunpcklqdq A_4_3, A_4_2, A_4_2 |
| 331 |
vmovdqu64 A_0_0, 0*8(%rdi) |
| 332 |
vmovdqu64 A_0_2, 2*8(%rdi) |
| 333 |
vmovdqu64 A_0_4, 4*8(%rdi) |
| 334 |
vmovdqu64 A_1_1, 6*8(%rdi) |
| 335 |
vmovdqu64 A_1_3, 8*8(%rdi) |
| 336 |
vmovdqu64 A_2_0, 10*8(%rdi) |
| 337 |
vmovdqu64 A_2_2, 0*8(%rax) |
| 338 |
vmovdqu64 A_2_4, 2*8(%rax) |
| 339 |
vmovdqu A_3_1, 4*8(%rax) |
| 340 |
vmovdqu A_3_3, 6*8(%rax) |
| 341 |
vmovdqu A_4_0, 8*8(%rax) |
| 342 |
vmovdqu A_4_2, 10*8(%rax) |
| 343 |
vmovq A_4_4, 12*8(%rax) |
| 344 |
|
| 345 |
xorl %eax, %eax |
| 346 |
|
| 347 |
clear_regs() |
| 348 |
ret_spec_stop |
| 349 |
CFI_ENDPROC() |
| 350 |
ELF(.size _gcry_keccak_f1600_state_permute64_avx512, |
| 351 |
.-_gcry_keccak_f1600_state_permute64_avx512) |
| 352 |
|
| 353 |
.globl _gcry_keccak_absorb_blocks_avx512 |
| 354 |
ELF(.type _gcry_keccak_absorb_blocks_avx512,@function) |
| 355 |
.align 64, 0xcc |
| 356 |
_gcry_keccak_absorb_blocks_avx512: |
| 357 |
/* input: |
| 358 |
* %rdi: state |
| 359 |
* %rsi: round constants |
| 360 |
* %rdx: lanes |
| 361 |
* %rcx: nlanes |
| 362 |
* %r8 : blocklanes |
| 363 |
* %r9 : lanes output pointer |
| 364 |
*/ |
| 365 |
CFI_STARTPROC() |
| 366 |
|
| 367 |
spec_stop_avx512; |
| 368 |
|
| 369 |
leaq 12*8(%rdi), %rax |
| 370 |
leaq (24-1)*8(%rsi), %r11 |
| 371 |
|
| 372 |
vmovdqu64 0*8(%rdi), A_0_0 |
| 373 |
vmovdqu64 1*8(%rdi), A_0_1 |
| 374 |
vmovdqu64 2*8(%rdi), A_0_2 |
| 375 |
vmovdqu64 3*8(%rdi), A_0_3 |
| 376 |
vmovdqu64 4*8(%rdi), A_0_4 |
| 377 |
vmovdqu64 5*8(%rdi), A_1_0 |
| 378 |
vmovdqu64 6*8(%rdi), A_1_1 |
| 379 |
vmovdqu64 7*8(%rdi), A_1_2 |
| 380 |
vmovdqu64 8*8(%rdi), A_1_3 |
| 381 |
vmovdqu64 9*8(%rdi), A_1_4 |
| 382 |
vmovdqu64 10*8(%rdi), A_2_0 |
| 383 |
vmovdqu64 11*8(%rdi), A_2_1 |
| 384 |
vmovdqu64 0*8(%rax), A_2_2 |
| 385 |
vmovdqu64 1*8(%rax), A_2_3 |
| 386 |
vmovdqu64 2*8(%rax), A_2_4 |
| 387 |
vmovdqu64 3*8(%rax), A_3_0 |
| 388 |
vmovdqu 4*8(%rax), A_3_1 |
| 389 |
vmovdqu 5*8(%rax), A_3_2 |
| 390 |
vmovdqu 6*8(%rax), A_3_3 |
| 391 |
vmovdqu 7*8(%rax), A_3_4 |
| 392 |
vmovdqu 8*8(%rax), A_4_0 |
| 393 |
vmovdqu 9*8(%rax), A_4_1 |
| 394 |
vmovdqu 10*8(%rax), A_4_2 |
| 395 |
vmovdqu 11*8(%rax), A_4_3 |
| 396 |
vmovq 12*8(%rax), A_4_4 |
| 397 |
|
| 398 |
cmpq $(104 >> 3), %r8 |
| 399 |
jb .Loop_absorb_72_ce |
| 400 |
je .Loop_absorb_104_ce |
| 401 |
cmpq $(144 >> 3), %r8 |
| 402 |
jb .Loop_absorb_136_ce |
| 403 |
je .Loop_absorb_144_ce |
| 404 |
jmp .Loop_absorb_168_ce |
| 405 |
|
| 406 |
.align 64, 0xcc |
| 407 |
.Loop_absorb_168_ce: |
| 408 |
subq %r8, %rcx // len - bsz |
| 409 |
jb .Labsorbed_ce |
| 410 |
|
| 411 |
vpxorq 0*8(%rdx), A_0_0, A_0_0 |
| 412 |
vpxorq 1*8(%rdx), A_0_1, A_0_1 |
| 413 |
vpxorq 2*8(%rdx), A_0_2, A_0_2 |
| 414 |
vpxorq 3*8(%rdx), A_0_3, A_0_3 |
| 415 |
vpxorq 4*8(%rdx), A_0_4, A_0_4 |
| 416 |
vpxorq 5*8(%rdx), A_1_0, A_1_0 |
| 417 |
vpxorq 6*8(%rdx), A_1_1, A_1_1 |
| 418 |
vpxorq 7*8(%rdx), A_1_2, A_1_2 |
| 419 |
vpxorq 8*8(%rdx), A_1_3, A_1_3 |
| 420 |
vpxorq 9*8(%rdx), A_1_4, A_1_4 |
| 421 |
vpxorq 10*8(%rdx), A_2_0, A_2_0 |
| 422 |
vpxorq 11*8(%rdx), A_2_1, A_2_1 |
| 423 |
vpxorq 12*8(%rdx), A_2_2, A_2_2 |
| 424 |
vpxorq 13*8(%rdx), A_2_3, A_2_3 |
| 425 |
vpxorq 14*8(%rdx), A_2_4, A_2_4 |
| 426 |
vpxorq 15*8(%rdx), A_3_0, A_3_0 |
| 427 |
vpxor 16*8(%rdx), A_3_1, A_3_1 |
| 428 |
vpxor 17*8(%rdx), A_3_2, A_3_2 |
| 429 |
vpxor 18*8(%rdx), A_3_3, A_3_3 |
| 430 |
vpxor 19*8(%rdx), A_3_4, A_3_4 |
| 431 |
vmovq 20*8(%rdx), C_0 |
| 432 |
leaq 21*8(%rdx), %rdx |
| 433 |
vpxorq C_0, A_4_0, A_4_0 |
| 434 |
|
| 435 |
movq %rsi, %r10 |
| 436 |
call KeccakF1600_ce |
| 437 |
|
| 438 |
jmp .Loop_absorb_168_ce |
| 439 |
|
| 440 |
.align 64, 0xcc |
| 441 |
.Loop_absorb_144_ce: |
| 442 |
subq %r8, %rcx // len - bsz |
| 443 |
jb .Labsorbed_ce |
| 444 |
|
| 445 |
vpxorq 0*8(%rdx), A_0_0, A_0_0 |
| 446 |
vpxorq 1*8(%rdx), A_0_1, A_0_1 |
| 447 |
vpxorq 2*8(%rdx), A_0_2, A_0_2 |
| 448 |
vpxorq 3*8(%rdx), A_0_3, A_0_3 |
| 449 |
vpxorq 4*8(%rdx), A_0_4, A_0_4 |
| 450 |
vpxorq 5*8(%rdx), A_1_0, A_1_0 |
| 451 |
vpxorq 6*8(%rdx), A_1_1, A_1_1 |
| 452 |
vpxorq 7*8(%rdx), A_1_2, A_1_2 |
| 453 |
vpxorq 8*8(%rdx), A_1_3, A_1_3 |
| 454 |
vpxorq 9*8(%rdx), A_1_4, A_1_4 |
| 455 |
vpxorq 10*8(%rdx), A_2_0, A_2_0 |
| 456 |
vpxorq 11*8(%rdx), A_2_1, A_2_1 |
| 457 |
vpxorq 12*8(%rdx), A_2_2, A_2_2 |
| 458 |
vpxorq 13*8(%rdx), A_2_3, A_2_3 |
| 459 |
vpxorq 14*8(%rdx), A_2_4, A_2_4 |
| 460 |
vpxorq 15*8(%rdx), A_3_0, A_3_0 |
| 461 |
vpxor 16*8(%rdx), A_3_1, A_3_1 |
| 462 |
vmovq 17*8(%rdx), C_0 |
| 463 |
leaq 18*8(%rdx), %rdx |
| 464 |
vpxor C_0, A_3_2, A_3_2 |
| 465 |
|
| 466 |
movq %rsi, %r10 |
| 467 |
call KeccakF1600_ce |
| 468 |
|
| 469 |
jmp .Loop_absorb_144_ce |
| 470 |
|
| 471 |
.align 64, 0xcc |
| 472 |
.Loop_absorb_136_ce: |
| 473 |
subq %r8, %rcx // len - bsz |
| 474 |
jb .Labsorbed_ce |
| 475 |
|
| 476 |
vpxorq 0*8(%rdx), A_0_0, A_0_0 |
| 477 |
vpxorq 1*8(%rdx), A_0_1, A_0_1 |
| 478 |
vpxorq 2*8(%rdx), A_0_2, A_0_2 |
| 479 |
vpxorq 3*8(%rdx), A_0_3, A_0_3 |
| 480 |
vpxorq 4*8(%rdx), A_0_4, A_0_4 |
| 481 |
vpxorq 5*8(%rdx), A_1_0, A_1_0 |
| 482 |
vpxorq 6*8(%rdx), A_1_1, A_1_1 |
| 483 |
vpxorq 7*8(%rdx), A_1_2, A_1_2 |
| 484 |
vpxorq 8*8(%rdx), A_1_3, A_1_3 |
| 485 |
vpxorq 9*8(%rdx), A_1_4, A_1_4 |
| 486 |
vpxorq 10*8(%rdx), A_2_0, A_2_0 |
| 487 |
vpxorq 11*8(%rdx), A_2_1, A_2_1 |
| 488 |
vpxorq 12*8(%rdx), A_2_2, A_2_2 |
| 489 |
vpxorq 13*8(%rdx), A_2_3, A_2_3 |
| 490 |
vpxorq 14*8(%rdx), A_2_4, A_2_4 |
| 491 |
vpxorq 15*8(%rdx), A_3_0, A_3_0 |
| 492 |
vmovq 16*8(%rdx), C_0 |
| 493 |
leaq 17*8(%rdx), %rdx |
| 494 |
vpxor C_0, A_3_1, A_3_1 |
| 495 |
|
| 496 |
movq %rsi, %r10 |
| 497 |
call KeccakF1600_ce |
| 498 |
|
| 499 |
jmp .Loop_absorb_136_ce |
| 500 |
|
| 501 |
.align 64, 0xcc |
| 502 |
.Loop_absorb_104_ce: |
| 503 |
subq %r8, %rcx // len - bsz |
| 504 |
jb .Labsorbed_ce |
| 505 |
|
| 506 |
vpxorq 0*8(%rdx), A_0_0, A_0_0 |
| 507 |
vpxorq 1*8(%rdx), A_0_1, A_0_1 |
| 508 |
vpxorq 2*8(%rdx), A_0_2, A_0_2 |
| 509 |
vpxorq 3*8(%rdx), A_0_3, A_0_3 |
| 510 |
vpxorq 4*8(%rdx), A_0_4, A_0_4 |
| 511 |
vpxorq 5*8(%rdx), A_1_0, A_1_0 |
| 512 |
vpxorq 6*8(%rdx), A_1_1, A_1_1 |
| 513 |
vpxorq 7*8(%rdx), A_1_2, A_1_2 |
| 514 |
vpxorq 8*8(%rdx), A_1_3, A_1_3 |
| 515 |
vpxorq 9*8(%rdx), A_1_4, A_1_4 |
| 516 |
vpxorq 10*8(%rdx), A_2_0, A_2_0 |
| 517 |
vpxorq 11*8(%rdx), A_2_1, A_2_1 |
| 518 |
vmovq 12*8(%rdx), C_0 |
| 519 |
leaq 13*8(%rdx), %rdx |
| 520 |
vpxorq C_0, A_2_2, A_2_2 |
| 521 |
|
| 522 |
movq %rsi, %r10 |
| 523 |
call KeccakF1600_ce |
| 524 |
|
| 525 |
jmp .Loop_absorb_104_ce |
| 526 |
|
| 527 |
.align 64, 0xcc |
| 528 |
.Loop_absorb_72_ce: |
| 529 |
subq %r8, %rcx // len - bsz |
| 530 |
jb .Labsorbed_ce |
| 531 |
|
| 532 |
vpxorq 0*8(%rdx), A_0_0, A_0_0 |
| 533 |
vpxorq 1*8(%rdx), A_0_1, A_0_1 |
| 534 |
vpxorq 2*8(%rdx), A_0_2, A_0_2 |
| 535 |
vpxorq 3*8(%rdx), A_0_3, A_0_3 |
| 536 |
vpxorq 4*8(%rdx), A_0_4, A_0_4 |
| 537 |
vpxorq 5*8(%rdx), A_1_0, A_1_0 |
| 538 |
vpxorq 6*8(%rdx), A_1_1, A_1_1 |
| 539 |
vpxorq 7*8(%rdx), A_1_2, A_1_2 |
| 540 |
vmovq 8*8(%rdx), C_0 |
| 541 |
leaq 9*8(%rdx), %rdx |
| 542 |
vpxorq C_0, A_1_3, A_1_3 |
| 543 |
|
| 544 |
movq %rsi, %r10 |
| 545 |
call KeccakF1600_ce |
| 546 |
|
| 547 |
jmp .Loop_absorb_72_ce |
| 548 |
|
| 549 |
.align 64, 0xcc |
| 550 |
.Labsorbed_ce: |
| 551 |
vpunpcklqdq A_0_1, A_0_0, A_0_0 |
| 552 |
vpunpcklqdq A_0_3, A_0_2, A_0_2 |
| 553 |
vpunpcklqdq A_1_0, A_0_4, A_0_4 |
| 554 |
vpunpcklqdq A_1_2, A_1_1, A_1_1 |
| 555 |
vpunpcklqdq A_1_4, A_1_3, A_1_3 |
| 556 |
vpunpcklqdq A_2_1, A_2_0, A_2_0 |
| 557 |
vpunpcklqdq A_2_3, A_2_2, A_2_2 |
| 558 |
vpunpcklqdq A_3_0, A_2_4, A_2_4 |
| 559 |
vpunpcklqdq A_3_2, A_3_1, A_3_1 |
| 560 |
vpunpcklqdq A_3_4, A_3_3, A_3_3 |
| 561 |
vpunpcklqdq A_4_1, A_4_0, A_4_0 |
| 562 |
vpunpcklqdq A_4_3, A_4_2, A_4_2 |
| 563 |
vmovdqu64 A_0_0, 0*8(%rdi) |
| 564 |
vmovdqu64 A_0_2, 2*8(%rdi) |
| 565 |
vmovdqu64 A_0_4, 4*8(%rdi) |
| 566 |
vmovdqu64 A_1_1, 6*8(%rdi) |
| 567 |
vmovdqu64 A_1_3, 8*8(%rdi) |
| 568 |
vmovdqu64 A_2_0, 10*8(%rdi) |
| 569 |
vmovdqu64 A_2_2, 0*8(%rax) |
| 570 |
vmovdqu64 A_2_4, 2*8(%rax) |
| 571 |
vmovdqu A_3_1, 4*8(%rax) |
| 572 |
vmovdqu A_3_3, 6*8(%rax) |
| 573 |
vmovdqu A_4_0, 8*8(%rax) |
| 574 |
vmovdqu A_4_2, 10*8(%rax) |
| 575 |
vmovq A_4_4, 12*8(%rax) |
| 576 |
|
| 577 |
leaq (%r8, %rcx), %rax // return value |
| 578 |
movq %rdx, (%r9) // return buffer pointer |
| 579 |
|
| 580 |
clear_regs() |
| 581 |
ret_spec_stop |
| 582 |
CFI_ENDPROC() |
| 583 |
ELF(.size _gcry_keccak_absorb_blocks_avx512, |
| 584 |
.-_gcry_keccak_absorb_blocks_avx512) |
| 585 |
|
| 586 |
#endif /* HAVE_GCC_INLINE_ASM_AVX512 */ |
| 587 |
#endif /* __x86_64 */ |