Debian Codegraph @

cipher/camellia-ppc9le.c

raw
1 /* camellia-ppc9le.c - POWER9 Vector Crypto Camellia implementation
2 * Copyright (C) 2023 Jussi Kivilinna <[email protected]>
3 *
4 * This file is part of Libgcrypt.
5 *
6 * Libgcrypt is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
10 *
11 * Libgcrypt is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include <config.h>
21
22 #if !defined(WORDS_BIGENDIAN) && defined(ENABLE_PPC_CRYPTO_SUPPORT) && \
23 defined(HAVE_COMPATIBLE_CC_PPC_ALTIVEC) && \
24 defined(HAVE_GCC_INLINE_ASM_PPC_ALTIVEC) && \
25 (SIZEOF_UNSIGNED_LONG == 8) && (__GNUC__ >= 4)
26
27 #ifdef HAVE_GCC_ATTRIBUTE_OPTIMIZE
28 # define FUNC_ATTR_OPT __attribute__((optimize("-O2")))
29 #else
30 # define FUNC_ATTR_OPT
31 #endif
32
33 #if defined(__clang__) && defined(HAVE_CLANG_ATTRIBUTE_PPC_TARGET)
34 # define SIMD128_OPT_ATTR __attribute__((target("arch=pwr9"))) FUNC_ATTR_OPT
35 #elif defined(HAVE_GCC_ATTRIBUTE_PPC_TARGET)
36 # define SIMD128_OPT_ATTR __attribute__((target("cpu=power9"))) FUNC_ATTR_OPT
37 #else
38 # define SIMD128_OPT_ATTR FUNC_ATTR_OPT
39 #endif
40
41 #define FUNC_ENC_BLK16 _gcry_camellia_ppc9_encrypt_blk16
42 #define FUNC_DEC_BLK16 _gcry_camellia_ppc9_decrypt_blk16
43 #define FUNC_KEY_SETUP _gcry_camellia_ppc9_keygen
44
45 #include "camellia-simd128.h"
46
47 #endif /* ENABLE_PPC_CRYPTO_SUPPORT */