Mercurial > vec
comparison src/impl/x86/sse41.c @ 23:e26874655738
*: huge refactor, new major release (hahaha)
I keep finding things that are broken...
The problem NOW was that vec would unintentionally build some
functions with extended instruction sets, which is Bad and would
mean that for all intents and purposes the CPU detection was
completely broken.
Now vec is no longer header only either. Boohoo. However this gives
a lot more flexibility to vec since we no longer want or need to
care about C++ crap.
The NEON and Altivec implementations have not been updated which
means they won't compile hence why they're commented out in the
cmake build file.
author | Paper <paper@tflc.us> |
---|---|
date | Sun, 24 Nov 2024 02:52:40 -0500 |
parents | |
children | e49e70f7012f |
comparison
equal
deleted
inserted
replaced
22:fbcd3fa6f8fc | 23:e26874655738 |
---|---|
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 | |
25 #include "vec/impl/x86/sse41.h" | |
26 #include "vec/impl/x86/sse2.h" | |
27 #include "vec/impl/generic.h" | |
28 | |
29 #include <immintrin.h> | |
30 | |
31 // SSE 4.1 provides a real _mm_mullo_epi32 | |
32 #define VEC_SSE41_DEFINE_OPERATIONS(sign) \ | |
33 union v##sign##int32x4_impl_data { \ | |
34 v##sign##int32x4 vec; \ | |
35 __m128i sse; \ | |
36 }; \ | |
37 \ | |
38 static v##sign##int32x4 v##sign##int32x4_sse41_mul(v##sign##int32x4 vec1, v##sign##int32x4 vec2) \ | |
39 { \ | |
40 union v##sign##int32x4_impl_data *vec1d = (union v##sign##int32x4_impl_data *)&vec1; \ | |
41 union v##sign##int32x4_impl_data *vec2d = (union v##sign##int32x4_impl_data *)&vec2; \ | |
42 \ | |
43 vec1d->sse = _mm_mullo_epi32(vec1d->sse, vec2d->sse); \ | |
44 return vec1d->vec; \ | |
45 } \ | |
46 \ | |
47 const v##sign##int32x4_impl v##sign##int32x4_impl_sse41 = { \ | |
48 v##sign##int32x4_generic_splat, \ | |
49 v##sign##int32x4_sse2_load_aligned, \ | |
50 v##sign##int32x4_sse2_load, \ | |
51 v##sign##int32x4_sse2_store_aligned, \ | |
52 v##sign##int32x4_sse2_store, \ | |
53 v##sign##int32x4_sse2_add, \ | |
54 v##sign##int32x4_sse2_sub, \ | |
55 v##sign##int32x4_sse41_mul, \ | |
56 v##sign##int32x4_generic_div, \ | |
57 v##sign##int32x4_generic_avg, \ | |
58 v##sign##int32x4_sse2_and, \ | |
59 v##sign##int32x4_sse2_or, \ | |
60 v##sign##int32x4_sse2_xor, \ | |
61 v##sign##int32x4_generic_not, \ | |
62 v##sign##int32x4_generic_lshift, \ | |
63 v##sign##int32x4_generic_rshift, \ | |
64 v##sign##int32x4_generic_lrshift, \ | |
65 v##sign##int32x4_generic_cmplt, \ | |
66 v##sign##int32x4_generic_cmple, \ | |
67 v##sign##int32x4_sse2_cmpeq, \ | |
68 v##sign##int32x4_generic_cmpge, \ | |
69 v##sign##int32x4_generic_cmpgt, \ | |
70 }; | |
71 | |
72 VEC_SSE41_DEFINE_OPERATIONS() | |
73 VEC_SSE41_DEFINE_OPERATIONS(u) |