Debian Codegraph @

third-party/simde/mips/msa/andi.h

raw
1 /* SPDX-License-Identifier: MIT
2 *
3 * Permission is hereby granted, free of charge, to any person
4 * obtaining a copy of this software and associated documentation
5 * files (the "Software"), to deal in the Software without
6 * restriction, including without limitation the rights to use, copy,
7 * modify, merge, publish, distribute, sublicense, and/or sell copies
8 * of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be
12 * included in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 *
23 * Copyright:
24 * 2021 Evan Nemerson <[email protected]>
25 */
26
27 #if !defined(SIMDE_MIPS_MSA_ANDI_H)
28 #define SIMDE_MIPS_MSA_ANDI_H
29
30 #include "types.h"
31
32 HEDLEY_DIAGNOSTIC_PUSH
33 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
34 SIMDE_BEGIN_DECLS_
35
36 SIMDE_FUNCTION_ATTRIBUTES
37 simde_v16u8
38 simde_msa_andi_b(simde_v16u8 a, const int imm0_255)
39 SIMDE_REQUIRE_CONSTANT_RANGE(imm0_255, 0, 255) {
40 #if defined(SIMDE_ARM_NEON_A32V7_NATIVE)
41 return vandq_u8(a, vdupq_n_u8(HEDLEY_STATIC_CAST(uint8_t, imm0_255)));
42 #elif defined(SIMDE_POWER_ALTIVEC_P6_NATIVE)
43 return vec_and(a, vec_splats(HEDLEY_STATIC_CAST(unsigned char, imm0_255)));
44 #else
45 simde_v16u8_private
46 a_ = simde_v16u8_to_private(a),
47 r_;
48
49 #if defined(SIMDE_X86_SSE2_NATIVE)
50 r_.m128i = _mm_and_si128(a_.m128i, _mm_set1_epi8(HEDLEY_STATIC_CAST(int8_t, imm0_255)));
51 #elif defined(SIMDE_WASM_SIMD128_NATIVE)
52 r_.v128 = wasm_v128_and(a_.v128, wasm_i8x16_splat(HEDLEY_STATIC_CAST(int8_t, imm0_255)));
53 #elif defined(SIMDE_VECTOR_SUBSCRIPT_SCALAR)
54 r_.values = a_.values & HEDLEY_STATIC_CAST(uint8_t, imm0_255);
55 #else
56 SIMDE_VECTORIZE
57 for (size_t i = 0 ; i < (sizeof(r_.values) / sizeof(r_.values[0])) ; i++) {
58 r_.values[i] = a_.values[i] & HEDLEY_STATIC_CAST(int8_t, imm0_255);
59 }
60 #endif
61
62 return simde_v16u8_from_private(r_);
63 #endif
64 }
65 #if defined(SIMDE_MIPS_MSA_NATIVE)
66 #define simde_msa_andi_b(a, imm0_255) __msa_andi_b((a), (imm0_255))
67 #endif
68 #if defined(SIMDE_MIPS_MSA_ENABLE_NATIVE_ALIASES)
69 #undef __msa_andi_b
70 #define __msa_andi_b(a, imm0_255) simde_msa_andi_b((a), (imm0_255))
71 #endif
72
73 SIMDE_END_DECLS_
74 HEDLEY_DIAGNOSTIC_POP
75
76 #endif /* !defined(SIMDE_MIPS_MSA_ANDI_H) */