Mercurial > vec
comparison src/impl/fallback.c @ 28:c6c99ab1088a
*: add min/max functions and a big big refactor (again)
agh, this time I added a few more implementations (and generally
made the code just a little faster...)
author | Paper <paper@tflc.us> |
---|---|
date | Thu, 24 Apr 2025 00:54:02 -0400 |
parents | 92156fe32755 |
children | bf6ad516f1e6 |
comparison
equal
deleted
inserted
replaced
27:d00b95f95dd1 | 28:c6c99ab1088a |
---|---|
1 /** | |
2 * vec - a tiny SIMD vector library in C99 | |
3 * | |
4 * Copyright (c) 2024 Paper | |
5 * | |
6 * Permission is hereby granted, free of charge, to any person obtaining a copy | |
7 * of this software and associated documentation files (the "Software"), to deal | |
8 * in the Software without restriction, including without limitation the rights | |
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
10 * copies of the Software, and to permit persons to whom the Software is | |
11 * furnished to do so, subject to the following conditions: | |
12 * | |
13 * The above copyright notice and this permission notice shall be included in all | |
14 * copies or substantial portions of the Software. | |
15 * | |
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
22 * SOFTWARE. | |
23 **/ | |
24 | |
1 #include "vec/impl/fallback.h" | 25 #include "vec/impl/fallback.h" |
2 | 26 |
3 #include <string.h> | 27 #include <string.h> |
4 | 28 |
5 // Fallback implementations - this is what an implementation should use if it | 29 // Fallback implementations - this is what an implementation should use if it |
6 // doesn't support a specific function *and* the actual representation in | 30 // doesn't support a specific function *and* the actual representation in |
7 // memory is unknown or yields incorrect results from the generic functions. | 31 // memory is unknown or yields incorrect results from the generic functions. |
8 // This is *extremely* unlikely; for x86 the layout is exactly the same in | 32 // This is *extremely* unlikely; for x86 the layout is exactly the same in |
9 // memory as the generic functions (i.e. it is literally stored as an array of | 33 // memory as the generic functions (i.e. it is literally stored as an array of |
10 // integers). This is likely true for AltiVec and NEON as well, but those | 34 // integers). This is also true for AltiVec. This is likely true for NEON as well, |
11 // aren't tested for now. | 35 // but that isn't tested for now. |
12 | 36 |
13 #define VEC_FALLBACK_OPERATION(op, sign, csign, bits, size) \ | 37 #define VEC_FALLBACK_OPERATION(op, sign, csign, bits, size) \ |
14 do { \ | 38 do { \ |
15 V##csign##INT##bits##x##size##_ALIGNED_ARRAY(varr1); \ | 39 V##csign##INT##bits##x##size##_ALIGNED_ARRAY(varr1); \ |
16 V##csign##INT##bits##x##size##_ALIGNED_ARRAY(varr2); \ | 40 V##csign##INT##bits##x##size##_ALIGNED_ARRAY(varr2); \ |