2 * Copyright (C) 2024 Mikulas Patocka
4 * This file is part of Ajla.
6 * Ajla is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, either version 3 of the License, or (at your option) any later
11 * Ajla is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * Ajla. If not, see <https://www.gnu.org/licenses/>.
19 #if TYPE_BITS <= EFFICIENT_WORD_SIZE
20 #define maybe_inline ipret_inline
25 #if defined(INLINE_ASM_GCC_ARM64) && (TYPE_MASK == 1 || TYPE_MASK == 2 || TYPE_MASK == 4)
26 gen_arm_div_mod(type, utype, uint32_t, "w", _)
27 #elif defined(INLINE_ASM_GCC_ARM64) && (TYPE_MASK == 8)
28 gen_arm_div_mod(type, utype, uint64_t, "x", _)
30 gen_generic_div_functions(type, utype)
33 gen_generic_power(type, utype)
35 #if defined(INLINE_ASM_GCC_X86) && TYPE_MASK == 1
36 gen_x86_rot(rol, type, utype, b, "=q"X86_ASM_M)
37 gen_x86_rot(ror, type, utype, b, "=q"X86_ASM_M)
38 #elif defined(INLINE_ASM_GCC_X86) && TYPE_MASK == 2
39 gen_x86_rot(rol, type, utype, w, "=r"X86_ASM_M)
40 gen_x86_rot(ror, type, utype, w, "=r"X86_ASM_M)
41 #elif defined(INLINE_ASM_GCC_X86) && TYPE_MASK == 4
42 gen_x86_rot(rol, type, utype, l, "=r"X86_ASM_M)
43 gen_x86_rot(ror, type, utype, l, "=r"X86_ASM_M)
44 #elif defined(INLINE_ASM_GCC_X86) && TYPE_MASK == 8 && !defined(INLINE_ASM_GCC_I386)
45 gen_x86_rot(rol, type, utype, q, "=r"X86_ASM_M)
46 gen_x86_rot(ror, type, utype, q, "=r"X86_ASM_M)
47 #elif defined(INLINE_ASM_GCC_ARM) && (TYPE_MASK == 1 || TYPE_MASK == 2 || TYPE_MASK == 4)
48 gen_arm_rot(rol, type, utype, uint32_t, false, "")
49 gen_arm_rot(ror, type, utype, uint32_t, true, "")
50 #elif defined(INLINE_ASM_GCC_ARM64) && (TYPE_MASK == 1 || TYPE_MASK == 2 || TYPE_MASK == 4)
51 gen_arm_rot(rol, type, utype, uint32_t, false, "w")
52 gen_arm_rot(ror, type, utype, uint32_t, true, "w")
53 #elif defined(INLINE_ASM_GCC_ARM64) && (TYPE_MASK == 8)
54 gen_arm_rot(rol, type, utype, uint64_t, false, "x")
55 gen_arm_rot(ror, type, utype, uint64_t, true, "x")
57 gen_generic_rot(rol, type, utype, false)
58 gen_generic_rot(ror, type, utype, true)
61 #if defined(INLINE_ASM_GCC_X86) && TYPE_MASK == 1
62 gen_x86_bit_mask(type, utype, b, "=q"X86_ASM_M)
63 #elif defined(INLINE_ASM_GCC_X86) && TYPE_MASK == 2
64 gen_x86_bit_mask(type, utype, w, "=r"X86_ASM_M)
65 #elif defined(INLINE_ASM_GCC_X86) && TYPE_MASK == 4
66 gen_x86_bit_mask(type, utype, l, "=r"X86_ASM_M)
67 #elif defined(INLINE_ASM_GCC_X86) && TYPE_MASK == 8 && !defined(INLINE_ASM_GCC_I386)
68 gen_x86_bit_mask(type, utype, q, "=r"X86_ASM_M)
70 gen_generic_bit_mask(type, utype)
72 gen_generic_bit_functions(type, utype)
74 cat(gen_generic_bswap_,TYPE_BITS)()
76 #if defined(INLINE_ASM_GCC_ARM64) && (TYPE_MASK == 1 || TYPE_MASK == 2 || TYPE_MASK == 4)
77 gen_arm_brev(type, utype, uint32_t, "w", _)
78 #elif defined(INLINE_ASM_GCC_ARM64) && (TYPE_MASK == 8)
79 gen_arm_brev(type, utype, uint64_t, "x", _)
80 #elif defined(INLINE_ASM_GCC_ARM64) && (TYPE_MASK == 16)
81 gen_arm_brev_2reg(type, utype, uint64_t, "x", _)
83 gen_generic_brev(type, utype)
86 gen_generic_bsfr_functions(type, utype)
87 gen_generic_popcnt(type, utype)