rsimd

Make SIMD instruction sets easier to use
git clone git://git.meso-star.fr/rsimd.git
Log | Files | Refs | README | LICENSE

sse_swz.h (2893B)


      1 /* Copyright (C) 2014-2019, 2021, 2023, 2025 Vincent Forest (vaplv@free.fr)
      2  *
      3  * The RSIMD library is free software: you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License as published
      5  * by the Free Software Foundation, either version 3 of the License, or
      6  * (at your option) any later version.
      7  *
      8  * The RSIMD library is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     11  * GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License
     14  * along with the RSIMD library. If not, see <http://www.gnu.org/licenses/>. */
     15 
     16 #ifndef RSIMD_SSE_SWZ_H
     17 #define RSIMD_SSE_SWZ_H
     18 
     19 /*
     20  * Helper macro for the generation of swizzling function
     21  */
     22 
     23 /* Swizzle operands */
     24 #define SWZ_X__ 0
     25 #define SWZ_Y__ 1
     26 #define SWZ_Z__ 2
     27 #define SWZ_W__ 3
     28 
     29 #define V4_SWZ_0__(Prefix, Func, Append, Op0, Op1, Op2, Op3)                   \
     30   static FINLINE Prefix##_T                                                    \
     31   Prefix ##_ ## Func ## Append(Prefix##_T vec)                                 \
     32   {                                                                            \
     33     return Prefix ## _SWZ__(vec, Op0, Op1, Op2, Op3);                          \
     34   }
     35 
     36 #define V4_SWZ_1__(Prefix, Func, Append, Op0, Op1, Op2)                        \
     37   V4_SWZ_0__(Prefix, Func ## Append, x, Op0, Op1, Op2, SWZ_X__)                \
     38   V4_SWZ_0__(Prefix, Func ## Append, y, Op0, Op1, Op2, SWZ_Y__)                \
     39   V4_SWZ_0__(Prefix, Func ## Append, z, Op0, Op1, Op2, SWZ_Z__)                \
     40   V4_SWZ_0__(Prefix, Func ## Append, w, Op0, Op1, Op2, SWZ_W__)
     41 
     42 #define V4_SWZ_2__(Prefix, Func, Append, Op0, Op1)                             \
     43   V4_SWZ_1__(Prefix, Func ## Append, x, Op0, Op1, SWZ_X__)                     \
     44   V4_SWZ_1__(Prefix, Func ## Append, y, Op0, Op1, SWZ_Y__)                     \
     45   V4_SWZ_1__(Prefix, Func ## Append, z, Op0, Op1, SWZ_Z__)                     \
     46   V4_SWZ_1__(Prefix, Func ## Append, w, Op0, Op1, SWZ_W__)
     47 
     48 #define V4_SWZ_3__(Prefix, Func, Op0)                                          \
     49   V4_SWZ_2__(Prefix, Func, x, Op0, SWZ_X__)                                    \
     50   V4_SWZ_2__(Prefix, Func, y, Op0, SWZ_Y__)                                    \
     51   V4_SWZ_2__(Prefix, Func, z, Op0, SWZ_Z__)                                    \
     52   V4_SWZ_2__(Prefix, Func, w, Op0, SWZ_W__)
     53 
     54 #define GENERATE_V4_SWZ_FUNCS__(Prefix)                                        \
     55   V4_SWZ_3__(Prefix, x, SWZ_X__)                                               \
     56   V4_SWZ_3__(Prefix, y, SWZ_Y__)                                               \
     57   V4_SWZ_3__(Prefix, z, SWZ_Z__)                                               \
     58   V4_SWZ_3__(Prefix, w, SWZ_W__)
     59 
     60 #endif /* RSIMD_SSE_SWZ_H */
     61 
     62