Debian Codegraph @

third-party/simde/arm/sve/ptrue.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_ARM_SVE_PTRUE_H)
28 #define SIMDE_ARM_SVE_PTRUE_H
29
30 #include "types.h"
31
32 HEDLEY_DIAGNOSTIC_PUSH
33 SIMDE_DISABLE_UNWANTED_DIAGNOSTICS
34
35 SIMDE_FUNCTION_ATTRIBUTES
36 simde_svbool_t
37 simde_svptrue_b8(void) {
38 #if defined(SIMDE_ARM_SVE_NATIVE)
39 return svptrue_b8();
40 #elif defined(SIMDE_X86_AVX512BW_NATIVE)
41 simde_svbool_t r;
42
43 #if SIMDE_ARM_SVE_VECTOR_SIZE >= 512
44 r = simde_svbool_from_mmask64(HEDLEY_STATIC_CAST(__mmask64, ~UINT64_C(0)));
45 #else
46 r = simde_svbool_from_mmask32(HEDLEY_STATIC_CAST(__mmask32, ~UINT32_C(0)));
47 #endif
48
49 return r;
50 #else
51 simde_svint8_t r;
52
53 for (int i = 0 ; i < HEDLEY_STATIC_CAST(int, simde_svcntb()) ; i++) {
54 r.values[i] = ~INT8_C(0);
55 }
56
57 return simde_svbool_from_svint8(r);
58 #endif
59 }
60 #if defined(SIMDE_ARM_SVE_ENABLE_NATIVE_ALIASES)
61 #undef simde_svptrue_b8
62 #define svptrue_b8() simde_svptrue_b8()
63 #endif
64
65 SIMDE_FUNCTION_ATTRIBUTES
66 simde_svbool_t
67 simde_svptrue_b16(void) {
68 #if defined(SIMDE_ARM_SVE_NATIVE)
69 return svptrue_b16();
70 #elif defined(SIMDE_X86_AVX512BW_NATIVE)
71 simde_svbool_t r;
72
73 #if SIMDE_ARM_SVE_VECTOR_SIZE >= 512
74 r = simde_svbool_from_mmask32(HEDLEY_STATIC_CAST(__mmask32, ~UINT32_C(0)));
75 #else
76 r = simde_svbool_from_mmask16(HEDLEY_STATIC_CAST(__mmask16, ~UINT16_C(0)));
77 #endif
78
79 return r;
80 #else
81 simde_svint16_t r;
82
83 for (int i = 0 ; i < HEDLEY_STATIC_CAST(int, simde_svcnth()) ; i++) {
84 r.values[i] = ~INT16_C(0);
85 }
86
87 return simde_svbool_from_svint16(r);
88 #endif
89 }
90 #if defined(SIMDE_ARM_SVE_ENABLE_NATIVE_ALIASES)
91 #undef simde_svptrue_b16
92 #define svptrue_b16() simde_svptrue_b16()
93 #endif
94
95 SIMDE_FUNCTION_ATTRIBUTES
96 simde_svbool_t
97 simde_svptrue_b32(void) {
98 #if defined(SIMDE_ARM_SVE_NATIVE)
99 return svptrue_b32();
100 #elif defined(SIMDE_X86_AVX512BW_NATIVE)
101 simde_svbool_t r;
102
103 #if SIMDE_ARM_SVE_VECTOR_SIZE >= 512
104 r = simde_svbool_from_mmask32(HEDLEY_STATIC_CAST(__mmask16, ~UINT16_C(0)));
105 #else
106 r = simde_svbool_from_mmask8(HEDLEY_STATIC_CAST(__mmask8, ~UINT8_C(0)));
107 #endif
108
109 return r;
110 #else
111 simde_svint32_t r;
112
113 for (int i = 0 ; i < HEDLEY_STATIC_CAST(int, simde_svcntw()) ; i++) {
114 r.values[i] = ~INT32_C(0);
115 }
116
117 return simde_svbool_from_svint32(r);
118 #endif
119 }
120 #if defined(SIMDE_ARM_SVE_ENABLE_NATIVE_ALIASES)
121 #undef simde_svptrue_b32
122 #define svptrue_b32() simde_svptrue_b32()
123 #endif
124
125 SIMDE_FUNCTION_ATTRIBUTES
126 simde_svbool_t
127 simde_svptrue_b64(void) {
128 #if defined(SIMDE_ARM_SVE_NATIVE)
129 return svptrue_b64();
130 #elif defined(SIMDE_X86_AVX512BW_NATIVE)
131 simde_svbool_t r;
132
133 #if SIMDE_ARM_SVE_VECTOR_SIZE >= 512
134 r = simde_svbool_from_mmask8(HEDLEY_STATIC_CAST(__mmask8, ~UINT8_C(0)));
135 #else
136 r = simde_svbool_from_mmask4(HEDLEY_STATIC_CAST(__mmask8, ~UINT8_C(0)));
137 #endif
138
139 return r;
140 #else
141 simde_svint64_t r;
142
143 for (int i = 0 ; i < HEDLEY_STATIC_CAST(int, simde_svcntd()) ; i++) {
144 r.values[i] = ~INT64_C(0);
145 }
146
147 return simde_svbool_from_svint64(r);
148 #endif
149 }
150 #if defined(SIMDE_ARM_SVE_ENABLE_NATIVE_ALIASES)
151 #undef simde_svptrue_b64
152 #define svptrue_b64() simde_svptrue_b64()
153 #endif
154
155 HEDLEY_DIAGNOSTIC_POP
156
157 #endif /* SIMDE_ARM_SVE_PTRUE_H */